1
+ − 1
<?php
+ − 2
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
+ − 3
/**
+ − 4
* Smiley rule Xhtml renderer
+ − 5
*
+ − 6
* PHP versions 4 and 5
+ − 7
*
+ − 8
* @category Text
+ − 9
* @package Text_Wiki
+ − 10
* @author Bertrand Gugger <bertrand@toggg.com>
+ − 11
* @copyright 2005 bertrand Gugger
+ − 12
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
+ − 13
* @version CVS: $Id: Smiley.php,v 1.2 2006/02/10 23:07:03 toggg Exp $
+ − 14
* @link http://pear.php.net/package/Text_Wiki
+ − 15
*/
+ − 16
+ − 17
/**
+ − 18
* Smiley rule Xhtml render class
+ − 19
*
+ − 20
* @category Text
+ − 21
* @package Text_Wiki
+ − 22
* @author Bertrand Gugger <bertrand@toggg.com>
+ − 23
* @copyright 2005 bertrand Gugger
+ − 24
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
+ − 25
* @version Release: @package_version@
+ − 26
* @link http://pear.php.net/package/Text_Wiki
+ − 27
* @see Text_Wiki::Text_Wiki_Render()
+ − 28
*/
+ − 29
class Text_Wiki_Render_Xhtml_Smiley extends Text_Wiki_Render {
+ − 30
+ − 31
/**
+ − 32
* Configuration keys for this rule
+ − 33
* 'prefix' => the path to smileys images inclusive file name prefix,
+ − 34
* starts with '/' ==> abolute reference
+ − 35
* if no file names prefix but some folder, terminates with '/'
+ − 36
* 'extension' => the file extension (inclusive '.'), e.g. :
+ − 37
* if prefix 'smileys/icon_' and extension '.gif'
+ − 38
* ':)' whose name is 'smile' will give relative file 'smileys/icon_smile.gif'
+ − 39
* if prefix '/image/smileys/' and extension '.png': absolute '/image/smileys/smile.gif'
+ − 40
* 'css' => optional style applied to smileys
+ − 41
*
+ − 42
* @access public
+ − 43
* @var array 'config-key' => mixed config-value
+ − 44
*/
+ − 45
var $conf = array(
+ − 46
'prefix' => 'images/smiles/icon_',
+ − 47
'extension' => '.gif',
+ − 48
'css' => null
+ − 49
);
+ − 50
+ − 51
/**
+ − 52
* Renders a token into text matching the requested format.
+ − 53
* process the Smileys
+ − 54
*
+ − 55
* @access public
+ − 56
* @param array $options The "options" portion of the token (second element).
+ − 57
* @return string The text rendered from the token options.
+ − 58
*/
+ − 59
function token($options)
+ − 60
{
+ − 61
$imageFile = $this->getConf('prefix') . $options['name'] . $this->getConf('extension');
+ − 62
+ − 63
// attempt to get the image size
+ − 64
$imageSize = @getimagesize($imageFile);
+ − 65
+ − 66
// return the HTML output
+ − 67
return '<img src="' . $this->textEncode($imageFile) . '"' .
+ − 68
(is_array($imageSize) ?
+ − 69
' width="' . $imageSize[0] . '" height="' . $imageSize[1] .'"' : '') .
+ − 70
' alt="' . $options['desc'] . '"' .
+ − 71
$this->formatConf(' class="%s"', 'css') . ' />';
+ − 72
}
+ − 73
}
+ − 74
?>