Просмотр файла system/inc/classes/BBcodeParser.class.php

Размер файла: 1.52Kb
<?php
/**
 * @name SHCMS Engine
 * @copyright Shamsik © 2012
 */
 
class BBcodeParser
{  
    function parserString($string) 
	{ 
		/**
		* Преобразование на HTML тэги
		* $patterns = array(); 
		*/
		$patterns = array(); 
        $patterns[0] = '/\[b]/'; 
        $patterns[1] = '/\[\/b]/'; 
        $patterns[2] = '/\[i]/'; 
        $patterns[3] = '/\[\/i]/'; 
        $patterns[4] = '/\[u]/'; 
        $patterns[5] = '/\[\/u]/'; 
        $patterns[6] = '/\[s]/'; 
        $patterns[7] = '/\[\/s]/'; 
        $patterns[8] = '/\[sup]/'; 
        $patterns[9] = '/\[\/sup]/'; 
        $patterns[10] = '/\[sub]/'; 
        $patterns[11] = '/\[\/sub]/'; 
		$patterns[12] = '/\[small]/';
        $patterns[13] = '/\[\/small]/';
		/**
		* HTML тэги
		* $replacements = array(); 
		*/
        $replacements = array(); 
        $replacements[0] = "<b>"; 
        $replacements[1] = "</b>"; 
        $replacements[2] = "<em>"; 
        $replacements[3] = "</em>"; 
        $replacements[4] = "<u>"; 
        $replacements[5] = "</u>"; 
        $replacements[6] = "<s>"; 
        $replacements[7] = "</s>"; 
        $replacements[8] = "<sup>"; 
        $replacements[9] = "</sup>"; 
        $replacements[10] = "<sub>"; 
        $replacements[11] = "</sub>"; 
        $replacements[12] = "<div style='font-size: smaller;'>"; 
        $replacements[13] = "</div>";
        $result = preg_replace($patterns, $replacements, $string); 
      return $result; 
    } 
}


$BBcodeParser = new BBcodeParser;



?>