public function parseCode($tag, $openNode, $body, $closeNode) { $source = $body[0]['text']; $language = 'php'; $path = 'geshi/'; $geshi = new GeSHi($source, $language, $path); $body[0]['text'] = htmlspecialchars_decode($geshi->parseCode()); // tutaj mozemy dodać geshi czy to tez sie podoba $openNode['text'].='<div class="code_title">Kod</div><pre class="prettyprint">'; $closeNode['text']='</pre>'.$closeNode['text']; }
$body[0]['text'] =$geshi->parseCode(); $body[0]['nohtmlspecialchars'] = 1;
$body[0]['text'] =$geshi->parseCode(); $body[0]['nohtmlspecialchars'] = 1;
[code lang='php']jakiś skrypt php[/code] [code lang='java'] jakiś skrypt java[/code]
'code'=>array( 'open'=>'div class="code_wrapper"', 'close'=>'div', 'notallowed_child'=>'all', 'leave_notallowed_child'=>1, 'leave_notallowed_parent'=>1, 'parse_body'=>'parseCode', 'attributes'=>array( 'lang'=>array( 'type'=>'string', 'values'=>array('php', 'js') ) ) ) );
public function parseCode($tag, &$openNode, &$body, &$closeNode) { $language = 'default'; { $language = $openNode['attributes']['tag_attributes']['lang']; } // dalszy kod }
'php'=>array( 'open'=>'div class="code_wrapper"', 'close'=>'div', 'notallowed_child'=>'all', 'leave_notallowed_child'=>1, 'leave_notallowed_parent'=>1, 'parse_body'=>'parsePHP' ), 'code'=>array( 'open'=>'div class="code_wrapper"', 'close'=>'div', 'notallowed_child'=>'all', 'leave_notallowed_child'=>1, 'leave_notallowed_parent'=>1, 'parse_body'=>'parseCode' ) ); public function parserPhp($tag, &$openNode, &$body, &$closeNode) { $language = 'php'; $this->parseCode($tag, $openNode, $body, $closeNode, 'php'); } public function parseCode($tag, &$openNode, &$body, &$closeNode, $language = 'default') { // laczymy tresc w całość $content = ''; foreach($body as $key => &$node) { $content.= $node['text']; $node['text'] = ''; // usuwamy zbedne elementy } require_once 'class.geshi.php'; $geshi = new GeSHi($content, $language); $body[0]['tagText'] = $content; $body[0]['text'] = $geshi->parseCode(); $body[0]['nohtmlspecialchars'] = 1; $openNode['text'].='<div class="code_title">Kod</div><div class="code_area">'; $closeNode['text']='</div>'.$closeNode['text']; }
'c'=>array( 'open'=>'div class="code_wrapper"', 'close'=>'div', 'notallowed_child'=>'all', 'leave_notallowed_child'=>1, 'leave_notallowed_parent'=>1, 'parse_body'=>'parseC' ),
'list'=>array( 'open'=>'ul', 'close'=>'ul', 'wrap_white_space'=>true, 'allowed_child'=>array('li'), 'notallowed_parent'=>array('list'), 'parse_body'=>'parseList' ), '*'=>array( 'open'=>'li', 'close'=>false, 'allowed_parent'=>array('list') ) );
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl"> <head> <meta http-equiv="Content-type" content="application/xhtml+xml; charset=iso-8859-2" /> <link rel="stylesheet" href=" [nazwa_arkusza_stylow.css] " type="text/css" /> </head> <body> <p> </p> </body> </html>
Warning: include_once(Bbcode/Filters/Basic.php) [function.include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Warning: include_once() [function.include]: Failed opening 'Bbcode/Filters/Basic.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Notice: filter not exists in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 268 Warning: include_once(Bbcode/Filters/Code.php) [function.include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Warning: include_once() [function.include]: Failed opening 'Bbcode/Filters/Code.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Notice: filter not exists in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 268 Warning: include_once(Bbcode/Filters/Url.php) [function.include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Warning: include_once() [function.include]: Failed opening 'Bbcode/Filters/Url.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Notice: filter not exists in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 268 Warning: include_once(Bbcode/Filters/List.php) [function.include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Warning: include_once() [function.include]: Failed opening 'Bbcode/Filters/List.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Notice: filter not exists in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 268 Warning: include_once(Bbcode/Filters/Image.php) [function.include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Warning: include_once() [function.include]: Failed opening 'Bbcode/Filters/Image.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Notice: filter not exists in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 268 Warning: include_once(Bbcode/Filters/Youtube.php) [function.include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264 Warning: include_once() [function.include]: Failed opening 'Bbcode/Filters/Youtube.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\smarty\class\Bbcode\BbCode.class.php on line 264
'notallowed_parent'=>array('code'), // uniemozliwia osadzenie code 'leave_notallowed_parent'=>true // ale samo istnienie tegoż taga pozostawia w tekście
'list'=>array( 'open'=>'ul', 'close'=>'ul', 'wrap_white_space'=>true, 'allowed_child'=>array('*'), 'notallowed_parent'=>array('list'), 'parse_body'=>'parseList' ), '*'=>array( 'open'=>'li', 'close'=>false ) );
<?php /** * Obsługa list (popularna na forach) * @package Parser * @subpackage Filters * @author LapKom * @version 0.1 */ class BbCodeFilterList { 'list'=>array( 'open'=>'ul', 'close'=>'ul', 'wrap_white_space'=>true, 'allowed_child'=>array('*','l'), 'notallowed_parent'=>array('list'), 'parse_body'=>'parseList', 'attributes'=>array( 'list'=>array( 'attr'=>'style', 'type'=>'string', 'values'=>array( '1', '01', 'a', 'A', 'i', 'I', ), ), ), ), '*'=>array( 'open'=>'li', 'close'=>false, 'allowed_parent'=>array('list'), ), ); /** * Parsuje LISTY * @param array $tag * @param array $openNode * @param array $body * @param array $closeNode * @param BbCodeSettings $settings */ public function parseList($tag, &$openNode, &$body, &$closeNode, $settings) { $listStyleType = $openNode['attributes']['tag_attributes']['list']; switch ($listStyleType) { case '1' : $type = 'decimal'; break; case '01' : $type = 'decimal-leading-zero'; break; case 'a' : $type = 'lower-alpha'; break; case 'A' : $type = 'upper-alpha'; break; case 'i' : $type = 'lower-roman'; break; case 'I' : $type = 'upper-roman'; break; } $listStyleType = $openNode['attributes']['tag_attributes']['list'] = 'list-style-type:'.$type; $openNode=BbCode::rebuildNode($tag, $openNode, $settings); } } } ?>
'l'=>array( 'open'=>'li', 'close'=>false, 'allowed_parent'=>array('list'), )
foreach($body as &$el) { }
'type' => int 0 'text' => string ' ' (length=4) 'nobr' => int 1 'type' => int 3 'original_text' => string '[l]' (length=3) 'tagname' => string 'l' (length=1) 'tagText' => string '[l]' (length=3) 'text' => string '<li/>' (length=5) 'type' => int 0 'text' => string ' Element listy ' (length=18) 'nobr' => int 1 'type' => int 3 'original_text' => string '[l]' (length=3) 'tagname' => string 'l' (length=1) 'tagText' => string '[l]' (length=3) 'text' => string '<li/>' (length=5) 'type' => int 0 'text' => string ' Element listy 2 ' (length=19) 'nobr' => int 1