| Joomla! | PHP Cross Reference | Web Portals |
1 <?php 2 /** 3 * @package Joomla.Administrator 4 * @subpackage com_contact 5 * 6 * @copyright Copyright (C) 2005 - 2012 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 class ContactViewContacts extends JViewLegacy 20 { 21 protected $items; 22 23 protected $pagination; 24 25 protected $state; 26 27 /** 28 * Display the view 29 * 30 * @return void 31 */ 32 public function display($tpl = null) 33 { 34 $this->items = $this->get('Items'); 35 $this->pagination = $this->get('Pagination'); 36 $this->state = $this->get('State'); 37 38 ContactHelper::addSubmenu('contacts'); 39 40 // Check for errors. 41 if (count($errors = $this->get('Errors'))) { 42 JError::raiseError(500, implode("\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 $item->order_up = true; 50 $item->order_dn = true; 51 } 52 53 $this->addToolbar(); 54 $this->sidebar = JHtmlSidebar::render(); 55 parent::display($tpl); 56 } 57 58 /** 59 * Add the page title and toolbar. 60 * 61 * @since 1.6 62 */ 63 protected function addToolbar() 64 { 65 require_once JPATH_COMPONENT.'/helpers/contact.php'; 66 $canDo = ContactHelper::getActions($this->state->get('filter.category_id')); 67 $user = JFactory::getUser(); 68 // Get the toolbar object instance 69 $bar = JToolBar::getInstance('toolbar'); 70 71 JToolbarHelper::title(JText::_('COM_CONTACT_MANAGER_CONTACTS'), 'contact.png'); 72 73 if ($canDo->get('core.create') || (count($user->getAuthorisedCategories('com_contact', 'core.create'))) > 0) { 74 JToolbarHelper::addNew('contact.add'); 75 } 76 77 if (($canDo->get('core.edit')) || ($canDo->get('core.edit.own'))) { 78 JToolbarHelper::editList('contact.edit'); 79 } 80 81 if ($canDo->get('core.edit.state')) { 82 JToolbarHelper::publish('contacts.publish', 'JTOOLBAR_PUBLISH', true); 83 JToolbarHelper::unpublish('contacts.unpublish', 'JTOOLBAR_UNPUBLISH', true); 84 JToolbarHelper::archiveList('contacts.archive'); 85 JToolbarHelper::checkin('contacts.checkin'); 86 } 87 88 if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) { 89 JToolbarHelper::deleteList('', 'contacts.delete', 'JTOOLBAR_EMPTY_TRASH'); 90 } 91 elseif ($canDo->get('core.edit.state')) { 92 JToolbarHelper::trash('contacts.trash'); 93 } 94 95 // Add a batch button 96 if ($user->authorise('core.edit')) 97 { 98 JHtml::_('bootstrap.modal', 'collapseModal'); 99 $title = JText::_('JTOOLBAR_BATCH'); 100 $dhtml = "<button data-toggle=\"modal\" data-target=\"#collapseModal\" class=\"btn btn-small\"> 101 <i class=\"icon-checkbox-partial\" title=\"$title\"></i> 102 $title</button>"; 103 $bar->appendButton('Custom', $dhtml, 'batch'); 104 } 105 106 if ($canDo->get('core.admin')) { 107 JToolbarHelper::preferences('com_contact'); 108 } 109 110 JToolbarHelper::help('JHELP_COMPONENTS_CONTACTS_CONTACTS'); 111 112 JHtmlSidebar::setAction('index.php?option=com_contact'); 113 114 JHtmlSidebar::addFilter( 115 JText::_('JOPTION_SELECT_PUBLISHED'), 116 'filter_published', 117 JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true) 118 ); 119 120 JHtmlSidebar::addFilter( 121 JText::_('JOPTION_SELECT_CATEGORY'), 122 'filter_category_id', 123 JHtml::_('select.options', JHtml::_('category.options', 'com_contact'), 'value', 'text', $this->state->get('filter.category_id')) 124 ); 125 126 JHtmlSidebar::addFilter( 127 JText::_('JOPTION_SELECT_ACCESS'), 128 'filter_access', 129 JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access')) 130 ); 131 132 JHtmlSidebar::addFilter( 133 JText::_('JOPTION_SELECT_LANGUAGE'), 134 'filter_language', 135 JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $this->state->get('filter.language')) 136 ); 137 } 138 139 /** 140 * Returns an array of fields the table can be sorted by 141 * 142 * @return array Array containing the field name to sort by as the key and display text as value 143 * 144 * @since 3.0 145 */ 146 protected function getSortFields() 147 { 148 return array( 149 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), 150 'a.published' => JText::_('JSTATUS'), 151 'a.name' => JText::_('JGLOBAL_TITLE'), 152 'category_title' => JText::_('JCATEGORY'), 153 'ul.name' => JText::_('COM_CONTACT_FIELD_LINKED_USER_LABEL'), 154 'a.featured' => JText::_('JFEATURED'), 155 'a.access' => JText::_('JGRID_HEADING_ACCESS'), 156 'a.language' => JText::_('JGRID_HEADING_LANGUAGE'), 157 'a.id' => JText::_('JGRID_HEADING_ID') 158 ); 159 } 160 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title