view.html.php
95 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 file management view. |
| 16 | * |
| 17 | * @since 1.0 |
| 18 | */ |
| 19 | class VikAppointmentsViewmanagefile extends JViewVAP |
| 20 | { |
| 21 | /** |
| 22 | * VikAppointments view display method. |
| 23 | * |
| 24 | * @return void |
| 25 | */ |
| 26 | function display($tpl = null) |
| 27 | { |
| 28 | $input = JFactory::getApplication()->input; |
| 29 | |
| 30 | // check if we should use a blank component layout |
| 31 | $blank = $input->get('tmpl') == 'component'; |
| 32 | |
| 33 | if (!$blank) |
| 34 | { |
| 35 | // set the toolbar |
| 36 | $this->addToolBar(); |
| 37 | } |
| 38 | |
| 39 | // get files |
| 40 | $file = $input->get('cid', array(), 'string'); |
| 41 | |
| 42 | // keep only the first one |
| 43 | $file = array_shift($file); |
| 44 | |
| 45 | // get file model |
| 46 | $model = JModelVAP::getInstance('file'); |
| 47 | |
| 48 | // load file details |
| 49 | $item = $model->getItem($file); |
| 50 | |
| 51 | if (!$item) |
| 52 | { |
| 53 | $error = $model->getError(); |
| 54 | |
| 55 | if (!$error instanceof Exception) |
| 56 | { |
| 57 | $error = new Exception($error, 500); |
| 58 | } |
| 59 | |
| 60 | // throw exception with error found |
| 61 | throw $error; |
| 62 | } |
| 63 | |
| 64 | $this->file = $item->id; |
| 65 | $this->content = $item->content; |
| 66 | $this->blank = $blank; |
| 67 | |
| 68 | // display the template |
| 69 | parent::display($tpl); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Setting the toolbar. |
| 74 | * |
| 75 | * @return void |
| 76 | * |
| 77 | * @since 1.7 |
| 78 | */ |
| 79 | private function addToolBar() |
| 80 | { |
| 81 | // add menu title and some buttons to the page |
| 82 | JToolbarHelper::title('VikAppointments - Manage File', 'vikappointments'); |
| 83 | |
| 84 | $user = JFactory::getUser(); |
| 85 | |
| 86 | if ($user->authorise('core.admin', 'com_vikappointments')) |
| 87 | { |
| 88 | JToolbarHelper::apply('file.save', JText::translate('VAPSAVE')); |
| 89 | JToolbarHelper::save('file.savecopy', JText::translate('VAPSAVEASCOPY')); |
| 90 | } |
| 91 | |
| 92 | JToolbarHelper::cancel('file.cancel', 'JTOOLBAR_CLOSE'); |
| 93 | } |
| 94 | } |
| 95 |