Annotation of /mambo/branches/4.6/mambots/content/mosloadposition.php
Parent Directory
|
Revision Log
Revision 617 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | csouza | 297 | * @package Mambo Open Source |
| 4 : | * @copyright (C) 2005 - 2006 Mambo Foundation Inc. | ||
| 5 : | root | 1 | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 6 : | csouza | 297 | * |
| 7 : | * Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure | ||
| 8 : | * that Mambo remained free Open Source software owned and managed by the community. | ||
| 9 : | root | 1 | * Mambo is Free Software |
| 10 : | csouza | 297 | */ |
| 11 : | root | 1 | |
| 12 : | /** ensure this file is being included by a parent file */ | ||
| 13 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 14 : | |||
| 15 : | $_MAMBOTS->registerFunction( 'onPrepareContent', 'botMosLoadPosition' ); | ||
| 16 : | |||
| 17 : | /** | ||
| 18 : | * Mambot that loads module positions within content | ||
| 19 : | */ | ||
| 20 : | csouza | 129 | function botMosLoadPosition( $published, &$row, &$cparams, $page=0, $params ) { |
| 21 : | root | 1 | global $database; |
| 22 : | |||
| 23 : | // expression to search for | ||
| 24 : | $regex = '/{mosloadposition\s*.*?}/i'; | ||
| 25 : | |||
| 26 : | counterpoi | 213 | t if (is_callable(array($row, 'getText'))) $localtext = $row->getText(); |
| 27 : | t else $localtext = $row->text; | ||
| 28 : | root | 1 | // find all instances of mambot and put in $matches |
| 29 : | counterpoi | 213 | t preg_match_all( $regex, $localtext, $matches ); |
| 30 : | root | 1 | |
| 31 : | // Number of mambots | ||
| 32 : | $count = count( $matches[0] ); | ||
| 33 : | |||
| 34 : | // mambot only processes if there are any instances of the mambot in the text | ||
| 35 : | if ( $count ) { | ||
| 36 : | neilt | 617 | |
| 37 : | // load mambot params info | ||
| 38 : | $query = "SELECT id FROM #__mambots WHERE element = 'mosloadposition' AND folder = 'content'"; | ||
| 39 : | $database->setQuery( $query ); | ||
| 40 : | $id = $database->loadResult(); | ||
| 41 : | $mambot = new mosMambot( $database ); | ||
| 42 : | $mambot->load( $id ); | ||
| 43 : | $params =& new mosParameters( $mambot->params ); | ||
| 44 : | |||
| 45 : | $style = $params->def( 'style', -2 ); | ||
| 46 : | root | 1 | |
| 47 : | counterpoi | 213 | t processPositions( $localtext, $matches, $count, $regex, $style ); |
| 48 : | t } | ||
| 49 : | t // Save the results of processing | ||
| 50 : | t if (is_callable(array($row, 'saveText'))) $row->saveText($localtext); | ||
| 51 : | t else $row->text = $localtext; | ||
| 52 : | t | ||
| 53 : | root | 1 | } |
| 54 : | |||
| 55 : | counterpoi | 213 | t function processPositions ( &$text, &$matches, $count, $regex, $style ) { |
| 56 : | root | 1 | global $database; |
| 57 : | |||
| 58 : | $query = "SELECT position" | ||
| 59 : | . "\n FROM #__template_positions" | ||
| 60 : | . "\n ORDER BY position" | ||
| 61 : | ; | ||
| 62 : | $database->setQuery( $query ); | ||
| 63 : | $positions = $database->loadResultArray(); | ||
| 64 : | |||
| 65 : | for ( $i=0; $i < $count; $i++ ) { | ||
| 66 : | $load = str_replace( 'mosloadposition', '', $matches[0][$i] ); | ||
| 67 : | $load = str_replace( '{', '', $load ); | ||
| 68 : | $load = str_replace( '}', '', $load ); | ||
| 69 : | $load = trim( $load ); | ||
| 70 : | |||
| 71 : | foreach ( $positions as $position ) { | ||
| 72 : | if ( $position == @$load ) { | ||
| 73 : | $modules = loadPosition( $load, $style ); | ||
| 74 : | counterpoi | 213 | t $text = preg_replace( '{'. $matches[0][$i] .'}', $modules, $text ); |
| 75 : | root | 1 | break; |
| 76 : | } | ||
| 77 : | } | ||
| 78 : | } | ||
| 79 : | |||
| 80 : | // removes tags without matching module positions | ||
| 81 : | counterpoi | 213 | t $text = preg_replace( $regex, '', $text ); |
| 82 : | root | 1 | } |
| 83 : | |||
| 84 : | function loadPosition( $position, $style=-2 ) { | ||
| 85 : | $modules = ''; | ||
| 86 : | if ( mosCountModules( $position ) ) { | ||
| 87 : | ob_start(); | ||
| 88 : | mosLoadModules ( $position, $style ); | ||
| 89 : | $modules = ob_get_contents(); | ||
| 90 : | ob_end_clean(); | ||
| 91 : | } | ||
| 92 : | |||
| 93 : | return $modules; | ||
| 94 : | } | ||
| 95 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

