view.html.php
91 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 API plugins view. |
| 16 | * |
| 17 | * @since 1.7 |
| 18 | */ |
| 19 | class VikAppointmentsViewapiplugins 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 | $filters = array(); |
| 35 | $filters['keysearch'] = $app->getUserStateFromRequest($this->getPoolName() . '.keysearch', 'keysearch', '', 'string'); |
| 36 | |
| 37 | $lim = $app->getUserStateFromRequest('com_vikappointments.limit', 'limit', $app->get('list_limit'), 'int'); |
| 38 | $lim0 = $this->getListLimitStart($filters); |
| 39 | $navbut = ""; |
| 40 | |
| 41 | $apis = VAPFactory::getApi(); |
| 42 | $rows = $apis->getPluginsList(); |
| 43 | |
| 44 | if (strlen($filters['keysearch'])) |
| 45 | { |
| 46 | // filter plugins by search keyword |
| 47 | $rows = array_filter($rows, function($plugin) use ($filters) |
| 48 | { |
| 49 | return stripos(strtolower($plugin->getName()), $filters['keysearch']) !== false || stripos(strtolower($plugin->getTitle()), $filters['keysearch']) !== false; |
| 50 | }); |
| 51 | |
| 52 | // do not keep the assoc keys |
| 53 | $rows = array_values($rows); |
| 54 | } |
| 55 | |
| 56 | if (($count = count($rows)) > $lim) |
| 57 | { |
| 58 | $rows = array_slice($rows, $lim0, $lim); |
| 59 | |
| 60 | jimport('joomla.html.pagination'); |
| 61 | $pageNav = new JPagination($count, $lim0, $lim); |
| 62 | $navbut = JLayoutHelper::render('blocks.pagination', ['pageNav' => $pageNav]); |
| 63 | } |
| 64 | |
| 65 | $this->rows = $rows; |
| 66 | $this->navbut = $navbut; |
| 67 | $this->filters = $filters; |
| 68 | |
| 69 | // display the template (default.php) |
| 70 | parent::display($tpl); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Setting the toolbar. |
| 75 | * |
| 76 | * @return void |
| 77 | */ |
| 78 | private function addToolBar() |
| 79 | { |
| 80 | // add menu title and some buttons to the page |
| 81 | JToolbarHelper::title(JText::translate('VAPMAINTITLEVIEWAPIPLUGINS'), 'vikappointments'); |
| 82 | |
| 83 | JToolBarHelper::back('JTOOLBAR_BACK', 'index.php?option=com_vikappointments&view=editconfigapp'); |
| 84 | |
| 85 | if (JFactory::getUser()->authorise('core.delete', 'com_vikappointments')) |
| 86 | { |
| 87 | JToolbarHelper::deleteList(VikAppointments::getConfirmSystemMessage(), 'apiplugin.delete'); |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 |