Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_contact
  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 contacts.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_contact
  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.      * @return  void 
  30.      */
  31.     public function display($tpl null)
  32.     {
  33.         $this->items        = $this->get('Items');
  34.         $this->pagination    = $this->get('Pagination');
  35.         $this->state        = $this->get('State');
  36.  
  37.         ContactHelper::addSubmenu('contacts');
  38.  
  39.         // Check for errors.
  40.         if (count($errors $this->get('Errors')))
  41.         {
  42.             JError::raiseError(500implode("\n"$errors));
  43.             return false;
  44.         }
  45.  
  46.         // Preprocess the list of items to find ordering divisions.
  47.         // TODO: Complete the ordering stuff with nested sets
  48.         foreach ($this->items as &$item)
  49.         {
  50.             $item->order_up true;
  51.             $item->order_dn true;
  52.         }
  53.  
  54.         $this->addToolbar();
  55.         $this->sidebar JHtmlSidebar::render();
  56.         parent::display($tpl);
  57.     }
  58.  
  59.     /**
  60.      * Add the page title and toolbar.
  61.      *
  62.      * @since   1.6
  63.      */
  64.     protected function addToolbar()
  65.     {
  66.         require_once JPATH_COMPONENT '/helpers/contact.php';
  67.         $canDo    JHelperContent::getActions($this->state->get('filter.category_id')0'com_contact');
  68.         $user    JFactory::getUser();
  69.  
  70.         // Get the toolbar object instance
  71.         $bar JToolBar::getInstance('toolbar');
  72.  
  73.         JToolbarHelper::title(JText::_('COM_CONTACT_MANAGER_CONTACTS')'address contact');
  74.  
  75.         if ($canDo->get('core.create'|| (count($user->getAuthorisedCategories('com_contact''core.create'))) 0)
  76.         {
  77.             JToolbarHelper::addNew('contact.add');
  78.         }
  79.  
  80.         if (($canDo->get('core.edit')) || ($canDo->get('core.edit.own')))
  81.         {
  82.             JToolbarHelper::editList('contact.edit');
  83.         }
  84.  
  85.         if ($canDo->get('core.edit.state'))
  86.         {
  87.             JToolbarHelper::publish('contacts.publish''JTOOLBAR_PUBLISH'true);
  88.             JToolbarHelper::unpublish('contacts.unpublish''JTOOLBAR_UNPUBLISH'true);
  89.             JToolbarHelper::archiveList('contacts.archive');
  90.             JToolbarHelper::checkin('contacts.checkin');
  91.         }
  92.  
  93.         if ($this->state->get('filter.published'== -&& $canDo->get('core.delete'))
  94.         {
  95.             JToolbarHelper::deleteList('''contacts.delete''JTOOLBAR_EMPTY_TRASH');
  96.         }
  97.         elseif ($canDo->get('core.edit.state'))
  98.         {
  99.             JToolbarHelper::trash('contacts.trash');
  100.         }
  101.  
  102.         // Add a batch button
  103.         if ($user->authorise('core.create''com_contacts'&& $user->authorise('core.edit''com_contacts'&& $user->authorise('core.edit.state''com_contacts'))
  104.         {
  105.             JHtml::_('bootstrap.modal''collapseModal');
  106.             $title JText::_('JTOOLBAR_BATCH');
  107.  
  108.             // Instantiate a new JLayoutFile instance and render the batch button
  109.             $layout new JLayoutFile('joomla.toolbar.batch');
  110.  
  111.             $dhtml $layout->render(array('title' => $title));
  112.             $bar->appendButton('Custom'$dhtml'batch');
  113.         }
  114.  
  115.         if ($canDo->get('core.admin'))
  116.         {
  117.             JToolbarHelper::preferences('com_contact');
  118.         }
  119.  
  120.         JToolbarHelper::help('JHELP_COMPONENTS_CONTACTS_CONTACTS');
  121.  
  122.         JHtmlSidebar::setAction('index.php?option=com_contact');
  123.  
  124.         JHtmlSidebar::addFilter(
  125.             JText::_('JOPTION_SELECT_PUBLISHED'),
  126.             'filter_published',
  127.             JHtml::_('select.options'JHtml::_('jgrid.publishedOptions')'value''text'$this->state->get('filter.published')true)
  128.         );
  129.  
  130.         JHtmlSidebar::addFilter(
  131.             JText::_('JOPTION_SELECT_CATEGORY'),
  132.             'filter_category_id',
  133.             JHtml::_('select.options'JHtml::_('category.options''com_contact')'value''text'$this->state->get('filter.category_id'))
  134.         );
  135.  
  136.         JHtmlSidebar::addFilter(
  137.             JText::_('JOPTION_SELECT_ACCESS'),
  138.             'filter_access',
  139.             JHtml::_('select.options'JHtml::_('access.assetgroups')'value''text'$this->state->get('filter.access'))
  140.         );
  141.  
  142.         JHtmlSidebar::addFilter(
  143.             JText::_('JOPTION_SELECT_LANGUAGE'),
  144.             'filter_language',
  145.             JHtml::_('select.options'JHtml::_('contentlanguage.existing'truetrue)'value''text'$this->state->get('filter.language'))
  146.         );
  147.  
  148.         JHtmlSidebar::addFilter(
  149.         JText::_('JOPTION_SELECT_TAG'),
  150.         'filter_tag',
  151.         JHtml::_('select.options'JHtml::_('tag.options'truetrue)'value''text'$this->state->get('filter.tag'))
  152.         );
  153.  
  154.     }
  155.  
  156.     /**
  157.      * Returns an array of fields the table can be sorted by
  158.      *
  159.      * @return  array  Array containing the field name to sort by as the key and display text as value
  160.      *
  161.      * @since   3.0
  162.      */
  163.     protected function getSortFields()
  164.     {
  165.         return array(
  166.             'a.ordering' => JText::_('JGRID_HEADING_ORDERING'),
  167.             'a.published' => JText::_('JSTATUS'),
  168.             'a.name' => JText::_('JGLOBAL_TITLE'),
  169.             'category_title' => JText::_('JCATEGORY'),
  170.             'ul.name' => JText::_('COM_CONTACT_FIELD_LINKED_USER_LABEL'),
  171.             'a.featured' => JText::_('JFEATURED'),
  172.             'a.access' => JText::_('JGRID_HEADING_ACCESS'),
  173.             'a.language' => JText::_('JGRID_HEADING_LANGUAGE'),
  174.             'a.id' => JText::_('JGRID_HEADING_ID')
  175.         );
  176.     }
  177. }

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