PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / trunk
VikAppointments Services Booking Calendar vtrunk
trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / views / editconfigapp / view.html.php
vikappointments / admin / views / editconfigapp Last commit date
tmpl 4 years ago index.html 4 years ago view.html.php 5 months ago
view.html.php
147 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.backup.manager');
15
16 /**
17 * VikAppointments applications configuration view.
18 *
19 * @since 1.7
20 */
21 class VikAppointmentsVieweditconfigapp extends JViewVAP
22 {
23 /**
24 * VikAppointments view display method.
25 *
26 * @return void
27 */
28 function display($tpl = null)
29 {
30 $app = JFactory::getApplication();
31
32 $root = JUri::root();
33
34 $cookie = $app->input->cookie;
35
36 $this->filters = [
37 'preview_status' => $cookie->getBool('vikappointments_customizer_preview_status', true),
38 'preview_page' => $cookie->getString('vikappointments_customizer_preview_page', $root),
39 ];
40
41 // set the toolbar
42 $this->addToolBar();
43
44 // get config
45 $this->config = VAPFactory::getConfig();
46
47 // fetch all the supported export types
48 $this->backupExportTypes = VAPBackupManager::getExportTypes();
49
50 // create customizer model
51 $this->customizerModel = JModelVAP::getInstance('customizer');
52
53 // fetch variables tree of CSS customizer
54 $this->customizerTree = $this->customizerModel->getVarsTree();
55
56 // fetch all the support pages
57 $this->menuItems = [];
58
59 if (VersionListener::isJoomla())
60 {
61 // get site menu
62 $menu = JApplicationCms::getInstance('site')->getMenu()->getMenu();
63
64 // check if we should use the SEF route or a plain link
65 $is_sef = $app->get('sef') && $app->get('sef_rewrite');
66
67 foreach ($menu as $item)
68 {
69 // build menu item name
70 $text = str_repeat('- ', $item->level - 1) . $item->title;
71
72 if ($item->language && $item->language !== '*')
73 {
74 // append language tag
75 $text .= ' (' . $item->language . ')';
76 }
77
78 $value = $root;
79
80 // exclude root in case of HOME
81 if (!$item->home)
82 {
83 if ($is_sef)
84 {
85 // use SEF route
86 $value .= $item->route;
87 }
88 else
89 {
90 // use plain link
91 $value .= $item->link;
92 }
93 }
94
95 // register menu item
96 $this->menuItems[] = JHtml::fetch('select.option', $value, $text);
97 }
98 }
99 else if (VersionListener::isWordpress())
100 {
101 // add empty option (HOME)
102 $this->menuItems[] = JHtml::fetch('select.option', $root, JText::translate('JGLOBAL_SELECT_AN_OPTION'));
103
104 // iterate all theme locations
105 foreach (wp_get_nav_menus() as $l)
106 {
107 // get all menu items assigned to this location
108 $items = wp_get_nav_menu_items($l);
109
110 // check if we have some items because the function above might return false,
111 // which could raise a warning since PHP 7 version
112 if ($items)
113 {
114 // iterate all menu items assigned to this location
115 foreach ($items as $item)
116 {
117 // register menu item
118 $this->menuItems[] = JHtml::fetch('select.option', $item->url, $item->title);
119 }
120 }
121 }
122 }
123
124 // display the template
125 parent::display($tpl);
126 }
127
128 /**
129 * Setting the toolbar.
130 *
131 * @return void
132 */
133 protected function addToolBar()
134 {
135 // add menu title and some buttons to the page
136 JToolBarHelper::title(JText::translate('VAPMAINTITLECONFIG'), 'vikappointments');
137
138 if (JFactory::getUser()->authorise('core.edit', 'com_vikappointments'))
139 {
140 JToolBarHelper::apply('configapp.save', JText::translate('VAPSAVE'));
141 JToolBarHelper::divider();
142 }
143
144 JToolBarHelper::cancel('dashboard.cancel', 'JTOOLBAR_CLOSE');
145 }
146 }
147