PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / helpers / libraries / import / exportable.php
vikappointments / site / helpers / libraries / import Last commit date
classes 3 days ago export 3 days ago forms 3 days ago samples 3 days ago column.php 3 days ago exportable.php 3 days ago factory.php 3 days ago index.html 3 days ago object.php 3 days ago
exportable.php
92 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 VAPLoader::import('libraries.import.object');
15
16 /**
17 * Interface used to define the structure of a class that should
18 * be able to export records with an abstract format.
19 *
20 * @since 1.6
21 */
22 abstract class Exportable
23 {
24 /**
25 * The configuration object.
26 *
27 * @var JRegistry
28 */
29 protected $options;
30
31 /**
32 * Class constructor.
33 *
34 * @param array $options An array of options.
35 */
36 public function __construct(array $options = array())
37 {
38 // we must use a registry because empty strings should
39 // be interpreted to return the default value
40 $this->options = new JRegistry($options);
41 }
42
43 /**
44 * Attempts to return a readable name.
45 *
46 * @return void
47 *
48 * @since 1.7
49 */
50 public function getName()
51 {
52 // extract name from class
53 $class = strtoupper(preg_replace("/^Exportable/i", '', get_class($this)));
54
55 $key = 'VAP_EXPORT_DRIVER_' . $class;
56 $name = JText::translate($key);
57
58 if ($key != $name)
59 {
60 // language definition found
61 return $name;
62 }
63
64 // just return the final chunk of the class name
65 return $class;
66 }
67
68 /**
69 * Getter to propagate options to callers.
70 *
71 * @return array An array of options.
72 *
73 * @since 1.7
74 */
75 public function getOptions()
76 {
77 return $this->options->toArray();
78 }
79
80 /**
81 * Creates the file with the given records and downloads it
82 * using the specified filename.
83 *
84 * @param string $name The file name.
85 * @param array $records The records to export.
86 * @param ImportObject $obj The object handler.
87 *
88 * @return void
89 */
90 abstract public function download($name, array $records = array(), ?ImportObject $obj = null);
91 }
92