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 / forms / columns / service.php
vikappointments / site / helpers / libraries / import / forms / columns Last commit date
city.php 3 days ago country.php 3 days ago currency.php 3 days ago date.php 3 days ago empgroup.php 3 days ago employee.php 3 days ago group.php 3 days ago index.html 3 days ago optiongroup.php 3 days ago service.php 3 days ago state.php 3 days ago user.php 3 days ago
service.php
75 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 /**
15 * Populate the options array with the existing services,
16 * in order to support the correct placeholders while
17 * importing and exporting the records.
18 *
19 * @since 1.7
20 */
21 class ImportColumnService extends ImportColumn
22 {
23 /**
24 * Services cache.
25 *
26 * @var array
27 */
28 private static $services = null;
29
30 /**
31 * Binds the internal properties with the given array/object.
32 *
33 * @param mixed $data Either an array or an object.
34 *
35 * @return void
36 */
37 protected function setup($data)
38 {
39 // use parent to set up data
40 parent::setup($data);
41
42 foreach (static::getServices() as $service)
43 {
44 // register service as option
45 $this->options[$service->id] = $service->name;
46 }
47 }
48
49 /**
50 * Loads a list of available services.
51 *
52 * @return array
53 */
54 protected static function getServices()
55 {
56 // load services only once
57 if (is_null(static::$services))
58 {
59 $dbo = JFactory::getDbo();
60
61 $q = $dbo->getQuery(true)
62 ->select($dbo->qn(array('id', 'name')))
63 ->from($dbo->qn('#__vikappointments_service'))
64 ->order($dbo->qn('ordering') . ' ASC');
65
66 $dbo->setQuery($q);
67
68 // cache services found
69 static::$services = $dbo->loadObjectList();
70 }
71
72 return static::$services;
73 }
74 }
75