| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @author Mambo Foundation Inc see README.php 5 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 6 * See COPYRIGHT.php for copyright notices and details. 7 * @license GNU/GPL Version 2, see LICENSE.php 8 * 9 * Redistributions of files must retain the above copyright notice. 10 * 11 * Mambo is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; version 2 of the License. 14 */ 15 16 /** ensure this file is being included by a parent file */ 17 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 18 19 $_MAMBOTS->registerFunction( 'onPrepareContent', 'botMosLoadPosition' ); 20 21 /** 22 * Mambot that loads module positions within content 23 */ 24 function botMosLoadPosition( $published, &$row, &$cparams, $page=0, $params ) { 25 global $database; 26 27 // expression to search for 28 $regex = '/{mosloadposition\s*.*?}/i'; 29 30 if (is_callable(array($row, 'getText'))) $localtext = $row->getText(); 31 else $localtext = $row->text; 32 // find all instances of mambot and put in $matches 33 preg_match_all( $regex, $localtext, $matches ); 34 35 // Number of mambots 36 $count = count( $matches[0] ); 37 38 // mambot only processes if there are any instances of the mambot in the text 39 if ( $count ) { 40 41 // load mambot params info 42 /*$query = "SELECT id FROM #__mambots WHERE element = 'mosloadposition' AND folder = 'content'"; 43 $database->setQuery( $query ); 44 $id = $database->loadResult(); 45 $mambot = new mosMambot( $database ); 46 $mambot->load( $id );*/ 47 $mambots =& mosMambotHandler::getInstance(); 48 $mambot = $mambots->getBot('mosloadposition','content'); 49 $params =& new mosParameters( (isset($mambot->params)?$mambot->params:'') ); 50 51 $style = $params->def( 'style', -2 ); 52 53 processPositions( $localtext, $matches, $count, $regex, $style ); 54 } 55 // Save the results of processing 56 if (is_callable(array($row, 'saveText'))) $row->saveText($localtext); 57 else $row->text = $localtext; 58 59 } 60 61 function processPositions ( &$text, &$matches, $count, $regex, $style ) { 62 global $database; 63 64 $query = "SELECT position" 65 . "\n FROM #__template_positions" 66 . "\n ORDER BY position" 67 ; 68 $database->setQuery( $query ); 69 $positions = $database->loadResultArray(); 70 71 for ( $i=0; $i < $count; $i++ ) { 72 $load = str_replace( 'mosloadposition', '', $matches[0][$i] ); 73 $load = str_replace( '{', '', $load ); 74 $load = str_replace( '}', '', $load ); 75 $load = trim( $load ); 76 77 foreach ( $positions as $position ) { 78 if ( $position == @$load ) { 79 $modules = loadPosition( $load, $style ); 80 $text = preg_replace( '{'. $matches[0][$i] .'}', $modules, $text ); 81 break; 82 } 83 } 84 } 85 86 // removes tags without matching module positions 87 $text = preg_replace( $regex, '', $text ); 88 } 89 90 function loadPosition( $position, $style=-2 ) { 91 $modules = ''; 92 if ( mosCountModules( $position ) ) { 93 ob_start(); 94 mosLoadModules ( $position, $style ); 95 $modules = ob_get_contents(); 96 ob_end_clean(); 97 } 98 99 return $modules; 100 } 101
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 8 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |