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
* The component list cache
protected static $components =
array();
* Get the component information.
* @param string $option The component option.
* @param boolean $strict If set and the component does not exist, the enabled attribute will be set to false.
* @return object An object with the information for the component.
public static function getComponent($option, $strict =
false)
if (!isset
(static::$components[$option]))
if (static::load($option))
$result =
static::$components[$option];
$result->enabled =
$strict ?
false :
true;
$result->params =
new JRegistry;
$result =
static::$components[$option];
* Checks if the component is enabled
* @param string $option The component option.
$result =
static::getComponent($option, true);
* Gets the parameter object for the component
* @param string $option The option for the component.
* @param boolean $strict If set and the component does not exist, false will be returned
* @return JRegistry A JRegistry object.
public static function getParams($option, $strict =
false)
$component =
static::getComponent($option, $strict);
return $component->params;
* Applies the global text filters to arbitrary text as per settings for current user groups
* @param string $text The string to filter
* @return string The filtered string
$config =
static::getParams('com_config');
$filters =
$config->get('filters');
$blackListTags =
array();
$blackListAttributes =
array();
$customListTags =
array();
$customListAttributes =
array();
$whiteListTags =
array();
$whiteListAttributes =
array();
// Cycle through each of the user groups the user is in.
// Remember they are included in the Public group as well.
foreach ($userGroups as $groupId)
// May have added a group by not saved the filters.
if (!isset
($filters->$groupId))
// Each group the user is in could have different filtering properties.
$filterData =
$filters->$groupId;
$filterType =
strtoupper($filterData->filter_type);
// Maximum HTML filtering.
elseif ($filterType ==
'NONE')
// Preprocess the tags and attributes.
$tags =
explode(',', $filterData->filter_tags);
$attributes =
explode(',', $filterData->filter_attributes);
$tempAttributes =
array();
foreach ($attributes as $attribute)
$attribute =
trim($attribute);
$tempAttributes[] =
$attribute;
// Collect the black or white list tags and attributes.
// Each list is cummulative.
$blackListTags =
array_merge($blackListTags, $tempTags);
$blackListAttributes =
array_merge($blackListAttributes, $tempAttributes);
elseif ($filterType ==
'CBL')
// Only set to true if Tags or Attributes were added
if ($tempTags ||
$tempAttributes)
$customListTags =
array_merge($customListTags, $tempTags);
$customListAttributes =
array_merge($customListAttributes, $tempAttributes);
elseif ($filterType ==
'WL')
$whiteListTags =
array_merge($whiteListTags, $tempTags);
$whiteListAttributes =
array_merge($whiteListAttributes, $tempAttributes);
// Remove duplicates before processing (because the black list uses both sets of arrays).
$customListAttributes =
array_unique($customListAttributes);
// Unfiltered assumes first priority.
// Custom blacklist precedes Default blacklist
// Override filter's default blacklist tags and attributes
$filter->tagBlacklist =
$customListTags;
if ($customListAttributes)
$filter->attrBlacklist =
$customListAttributes;
// Black lists take second precedence.
// Remove the white-listed tags and attributes from the black-list.
$blackListTags =
array_diff($blackListTags, $whiteListTags);
$blackListAttributes =
array_diff($blackListAttributes, $whiteListAttributes);
// Remove white listed tags from filter's default blacklist
$filter->tagBlacklist =
array_diff($filter->tagBlacklist, $whiteListTags);
// Remove white listed attributes from filter's default blacklist
if ($whiteListAttributes)
$filter->attrBlacklist =
array_diff($filter->attrBlacklist);
// White lists take third precedence.
// Turn off XSS auto clean
// No HTML takes last place.
$text =
$filter->clean($text, 'html');
* @param string $option The component option.
* @param array $params The component parameters
// Load template language files.
$template =
$app->getTemplate(true)->template;
$lang->load('tpl_' .
$template, JPATH_BASE, null, false, true)
||
$lang->load('tpl_' .
$template, JPATH_THEMES .
"/$template", null, false, true);
throw
new Exception(JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404);
// Set scope to component name
// Build the component path.
// Define component path.
$path =
JPATH_COMPONENT .
'/' .
$file .
'.php';
// If component is disabled throw error
if (!static::isEnabled($option) ||
!file_exists($path))
throw
new Exception(JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404);
// Load common and local language files.
$lang->load($option, JPATH_BASE, null, false, true) ||
$lang->load($option, JPATH_COMPONENT, null, false, true);
// Handle template preview outlining.
// Execute the component.
$contents =
static::executeComponent($path);
* @param string $path The component path.
* @return string The component output
* Load the installed components into the components property.
* @param string $option The element value for the extension
* @return boolean True on success
* @deprecated 4.0 Use JComponentHelper::load() instead
protected static function _load($option)
return static::load($option);
* Load the installed components into the components property.
* @param string $option The element value for the extension
* @return boolean True on success
protected static function load($option)
$query =
$db->getQuery(true)
->select('extension_id AS id, element AS "option", params, enabled')
->where($db->quoteName('type') .
' = ' .
$db->quote('component'))
->where($db->quoteName('element') .
' = ' .
$db->quote($option));
static::$components[$option] =
$cache->get(array($db, 'loadObject'), null, $option, false);
catch
(RuntimeException $e)
JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, $e->getMessage()), JLog::WARNING, 'jerror');
if (empty(static::$components[$option]))
$error =
JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND');
JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, $error), JLog::WARNING, 'jerror');
// Convert the params to an object.
if (is_string(static::$components[$option]->params))
$temp->loadString(static::$components[$option]->params);
static::$components[$option]->params =
$temp;
Documentation generated on Tue, 19 Nov 2013 15:04:25 +0100 by phpDocumentor 1.4.3