| [ 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 // No direct access 8 defined('_JEXEC') or die; 9 10 /** 11 * Categories helper. 12 * 13 * @package Joomla.Administrator 14 * @subpackage com_categories 15 * @since 1.6 16 */ 17 class CategoriesHelper 18 { 19 /** 20 * Configure the Submenu links. 21 * 22 * @param string The extension being used for the categories. 23 * 24 * @return void 25 * @since 1.6 26 */ 27 public static function addSubmenu($extension) 28 { 29 // Avoid nonsense situation. 30 if ($extension == 'com_categories') { 31 return; 32 } 33 34 $parts = explode('.', $extension); 35 $component = $parts[0]; 36 37 if (count($parts) > 1) { 38 $section = $parts[1]; 39 } 40 41 // Try to find the component helper. 42 $eName = str_replace('com_', '', $component); 43 $file = JPath::clean(JPATH_ADMINISTRATOR.'/components/'.$component.'/helpers/'.$eName.'.php'); 44 45 if (file_exists($file)) { 46 require_once $file; 47 48 $prefix = ucfirst(str_replace('com_', '', $component)); 49 $cName = $prefix.'Helper'; 50 51 if (class_exists($cName)) { 52 53 if (is_callable(array($cName, 'addSubmenu'))) { 54 $lang = JFactory::getLanguage(); 55 // loading language file from the administrator/language directory then 56 // loading language file from the administrator/components/*extension*/language directory 57 $lang->load($component, JPATH_BASE, null, false, false) 58 || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR.'/components/'.$component), null, false, false) 59 || $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false) 60 || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR.'/components/'.$component), $lang->getDefault(), false, false); 61 call_user_func(array($cName, 'addSubmenu'), 'categories'.(isset($section)?'.'.$section:'')); 62 } 63 } 64 } 65 } 66 67 /** 68 * Gets a list of the actions that can be performed. 69 * 70 * @param string $extension The extension. 71 * @param int $categoryId The category ID. 72 * 73 * @return JObject 74 * @since 1.6 75 */ 76 public static function getActions($extension, $categoryId = 0) 77 { 78 $user = JFactory::getUser(); 79 $result = new JObject; 80 $parts = explode('.', $extension); 81 $component = $parts[0]; 82 83 if (empty($categoryId)) { 84 $assetName = $component; 85 } 86 else { 87 $assetName = $component.'.category.'.(int) $categoryId; 88 } 89 90 $actions = array( 91 'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.own', 'core.edit.state', 'core.delete' 92 ); 93 94 foreach ($actions as $action) { 95 $result->set($action, $user->authorise($action, $assetName)); 96 } 97 98 return $result; 99 } 100 }
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 |