view.html.php
85 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 media management view. |
| 16 | * |
| 17 | * @since 1.2 |
| 18 | */ |
| 19 | class VikAppointmentsViewmanagemedia 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 | |
| 31 | // set the toolbar |
| 32 | $this->addToolBar(); |
| 33 | |
| 34 | $filename = $input->get('cid', array(''), 'string'); |
| 35 | $filename = $filename[0]; |
| 36 | |
| 37 | if (empty($filename) || !file_exists(VAPMEDIA . DIRECTORY_SEPARATOR . $filename)) |
| 38 | { |
| 39 | $app->redirect('index.php?option=com_vikappointments&view=media'); |
| 40 | exit; |
| 41 | } |
| 42 | |
| 43 | $media = AppointmentsHelper::getFileProperties(VAPMEDIA . DIRECTORY_SEPARATOR . $filename); |
| 44 | $thumb = AppointmentsHelper::getFileProperties(VAPMEDIA_SMALL . DIRECTORY_SEPARATOR . $filename); |
| 45 | |
| 46 | // fetch media attributes |
| 47 | $attrs = JModelVAP::getInstance('media')->getItem($media['name'], $new = true); |
| 48 | |
| 49 | // inject media attributes within the array |
| 50 | foreach ($attrs as $k => $v) |
| 51 | { |
| 52 | // do not overwrite an existing attribute |
| 53 | if (!isset($media[$k])) |
| 54 | { |
| 55 | $media[$k] = $v; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | $this->media = &$media; |
| 60 | $this->thumb = &$thumb; |
| 61 | |
| 62 | // display the template |
| 63 | parent::display($tpl); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Setting the toolbar. |
| 68 | * |
| 69 | * @return void |
| 70 | */ |
| 71 | private function addToolBar() { |
| 72 | // add menu title and some buttons to the page |
| 73 | JToolbarHelper::title(JText::translate('VAPMAINTITLEEDITMEDIA'), 'vikappointments'); |
| 74 | |
| 75 | if (JFactory::getUser()->authorise('core.edit', 'com_vikappointments')) |
| 76 | { |
| 77 | JToolbarHelper::apply('media.save', JText::translate('VAPSAVE')); |
| 78 | JToolbarHelper::save('media.saveclose', JText::translate('VAPSAVEANDCLOSE')); |
| 79 | JToolbarHelper::save2new('media.savenew', JText::translate('VAPSAVEANDNEW')); |
| 80 | } |
| 81 | |
| 82 | JToolbarHelper::cancel('media.cancel', 'JTOOLBAR_CLOSE'); |
| 83 | } |
| 84 | } |
| 85 |