PageRenderTime 47ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/joebushi/joomla
PHP | 88 lines | 53 code | 12 blank | 23 comment | 9 complexity | 2d10d44288c19b17946447202911b10e MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  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 to edit a redirect link.
  12. *
  13. * @package Joomla.Administrator
  14. * @subpackage com_redirect
  15. * @since 1.6
  16. */
  17. class RedirectViewLink extends JView
  18. {
  19. protected $state;
  20. protected $item;
  21. protected $form;
  22. /**
  23. * Display the view
  24. */
  25. public function display($tpl = null)
  26. {
  27. $app = JFactory::getApplication();
  28. $state = $this->get('State');
  29. $item = $this->get('Item');
  30. $form = $this->get('Form');
  31. // Check for errors.
  32. if (count($errors = $this->get('Errors'))) {
  33. JError::raiseError(500, implode("\n", $errors));
  34. return false;
  35. }
  36. // Bind the record to the form.
  37. $form->bind($item);
  38. $this->assignRef('state', $state);
  39. $this->assignRef('item', $item);
  40. $this->assignRef('form', $form);
  41. $this->_setToolbar();
  42. parent::display($tpl);
  43. }
  44. /**
  45. * Setup the Toolbar
  46. */
  47. protected function _setToolbar()
  48. {
  49. JRequest::setVar('hidemainmenu', true);
  50. $user = JFactory::getUser();
  51. $isNew = ($this->item->id == 0);
  52. $canDo = RedirectHelper::getActions();
  53. JToolBarHelper::title(JText::_('Redir_Manager_Link'));
  54. // If not checked out, can save the item.
  55. if ($canDo->get('core.edit'))
  56. {
  57. JToolBarHelper::apply('link.apply', 'JToolbar_Apply');
  58. JToolBarHelper::save('link.save', 'JToolbar_Save');
  59. }
  60. // If an existing item, can save to a copy.
  61. if (!$isNew && $canDo->get('core.create')) {
  62. JToolBarHelper::custom('link.save2copy§', 'copy.png', 'copy_f2.png', 'JToolbar_Save_as_Copy', false);
  63. }
  64. if ($canDo->get('core.edit') && $canDo->get('core.create'))
  65. {
  66. JToolBarHelper::addNew('link.save2new', 'JToolbar_Save_and_new');
  67. }
  68. if (empty($this->item->id)) {
  69. JToolBarHelper::cancel('link.cancel', 'JToolbar_Cancel');
  70. }
  71. else {
  72. JToolBarHelper::cancel('link.cancel', 'JToolbar_Close');
  73. }
  74. JToolBarHelper::help('screen.redirect.link');
  75. }
  76. }