Source for file loadmodule.php
Documentation is available at loadmodule.php
* @subpackage Content.loadmodule
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Plug-in to enable loading modules into content (e.g. articles)
* This uses the {loadmodule} syntax
* @subpackage Content.loadmodule
protected static $modules =
array();
protected static $mods =
array();
* Plugin that loads module positions within content
* @param string $context The context of the content being passed to the plugin.
* @param object &$article The article object. Note $article->text is also available
* @param mixed &$params The article params
* @param integer $page The 'page' number
* @return mixed true if there is an error. Void otherwise.
// Don't run this plugin when the content is being indexed
if ($context ==
'com_finder.indexer')
// Simple performance check to determine whether bot should process further
if (strpos($article->text, 'loadposition') ===
false &&
strpos($article->text, 'loadmodule') ===
false)
// Expression to search for (positions)
$regex =
'/{loadposition\s(.*?)}/i';
$style =
$this->params->def('style', 'none');
// Expression to search for(modules)
$regexmod =
'/{loadmodule\s(.*?)}/i';
$stylemod =
$this->params->def('style', 'none');
// Find all instances of plugin and put in $matches for loadposition
// $matches[0] is full pattern match, $matches[1] is the position
foreach ($matches as $match)
$matcheslist =
explode(',', $match[1]);
// We may not have a module style so fall back to the plugin default.
$matcheslist[1] =
$style;
$position =
trim($matcheslist[0]);
$style =
trim($matcheslist[1]);
$output =
$this->_load($position, $style);
// We should replace only first occurrence in order to allow positions with the same name to regenerate their content:
$style =
$this->params->def('style', 'none');
// Find all instances of plugin and put in $matchesmod for loadmodule
preg_match_all($regexmod, $article->text, $matchesmod, PREG_SET_ORDER);
// If no matches, skip this
foreach ($matchesmod as $matchmod)
$matchesmodlist =
explode(',', $matchmod[1]);
// We may not have a specific module so set to null
$matchesmodlist[1] =
null;
// We may not have a module style so fall back to the plugin default.
$matchesmodlist[2] =
$stylemod;
$module =
trim($matchesmodlist[0]);
$stylemod =
trim($matchesmodlist[2]);
// $match[0] is full pattern match, $match[1] is the module,$match[2] is the title
$output =
$this->_loadmod($module, $name, $stylemod);
// We should replace only first occurrence in order to allow positions with the same name to regenerate their content:
$stylemod =
$this->params->def('style', 'none');
* Loads and renders the module
* @param string $position The position assigned to the module
* @param string $style The style assigned to the module
protected function _load($position, $style =
'none')
self::$modules[$position] =
'';
$document =
JFactory::getDocument();
$renderer =
$document->loadRenderer('module');
$params =
array('style' =>
$style);
foreach ($modules as $module)
echo
$renderer->render($module, $params);
self::$modules[$position] =
ob_get_clean();
return self::$modules[$position];
* This is always going to get the first instance of the module type unless
* @param string $module The module title
* @param string $title The title of the module
* @param string $style The style of the module
protected function _loadmod($module, $title, $style =
'none')
self::$mods[$module] =
'';
$document =
JFactory::getDocument();
$renderer =
$document->loadRenderer('module');
// If the module without the mod_ isn't found, try it with mod_.
// This allows people to enter it either way in the content
$params =
array('style' =>
$style);
echo
$renderer->render($mod, $params);
self::$mods[$module] =
ob_get_clean();
return self::$mods[$module];
Documentation generated on Tue, 19 Nov 2013 15:07:24 +0100 by phpDocumentor 1.4.3