PluginProbe
VikAppointments Services Booking Calendar / 1.2.20
VikAppointments Services Booking Calendar v1.2.20
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / views / managelangmedia / view.html.php
view.html.php
125 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 translation media management view.
16 *
17 * @since 1.7.2
18 */
19 class VikAppointmentsViewmanagelangmedia extends JViewVAP
20 {
21 /**
22 * VikAppointments view display method.
23 *
24 * @return void
25 */
26 function display($tpl = null)
27 {
28 $app = JFactory::getApplication();
29 $input = $app->input;
30 $dbo = JFactory::getDbo();
31
32 $image = $input->getString('image', 0);
33
34 $ids = $input->get('cid', array(), 'uint');
35 $type = $ids ? 'edit' : 'new';
36
37 // set the toolbar
38 $this->addToolBar($type);
39
40 $language = null;
41
42 // load translation details in case of management
43 if ($type == 'edit')
44 {
45 $q = $dbo->getQuery(true);
46
47 $q->select('*')
48 ->from($dbo->qn('#__vikappointments_lang_media'))
49 ->where($dbo->qn('id') . ' = ' . $ids[0]);
50
51 $dbo->setQuery($q, 0, 1);
52 $language = $dbo->loadObject();
53
54 if ($language)
55 {
56 // retrieve media image from translation object
57 $image = $language->image;
58 }
59 }
60
61 // get default details
62 $default = null;
63
64 $q = $dbo->getQuery(true)
65 ->select($dbo->qn(array('id', 'image', 'alt', 'title', 'caption')))
66 ->from($dbo->qn('#__vikappointments_media'))
67 ->where($dbo->qn('image') . ' = ' . $dbo->q($image));
68
69 $dbo->setQuery($q, 0, 1);
70 $default = $dbo->loadObject();
71
72 if (!$default)
73 {
74 $app->enqueueMessage(JText::translate('VAPMANAGEMEDIANOTRX'), 'warning');
75 $app->redirect('index.php?option=com_vikappointments&task=media.edit&cid[]=' . $image);
76 $app->close();
77 }
78
79 $this->default = $default;
80 $this->language = $language;
81
82 // display the template
83 parent::display($tpl);
84 }
85
86 /**
87 * Setting the toolbar.
88 *
89 * @param string $type The view type ('edit' or 'new').
90 *
91 * @return void
92 *
93 * @since 1.7
94 */
95 private function addToolBar($type)
96 {
97 // add menu title and some buttons to the page
98 if ($type == 'edit')
99 {
100 JToolbarHelper::title(JText::translate('VAP_TRX_EDIT_TITLE'), 'vikappointments');
101 }
102 else
103 {
104 JToolbarHelper::title(JText::translate('VAP_TRX_NEW_TITLE'), 'vikappointments');
105 }
106
107 $user = JFactory::getUser();
108
109 if ($user->authorise('core.edit', 'com_vikappointments')
110 || $user->authorise('core.create', 'com_vikappointments'))
111 {
112 JToolbarHelper::apply('langmedia.save', JText::translate('VAPSAVE'));
113 JToolbarHelper::save('langmedia.saveclose', JText::translate('VAPSAVEANDCLOSE'));
114 }
115
116 if ($user->authorise('core.edit', 'com_vikappointments')
117 && $user->authorise('core.create', 'com_vikappointments'))
118 {
119 JToolbarHelper::save2new('langmedia.savenew', JText::translate('VAPSAVEANDNEW'));
120 }
121
122 JToolbarHelper::cancel('langmedia.cancel', $type == 'edit' ? 'JTOOLBAR_CLOSE' : 'JTOOLBAR_CANCEL');
123 }
124 }
125