/administrator/components/com_finder/views/filters/view.html.php

https://bitbucket.org/eternaware/joomus · PHP · 103 lines · 58 code · 12 blank · 33 comment · 5 complexity · 989c7ccf41aa0ff5d626280caaaf3bb3 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Administrator
  4. * @subpackage com_finder
  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
  8. */
  9. defined('_JEXEC') or die;
  10. /**
  11. * Filters view class for Finder.
  12. *
  13. * @package Joomla.Administrator
  14. * @subpackage com_finder
  15. * @since 2.5
  16. */
  17. class FinderViewFilters extends JViewLegacy
  18. {
  19. /**
  20. * Method to display the view.
  21. *
  22. * @param string $tpl A template file to load. [optional]
  23. *
  24. * @return mixed A string if successful, otherwise a JError object.
  25. *
  26. * @since 2.5
  27. */
  28. public function display($tpl = null)
  29. {
  30. // Load the view data.
  31. $this->items = $this->get('Items');
  32. $this->pagination = $this->get('Pagination');
  33. $this->total = $this->get('Total');
  34. $this->state = $this->get('State');
  35. FinderHelper::addSubmenu('filters');
  36. // Check for errors.
  37. if (count($errors = $this->get('Errors')))
  38. {
  39. JError::raiseError(500, implode("\n", $errors));
  40. return false;
  41. }
  42. JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
  43. // Configure the toolbar.
  44. $this->addToolbar();
  45. parent::display($tpl);
  46. }
  47. /**
  48. * Method to configure the toolbar for this view.
  49. *
  50. * @return void
  51. *
  52. * @since 2.5
  53. */
  54. protected function addToolbar()
  55. {
  56. $canDo = FinderHelper::getActions();
  57. JToolbarHelper::title(JText::_('COM_FINDER_FILTERS_TOOLBAR_TITLE'), 'finder');
  58. $toolbar = JToolbar::getInstance('toolbar');
  59. if ($canDo->get('core.create'))
  60. {
  61. JToolbarHelper::addNew('filter.add');
  62. JToolbarHelper::editList('filter.edit');
  63. JToolbarHelper::divider();
  64. }
  65. if ($canDo->get('core.edit.state'))
  66. {
  67. JToolbarHelper::publishList('filters.publish');
  68. JToolbarHelper::unpublishList('filters.unpublish');
  69. JToolbarHelper::divider();
  70. }
  71. if ($canDo->get('core.delete'))
  72. {
  73. JToolbarHelper::deleteList('', 'filters.delete');
  74. JToolbarHelper::divider();
  75. }
  76. if ($canDo->get('core.admin'))
  77. {
  78. JToolbarHelper::preferences('com_finder');
  79. }
  80. JToolbarHelper::divider();
  81. $toolbar->appendButton('Popup', 'stats', 'COM_FINDER_STATISTICS', 'index.php?option=com_finder&view=statistics&tmpl=component', 550, 350);
  82. JToolbarHelper::divider();
  83. JToolbarHelper::help('JHELP_COMPONENTS_FINDER_MANAGE_SEARCH_FILTERS');
  84. JSubMenuHelper::setAction('index.php?option=com_finder&view=filters');
  85. JSubMenuHelper::addFilter(
  86. JText::_('COM_FINDER_INDEX_FILTER_BY_STATE'),
  87. 'filter_state',
  88. JHtml::_('select.options', JHtml::_('finder.statelist'), 'value', 'text', $this->state->get('filter.state'))
  89. );
  90. }
  91. }