/administrator/components/com_redirect/views/links/view.html.php

https://github.com/joebushi/joomla · PHP · 88 lines · 57 code · 10 blank · 21 comment · 12 complexity · f98c6bb57a86e6f4cd3d07d05860d612 MD5 · raw file

  1. <?php
  2. /**
  3. * @version $Id$
  4. * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  5. * @license GNU General Public License version 2 or later; see LICENSE.txt
  6. */
  7. // No direct access.
  8. defined('_JEXEC') or die;
  9. jimport('joomla.application.component.view');
  10. /**
  11. * View class for a list of redirection links.
  12. *
  13. * @package Joomla.Administrator
  14. * @subpackage com_redirect
  15. * @since 1.6
  16. */
  17. class RedirectViewLinks extends JView
  18. {
  19. protected $state;
  20. protected $items;
  21. protected $pagination;
  22. /**
  23. * Display the view
  24. */
  25. public function display($tpl = null)
  26. {
  27. $state = $this->get('State');
  28. $items = $this->get('Items');
  29. $pagination = $this->get('Pagination');
  30. // Check for errors.
  31. if (count($errors = $this->get('Errors'))) {
  32. JError::raiseError(500, implode("\n", $errors));
  33. return false;
  34. }
  35. // Assign data to the view.
  36. $this->assignRef('state', $state);
  37. $this->assignRef('items', $items);
  38. $this->assignRef('pagination', $pagination);
  39. $this->assign('enabled', RedirectHelper::isEnabled());
  40. parent::display($tpl);
  41. $this->_setToolbar();
  42. }
  43. /**
  44. * Setup the Toolbar.
  45. */
  46. protected function _setToolbar()
  47. {
  48. $state = $this->get('State');
  49. $canDo = RedirectHelper::getActions();
  50. JToolBarHelper::title(JText::_('Redir_Manager_Links'), 'redirect');
  51. if ($canDo->get('core.create')) {
  52. JToolBarHelper::addNew('link.add');
  53. }
  54. if ($canDo->get('core.edit')) {
  55. JToolBarHelper::editList('link.edit');
  56. }
  57. if ($canDo->get('core.edit.state')) {
  58. JToolBarHelper::custom('links.publish', 'publish.png', 'publish_f2.png', 'JToolbar_Enable', true);
  59. JToolBarHelper::custom('links.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JToolbar_Disable', true);
  60. JToolBarHelper::divider();
  61. if ($state->get('filter.published') != -1) {
  62. JToolBarHelper::archiveList('links.archive');
  63. }
  64. }
  65. if ($state->get('filter.published') == -2 && $canDo->get('core.delete')) {
  66. JToolBarHelper::deleteList('', 'links.delete');
  67. }
  68. else if ($canDo->get('core.edit.state')) {
  69. JToolBarHelper::trash('links.trash');
  70. }
  71. if ($canDo->get('core.admin')) {
  72. JToolBarHelper::divider();
  73. JToolBarHelper::preferences('com_redirect');
  74. }
  75. JToolBarHelper::divider();
  76. JToolBarHelper::help('screen.redirect');
  77. }
  78. }