Annotation of /mambo/branches/4.6/mambots/content/mossef.php
Parent Directory
|
Revision Log
Revision 297 - (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 : | mambo | 117 | $this->registerFunction( 'onPrepareContent', 'botMosSef' ); |
| 16 : | root | 1 | |
| 17 : | /** | ||
| 18 : | * Converting internal relative links to SEF URLs | ||
| 19 : | * | ||
| 20 : | * <b>Usage:</b> | ||
| 21 : | * <code><a href="...relative link..."></code> | ||
| 22 : | */ | ||
| 23 : | function botMosSef( $published, &$row, &$params, $page=0 ) { | ||
| 24 : | global $mosConfig_absolute_path, $mosConfig_live_site; | ||
| 25 : | |||
| 26 : | counterpoi | 213 | t if (is_callable(array($row, 'getText'))) $localtext = $row->getText(); |
| 27 : | t else $localtext = $row->text; | ||
| 28 : | root | 1 | // define the regular expression for the bot |
| 29 : | $regex = "#href=\"(.*?)\"#s"; | ||
| 30 : | |||
| 31 : | // perform the replacement | ||
| 32 : | counterpoi | 213 | t $localtext = preg_replace_callback( $regex, 'botMosSef_replacer', $localtext ); |
| 33 : | root | 1 | |
| 34 : | counterpoi | 213 | t if (is_callable(array($row, 'saveText'))) $row->saveText($localtext); |
| 35 : | t else $row->text = $localtext; | ||
| 36 : | t | ||
| 37 : | root | 1 | return true; |
| 38 : | } | ||
| 39 : | /** | ||
| 40 : | * Replaces the matched tags | ||
| 41 : | * @param array An array of matches (see preg_match_all) | ||
| 42 : | * @return string | ||
| 43 : | */ | ||
| 44 : | function botMosSef_replacer( &$matches ) { | ||
| 45 : | if ( substr($matches[1],0,1)=="#" ) { | ||
| 46 : | // anchor | ||
| 47 : | $temp = split("index.php", $_SERVER['REQUEST_URI']); | ||
| 48 : | return "href=\"".sefRelToAbs("index.php".@$temp[1]).$matches[1]."\""; | ||
| 49 : | } else { | ||
| 50 : | return "href=\"".sefRelToAbs($matches[1])."\""; | ||
| 51 : | } | ||
| 52 : | } | ||
| 53 : | mambo | 117 | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

