| [ 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', 'botMosCode' ); 20 21 /** 22 * Code Highlighting Mambot 23 * 24 * <strong>Usage:</strong> 25 * <code>{moscode}...some code...{/moscode}</code> 26 */ 27 function botMosCode( $published, &$row, &$params, $page=0 ) { 28 // define the regular expression for the bot 29 $regex = "#{moscode}(.*?){/moscode}#s"; 30 31 if (is_callable(array($row, 'getText'))) $localtext = $row->getText(); 32 else $localtext = $row->text; 33 if (!$published) { 34 $localtext = preg_replace( $regex, '', $localtext ); 35 if (is_callable(array($row, 'saveText'))) $row->saveText($localtext); 36 else $row->text = $localtext; 37 return; 38 } 39 40 41 // perform the replacement 42 $localtext = preg_replace_callback( $regex, 'botMosCode_replacer', $localtext ); 43 if (is_callable(array($row, 'saveText'))) $row->saveText($localtext); 44 else $row->text = $localtext; 45 46 return true; 47 } 48 /** 49 * Replaces the matched tags an image 50 * @param array An array of matches (see preg_match_all) 51 * @return string 52 */ 53 function botMosCode_replacer( &$matches ) { 54 $html_entities_match = array("#<#", "#>#"); 55 $html_entities_replace = array("<", ">"); 56 57 $text = $matches[1]; 58 59 $text = preg_replace($html_entities_match, $html_entities_replace, $text ); 60 61 // Replace 2 spaces with " " so non-tabbed code indents without making huge long lines. 62 $text = str_replace(" ", " ", $text); 63 // now Replace 2 spaces with " " to catch odd #s of spaces. 64 $text = str_replace(" ", " ", $text); 65 66 // Replace tabs with " " so tabbed code indents sorta right without making huge long lines. 67 $text = str_replace("\t", " ", $text); 68 69 $text = str_replace('<', '<', $text); 70 $text = str_replace('>', '>', $text); 71 72 $text = highlight_string( $text, 1 ); 73 74 $text = str_replace('&nbsp;', ' ', $text); 75 $text = str_replace('<br/>', '<br />', $text); 76 $text = str_replace('<font color="#007700"><</font><font color="#0000BB">br</font><font color="#007700">/>','<br />', $text); 77 $text = str_replace('&</font><font color="#0000CC">nbsp</font><font color="#006600">;', ' ', $text); 78 $text = str_replace('&</font><font color="#0000BB">nbsp</font><font color="#007700">;', ' ', $text); 79 $text = str_replace('<font color="#007700">;<</font><font color="#0000BB">br</font><font color="#007700">/>','<br />', $text); 80 81 return $text; 82 } 83 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed May 23 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 |