| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 4 * @license GNU General Public License version 2 or later; see LICENSE.txt 5 */ 6 7 // Check to ensure this file is included in Joomla! 8 defined('_JEXEC') or die; 9 10 jimport('joomla.application.component.view'); 11 12 /** 13 * HTML View class for the Categories component 14 * 15 * @static 16 * @package Joomla.Administrator 17 * @subpackage com_categories 18 */ 19 class CategoriesViewCategory extends JView 20 { 21 protected $form; 22 protected $item; 23 protected $state; 24 25 /** 26 * Display the view 27 */ 28 public function display($tpl = null) 29 { 30 $this->form = $this->get('Form'); 31 $this->item = $this->get('Item'); 32 $this->state = $this->get('State'); 33 $this->canDo = CategoriesHelper::getActions($this->state->get('category.component')); 34 35 // Check for errors. 36 if (count($errors = $this->get('Errors'))) { 37 JError::raiseError(500, implode("\n", $errors)); 38 return false; 39 } 40 41 parent::display($tpl); 42 JRequest::setVar('hidemainmenu', true); 43 $this->addToolbar(); 44 } 45 46 /** 47 * Add the page title and toolbar. 48 * 49 * @since 1.6 50 */ 51 protected function addToolbar() 52 { 53 // Initialise variables. 54 $extension = JRequest::getCmd('extension'); 55 $user = JFactory::getUser(); 56 $userId = $user->get('id'); 57 58 $isNew = ($this->item->id == 0); 59 $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId); 60 61 // Avoid nonsense situation. 62 if ($extension == 'com_categories') { 63 return; 64 } 65 66 // The extension can be in the form com_foo.section 67 $parts = explode('.', $extension); 68 $component = $parts[0]; 69 $section = (count($parts) > 1) ? $parts[1] : null; 70 71 // Need to load the menu language file as mod_menu hasn't been loaded yet. 72 $lang = JFactory::getLanguage(); 73 $lang->load($component, JPATH_BASE, null, false, false) 74 || $lang->load($component, JPATH_ADMINISTRATOR.'/components/'.$component, null, false, false) 75 || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false) 76 || $lang->load($component, JPATH_ADMINISTRATOR.'/components/'.$component, $lang->getDefault(), false, false); 77 78 // Load the category helper. 79 require_once JPATH_COMPONENT.'/helpers/categories.php'; 80 81 // Get the results for each action. 82 $canDo = CategoriesHelper::getActions($component, $this->item->id); 83 84 // If a component categories title string is present, let's use it. 85 if ($lang->hasKey($component_title_key = $component.($section?"_$section":'').'_CATEGORY_'.($isNew?'ADD':'EDIT').'_TITLE')) { 86 $title = JText::_($component_title_key); 87 } 88 // Else if the component section string exits, let's use it 89 elseif ($lang->hasKey($component_section_key = $component.($section?"_$section":''))) { 90 $title = JText::sprintf( 'COM_CATEGORIES_CATEGORY_'.($isNew?'ADD':'EDIT').'_TITLE', $this->escape(JText::_($component_section_key))); 91 } 92 // Else use the base title 93 else { 94 $title = JText::_('COM_CATEGORIES_CATEGORY_BASE_'.($isNew?'ADD':'EDIT').'_TITLE'); 95 } 96 97 // Load specific css component 98 JHtml::_('stylesheet', $component.'/administrator/categories.css', array(), true); 99 100 // Prepare the toolbar. 101 JToolBarHelper::title($title, 'category-'.($isNew?'add':'edit').' '.substr($component, 4).($section?"-$section":'').'-category-'.($isNew?'add':'edit')); 102 103 // For new records, check the create permission. 104 if ($isNew && (count($user->getAuthorisedCategories($component, 'core.create')) > 0)) { 105 JToolBarHelper::apply('category.apply'); 106 JToolBarHelper::save('category.save'); 107 JToolBarHelper::save2new('category.save2new'); 108 } 109 110 // If not checked out, can save the item. 111 elseif (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_user_id == $userId))) { 112 JToolBarHelper::apply('category.apply'); 113 JToolBarHelper::save('category.save'); 114 if ($canDo->get('core.create')) { 115 JToolBarHelper::save2new('category.save2new'); 116 } 117 } 118 119 // If an existing item, can save to a copy. 120 if (!$isNew && $canDo->get('core.create')) { 121 JToolBarHelper::save2copy('category.save2copy'); 122 } 123 124 if (empty($this->item->id)) { 125 JToolBarHelper::cancel('category.cancel'); 126 } 127 else { 128 JToolBarHelper::cancel('category.cancel', 'JTOOLBAR_CLOSE'); 129 } 130 131 JToolBarHelper::divider(); 132 133 // Compute the ref_key if it does exist in the component 134 if (!$lang->hasKey($ref_key = strtoupper($component.($section?"_$section":'')).'_CATEGORY_'.($isNew?'ADD':'EDIT').'_HELP_KEY')) { 135 $ref_key = 'JHELP_COMPONENTS_'.strtoupper(substr($component, 4).($section?"_$section":'')).'_CATEGORY_'.($isNew?'ADD':'EDIT'); 136 } 137 138 // Get help for the category/section view for the component by 139 // -remotely searching in a language defined dedicated URL: *component*_HELP_URL 140 // -locally searching in a component help file if helpURL param exists in the component and is set to '' 141 // -remotely searching in a component URL if helpURL param exists in the component and is NOT set to '' 142 if ($lang->hasKey($lang_help_url = strtoupper($component).'_HELP_URL')) { 143 $debug = $lang->setDebug(false); 144 $url = JText::_($lang_help_url); 145 $lang->setDebug($debug); 146 } 147 else { 148 $url = null; 149 } 150 JToolBarHelper::help($ref_key, JComponentHelper::getParams( $component )->exists('helpURL'), $url, $component); 151 } 152 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |