| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: loadmodule.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 6 * @license GNU/GPL, see LICENSE.php 7 * Joomla! is free software. This version may have been modified pursuant 8 * to the GNU General Public License, and as distributed it includes or 9 * is derivative of works licensed under the GNU General Public License or 10 * other free or open source software licenses. 11 * See COPYRIGHT.php for copyright notices and details. 12 */ 13 14 // no direct access 15 defined( '_JEXEC' ) or die( 'Restricted access' ); 16 17 $mainframe->registerEvent( 'onPrepareContent', 'plgContentLoadModule' ); 18 19 /** 20 * Plugin that loads module positions within content 21 */ 22 function plgContentLoadModule( &$row, &$params, $page=0 ) 23 { 24 $db =& JFactory::getDBO(); 25 // simple performance check to determine whether bot should process further 26 if ( JString::strpos( $row->text, 'loadposition' ) === false ) { 27 return true; 28 } 29 30 // Get plugin info 31 $plugin =& JPluginHelper::getPlugin('content', 'loadmodule'); 32 33 // expression to search for 34 $regex = '/{loadposition\s*.*?}/i'; 35 36 $pluginParams = new JParameter( $plugin->params ); 37 38 // check whether plugin has been unpublished 39 if ( !$pluginParams->get( 'enabled', 1 ) ) { 40 $row->text = preg_replace( $regex, '', $row->text ); 41 return true; 42 } 43 44 // find all instances of plugin and put in $matches 45 preg_match_all( $regex, $row->text, $matches ); 46 47 // Number of plugins 48 $count = count( $matches[0] ); 49 50 // plugin only processes if there are any instances of the plugin in the text 51 if ( $count ) { 52 // Get plugin parameters 53 $style = $pluginParams->def( 'style', -2 ); 54 55 plgContentProcessPositions( $row, $matches, $count, $regex, $style ); 56 } 57 } 58 59 function plgContentProcessPositions ( &$row, &$matches, $count, $regex, $style ) 60 { 61 for ( $i=0; $i < $count; $i++ ) 62 { 63 $load = str_replace( 'loadposition', '', $matches[0][$i] ); 64 $load = str_replace( '{', '', $load ); 65 $load = str_replace( '}', '', $load ); 66 $load = trim( $load ); 67 68 $modules = plgContentLoadPosition( $load, $style ); 69 $row->text = str_replace($matches[0][$i], $modules, $row->text ); 70 } 71 72 // removes tags without matching module positions 73 $row->text = preg_replace( $regex, '', $row->text ); 74 } 75 76 function plgContentLoadPosition( $position, $style=-2 ) 77 { 78 $document = &JFactory::getDocument(); 79 $renderer = $document->loadRenderer('module'); 80 $params = array('style'=>$style); 81 82 $contents = ''; 83 foreach (JModuleHelper::getModules($position) as $mod) { 84 $contents .= $renderer->render($mod, $params); 85 } 86 return $contents; 87 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |