| [ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: mossef.php 4861 2006-08-31 13:55:47Z predator $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. 6 * @license http://www.gnu.org/copyleft/gpl.html 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( '_VALID_MOS' ) or die( 'Restricted access' ); 16 17 $_MAMBOTS->registerFunction( 'onPrepareContent', 'botMosSef' ); 18 19 /** 20 * Converting internal relative links to SEF URLs 21 * 22 * <b>Usage:</b> 23 * <code><a href="...relative link..."></code> 24 */ 25 function botMosSef( $published, &$row, &$params, $page=0 ) { 26 global $mosConfig_sef; 27 28 // check whether mambot has been unpublished 29 if ( !$published ) { 30 return true; 31 } 32 33 // check whether SEF is off 34 if ( !$mosConfig_sef ) { 35 return true; 36 } 37 38 // simple performance check to determine whether bot should process further 39 if ( strpos( $row->text, 'href="' ) === false ) { 40 return true; 41 } 42 43 // define the regular expression for the bot 44 $regex = "#href=\"(.*?)\"#s"; 45 46 // perform the replacement 47 $row->text = preg_replace_callback( $regex, 'botMosSef_replacer', $row->text ); 48 49 return true; 50 } 51 52 /** 53 * Replaces the matched tags 54 * @param array An array of matches (see preg_match_all) 55 * @return string 56 */ 57 function botMosSef_replacer( &$matches ) { 58 // original text that might be replaced 59 $original = 'href="'. $matches[1] .'"'; 60 61 // array list of non http/https URL schemes 62 $url_schemes = explode( ', ', _URL_SCHEMES ); 63 64 foreach ( $url_schemes as $url ) { 65 // disable bot from being applied to specific URL Scheme tag 66 if ( strpos( $matches[1], $url ) !== false ) { 67 return $original; 68 } 69 } 70 71 if ( strpos( $matches[1], 'index.php?option' ) !== false ) { 72 // links containing 'index.php?option 73 // convert url to SEF link 74 $link = sefRelToAbs( $matches[1] ); 75 // reconstruct html output 76 $replace = 'href="'. $link .'"'; 77 78 return $replace; 79 } else if ( strpos( $matches[1], '#' ) === 0 ) { 80 // special handling for anchor only links 81 $url = $_SERVER['REQUEST_URI']; 82 $url = explode( '?option', $url ); 83 84 if (is_array($url) && isset($url[1])) { 85 $link = 'index.php?option'. $url[1] ; 86 // convert url to SEF link 87 $link = sefRelToAbs( $link ) . $matches[1]; 88 } else { 89 $link = $matches[1]; 90 // convert url to SEF link 91 $link = sefRelToAbs( $link ); 92 } 93 // reconstruct html output 94 $replace = 'href="'. $link .'"'; 95 96 return $replace; 97 } else { 98 return $original; 99 } 100 } 101 ?> 102
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
|