Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_banners
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * View class for a list of banners.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_banners
  17.  * @since       1.6
  18.  */
  19. {
  20.     protected $categories;
  21.  
  22.     protected $items;
  23.  
  24.     protected $pagination;
  25.  
  26.     protected $state;
  27.  
  28.     /**
  29.      * Method to display the view.
  30.      *
  31.      * @param   string  $tpl  A template file to load. [optional]
  32.      *
  33.      * @return  mixed  A string if successful, otherwise a JError object.
  34.      *
  35.      * @since   1.6
  36.      */
  37.     public function display($tpl null)
  38.     {
  39.         $this->categories    = $this->get('CategoryOrders');
  40.         $this->items        = $this->get('Items');
  41.         $this->pagination    = $this->get('Pagination');
  42.         $this->state        = $this->get('State');
  43.         $this->filterForm    $this->get('FilterForm');
  44.         $this->activeFilters $this->get('ActiveFilters');
  45.  
  46.         // Check for errors.
  47.         if (count($errors $this->get('Errors')))
  48.         {
  49.             JError::raiseError(500implode("\n"$errors));
  50.  
  51.             return false;
  52.         }
  53.  
  54.         BannersHelper::addSubmenu('banners');
  55.  
  56.         $this->addToolbar();
  57.         require_once JPATH_COMPONENT '/models/fields/bannerclient.php';
  58.  
  59.         // Include the component HTML helpers.
  60.         JHtml::addIncludePath(JPATH_COMPONENT '/helpers/html');
  61.  
  62.         $this->sidebar JHtmlSidebar::render();
  63.         parent::display($tpl);
  64.     }
  65.  
  66.     /**
  67.      * Add the page title and toolbar.
  68.      *
  69.      * @return  void 
  70.      *
  71.      * @since   1.6
  72.      */
  73.     protected function addToolbar()
  74.     {
  75.         require_once JPATH_COMPONENT '/helpers/banners.php';
  76.  
  77.         $canDo JHelperContent::getActions($this->state->get('filter.category_id')0'com_banners');
  78.         $user JFactory::getUser();
  79.  
  80.         // Get the toolbar object instance
  81.         $bar JToolBar::getInstance('toolbar');
  82.  
  83.         JToolbarHelper::title(JText::_('COM_BANNERS_MANAGER_BANNERS')'banners.png');
  84.  
  85.         if (count($user->getAuthorisedCategories('com_banners''core.create')) 0)
  86.         {
  87.             JToolbarHelper::addNew('banner.add');
  88.         }
  89.  
  90.         if (($canDo->get('core.edit')))
  91.         {
  92.             JToolbarHelper::editList('banner.edit');
  93.         }
  94.  
  95.         if ($canDo->get('core.edit.state'))
  96.         {
  97.             if ($this->state->get('filter.state'!= 2)
  98.             {
  99.                 JToolbarHelper::publish('banners.publish''JTOOLBAR_PUBLISH'true);
  100.                 JToolbarHelper::unpublish('banners.unpublish''JTOOLBAR_UNPUBLISH'true);
  101.             }
  102.  
  103.             if ($this->state->get('filter.state'!= -1)
  104.             {
  105.                 if ($this->state->get('filter.state'!= 2)
  106.                 {
  107.                     JToolbarHelper::archiveList('banners.archive');
  108.                 }
  109.                 elseif ($this->state->get('filter.state'== 2)
  110.                 {
  111.                     JToolbarHelper::unarchiveList('banners.publish');
  112.                 }
  113.             }
  114.         }
  115.  
  116.         if ($canDo->get('core.edit.state'))
  117.         {
  118.             JToolbarHelper::checkin('banners.checkin');
  119.         }
  120.  
  121.         if ($this->state->get('filter.state'== -&& $canDo->get('core.delete'))
  122.         {
  123.             JToolbarHelper::deleteList('''banners.delete''JTOOLBAR_EMPTY_TRASH');
  124.         }
  125.         elseif ($canDo->get('core.edit.state'))
  126.         {
  127.             JToolbarHelper::trash('banners.trash');
  128.         }
  129.  
  130.         // Add a batch button
  131.         if ($user->authorise('core.create''com_banners'&& $user->authorise('core.edit''com_banners'&& $user->authorise('core.edit.state''com_banners'))
  132.         {
  133.             JHtml::_('bootstrap.modal''collapseModal');
  134.             $title JText::_('JTOOLBAR_BATCH');
  135.  
  136.             // Instantiate a new JLayoutFile instance and render the batch button
  137.             $layout new JLayoutFile('joomla.toolbar.batch');
  138.  
  139.             $dhtml $layout->render(array('title' => $title));
  140.             $bar->appendButton('Custom'$dhtml'batch');
  141.         }
  142.  
  143.         if ($canDo->get('core.admin'))
  144.         {
  145.             JToolbarHelper::preferences('com_banners');
  146.         }
  147.  
  148.         JToolbarHelper::help('JHELP_COMPONENTS_BANNERS_BANNERS');
  149.     }
  150.  
  151.     /**
  152.      * Returns an array of fields the table can be sorted by
  153.      *
  154.      * @return  array  Array containing the field name to sort by as the key and display text as value
  155.      *
  156.      * @since   3.0
  157.      */
  158.     protected function getSortFields()
  159.     {
  160.         return array(
  161.             'ordering' => JText::_('JGRID_HEADING_ORDERING'),
  162.             'a.state' => JText::_('JSTATUS'),
  163.             'a.name' => JText::_('COM_BANNERS_HEADING_NAME'),
  164.             'a.sticky' => JText::_('COM_BANNERS_HEADING_STICKY'),
  165.             'client_name' => JText::_('COM_BANNERS_HEADING_CLIENT'),
  166.             'impmade' => JText::_('COM_BANNERS_HEADING_IMPRESSIONS'),
  167.             'clicks' => JText::_('COM_BANNERS_HEADING_CLICKS'),
  168.             'a.language' => JText::_('JGRID_HEADING_LANGUAGE'),
  169.             'a.id' => JText::_('JGRID_HEADING_ID')
  170.         );
  171.     }
  172. }

Documentation generated on Tue, 19 Nov 2013 15:17:48 +0100 by phpDocumentor 1.4.3