[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/mambots/content/ -> mossef.php (source)

   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  $this->registerFunction( 'onPrepareContent', 'botMosSef' );
  20  
  21  /**
  22  * Converting internal relative links to SEF URLs
  23  *
  24  * <strong>Usage:</strong>
  25  * <code><a href="...relative link..."></code>
  26  */
  27  function botMosSef( $published, &$row, &$params, $page=0 ) {
  28      global $mosConfig_absolute_path, $mosConfig_live_site;
  29  
  30      if (is_callable(array($row, 'getText'))) $localtext = $row->getText();
  31      else $localtext = $row->text;
  32      // define the regular expression for the bot
  33      $regex = "#href=\"(.*?)\"#s";
  34  
  35      // perform the replacement
  36      $localtext = preg_replace_callback( $regex, 'botMosSef_replacer', $localtext );
  37  
  38      if (is_callable(array($row, 'saveText'))) $row->saveText($localtext);
  39      else $row->text = $localtext;
  40  
  41      return true;
  42  }
  43  /**
  44  * Replaces the matched tags
  45  * @param array An array of matches (see preg_match_all)
  46  * @return string
  47  */
  48  function botMosSef_replacer( &$matches ) {
  49      if ( substr($matches[1],0,1)=="#" ) {
  50          // anchor
  51          $temp = split("index.php", $_SERVER['REQUEST_URI']);
  52          return "href=\"".sefRelToAbs("index.php".@$temp[1]).$matches[1]."\"";
  53      } else {
  54          return "href=\"".sefRelToAbs($matches[1])."\"";
  55      }
  56  }
  57  ?>