/administrator/components/com_banners/views/tracks/view.html.php
PHP | 114 lines | 67 code | 17 blank | 30 comment | 3 complexity | 34d2368c83f875315c72de45f06b2765 MD5 | raw file
Possible License(s): LGPL-2.1
1<?php 2/** 3 * @package Joomla.Administrator 4 * @subpackage com_banners 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 10defined('_JEXEC') or die; 11 12/** 13 * View class for a list of tracks. 14 * 15 * @package Joomla.Administrator 16 * @subpackage com_banners 17 * @since 1.6 18 */ 19class BannersViewTracks extends JViewLegacy 20{ 21 protected $items; 22 23 protected $pagination; 24 25 protected $state; 26 27 /** 28 * Display the view 29 */ 30 public function display($tpl = null) 31 { 32 $this->items = $this->get('Items'); 33 $this->pagination = $this->get('Pagination'); 34 $this->state = $this->get('State'); 35 36 // Check for errors. 37 if (count($errors = $this->get('Errors'))) { 38 JError::raiseError(500, implode("\n", $errors)); 39 return false; 40 } 41 42 BannersHelper::addSubmenu('tracks'); 43 44 $this->addToolbar(); 45 require_once JPATH_COMPONENT .'/models/fields/bannerclient.php'; 46 parent::display($tpl); 47 } 48 49 /** 50 * Add the page title and toolbar. 51 * 52 * @since 1.6 53 */ 54 protected function addToolbar() 55 { 56 require_once JPATH_COMPONENT.'/helpers/banners.php'; 57 58 $canDo = BannersHelper::getActions($this->state->get('filter.category_id')); 59 60 JToolbarHelper::title(JText::_('COM_BANNERS_MANAGER_TRACKS'), 'banners-tracks.png'); 61 62 $bar = JToolBar::getInstance('toolbar'); 63 $bar->appendButton('Popup', 'export', 'JTOOLBAR_EXPORT', 'index.php?option=com_banners&view=download&tmpl=component', 600, 300); 64 $document = JFactory::getDocument(); 65 $app = JFactory::getApplication(); 66 if ($canDo->get('core.delete')) { 67 $bar->appendButton('Confirm', 'COM_BANNERS_DELETE_MSG', 'delete', 'COM_BANNERS_TRACKS_DELETE', 'tracks.delete', false); 68 JToolbarHelper::divider(); 69 } 70 if ($canDo->get('core.admin')) { 71 JToolbarHelper::preferences('com_banners'); 72 JToolbarHelper::divider(); 73 } 74 JToolbarHelper::help('JHELP_COMPONENTS_BANNERS_TRACKS'); 75 76 JSubMenuHelper::setAction('index.php?option=com_banners&view=tracks'); 77 78 JSubMenuHelper::addFilter( 79 JText::_('COM_BANNERS_SELECT_CLIENT'), 80 'filter_client_id', 81 JHtml::_('select.options', BannersHelper::getClientOptions(), 'value', 'text', $this->state->get('filter.client_id')) 82 ); 83 84 JSubMenuHelper::addFilter( 85 JText::_('JOPTION_SELECT_CATEGORY'), 86 'filter_category_id', 87 JHtml::_('select.options', JHtml::_('category.options', 'com_banners'), 'value', 'text', $this->state->get('filter.category_id')) 88 ); 89 90 JSubMenuHelper::addFilter( 91 JText::_('COM_BANNERS_SELECT_TYPE'), 92 'filter_type', 93 JHtml::_('select.options', array(JHtml::_('select.option', 1, JText::_('COM_BANNERS_IMPRESSION')), JHtml::_('select.option', 2, JText::_('COM_BANNERS_CLICK'))), 'value', 'text', $this->state->get('filter.type')) 94 ); 95 } 96 97 /** 98 * Returns an array of fields the table can be sorted by 99 * 100 * @return array Array containing the field name to sort by as the key and display text as value 101 * 102 * @since 3.0 103 */ 104 protected function getSortFields() 105 { 106 return array( 107 'b.name' => JText::_('COM_BANNERS_HEADING_NAME'), 108 'cl.name' => JText::_('COM_BANNERS_HEADING_CLIENT'), 109 'track_type' => JText::_('COM_BANNERS_HEADING_TYPE'), 110 'count' => JText::_('COM_BANNERS_HEADING_COUNT'), 111 'track_date' => JText::_('JDATE') 112 ); 113 } 114}