Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_content
  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 articles.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_content
  17.  * @since       1.6
  18.  */
  19. {
  20.     protected $items;
  21.  
  22.     protected $pagination;
  23.  
  24.     protected $state;
  25.  
  26.     /**
  27.      * Display the view
  28.      *
  29.      * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  30.      *
  31.      * @return  void 
  32.      */
  33.     public function display($tpl = null)
  34.     {
  35.         if ($this->getLayout() !== 'modal')
  36.         {
  37.             ContentHelper::addSubmenu('articles');
  38.         }
  39.  
  40.         $this->items         = $this->get('Items');
  41.         $this->pagination    = $this->get('Pagination');
  42.         $this->state         = $this->get('State');
  43.         $this->authors       = $this->get('Authors');
  44.         $this->filterForm    = $this->get('FilterForm');
  45.         $this->activeFilters = $this->get('ActiveFilters');
  46.  
  47.         // Check for errors.
  48.         if (count($errors = $this->get('Errors')))
  49.         {
  50.             JError::raiseError(500, implode("\n", $errors));
  51.  
  52.             return false;
  53.         }
  54.  
  55.         // Levels filter.
  56.         $options    = array();
  57.         $options[]    = JHtml::_('select.option', '1', JText::_('J1'));
  58.         $options[]    = JHtml::_('select.option', '2', JText::_('J2'));
  59.         $options[]    = JHtml::_('select.option', '3', JText::_('J3'));
  60.         $options[]    = JHtml::_('select.option', '4', JText::_('J4'));
  61.         $options[]    = JHtml::_('select.option', '5', JText::_('J5'));
  62.         $options[]    = JHtml::_('select.option', '6', JText::_('J6'));
  63.         $options[]    = JHtml::_('select.option', '7', JText::_('J7'));
  64.         $options[]    = JHtml::_('select.option', '8', JText::_('J8'));
  65.         $options[]    = JHtml::_('select.option', '9', JText::_('J9'));
  66.         $options[]    = JHtml::_('select.option', '10', JText::_('J10'));
  67.  
  68.         $this->f_levels = $options;
  69.  
  70.         // We don't need toolbar in the modal window.
  71.         if ($this->getLayout() !== 'modal')
  72.         {
  73.             $this->addToolbar();
  74.             $this->sidebar = JHtmlSidebar::render();
  75.         }
  76.  
  77.         parent::display($tpl);
  78.     }
  79.  
  80.     /**
  81.      * Add the page title and toolbar.
  82.      *
  83.      * @return  void 
  84.      *
  85.      * @since   1.6
  86.      */
  87.     protected function addToolbar()
  88.     {
  89.         $canDo = JHelperContent::getActions($this->state->get('filter.category_id'), 0, 'com_content');
  90.         $user  = JFactory::getUser();
  91.  
  92.         // Get the toolbar object instance
  93.         $bar = JToolBar::getInstance('toolbar');
  94.  
  95.         JToolbarHelper::title(JText::_('COM_CONTENT_ARTICLES_TITLE'), 'stack article');
  96.  
  97.         if ($canDo->get('core.create') || (count($user->getAuthorisedCategories('com_content', 'core.create'))) > 0 )
  98.         {
  99.             JToolbarHelper::addNew('article.add');
  100.         }
  101.  
  102.         if (($canDo->get('core.edit')) || ($canDo->get('core.edit.own')))
  103.         {
  104.             JToolbarHelper::editList('article.edit');
  105.         }
  106.  
  107.         if ($canDo->get('core.edit.state'))
  108.         {
  109.             JToolbarHelper::publish('articles.publish', 'JTOOLBAR_PUBLISH', true);
  110.             JToolbarHelper::unpublish('articles.unpublish', 'JTOOLBAR_UNPUBLISH', true);
  111.             JToolbarHelper::custom('articles.featured', 'featured.png', 'featured_f2.png', 'JFEATURED', true);
  112.             JToolbarHelper::archiveList('articles.archive');
  113.             JToolbarHelper::checkin('articles.checkin');
  114.         }
  115.  
  116.         if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete'))
  117.         {
  118.             JToolbarHelper::deleteList('', 'articles.delete', 'JTOOLBAR_EMPTY_TRASH');
  119.         }
  120.         elseif ($canDo->get('core.edit.state'))
  121.         {
  122.             JToolbarHelper::trash('articles.trash');
  123.         }
  124.  
  125.         // Add a batch button
  126.         if ($user->authorise('core.create', 'com_content') && $user->authorise('core.edit', 'com_content') && $user->authorise('core.edit.state', 'com_content'))
  127.         {
  128.             JHtml::_('bootstrap.modal', 'collapseModal');
  129.             $title = JText::_('JTOOLBAR_BATCH');
  130.  
  131.             // Instantiate a new JLayoutFile instance and render the batch button
  132.             $layout = new JLayoutFile('joomla.toolbar.batch');
  133.  
  134.             $dhtml = $layout->render(array('title' => $title));
  135.             $bar->appendButton('Custom', $dhtml, 'batch');
  136.         }
  137.  
  138.         if ($canDo->get('core.admin'))
  139.         {
  140.             JToolbarHelper::preferences('com_content');
  141.         }
  142.  
  143.         JToolbarHelper::help('JHELP_CONTENT_ARTICLE_MANAGER');
  144.     }
  145.  
  146.     /**
  147.      * Returns an array of fields the table can be sorted by
  148.      *
  149.      * @return  array  Array containing the field name to sort by as the key and display text as value
  150.      *
  151.      * @since   3.0
  152.      */
  153.     protected function getSortFields()
  154.     {
  155.         return array(
  156.             'a.ordering'     => JText::_('JGRID_HEADING_ORDERING'),
  157.             'a.state'        => JText::_('JSTATUS'),
  158.             'a.title'        => JText::_('JGLOBAL_TITLE'),
  159.             'category_title' => JText::_('JCATEGORY'),
  160.             'access_level'   => JText::_('JGRID_HEADING_ACCESS'),
  161.             'a.created_by'   => JText::_('JAUTHOR'),
  162.             'language'       => JText::_('JGRID_HEADING_LANGUAGE'),
  163.             'a.created'      => JText::_('JDATE'),
  164.             'a.id'           => JText::_('JGRID_HEADING_ID'),
  165.             'a.featured'     => JText::_('JFEATURED')
  166.         );
  167.     }
  168. }

Documentation generated on Tue, 19 Nov 2013 15:16:55 +0100 by phpDocumentor 1.4.3