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 / libraries / mvc / admin / views / shortcode / view.html.php
vikappointments / libraries / mvc / admin / views / shortcode Last commit date
tmpl 3 days ago view.html.php 3 days ago
view.html.php
105 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 * VikAppointments Shortcode view.
16 *
17 * @since 1.0
18 */
19 class VikAppointmentsViewShortcode extends JViewVAP
20 {
21 /**
22 * @override
23 * View display method.
24 *
25 * @return void
26 */
27 public function display($tpl = null)
28 {
29 $app = JFactory::getApplication();
30 $input = $app->input;
31
32 $model = $this->getModel();
33
34 $return = $input->getBase64('return', '');
35
36 $shortcode = (array) $model->loadFormData();
37
38 JLoader::import('adapter.filesystem.folder');
39
40 // views
41
42 $views = array();
43
44 // get all the views that contain a default.xml file
45 // [0] : base path
46 // [1] : query
47 // [2] : true for recursive search
48 // [3] : true to return full paths
49 $files = JFolder::files(VAPBASE . DIRECTORY_SEPARATOR . 'views', 'default.xml', true, true);
50
51 foreach ($files as $f)
52 {
53 // retrieve the view ID from the path: /views/[ID]/tmpl/default.xml
54 if (preg_match("/[\/\\\\]views[\/\\\\](.*?)[\/\\\\]tmpl[\/\\\\]default\.xml$/i", $f, $matches))
55 {
56 $id = $matches[1];
57 // load the XML form
58 $form = JForm::getInstance($id, $f);
59 // get the view title
60 $views[$id] = array(
61 'name' => (string) $form->getXml()->layout->attributes()->title,
62 'desc' => (string) $form->getXml()->layout->message,
63 );
64 }
65 }
66
67 // obtain the type form
68 $form = $model->getTypeForm($shortcode);
69
70 $this->shortcode = $shortcode;
71 $this->views = $views;
72 $this->returnLink = $return;
73 $this->form = $form;
74
75 $this->shortcodesList = JModelVAP::getInstance('shortcodes')->all();
76
77 $this->addToolbar();
78
79 // display parent
80 parent::display($tpl);
81 }
82
83 /**
84 * Helper method to setup the toolbar.
85 *
86 * @return void
87 */
88 public function addToolbar()
89 {
90 if ($this->shortcode['id'] > 0)
91 {
92 JToolbarHelper::title(JText::translate('VAPEDITSHORTCDMENUTITLE'));
93 }
94 else
95 {
96 JToolbarHelper::title(JText::translate('VAPNEWSHORTCDMENUTITLE'));
97 }
98
99 JToolbarHelper::apply('shortcode.save');
100 JToolbarHelper::save('shortcode.saveclose');
101 JToolbarHelper::save2new('shortcode.savenew');
102 JToolbarHelper::cancel('shortcodes.cancel');
103 }
104 }
105