Source for file helper.php
Documentation is available at helper.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* @package Joomla.Libraries
* Get module by name (real, eg 'Breadcrumbs' or folder, eg 'mod_breadcrumbs')
* @param string $name The name of the module
* @param string $title The title of the module, optional
* @return object The Module object
public static function &getModule($name, $title =
null)
$modules =
& static::load();
$total =
count($modules);
for ($i =
0; $i <
$total; $i++
)
// Match the name of the module
if ($modules[$i]->name ==
$name ||
$modules[$i]->module ==
$name)
// Match the title if we're looking for a specific instance of the module
if (!$title ||
$modules[$i]->title ==
$title)
// If we didn't find it, and the name is mod_something, create a dummy object
* Get modules by position
* @param string $position The position of the module
* @return array An array of module objects
$modules =
& static::load();
$total =
count($modules);
for ($i =
0; $i <
$total; $i++
)
if ($modules[$i]->position ==
$position)
$result[] =
&$modules[$i];
if ($input->getBool('tp') &&
JComponentHelper::getParams('com_templates')->get('template_positions_display'))
$result[0] =
static::getModule('mod_' .
$position);
$result[0]->title =
$position;
$result[0]->content =
$position;
$result[0]->position =
$position;
* Checks if a module is enabled. A given module will only be returned
* if it meets the following criteria: it is enabled, it is assigned to
* the current menu item or all items, and the user meets the access level
* @param string $module The module name
* @return boolean See description for conditions.
$result =
static::getModule($module);
return (!is_null($result) &&
$result->id !==
0);
* @param object $module A module object.
* @param array $attribs An array of attributes for the module (probably from the XML).
* @return string The HTML content of the module output.
public static function renderModule($module, $attribs =
array())
JProfiler::getInstance('Application')->mark('beforeRenderModule ' .
$module->module .
' (' .
$module->title .
')');
// Set scope to component name
$app->scope =
$module->module;
$params->loadString($module->params);
$template =
$app->getTemplate();
$module->module =
preg_replace('/[^A-Z0-9_\.-]/i', '', $module->module);
$path =
JPATH_BASE .
'/modules/' .
$module->module .
'/' .
$module->module .
'.php';
// 1.5 or Core then 1.6 3PD
$lang->load($module->module, JPATH_BASE, null, false, true) ||
$lang->load($module->module, dirname($path), null, false, true);
// Load the module chrome functions
$chromePath =
JPATH_THEMES .
'/' .
$template .
'/html/modules.php';
if (!isset
($chrome[$chromePath]))
include_once $chromePath;
$chrome[$chromePath] =
true;
// Check if the current module has a style param to override template module style
$paramsChromeStyle =
$params->get('style');
$attribs['style'] =
preg_replace('/^(system|' .
$template .
')\-/i', '', $paramsChromeStyle);
// Make sure a style is set
if (!isset
($attribs['style']))
$attribs['style'] =
'none';
// Dynamically add outline style
if ($app->input->getBool('tp') &&
JComponentHelper::getParams('com_templates')->get('template_positions_display'))
$attribs['style'] .=
' outline';
foreach (explode(' ', $attribs['style']) as $style)
$chromeMethod =
'modChrome_' .
$style;
// Apply chrome and render module
$module->style =
$attribs['style'];
$chromeMethod($module, $params, $attribs);
JProfiler::getInstance('Application')->mark('afterRenderModule ' .
$module->module .
' (' .
$module->title .
')');
* Get the path to a layout for a module
* @param string $module The name of the module
* @param string $layout The name of the module layout. If alternative layout, in the form template:filename.
* @return string The path to the module layout
public static function getLayoutPath($module, $layout =
'default')
$defaultLayout =
$layout;
if (strpos($layout, ':') !==
false)
// Get the template and file name from the string
$template =
($temp[0] ==
'_') ?
$template :
$temp[0];
$defaultLayout =
($temp[1]) ?
$temp[1] :
'default';
// Build the template and base path for the layout
$tPath =
JPATH_THEMES .
'/' .
$template .
'/html/' .
$module .
'/' .
$layout .
'.php';
$bPath =
JPATH_BASE .
'/modules/' .
$module .
'/tmpl/' .
$defaultLayout .
'.php';
$dPath =
JPATH_BASE .
'/modules/' .
$module .
'/tmpl/default.php';
// If the template has a layout override use it
* Load published modules.
* @deprecated 4.0 Use JModuleHelper::load() instead
protected static function &_load()
* Load published modules.
protected static function &load()
$Itemid =
$app->input->getInt('Itemid');
$groups =
implode(',', $user->getAuthorisedViewLevels());
$clientId = (int)
$app->getClientId();
$query =
$db->getQuery(true)
->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params, mm.menuid')
->from('#__modules AS m')
->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = m.id')
->where('m.published = 1')
->join('LEFT', '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id')
->where('e.enabled = 1');
$nullDate =
$db->getNullDate();
$query->where('(m.publish_up = ' .
$db->quote($nullDate) .
' OR m.publish_up <= ' .
$db->quote($now) .
')')
->where('(m.publish_down = ' .
$db->quote($nullDate) .
' OR m.publish_down >= ' .
$db->quote($now) .
')')
->where('m.access IN (' .
$groups .
')')
->where('m.client_id = ' .
$clientId)
->where('(mm.menuid = ' . (int)
$Itemid .
' OR mm.menuid <= 0)');
if ($app->isSite() &&
$app->getLanguageFilter())
$query->where('m.language IN (' .
$db->quote($lang) .
',' .
$db->quote('*') .
')');
$query->order('m.position, m.ordering');
$modules =
$db->loadObjectList();
catch
(RuntimeException $e)
// Apply negative selections and eliminate duplicates
$negId =
$Itemid ? -(int)
$Itemid :
false;
for ($i =
0, $n =
count($modules); $i <
$n; $i++
)
// The module is excluded if there is an explicit prohibition
$negHit =
($negId === (int)
$module->menuid);
if (isset
($dupes[$module->id]))
// If this item has been excluded, keep the duplicate flag set,
// but remove any item from the cleaned array.
unset
($clean[$module->id]);
$dupes[$module->id] =
true;
// Only accept modules without explicit exclusions.
$module->name =
substr($module->module, 4);
$module->position =
strtolower($module->position);
$clean[$module->id] =
$module;
// Return to simple indexing that matches the query order.
* 'static' One cache file for all pages with the same module parameters
* 'oldstatic' 1.5 definition of module caching, one cache file for all pages
* with the same module id and user aid,
* 'itemid' Changes on itemid change, to be called from inside the module:
* 'safeuri' Id created from $cacheparams->modeparams array,
* 'id' Module sets own cache id's
* @param object $module Module object
* @param object $moduleparams Module parameters
* @param object $cacheparams Module cache parameters - id or url parameters, depending on the module cache mode
* @see JFilterInput::clean()
public static function moduleCache($module, $moduleparams, $cacheparams)
if (!isset
($cacheparams->modeparams))
$cacheparams->modeparams =
null;
if (!isset
($cacheparams->cachegroup))
$cacheparams->cachegroup =
$module->module;
// Turn cache off for internal callers if parameters are set to off and for all logged in users
if ($moduleparams->get('owncache', null) ===
'0' ||
$conf->get('caching') ==
0 ||
$user->get('id'))
$cache->setCaching(false);
// Module cache is set in seconds, global cache in minutes, setLifeTime works in minutes
$cache->setLifeTime($moduleparams->get('cache_time', $conf->get('cachetime') *
60) /
60);
$wrkaroundoptions =
array('nopathway' =>
1, 'nohead' =>
0, 'nomodules' =>
1, 'modulemode' =>
1, 'mergehead' =>
1);
$view_levels =
md5(serialize($user->getAuthorisedViewLevels()));
switch ($cacheparams->cachemode)
array($cacheparams->class, $cacheparams->method),
$cacheparams->methodparams,
$cacheparams->modeparams,
foreach ($cacheparams->modeparams as $key =>
$value)
// Use int filter for id/catid to clean out spamy slugs
$safeuri->$key =
$noHtmlFilter->clean($uri[$key], $value);
$secureid =
md5(serialize(array($safeuri, $cacheparams->method, $moduleparams)));
array($cacheparams->class, $cacheparams->method),
$cacheparams->methodparams,
$module->id .
$view_levels .
$secureid,
array($cacheparams->class,
$cacheparams->methodparams,
$module->module .
md5(serialize($cacheparams->methodparams)),
// Provided for backward compatibility, not really useful.
array($cacheparams->class, $cacheparams->method),
$cacheparams->methodparams,
$module->id .
$view_levels,
array($cacheparams->class, $cacheparams->method),
$cacheparams->methodparams,
Documentation generated on Tue, 19 Nov 2013 15:04:40 +0100 by phpDocumentor 1.4.3