Source for file modules.php
Documentation is available at modules.php
* @package Joomla.Administrator
* @subpackage com_modules
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Modules component helper.
* @package Joomla.Administrator
* @subpackage com_modules
* @param string $vName The name of the active view.
// Not used in this component.
* Gets a list of the actions that can be performed.
* @param integer The module ID.
$assetName =
'com_modules';
$assetName =
'com_modules.module.'.(int)
$moduleId;
JPATH_ADMINISTRATOR .
'/components/com_modules/access.xml', "/access/section[@name='component']/"
foreach ($actions as $action)
$result->set($action->name, $user->authorise($action->name, $assetName));
* Get a list of filter options for the state of a module.
* @return array An array of JHtmlOption elements.
// Build the filter options.
$options[] =
JHtml::_('select.option', '1', JText::_('JPUBLISHED'));
$options[] =
JHtml::_('select.option', '0', JText::_('JUNPUBLISHED'));
$options[] =
JHtml::_('select.option', '-2', JText::_('JTRASHED'));
* Get a list of filter options for the application clients.
* @return array An array of JHtmlOption elements.
// Build the filter options.
$options[] =
JHtml::_('select.option', '0', JText::_('JSITE'));
$options[] =
JHtml::_('select.option', '1', JText::_('JADMINISTRATOR'));
* Get a list of modules positions
* @param integer $clientId Client ID
* @return array A list of positions
public static function getPositions($clientId, $editPositions =
false)
$query =
$db->getQuery(true)
->select('DISTINCT(position)')
->where($db->quoteName('client_id') .
' = ' . (int)
$clientId)
$positions =
$db->loadColumn();
$positions =
is_array($positions) ?
$positions :
array();
catch
(RuntimeException $e)
foreach ($positions as $position)
if (!$position &&
!$editPositions)
$options[] =
JHtml::_('select.option', 'none', ':: ' .
JText::_('JNONE') .
' ::');
$options[] =
JHtml::_('select.option', $position, $position);
* Return a list of templates
* @param integer $clientId Client ID
* @param string $state State
* @param string $template Template name
* @return array List of templates
public static function getTemplates($clientId =
0, $state =
'', $template =
'')
// Get the database object and a new query object.
$query =
$db->getQuery(true);
$query->select('element, name, enabled')
->where('client_id = ' . (int)
$clientId)
->where('type = ' .
$db->quote('template'));
$query->where('enabled = ' .
$db->quote($state));
$query->where('element = ' .
$db->quote($template));
// Set the query and load the templates.
$templates =
$db->loadObjectList('element');
* Get a list of the unique modules installed in the client application.
* @param int $clientId The client id.
* @return array Array of unique modules
$query =
$db->getQuery(true)
->select('element AS value, name AS text')
->from('#__extensions as e')
->where('e.client_id = ' . (int)
$clientId)
->where('type = ' .
$db->quote('module'))
->join('LEFT', '#__modules as m ON m.module=e.element AND m.client_id=e.client_id')
->where('m.module IS NOT NULL')
$modules =
$db->loadObjectList();
foreach ($modules as $i =>
$module)
$extension =
$module->value;
$source =
$path .
"/modules/$extension";
$lang->load("$extension.sys", $path, null, false, true)
||
$lang->load("$extension.sys", $source, null, false, true);
$modules[$i]->text =
JText::_($module->text);
* Get a list of the assignment options for modules to menus.
* @param int $clientId The client id.
$options[] =
JHtml::_('select.option', '0', 'COM_MODULES_OPTION_MENU_ALL');
$options[] =
JHtml::_('select.option', '-', 'COM_MODULES_OPTION_MENU_NONE');
$options[] =
JHtml::_('select.option', '1', 'COM_MODULES_OPTION_MENU_INCLUDE');
$options[] =
JHtml::_('select.option', '-1', 'COM_MODULES_OPTION_MENU_EXCLUDE');
* Return a translated module position name
* @param string $template Template name
* @param string $position Position name
* @return string Return a translated position name
$lang->load('tpl_'.
$template.
'.sys', $path, null, false, false)
||
$lang->load('tpl_'.
$template.
'.sys', $path.
'/templates/'.
$template, null, false, false)
||
$lang->load('tpl_'.
$template.
'.sys', $path, $lang->getDefault(), false, false)
||
$lang->load('tpl_'.
$template.
'.sys', $path.
'/templates/'.
$template, $lang->getDefault(), false, false);
$langKey =
strtoupper('TPL_' .
$template .
'_POSITION_' .
$position);
// Avoid untranslated strings
if (!self::isTranslatedText($langKey, $text))
// Modules component translation
$langKey =
strtoupper('COM_MODULES_POSITION_' .
$position);
// Avoid untranslated strings
if (!self::isTranslatedText($langKey, $text))
// Try to humanize the position name
* Check if the string was translated
* @param string $langKey Language file text key
* @param string $text The "translated" text to be checked
* @return boolean Return true for translated text
return $text !==
$langKey;
* Create and return a new Option
* @param string $value The option value [optional]
* @param string $text The option text [optional]
* @return object The option as an object (stdClass instance)
public static function createOption($value =
'', $text =
'')
* Create and return a new Option Group
* @param string $label Value and label for group [optional]
* @param array $options Array of options to insert into group [optional]
* @return array Return the new group as an array
$group['value'] =
$label;
$group['items'] =
$options;
Documentation generated on Tue, 19 Nov 2013 15:08:53 +0100 by phpDocumentor 1.4.3