/administrator/components/com_banners/views/tracks/view.html.php

https://bitbucket.org/eternaware/joomus · PHP · 114 lines · 67 code · 17 blank · 30 comment · 3 complexity · 34d2368c83f875315c72de45f06b2765 MD5 · raw file

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