Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_menus
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * The HTML Menus Menu Item View.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_menus
  17.  * @since       1.6
  18.  */
  19. class MenusViewItem extends JViewLegacy
  20. {
  21.     protected $form;
  22.  
  23.     protected $item;
  24.  
  25.     protected $modules;
  26.  
  27.     protected $state;
  28.  
  29.     /**
  30.      * Display the view
  31.      */
  32.     public function display($tpl null)
  33.     {
  34.         $this->form        = $this->get('Form');
  35.         $this->item        = $this->get('Item');
  36.         $this->modules    = $this->get('Modules');
  37.         $this->state    = $this->get('State');
  38.  
  39.         // Check for errors.
  40.         if (count($errors $this->get('Errors')))
  41.         {
  42.             JError::raiseError(500implode("\n"$errors));
  43.             return false;
  44.         }
  45.  
  46.         parent::display($tpl);
  47.         $this->addToolbar();
  48.     }
  49.  
  50.     /**
  51.      * Add the page title and toolbar.
  52.      *
  53.      * @since   1.6
  54.      */
  55.     protected function addToolbar()
  56.     {
  57.         $input JFactory::getApplication()->input;
  58.         $input->set('hidemainmenu'true);
  59.  
  60.         $user        JFactory::getUser();
  61.         $isNew        ($this->item->id == 0);
  62.         $checkedOut    !($this->item->checked_out == || $this->item->checked_out == $user->get('id'));
  63.         $canDo        MenusHelper::getActions($this->state->get('filter.parent_id'));
  64.  
  65.         JToolbarHelper::title(JText::_($isNew 'COM_MENUS_VIEW_NEW_ITEM_TITLE' 'COM_MENUS_VIEW_EDIT_ITEM_TITLE')'list menu-add');
  66.  
  67.         // If a new item, can save the item.  Allow users with edit permissions to apply changes to prevent returning to grid.
  68.         if ($isNew && $canDo->get('core.create'))
  69.         {
  70.             if ($canDo->get('core.edit'))
  71.             {
  72.                 JToolbarHelper::apply('item.apply');
  73.             }
  74.             JToolbarHelper::save('item.save');
  75.         }
  76.  
  77.         // If not checked out, can save the item.
  78.         if (!$isNew && !$checkedOut && $canDo->get('core.edit'))
  79.         {
  80.             JToolbarHelper::apply('item.apply');
  81.             JToolbarHelper::save('item.save');
  82.         }
  83.  
  84.         // If the user can create new items, allow them to see Save & New
  85.         if ($canDo->get('core.create'))
  86.         {
  87.             JToolbarHelper::save2new('item.save2new');
  88.         }
  89.  
  90.         // If an existing item, can save to a copy only if we have create rights.
  91.         if (!$isNew && $canDo->get('core.create'))
  92.         {
  93.             JToolbarHelper::save2copy('item.save2copy');
  94.         }
  95.  
  96.         if ($isNew)
  97.         {
  98.             JToolbarHelper::cancel('item.cancel');
  99.         }
  100.         else
  101.         {
  102.             JToolbarHelper::cancel('item.cancel''JTOOLBAR_CLOSE');
  103.         }
  104.  
  105.         JToolbarHelper::divider();
  106.  
  107.         // Get the help information for the menu item.
  108.         $lang JFactory::getLanguage();
  109.  
  110.         $help $this->get('Help');
  111.         if ($lang->hasKey($help->url))
  112.         {
  113.             $debug $lang->setDebug(false);
  114.             $url JText::_($help->url);
  115.             $lang->setDebug($debug);
  116.         }
  117.         else
  118.         {
  119.             $url $help->url;
  120.         }
  121.         JToolbarHelper::help($help->key$help->local$url);
  122.     }
  123. }

Documentation generated on Tue, 19 Nov 2013 15:17:28 +0100 by phpDocumentor 1.4.3