Source for file _smilies.renderer.php
Documentation is available at _smilies.renderer.php
* This file implements the Image Smilies Renderer plugin for b2evolution
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
require_once dirname(__FILE__
).
'/../renderer.class.php';
* Text similes search array
* {@internal smilies_Rendererplugin::smilies_Rendererplugin(-)}}
require
dirname(__FILE__
).
'/../_smilies.conf.php';
* {@internal smilies_Rendererplugin::render(-)}}
* @param string content to render (by reference) / rendered content
* @param string Output format, see {@link format_to_output()}
* @return boolean true if we can render something for the required output format
function render( & $content, $format )
if( ! parent::render( $content, $format ) )
{ // We cannot render the required format
if( ! isset
( $this->search ) )
{ // We haven't prepared the smilies yet
$tmpsmilies =
$this->smilies;
uksort($tmpsmilies, 'smiliescmp');
foreach($tmpsmilies as $smiley =>
$img)
$this->search[] =
$smiley;
for ($i =
0; $i <
strlen($smiley); $i++
)
$smiley_masked .=
'&#'.
ord(substr($smiley, $i, 1)).
';';
// We don't use getimagesize() here until we have a mean
// to preprocess smilies. It takes up to much time when
// processing them at display time.
$this->replace[] =
'<img src="'.
$this->smilies_path.
'/'.
$img.
'" alt="'.
$smiley_masked.
'" class="middle" />';
// REPLACE: But not in code blocks.
if( strpos( $content , '<code>' ) !==
false )
{ // If there are code tags run this substitution
$content_parts =
preg_split("/<\/?code>/", $content);
for ( $x =
0 ; $x <
count( $content_parts ) ; $x++
)
{ // If x is even then it's not code and replace any smiles
$content .=
str_replace( $this->search, $this->replace, $content_parts[$x] );
{ // If x is odd don't replace smiles. and put code tags back in.
$content .=
'<code>' .
$content_parts[$x] .
'</code>';
{ // No code blocks, replace on the whole thing
$content =
str_replace( $this->search, $this->replace, $content);
* sorts the smilies' array by length
* this is important if you want :)) to superseede :) for example