| [ 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 * Modules component helper. 12 * 13 * @package Joomla.Administrator 14 * @subpackage com_modules 15 * @since 1.6 16 */ 17 abstract class ModulesHelper 18 { 19 /** 20 * Configure the Linkbar. 21 * 22 * @param string The name of the active view. 23 */ 24 public static function addSubmenu($vName) 25 { 26 // Not used in this component. 27 } 28 29 /** 30 * Gets a list of the actions that can be performed. 31 * 32 * @return JObject 33 */ 34 public static function getActions() 35 { 36 $user = JFactory::getUser(); 37 $result = new JObject; 38 39 $actions = array( 40 'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.state', 'core.delete' 41 ); 42 43 foreach ($actions as $action) { 44 $result->set($action, $user->authorise($action, 'com_modules')); 45 } 46 47 return $result; 48 } 49 50 /** 51 * Get a list of filter options for the state of a module. 52 * 53 * @return array An array of JHtmlOption elements. 54 */ 55 public static function getStateOptions() 56 { 57 // Build the filter options. 58 $options = array(); 59 $options[] = JHtml::_('select.option', '1', JText::_('JPUBLISHED')); 60 $options[] = JHtml::_('select.option', '0', JText::_('JUNPUBLISHED')); 61 $options[] = JHtml::_('select.option', '-2', JText::_('JTRASHED')); 62 return $options; 63 } 64 65 /** 66 * Get a list of filter options for the application clients. 67 * 68 * @return array An array of JHtmlOption elements. 69 */ 70 public static function getClientOptions() 71 { 72 // Build the filter options. 73 $options = array(); 74 $options[] = JHtml::_('select.option', '0', JText::_('JSITE')); 75 $options[] = JHtml::_('select.option', '1', JText::_('JADMINISTRATOR')); 76 return $options; 77 } 78 79 static function getPositions($clientId) 80 { 81 jimport('joomla.filesystem.folder'); 82 83 $db = JFactory::getDbo(); 84 $query = $db->getQuery(true); 85 86 $query->select('DISTINCT(position)'); 87 $query->from('#__modules'); 88 $query->where($db->quoteName('client_id').' = '.(int) $clientId); 89 $query->order('position'); 90 91 $db->setQuery($query); 92 $positions = $db->loadColumn(); 93 $positions = (is_array($positions)) ? $positions : array(); 94 95 if ($error = $db->getErrorMsg()) { 96 JError::raiseWarning(500, $error); 97 return; 98 } 99 100 // Build the list 101 $options = array(); 102 foreach ($positions as $position) 103 { 104 if (!$position) 105 { 106 $options[] = JHtml::_('select.option', 'none', ':: '.JText::_('JNONE').' ::'); 107 108 } 109 else 110 { 111 $options[] = JHtml::_('select.option', $position, $position); 112 } 113 } 114 return $options; 115 } 116 117 public static function getTemplates($clientId = 0, $state = '', $template='') 118 { 119 $db = JFactory::getDbo(); 120 // Get the database object and a new query object. 121 $query = $db->getQuery(true); 122 123 // Build the query. 124 $query->select('element, name, enabled'); 125 $query->from('#__extensions'); 126 $query->where('client_id = '.(int) $clientId); 127 $query->where('type = '.$db->quote('template')); 128 if ($state!='') { 129 $query->where('enabled = '.$db->quote($state)); 130 } 131 if ($template!='') { 132 $query->where('element = '.$db->quote($template)); 133 } 134 135 // Set the query and load the templates. 136 $db->setQuery($query); 137 $templates = $db->loadObjectList('element'); 138 return $templates; 139 } 140 141 /** 142 * Get a list of the unique modules installed in the client application. 143 * 144 * @param int The client id. 145 * 146 * @return array 147 */ 148 public static function getModules($clientId) 149 { 150 $db = JFactory::getDbo(); 151 $query = $db->getQuery(true); 152 153 $query->select('element AS value, name AS text'); 154 $query->from('#__extensions as e'); 155 $query->where('e.client_id = '.(int)$clientId); 156 $query->where('type = '.$db->quote('module')); 157 $query->leftJoin('#__modules as m ON m.module=e.element AND m.client_id=e.client_id'); 158 $query->where('m.module IS NOT NULL'); 159 $query->group('element,name'); 160 161 $db->setQuery($query); 162 $modules = $db->loadObjectList(); 163 $lang = JFactory::getLanguage(); 164 foreach ($modules as $i=>$module) { 165 $extension = $module->value; 166 $path = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE; 167 $source = $path . "/modules/$extension"; 168 $lang->load("$extension.sys", $path, null, false, false) 169 || $lang->load("$extension.sys", $source, null, false, false) 170 || $lang->load("$extension.sys", $path, $lang->getDefault(), false, false) 171 || $lang->load("$extension.sys", $source, $lang->getDefault(), false, false); 172 $modules[$i]->text = JText::_($module->text); 173 } 174 JArrayHelper::sortObjects($modules, 'text', 1, true, $lang->getLocale()); 175 return $modules; 176 } 177 178 /** 179 * Get a list of the assignment options for modules to menus. 180 * 181 * @param int The client id. 182 * 183 * @return array 184 */ 185 public static function getAssignmentOptions($clientId) 186 { 187 $options = array(); 188 $options[] = JHtml::_('select.option', '0', 'COM_MODULES_OPTION_MENU_ALL'); 189 $options[] = JHtml::_('select.option', '-', 'COM_MODULES_OPTION_MENU_NONE'); 190 191 if ($clientId == 0) { 192 $options[] = JHtml::_('select.option', '1', 'COM_MODULES_OPTION_MENU_INCLUDE'); 193 $options[] = JHtml::_('select.option', '-1', 'COM_MODULES_OPTION_MENU_EXCLUDE'); 194 } 195 196 return $options; 197 } 198 }
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 |