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 / admin / views / managecountry / view.html.php
vikappointments / admin / views / managecountry Last commit date
tmpl 2 days ago index.html 2 days ago view.html.php 2 days ago
view.html.php
117 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 country management view.
16 *
17 * @since 1.5
18 */
19 class VikAppointmentsViewmanagecountry extends JViewVAP
20 {
21 /**
22 * VikAppointments view display method.
23 *
24 * @return void
25 */
26 function display($tpl = null)
27 {
28 $dbo = JFactory::getDbo();
29 $app = JFactory::getApplication();
30 $input = $app->input;
31
32 $ids = $input->getUint('cid', array());
33 $type = $ids ? 'edit' : 'new';
34
35 // set the toolbar
36 $this->addToolBar($type);
37
38 $country = null;
39
40 if ($type == 'edit')
41 {
42 $q = $dbo->getQuery(true)
43 ->select('*')
44 ->from($dbo->qn('#__vikappointments_countries'))
45 ->where($dbo->qn('id') . ' = ' . $ids[0]);
46
47 $dbo->setQuery($q, 0, 1);
48 $country = $dbo->loadObject();
49 }
50
51 if (empty($country))
52 {
53 $country = (object) $this->getBlankItem();
54 }
55
56 // use country data stored in user state
57 $this->injectUserStateData($country, 'vap.country.data');
58
59 $this->country = $country;
60
61 // display the template
62 parent::display($tpl);
63 }
64
65 /**
66 * Setting the toolbar.
67 *
68 * @return void
69 */
70 protected function addToolBar($type)
71 {
72 // add menu title and some buttons to the page
73 if ($type == 'edit')
74 {
75 JToolBarHelper::title(JText::translate('VAPMAINTITLEEDITCOUNTRY'), 'vikappointments');
76 }
77 else
78 {
79 JToolBarHelper::title(JText::translate('VAPMAINTITLENEWCOUNTRY'), 'vikappointments');
80 }
81
82 $user = JFactory::getUser();
83
84 if ($user->authorise('core.edit', 'com_vikappointments')
85 || $user->authorise('core.create', 'com_vikappointments'))
86 {
87 JToolbarHelper::apply('country.save', JText::translate('VAPSAVE'));
88 JToolbarHelper::save('country.saveclose', JText::translate('VAPSAVEANDCLOSE'));
89 }
90
91 if ($user->authorise('core.edit', 'com_vikappointments')
92 && $user->authorise('core.create', 'com_vikappointments'))
93 {
94 JToolbarHelper::save2new('country.savenew', JText::translate('VAPSAVEANDNEW'));
95 }
96
97 JToolBarHelper::cancel('country.cancel', $type == 'edit' ? 'JTOOLBAR_CLOSE' : 'JTOOLBAR_CANCEL');
98 }
99
100 /**
101 * Returns a blank item.
102 *
103 * @return array A blank item for new requests.
104 */
105 protected function getBlankItem()
106 {
107 return array(
108 'id' => 0,
109 'country_name' => '',
110 'country_2_code' => '',
111 'country_3_code' => '',
112 'phone_prefix' => '',
113 'published' => 0,
114 );
115 }
116 }
117