From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- .../Text/Highlighter/Renderer/Array.php | 396 ++++----- .../Text/Highlighter/Renderer/BB.php | 474 +++++------ .../Text/Highlighter/Renderer/Console.php | 414 +++++----- .../Text/Highlighter/Renderer/Html.php | 890 ++++++++++----------- .../Text/Highlighter/Renderer/HtmlTags.php | 372 ++++----- .../Text/Highlighter/Renderer/JSON.php | 170 ++-- .../Text/Highlighter/Renderer/XML.php | 204 ++--- 7 files changed, 1460 insertions(+), 1460 deletions(-) (limited to 'framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer') diff --git a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Array.php b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Array.php index 5a0c9c09..ef3ffec1 100644 --- a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Array.php +++ b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Array.php @@ -1,199 +1,199 @@ -class => content pairs. - * Based on the HTML renderer by Andrey Demenev. - * - * LICENSE: This source file is subject to version 3.0 of the PHP license - * that is available through the world-wide-web at the following URI: - * http://www.php.net/license/3_0.txt. If you did not receive a copy of - * the PHP License and are unable to obtain it through the web, please - * send a note to license@php.net so we can mail you a copy immediately. - * - * @category Text - * @package Text_Highlighter - * @author Stoyan Stefanov - * @copyright 2006 Stoyan Stefanov - * @license http://www.php.net/license/3_0.txt PHP License - * @version CVS: $Id: Array.php,v 1.1 2007/06/03 02:37:08 ssttoo Exp $ - * @link http://pear.php.net/package/Text_Highlighter - */ - -/** - * @ignore - */ - -require_once dirname(__FILE__).'/../Renderer.php'; - -/** - * Array renderer, based on Andrey Demenev's HTML renderer. - * - * In addition to the options supported by the HTML renderer, - * the following options were also introduced: - * - * - * - * @author Stoyan Stefanov - * @category Text - * @package Text_Highlighter - * @copyright 2006 Stoyan Stefanov - * @license http://www.php.net/license/3_0.txt PHP License - * @version Release: 0.5.0 - * @link http://pear.php.net/package/Text_Highlighter - */ - -class Text_Highlighter_Renderer_Array extends Text_Highlighter_Renderer -{ - - /**#@+ - * @access private - */ - - /** - * Tab size - * - * @var integer - */ - var $_tabsize = 4; - - /** - * Should htmlentities() will be called - * - * @var boolean - */ - var $_htmlspecialchars = true; - - /** - * Enumerated or associative array - * - * @var integer - */ - var $_enumerated = false; - - /** - * Array containing highlighting rules - * - * @var array - */ - var $_output = array(); - - /**#@-*/ - - /** - * Preprocesses code - * - * @access public - * - * @param string $str Code to preprocess - * @return string Preprocessed code - */ - function preprocess($str) - { - // normalize whitespace and tabs - $str = str_replace("\r\n","\n", $str); - // some browsers refuse to display empty lines - $str = preg_replace('~^$~m'," ", $str); - $str = str_replace("\t",str_repeat(' ', $this->_tabsize), $str); - return rtrim($str); - } - - - /** - * Resets renderer state - * - * Descendents of Text_Highlighter call this method from the constructor, - * passing $options they get as parameter. - * - * @access protected - */ - function reset() - { - $this->_output = array(); - $this->_lastClass = 'default'; - if (isset($this->_options['tabsize'])) { - $this->_tabsize = $this->_options['tabsize']; - } - if (isset($this->_options['htmlspecialchars'])) { - $this->_htmlspecialchars = $this->_options['htmlspecialchars']; - } - if (isset($this->_options['enumerated'])) { - $this->_enumerated = $this->_options['enumerated']; - } - } - - - - /** - * Accepts next token - * - * @abstract - * @access public - * @param string $class Token class - * @param string $content Token content - */ - function acceptToken($class, $content) - { - - - $theClass = $this->_getFullClassName($class); - if ($this->_htmlspecialchars) { - $content = htmlspecialchars($content); - } - if ($this->_enumerated) { - $this->_output[] = array($class, $content); - } else { - $this->_output[][$class] = $content; - } - $this->_lastClass = $class; - - } - - - /** - * Given a CSS class name, returns the class name - * with language name prepended, if necessary - * - * @access private - * - * @param string $class Token class - */ - function _getFullClassName($class) - { - if (!empty($this->_options['use_language'])) { - $theClass = $this->_language . '-' . $class; - } else { - $theClass = $class; - } - return $theClass; - } - - /** - * Get generated output - * - * @abstract - * @return array Highlighted code as an array - * @access public - */ - function getOutput() - { - return $this->_output; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ - +class => content pairs. + * Based on the HTML renderer by Andrey Demenev. + * + * LICENSE: This source file is subject to version 3.0 of the PHP license + * that is available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. If you did not receive a copy of + * the PHP License and are unable to obtain it through the web, please + * send a note to license@php.net so we can mail you a copy immediately. + * + * @category Text + * @package Text_Highlighter + * @author Stoyan Stefanov + * @copyright 2006 Stoyan Stefanov + * @license http://www.php.net/license/3_0.txt PHP License + * @version CVS: $Id: Array.php,v 1.1 2007/06/03 02:37:08 ssttoo Exp $ + * @link http://pear.php.net/package/Text_Highlighter + */ + +/** + * @ignore + */ + +require_once dirname(__FILE__).'/../Renderer.php'; + +/** + * Array renderer, based on Andrey Demenev's HTML renderer. + * + * In addition to the options supported by the HTML renderer, + * the following options were also introduced: + *
  • htmlspecialchars - whether or not htmlspecialchars() will + * be called on the content, default TRUE
  • + *
  • enumerated - type of array produced, default FALSE, + * meaning associative array
  • + *
+ * + * + * @author Stoyan Stefanov + * @category Text + * @package Text_Highlighter + * @copyright 2006 Stoyan Stefanov + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.5.0 + * @link http://pear.php.net/package/Text_Highlighter + */ + +class Text_Highlighter_Renderer_Array extends Text_Highlighter_Renderer +{ + + /**#@+ + * @access private + */ + + /** + * Tab size + * + * @var integer + */ + var $_tabsize = 4; + + /** + * Should htmlentities() will be called + * + * @var boolean + */ + var $_htmlspecialchars = true; + + /** + * Enumerated or associative array + * + * @var integer + */ + var $_enumerated = false; + + /** + * Array containing highlighting rules + * + * @var array + */ + var $_output = array(); + + /**#@-*/ + + /** + * Preprocesses code + * + * @access public + * + * @param string $str Code to preprocess + * @return string Preprocessed code + */ + function preprocess($str) + { + // normalize whitespace and tabs + $str = str_replace("\r\n","\n", $str); + // some browsers refuse to display empty lines + $str = preg_replace('~^$~m'," ", $str); + $str = str_replace("\t",str_repeat(' ', $this->_tabsize), $str); + return rtrim($str); + } + + + /** + * Resets renderer state + * + * Descendents of Text_Highlighter call this method from the constructor, + * passing $options they get as parameter. + * + * @access protected + */ + function reset() + { + $this->_output = array(); + $this->_lastClass = 'default'; + if (isset($this->_options['tabsize'])) { + $this->_tabsize = $this->_options['tabsize']; + } + if (isset($this->_options['htmlspecialchars'])) { + $this->_htmlspecialchars = $this->_options['htmlspecialchars']; + } + if (isset($this->_options['enumerated'])) { + $this->_enumerated = $this->_options['enumerated']; + } + } + + + + /** + * Accepts next token + * + * @abstract + * @access public + * @param string $class Token class + * @param string $content Token content + */ + function acceptToken($class, $content) + { + + + $theClass = $this->_getFullClassName($class); + if ($this->_htmlspecialchars) { + $content = htmlspecialchars($content); + } + if ($this->_enumerated) { + $this->_output[] = array($class, $content); + } else { + $this->_output[][$class] = $content; + } + $this->_lastClass = $class; + + } + + + /** + * Given a CSS class name, returns the class name + * with language name prepended, if necessary + * + * @access private + * + * @param string $class Token class + */ + function _getFullClassName($class) + { + if (!empty($this->_options['use_language'])) { + $theClass = $this->_language . '-' . $class; + } else { + $theClass = $class; + } + return $theClass; + } + + /** + * Get generated output + * + * @abstract + * @return array Highlighted code as an array + * @access public + */ + function getOutput() + { + return $this->_output; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ + ?> \ No newline at end of file diff --git a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/BB.php b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/BB.php index 84bc67c0..3536260b 100644 --- a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/BB.php +++ b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/BB.php @@ -1,238 +1,238 @@ - - * @copyright 2005 Stoyan Stefanov - * @license http://www.php.net/license/3_0.txt PHP License - * @version CVS: $Id: BB.php,v 1.1 2007/06/03 02:37:08 ssttoo Exp $ - * @link http://pear.php.net/package/Text_Highlighter - */ - -/** - * @ignore - */ - -require_once dirname(__FILE__).'/../Renderer.php'; - -/** - * BB code renderer, based on Andrey Demenev's HTML renderer. - * - * Elements of $options argument of constructor (each being optional): - * - * - 'numbers' - Line numbering TRUE or FALSE - * - 'tabsize' - Tab size, default is 4 - * - 'bb_tags' - An array containing three BB tags, see below - * - 'tag_brackets' - An array that conains opening and closing tags, [ and ] - * - 'colors' - An array with all the colors to be used for highlighting - * - * The default BB tags are: - * - 'color' => 'color' - * - 'list' => 'list' - * - 'list_item' => '*' - * - * The default colors for the highlighter are: - * - 'default' => 'Black', - * - 'code' => 'Gray', - * - 'brackets' => 'Olive', - * - 'comment' => 'Orange', - * - 'mlcomment' => 'Orange', - * - 'quotes' => 'Darkred', - * - 'string' => 'Red', - * - 'identifier' => 'Blue', - * - 'builtin' => 'Teal', - * - 'reserved' => 'Green', - * - 'inlinedoc' => 'Blue', - * - 'var' => 'Darkblue', - * - 'url' => 'Blue', - * - 'special' => 'Navy', - * - 'number' => 'Maroon', - * - 'inlinetags' => 'Blue', - * - * - * @author Stoyan Stefanov - * @category Text - * @package Text_Highlighter - * @copyright 20045 Stoyan Stefanov - * @license http://www.php.net/license/3_0.txt PHP License - * @version Release: 0.5.0 - * @link http://pear.php.net/package/Text_Highlighter - */ - -class Text_Highlighter_Renderer_BB extends Text_Highlighter_Renderer_Array -{ - - /**#@+ - * @access private - */ - - /** - * Line numbering - will use the specified BB tag for listings - * - * @var boolean - */ - var $_numbers = false; - - /** - * BB tags to be used - * - * @var array - */ - var $_bb_tags = array ( - 'color' => 'color', - 'list' => 'list', - 'list_item' => '*', - 'code' => 'code', - ); - - /** - * BB brackets - [ and ] - * - * @var array - */ - var $_tag_brackets = array ('start' => '[', 'end' => ']'); - - /** - * Colors map - * - * @var boolean - */ - var $_colors = array( - 'default' => 'Black', - 'code' => 'Gray', - 'brackets' => 'Olive', - 'comment' => 'Orange', - 'mlcomment' => 'Orange', - 'quotes' => 'Darkred', - 'string' => 'Red', - 'identifier' => 'Blue', - 'builtin' => 'Teal', - 'reserved' => 'Green', - 'inlinedoc' => 'Blue', - 'var' => 'Darkblue', - 'url' => 'Blue', - 'special' => 'Navy', - 'number' => 'Maroon', - 'inlinetags' => 'Blue', - ); - - /**#@-*/ - - /** - * Resets renderer state - * - * @access protected - * - * - * Descendents of Text_Highlighter call this method from the constructor, - * passing $options they get as parameter. - */ - function reset() - { - parent::reset(); - if (isset($this->_options['numbers'])) { - $this->_numbers = $this->_options['numbers']; - } - if (isset($this->_options['bb_tags'])) { - $this->_bb_tags = array_merge($this->_bb_tags, $this->_options['bb_tags']); - } - if (isset($this->_options['tag_brackets'])) { - $this->_tag_brackets = array_merge($this->_tag_brackets, $this->_options['tag_brackets']); - } - if (isset($this->_options['colors'])) { - $this->_colors = array_merge($this->_colors, $this->_options['colors']); - } - } - - - /** - * Signals that no more tokens are available - * - * @abstract - * @access public - * - */ - function finalize() - { - - // get parent's output - parent::finalize(); - $output = parent::getOutput(); - - $bb_output = ''; - - $color_start = $this->_tag_brackets['start'] . $this->_bb_tags['color'] . '=%s' . $this->_tag_brackets['end']; - $color_end = $this->_tag_brackets['start'] . '/' . $this->_bb_tags['color'] . $this->_tag_brackets['end']; - - // loop through each class=>content pair - foreach ($output AS $token) { - - if ($this->_enumerated) { - $class = $token[0]; - $content = $token[1]; - } else { - $key = key($token); - $class = $key; - $content = $token[$key]; - } - - $iswhitespace = ctype_space($content); - if (!$iswhitespace && !empty($this->_colors[$class])) { - $bb_output .= sprintf($color_start, $this->_colors[$class]); - $bb_output .= $content; - $bb_output .= $color_end; - } else { - $bb_output .= $content; - } - } - - if ($this->_numbers) { - - $item_tag = $this->_tag_brackets['start'] . - $this->_bb_tags['list_item'] . - $this->_tag_brackets['end']; - $this->_output = $item_tag . str_replace("\n", "\n". $item_tag .' ', $bb_output); - $this->_output = $this->_tag_brackets['start'] . - $this->_bb_tags['list'] . - $this->_tag_brackets['end'] . - $this->_output . - $this->_tag_brackets['start'] . - '/'. - $this->_bb_tags['list'] . - $this->_tag_brackets['end'] - ; - } else { - $this->_output = $this->_tag_brackets['start'] . - $this->_bb_tags['code'] . - $this->_tag_brackets['end'] . - $bb_output . - $this->_tag_brackets['start'] . - '/' . - $this->_bb_tags['code'] . - $this->_tag_brackets['end']; - } - } - -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ - + + * @copyright 2005 Stoyan Stefanov + * @license http://www.php.net/license/3_0.txt PHP License + * @version CVS: $Id: BB.php,v 1.1 2007/06/03 02:37:08 ssttoo Exp $ + * @link http://pear.php.net/package/Text_Highlighter + */ + +/** + * @ignore + */ + +require_once dirname(__FILE__).'/../Renderer.php'; + +/** + * BB code renderer, based on Andrey Demenev's HTML renderer. + * + * Elements of $options argument of constructor (each being optional): + * + * - 'numbers' - Line numbering TRUE or FALSE + * - 'tabsize' - Tab size, default is 4 + * - 'bb_tags' - An array containing three BB tags, see below + * - 'tag_brackets' - An array that conains opening and closing tags, [ and ] + * - 'colors' - An array with all the colors to be used for highlighting + * + * The default BB tags are: + * - 'color' => 'color' + * - 'list' => 'list' + * - 'list_item' => '*' + * + * The default colors for the highlighter are: + * - 'default' => 'Black', + * - 'code' => 'Gray', + * - 'brackets' => 'Olive', + * - 'comment' => 'Orange', + * - 'mlcomment' => 'Orange', + * - 'quotes' => 'Darkred', + * - 'string' => 'Red', + * - 'identifier' => 'Blue', + * - 'builtin' => 'Teal', + * - 'reserved' => 'Green', + * - 'inlinedoc' => 'Blue', + * - 'var' => 'Darkblue', + * - 'url' => 'Blue', + * - 'special' => 'Navy', + * - 'number' => 'Maroon', + * - 'inlinetags' => 'Blue', + * + * + * @author Stoyan Stefanov + * @category Text + * @package Text_Highlighter + * @copyright 20045 Stoyan Stefanov + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.5.0 + * @link http://pear.php.net/package/Text_Highlighter + */ + +class Text_Highlighter_Renderer_BB extends Text_Highlighter_Renderer_Array +{ + + /**#@+ + * @access private + */ + + /** + * Line numbering - will use the specified BB tag for listings + * + * @var boolean + */ + var $_numbers = false; + + /** + * BB tags to be used + * + * @var array + */ + var $_bb_tags = array ( + 'color' => 'color', + 'list' => 'list', + 'list_item' => '*', + 'code' => 'code', + ); + + /** + * BB brackets - [ and ] + * + * @var array + */ + var $_tag_brackets = array ('start' => '[', 'end' => ']'); + + /** + * Colors map + * + * @var boolean + */ + var $_colors = array( + 'default' => 'Black', + 'code' => 'Gray', + 'brackets' => 'Olive', + 'comment' => 'Orange', + 'mlcomment' => 'Orange', + 'quotes' => 'Darkred', + 'string' => 'Red', + 'identifier' => 'Blue', + 'builtin' => 'Teal', + 'reserved' => 'Green', + 'inlinedoc' => 'Blue', + 'var' => 'Darkblue', + 'url' => 'Blue', + 'special' => 'Navy', + 'number' => 'Maroon', + 'inlinetags' => 'Blue', + ); + + /**#@-*/ + + /** + * Resets renderer state + * + * @access protected + * + * + * Descendents of Text_Highlighter call this method from the constructor, + * passing $options they get as parameter. + */ + function reset() + { + parent::reset(); + if (isset($this->_options['numbers'])) { + $this->_numbers = $this->_options['numbers']; + } + if (isset($this->_options['bb_tags'])) { + $this->_bb_tags = array_merge($this->_bb_tags, $this->_options['bb_tags']); + } + if (isset($this->_options['tag_brackets'])) { + $this->_tag_brackets = array_merge($this->_tag_brackets, $this->_options['tag_brackets']); + } + if (isset($this->_options['colors'])) { + $this->_colors = array_merge($this->_colors, $this->_options['colors']); + } + } + + + /** + * Signals that no more tokens are available + * + * @abstract + * @access public + * + */ + function finalize() + { + + // get parent's output + parent::finalize(); + $output = parent::getOutput(); + + $bb_output = ''; + + $color_start = $this->_tag_brackets['start'] . $this->_bb_tags['color'] . '=%s' . $this->_tag_brackets['end']; + $color_end = $this->_tag_brackets['start'] . '/' . $this->_bb_tags['color'] . $this->_tag_brackets['end']; + + // loop through each class=>content pair + foreach ($output AS $token) { + + if ($this->_enumerated) { + $class = $token[0]; + $content = $token[1]; + } else { + $key = key($token); + $class = $key; + $content = $token[$key]; + } + + $iswhitespace = ctype_space($content); + if (!$iswhitespace && !empty($this->_colors[$class])) { + $bb_output .= sprintf($color_start, $this->_colors[$class]); + $bb_output .= $content; + $bb_output .= $color_end; + } else { + $bb_output .= $content; + } + } + + if ($this->_numbers) { + + $item_tag = $this->_tag_brackets['start'] . + $this->_bb_tags['list_item'] . + $this->_tag_brackets['end']; + $this->_output = $item_tag . str_replace("\n", "\n". $item_tag .' ', $bb_output); + $this->_output = $this->_tag_brackets['start'] . + $this->_bb_tags['list'] . + $this->_tag_brackets['end'] . + $this->_output . + $this->_tag_brackets['start'] . + '/'. + $this->_bb_tags['list'] . + $this->_tag_brackets['end'] + ; + } else { + $this->_output = $this->_tag_brackets['start'] . + $this->_bb_tags['code'] . + $this->_tag_brackets['end'] . + $bb_output . + $this->_tag_brackets['start'] . + '/' . + $this->_bb_tags['code'] . + $this->_tag_brackets['end']; + } + } + +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ + ?> \ No newline at end of file diff --git a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Console.php b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Console.php index 30e4ed69..224cf71d 100644 --- a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Console.php +++ b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Console.php @@ -1,208 +1,208 @@ - - * @copyright 2004-2006 Andrey Demenev - * @license http://www.php.net/license/3_0.txt PHP License - * @version CVS: $Id: Console.php,v 1.1 2007/06/03 02:37:08 ssttoo Exp $ - * @link http://pear.php.net/package/Text_Highlighter - */ - -/** - * @ignore - */ - -require_once dirname(__FILE__).'/../Renderer.php'; - -define ('HL_CONSOLE_DEFCOLOR', "\033[0m"); - -/** - * Console renderer - * - * Suitable for displaying text on color-capable terminals, directly - * or trough less -r - * - * Elements of $options argument of constructor (each being optional): - * - * - 'numbers' - whether to add line numbers - * - 'tabsize' - Tab size - * - 'colors' - additional colors - * - * @author Andrey Demenev - * @category Text - * @package Text_Highlighter - * @copyright 2004-2006 Andrey Demenev - * @license http://www.php.net/license/3_0.txt PHP License - * @version Release: 0.7.0 - * @link http://pear.php.net/package/Text_Highlighter - */ - -class Text_Highlighter_Renderer_Console extends Text_Highlighter_Renderer -{ - - /**#@+ - * @access private - */ - - /** - * class of last outputted text chunk - * - * @var string - */ - var $_lastClass; - - /** - * Line numbering - * - * @var boolean - */ - var $_numbers = false; - - /** - * Tab size - * - * @var integer - */ - var $_tabsize = 4; - - /** - * Highlighted code - * - * @var string - */ - var $_output = ''; - - /**#@-*/ - - var $_colors = array(); - - var $_defColors = array( - 'default' => "\033[0m", - 'inlinetags' => "\033[31m", - 'brackets' => "\033[36m", - 'quotes' => "\033[34m", - 'inlinedoc' => "\033[34m", - 'var' => "\033[1m", - 'types' => "\033[32m", - 'number' => "\033[32m", - 'string' => "\033[31m", - 'reserved' => "\033[35m", - 'comment' => "\033[33m", - 'mlcomment' => "\033[33m", - ); - - function preprocess($str) - { - // normalize whitespace and tabs - $str = str_replace("\r\n","\n", $str); - $str = str_replace("\t",str_repeat(' ', $this->_tabsize), $str); - return rtrim($str); - } - - - /** - * Resets renderer state - * - * @access protected - * - * - * Descendents of Text_Highlighter call this method from the constructor, - * passing $options they get as parameter. - */ - function reset() - { - $this->_lastClass = ''; - if (isset($this->_options['numbers'])) { - $this->_numbers = (bool)$this->_options['numbers']; - } else { - $this->_numbers = false; - } - if (isset($this->_options['tabsize'])) { - $this->_tabsize = $this->_options['tabsize']; - } else { - $this->_tabsize = 4; - } - if (isset($this->_options['colors'])) { - $this->_colors = array_merge($this->_defColors, $this->_options['colors']); - } else { - $this->_colors = $this->_defColors; - } - $this->_output = ''; - } - - - - /** - * Accepts next token - * - * @access public - * - * @param string $class Token class - * @param string $content Token content - */ - function acceptToken($class, $content) - { - if (isset($this->_colors[$class])) { - $color = $this->_colors[$class]; - } else { - $color = $this->_colors['default']; - } - if ($this->_lastClass != $class) { - $this->_output .= $color; - } - $content = str_replace("\n", $this->_colors['default'] . "\n" . $color, $content); - $content .= $this->_colors['default']; - $this->_output .= $content; - } - - /** - * Signals that no more tokens are available - * - * @access public - * - */ - function finalize() - { - if ($this->_numbers) { - $nlines = substr_count($this->_output, "\n") + 1; - $len = strlen($nlines); - $i = 1; - $this->_output = preg_replace('~^~em', '" " . str_pad($i++, $len, " ", STR_PAD_LEFT) . ": "', $this->_output); - } - $this->_output .= HL_CONSOLE_DEFCOLOR . "\n"; - } - - /** - * Get generated output - * - * @return string Highlighted code - * @access public - * - */ - function getOutput() - { - return $this->_output; - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ - + + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version CVS: $Id: Console.php,v 1.1 2007/06/03 02:37:08 ssttoo Exp $ + * @link http://pear.php.net/package/Text_Highlighter + */ + +/** + * @ignore + */ + +require_once dirname(__FILE__).'/../Renderer.php'; + +define ('HL_CONSOLE_DEFCOLOR', "\033[0m"); + +/** + * Console renderer + * + * Suitable for displaying text on color-capable terminals, directly + * or trough less -r + * + * Elements of $options argument of constructor (each being optional): + * + * - 'numbers' - whether to add line numbers + * - 'tabsize' - Tab size + * - 'colors' - additional colors + * + * @author Andrey Demenev + * @category Text + * @package Text_Highlighter + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.7.0 + * @link http://pear.php.net/package/Text_Highlighter + */ + +class Text_Highlighter_Renderer_Console extends Text_Highlighter_Renderer +{ + + /**#@+ + * @access private + */ + + /** + * class of last outputted text chunk + * + * @var string + */ + var $_lastClass; + + /** + * Line numbering + * + * @var boolean + */ + var $_numbers = false; + + /** + * Tab size + * + * @var integer + */ + var $_tabsize = 4; + + /** + * Highlighted code + * + * @var string + */ + var $_output = ''; + + /**#@-*/ + + var $_colors = array(); + + var $_defColors = array( + 'default' => "\033[0m", + 'inlinetags' => "\033[31m", + 'brackets' => "\033[36m", + 'quotes' => "\033[34m", + 'inlinedoc' => "\033[34m", + 'var' => "\033[1m", + 'types' => "\033[32m", + 'number' => "\033[32m", + 'string' => "\033[31m", + 'reserved' => "\033[35m", + 'comment' => "\033[33m", + 'mlcomment' => "\033[33m", + ); + + function preprocess($str) + { + // normalize whitespace and tabs + $str = str_replace("\r\n","\n", $str); + $str = str_replace("\t",str_repeat(' ', $this->_tabsize), $str); + return rtrim($str); + } + + + /** + * Resets renderer state + * + * @access protected + * + * + * Descendents of Text_Highlighter call this method from the constructor, + * passing $options they get as parameter. + */ + function reset() + { + $this->_lastClass = ''; + if (isset($this->_options['numbers'])) { + $this->_numbers = (bool)$this->_options['numbers']; + } else { + $this->_numbers = false; + } + if (isset($this->_options['tabsize'])) { + $this->_tabsize = $this->_options['tabsize']; + } else { + $this->_tabsize = 4; + } + if (isset($this->_options['colors'])) { + $this->_colors = array_merge($this->_defColors, $this->_options['colors']); + } else { + $this->_colors = $this->_defColors; + } + $this->_output = ''; + } + + + + /** + * Accepts next token + * + * @access public + * + * @param string $class Token class + * @param string $content Token content + */ + function acceptToken($class, $content) + { + if (isset($this->_colors[$class])) { + $color = $this->_colors[$class]; + } else { + $color = $this->_colors['default']; + } + if ($this->_lastClass != $class) { + $this->_output .= $color; + } + $content = str_replace("\n", $this->_colors['default'] . "\n" . $color, $content); + $content .= $this->_colors['default']; + $this->_output .= $content; + } + + /** + * Signals that no more tokens are available + * + * @access public + * + */ + function finalize() + { + if ($this->_numbers) { + $nlines = substr_count($this->_output, "\n") + 1; + $len = strlen($nlines); + $i = 1; + $this->_output = preg_replace('~^~em', '" " . str_pad($i++, $len, " ", STR_PAD_LEFT) . ": "', $this->_output); + } + $this->_output .= HL_CONSOLE_DEFCOLOR . "\n"; + } + + /** + * Get generated output + * + * @return string Highlighted code + * @access public + * + */ + function getOutput() + { + return $this->_output; + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ + ?> \ No newline at end of file diff --git a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Html.php b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Html.php index 40cb3f59..a0bcfec2 100644 --- a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Html.php +++ b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/Html.php @@ -1,446 +1,446 @@ - - * @copyright 2004-2006 Andrey Demenev - * @license http://www.php.net/license/3_0.txt PHP License - * @version CVS: $Id: Html.php,v 1.1 2007/06/03 02:37:09 ssttoo Exp $ - * @link http://pear.php.net/package/Text_Highlighter - */ - -/** - * @ignore - */ - -require_once dirname(__FILE__).'/../Renderer.php'; -require_once dirname(__FILE__).'/../Renderer/Array.php'; - -// BC trick : only define constants if Text/Highlighter.php -// is not yet included -if (!defined('HL_NUMBERS_LI')) { - /**#@+ - * Constant for use with $options['numbers'] - */ - /** - * use numbered list, deprecated, use HL_NUMBERS_OL instaed - * @deprecated - */ - define ('HL_NUMBERS_LI' , 1); - /** - * Use 2-column table with line numbers in left column and code in right column. - */ - define ('HL_NUMBERS_TABLE' , 2); - /**#@-*/ -} - - -/**#@+ - * Constant for use with $options['numbers'] - */ -/** - * Use numbered list - */ -define ('HL_NUMBERS_OL', 1); -/** - * Use non-numbered list - */ -define ('HL_NUMBERS_UL', 3); -/**#@-*/ - - -/** - * HTML renderer - * - * Elements of $options argument of constructor (each being optional): - * - * - 'numbers' - Line numbering style 0 or {@link HL_NUMBERS_TABLE} - * or {@link HL_NUMBERS_UL} or {@link HL_NUMBERS_OL} - * - 'numbers_start' - starting number for numbered lines - * - 'tabsize' - Tab size - * - 'style_map' - Mapping of keywords to formatting rules using inline styles - * - 'class_map' - Mapping of keywords to formatting rules using class names - * - 'doclinks' - array that has keys "url", "target" and "elements", used for - * generating links to online documentation - * - 'use_language' - class names will be prefixed with language, like "php-reserved" or "css-code" - * - * Example of setting documentation links: - * $options['doclinks'] = array( - * 'url' => 'http://php.net/%s', - * 'target' => '_blank', - * 'elements' => array('reserved', 'identifier') - * ); - * - * Example of setting class names map: - * $options['class_map'] = array( - * 'main' => 'my-main', - * 'table' => 'my-table', - * 'gutter' => 'my-gutter', - * 'brackets' => 'my-brackets', - * 'builtin' => 'my-builtin', - * 'code' => 'my-code', - * 'comment' => 'my-comment', - * 'default' => 'my-default', - * 'identifier' => 'my-identifier', - * 'inlinedoc' => 'my-inlinedoc', - * 'inlinetags' => 'my-inlinetags', - * 'mlcomment' => 'my-mlcomment', - * 'number' => 'my-number', - * 'quotes' => 'my-quotes', - * 'reserved' => 'my-reserved', - * 'special' => 'my-special', - * 'string' => 'my-string', - * 'url' => 'my-url', - * 'var' => 'my-var', - * ); - * - * Example of setting styles mapping: - * $options['style_map'] = array( - * 'main' => 'color: black', - * 'table' => 'border: 1px solid black', - * 'gutter' => 'background-color: yellow', - * 'brackets' => 'color: blue', - * 'builtin' => 'color: red', - * 'code' => 'color: green', - * 'comment' => 'color: orange', - * // .... - * ); - * - * - * @author Andrey Demenev - * @category Text - * @package Text_Highlighter - * @copyright 2004-2006 Andrey Demenev - * @license http://www.php.net/license/3_0.txt PHP License - * @version Release: 0.7.0 - * @link http://pear.php.net/package/Text_Highlighter - */ - -class Text_Highlighter_Renderer_Html extends Text_Highlighter_Renderer_Array -{ - - /**#@+ - * @access private - */ - - /** - * Line numbering style - * - * @var integer - */ - var $_numbers = 0; - - /** - * For numberered lines - where to start - * - * @var integer - */ - var $_numbers_start = 0; - - /** - * Tab size - * - * @var integer - */ - var $_tabsize = 4; - - /** - * Highlighted code - * - * @var string - */ - var $_output = ''; - - /** - * Mapping of keywords to formatting rules using inline styles - * - * @var array - */ - var $_style_map = array(); - - /** - * Mapping of keywords to formatting rules using class names - * - * @var array - */ - var $_class_map = array( - 'main' => 'hl-main', - 'table' => 'hl-table', - 'gutter' => 'hl-gutter', - 'brackets' => 'hl-brackets', - 'builtin' => 'hl-builtin', - 'code' => 'hl-code', - 'comment' => 'hl-comment', - 'default' => 'hl-default', - 'identifier' => 'hl-identifier', - 'inlinedoc' => 'hl-inlinedoc', - 'inlinetags' => 'hl-inlinetags', - 'mlcomment' => 'hl-mlcomment', - 'number' => 'hl-number', - 'quotes' => 'hl-quotes', - 'reserved' => 'hl-reserved', - 'special' => 'hl-special', - 'string' => 'hl-string', - 'url' => 'hl-url', - 'var' => 'hl-var', - ); - - /** - * Setup for links to online documentation - * - * This is an array with keys: - * - url, ex. http://php.net/%s - * - target, ex. _blank, default - no target - * - elements, default is array('reserved', 'identifier') - * - * @var array - */ - var $_doclinks = array(); - - /**#@-*/ - - /** - * Resets renderer state - * - * @access protected - * - * - * Descendents of Text_Highlighter call this method from the constructor, - * passing $options they get as parameter. - */ - function reset() - { - $this->_output = ''; - if (isset($this->_options['numbers'])) { - $this->_numbers = (int)$this->_options['numbers']; - if ($this->_numbers != HL_NUMBERS_LI - && $this->_numbers != HL_NUMBERS_UL - && $this->_numbers != HL_NUMBERS_OL - && $this->_numbers != HL_NUMBERS_TABLE - ) { - $this->_numbers = 0; - } - } - if (isset($this->_options['tabsize'])) { - $this->_tabsize = $this->_options['tabsize']; - } - if (isset($this->_options['numbers_start'])) { - $this->_numbers_start = intval($this->_options['numbers_start']); - } - if (isset($this->_options['doclinks']) && - is_array($this->_options['doclinks']) && - !empty($this->_options['doclinks']['url']) - ) { - - $this->_doclinks = $this->_options['doclinks']; // keys: url, target, elements array - - if (empty($this->_options['doclinks']['elements'])) { - $this->_doclinks['elements'] = array('reserved', 'identifier'); - } - } - if (isset($this->_options['style_map'])) { - $this->_style_map = $this->_options['style_map']; - } - if (isset($this->_options['class_map'])) { - $this->_class_map = array_merge($this->_class_map, $this->_options['class_map']); - } - $this->_htmlspecialchars = true; - - } - - - /** - * Given a CSS class name, returns the class name - * with language name prepended, if necessary - * - * @access private - * - * @param string $class Token class - */ - function _getFullClassName($class) - { - if (!empty($this->_options['use_language'])) { - $the_class = $this->_language . '-' . $class; - } else { - $the_class = $class; - } - return $the_class; - } - - /** - * Signals that no more tokens are available - * - * @access public - */ - function finalize() - { - - // get parent's output - parent::finalize(); - $output = parent::getOutput(); - if(empty($output)) - return; - - $html_output = ''; - // loop through each class=>content pair - foreach ($output AS $token) { - - if ($this->_enumerated) { - $the_class = $token[0]; - $content = $token[1]; - } else { - $key = key($token); - $the_class = $key; - $content = $token[$key]; - } - - $span = $this->_getStyling($the_class); - $decorated_output = $this->_decorate($content, $key); - //print "
 token = ".var_export($token, true)." -- span = " . htmlentities($span). "-- deco = ".$decorated_output."
\n"; - $html_output .= sprintf($span, $decorated_output); - } - - // format lists - if (!empty($this->_numbers) && - ( - $this->_numbers == HL_NUMBERS_LI || - $this->_numbers == HL_NUMBERS_UL || - $this->_numbers == HL_NUMBERS_OL - ) - ) { - //$html_output = "
".$html_output."
"; - // additional whitespace for browsers that do not display - // empty list items correctly - $this->_output = '
  •  ' . str_replace("\n", "
  • \n
  •  ", $html_output) . '
  • '; - - - $start = ''; - if ($this->_numbers == HL_NUMBERS_OL && intval($this->_numbers_start) > 0) { - $start = ' start="' . $this->_numbers_start . '"'; - } - - $list_tag = 'ol'; - if ($this->_numbers == HL_NUMBERS_UL) { - $list_tag = 'ul'; - } - - - $this->_output = '<' . $list_tag . $start - . ' ' . $this->_getStyling('main', false) . '>' - . $this->_output . ''; - - // render a table - } else if ($this->_numbers == HL_NUMBERS_TABLE) { - - - $start_number = 0; - if (intval($this->_numbers_start)) { - $start_number = $this->_numbers_start - 1; - } - - $numbers = ''; - - $nlines = substr_count($html_output,"\n")+1; - for ($i=1; $i <= $nlines; $i++) { - $numbers .= ($start_number + $i) . "\n"; - } - $this->_output = '_getStyling('table', false) . ' width="100%">' . - '
    _getStyling('gutter', false) .' align="right" valign="top">' . - '
    ' . $numbers . '
    _getStyling('main', false) . - ' valign="top">
    ' .
    -                             $html_output . '
    '; - } - if (!$this->_numbers) { - $this->_output = '
    ' . $html_output . '
    '; - } - $this->_output = '
    _getStyling('main', false) . '>' . $this->_output . '
    '; - } - - - /** - * Provides additional formatting to a keyword - * - * @param string $content Keyword - * @return string Keyword with additional formatting - * @access public - * - */ - function _decorate($content, $key) - { - // links to online documentation - if (!empty($this->_doclinks) && - !empty($this->_doclinks['url']) && - in_array($key, $this->_doclinks['elements']) - ) { - - $link = '_doclinks['target'])) { - $link.= ' target="' . $this->_doclinks['target'] . '"'; - } - $link .= '>'; - $link.= $content; - $link.= ''; - - $content = $link; - - } - - return $content; - } - - /** - * Returns class and/or style attribute, - * optionally enclosed in a span tag - * - * @param string $class Class name - * @paran boolean $span_tag Whether or not to return styling attributes in a >span< tag - * @return string span tag or just a class and/or style attributes - * @access private - */ - function _getStyling($class, $span_tag = true) - { - $attrib = ''; - if (!empty($this->_style_map) && - !empty($this->_style_map[$class]) - ) { - $attrib = 'style="'. $this->_style_map[$class] .'"'; - } - if (!empty($this->_class_map) && - !empty($this->_class_map[$class]) - ) { - if ($attrib) { - $attrib .= ' '; - } - $attrib .= 'class="'. $this->_getFullClassName($this->_class_map[$class]) .'"'; - } - - if ($span_tag) { - $span = '%s'; - return $span; - } else { - return $attrib; - } - - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ - + + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version CVS: $Id: Html.php,v 1.1 2007/06/03 02:37:09 ssttoo Exp $ + * @link http://pear.php.net/package/Text_Highlighter + */ + +/** + * @ignore + */ + +require_once dirname(__FILE__).'/../Renderer.php'; +require_once dirname(__FILE__).'/../Renderer/Array.php'; + +// BC trick : only define constants if Text/Highlighter.php +// is not yet included +if (!defined('HL_NUMBERS_LI')) { + /**#@+ + * Constant for use with $options['numbers'] + */ + /** + * use numbered list, deprecated, use HL_NUMBERS_OL instaed + * @deprecated + */ + define ('HL_NUMBERS_LI' , 1); + /** + * Use 2-column table with line numbers in left column and code in right column. + */ + define ('HL_NUMBERS_TABLE' , 2); + /**#@-*/ +} + + +/**#@+ + * Constant for use with $options['numbers'] + */ +/** + * Use numbered list + */ +define ('HL_NUMBERS_OL', 1); +/** + * Use non-numbered list + */ +define ('HL_NUMBERS_UL', 3); +/**#@-*/ + + +/** + * HTML renderer + * + * Elements of $options argument of constructor (each being optional): + * + * - 'numbers' - Line numbering style 0 or {@link HL_NUMBERS_TABLE} + * or {@link HL_NUMBERS_UL} or {@link HL_NUMBERS_OL} + * - 'numbers_start' - starting number for numbered lines + * - 'tabsize' - Tab size + * - 'style_map' - Mapping of keywords to formatting rules using inline styles + * - 'class_map' - Mapping of keywords to formatting rules using class names + * - 'doclinks' - array that has keys "url", "target" and "elements", used for + * generating links to online documentation + * - 'use_language' - class names will be prefixed with language, like "php-reserved" or "css-code" + * + * Example of setting documentation links: + * $options['doclinks'] = array( + * 'url' => 'http://php.net/%s', + * 'target' => '_blank', + * 'elements' => array('reserved', 'identifier') + * ); + * + * Example of setting class names map: + * $options['class_map'] = array( + * 'main' => 'my-main', + * 'table' => 'my-table', + * 'gutter' => 'my-gutter', + * 'brackets' => 'my-brackets', + * 'builtin' => 'my-builtin', + * 'code' => 'my-code', + * 'comment' => 'my-comment', + * 'default' => 'my-default', + * 'identifier' => 'my-identifier', + * 'inlinedoc' => 'my-inlinedoc', + * 'inlinetags' => 'my-inlinetags', + * 'mlcomment' => 'my-mlcomment', + * 'number' => 'my-number', + * 'quotes' => 'my-quotes', + * 'reserved' => 'my-reserved', + * 'special' => 'my-special', + * 'string' => 'my-string', + * 'url' => 'my-url', + * 'var' => 'my-var', + * ); + * + * Example of setting styles mapping: + * $options['style_map'] = array( + * 'main' => 'color: black', + * 'table' => 'border: 1px solid black', + * 'gutter' => 'background-color: yellow', + * 'brackets' => 'color: blue', + * 'builtin' => 'color: red', + * 'code' => 'color: green', + * 'comment' => 'color: orange', + * // .... + * ); + * + * + * @author Andrey Demenev + * @category Text + * @package Text_Highlighter + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.7.0 + * @link http://pear.php.net/package/Text_Highlighter + */ + +class Text_Highlighter_Renderer_Html extends Text_Highlighter_Renderer_Array +{ + + /**#@+ + * @access private + */ + + /** + * Line numbering style + * + * @var integer + */ + var $_numbers = 0; + + /** + * For numberered lines - where to start + * + * @var integer + */ + var $_numbers_start = 0; + + /** + * Tab size + * + * @var integer + */ + var $_tabsize = 4; + + /** + * Highlighted code + * + * @var string + */ + var $_output = ''; + + /** + * Mapping of keywords to formatting rules using inline styles + * + * @var array + */ + var $_style_map = array(); + + /** + * Mapping of keywords to formatting rules using class names + * + * @var array + */ + var $_class_map = array( + 'main' => 'hl-main', + 'table' => 'hl-table', + 'gutter' => 'hl-gutter', + 'brackets' => 'hl-brackets', + 'builtin' => 'hl-builtin', + 'code' => 'hl-code', + 'comment' => 'hl-comment', + 'default' => 'hl-default', + 'identifier' => 'hl-identifier', + 'inlinedoc' => 'hl-inlinedoc', + 'inlinetags' => 'hl-inlinetags', + 'mlcomment' => 'hl-mlcomment', + 'number' => 'hl-number', + 'quotes' => 'hl-quotes', + 'reserved' => 'hl-reserved', + 'special' => 'hl-special', + 'string' => 'hl-string', + 'url' => 'hl-url', + 'var' => 'hl-var', + ); + + /** + * Setup for links to online documentation + * + * This is an array with keys: + * - url, ex. http://php.net/%s + * - target, ex. _blank, default - no target + * - elements, default is array('reserved', 'identifier') + * + * @var array + */ + var $_doclinks = array(); + + /**#@-*/ + + /** + * Resets renderer state + * + * @access protected + * + * + * Descendents of Text_Highlighter call this method from the constructor, + * passing $options they get as parameter. + */ + function reset() + { + $this->_output = ''; + if (isset($this->_options['numbers'])) { + $this->_numbers = (int)$this->_options['numbers']; + if ($this->_numbers != HL_NUMBERS_LI + && $this->_numbers != HL_NUMBERS_UL + && $this->_numbers != HL_NUMBERS_OL + && $this->_numbers != HL_NUMBERS_TABLE + ) { + $this->_numbers = 0; + } + } + if (isset($this->_options['tabsize'])) { + $this->_tabsize = $this->_options['tabsize']; + } + if (isset($this->_options['numbers_start'])) { + $this->_numbers_start = intval($this->_options['numbers_start']); + } + if (isset($this->_options['doclinks']) && + is_array($this->_options['doclinks']) && + !empty($this->_options['doclinks']['url']) + ) { + + $this->_doclinks = $this->_options['doclinks']; // keys: url, target, elements array + + if (empty($this->_options['doclinks']['elements'])) { + $this->_doclinks['elements'] = array('reserved', 'identifier'); + } + } + if (isset($this->_options['style_map'])) { + $this->_style_map = $this->_options['style_map']; + } + if (isset($this->_options['class_map'])) { + $this->_class_map = array_merge($this->_class_map, $this->_options['class_map']); + } + $this->_htmlspecialchars = true; + + } + + + /** + * Given a CSS class name, returns the class name + * with language name prepended, if necessary + * + * @access private + * + * @param string $class Token class + */ + function _getFullClassName($class) + { + if (!empty($this->_options['use_language'])) { + $the_class = $this->_language . '-' . $class; + } else { + $the_class = $class; + } + return $the_class; + } + + /** + * Signals that no more tokens are available + * + * @access public + */ + function finalize() + { + + // get parent's output + parent::finalize(); + $output = parent::getOutput(); + if(empty($output)) + return; + + $html_output = ''; + // loop through each class=>content pair + foreach ($output AS $token) { + + if ($this->_enumerated) { + $the_class = $token[0]; + $content = $token[1]; + } else { + $key = key($token); + $the_class = $key; + $content = $token[$key]; + } + + $span = $this->_getStyling($the_class); + $decorated_output = $this->_decorate($content, $key); + //print "
     token = ".var_export($token, true)." -- span = " . htmlentities($span). "-- deco = ".$decorated_output."
    \n"; + $html_output .= sprintf($span, $decorated_output); + } + + // format lists + if (!empty($this->_numbers) && + ( + $this->_numbers == HL_NUMBERS_LI || + $this->_numbers == HL_NUMBERS_UL || + $this->_numbers == HL_NUMBERS_OL + ) + ) { + //$html_output = "
    ".$html_output."
    "; + // additional whitespace for browsers that do not display + // empty list items correctly + $this->_output = '
  •  ' . str_replace("\n", "
  • \n
  •  ", $html_output) . '
  • '; + + + $start = ''; + if ($this->_numbers == HL_NUMBERS_OL && intval($this->_numbers_start) > 0) { + $start = ' start="' . $this->_numbers_start . '"'; + } + + $list_tag = 'ol'; + if ($this->_numbers == HL_NUMBERS_UL) { + $list_tag = 'ul'; + } + + + $this->_output = '<' . $list_tag . $start + . ' ' . $this->_getStyling('main', false) . '>' + . $this->_output . ''; + + // render a table + } else if ($this->_numbers == HL_NUMBERS_TABLE) { + + + $start_number = 0; + if (intval($this->_numbers_start)) { + $start_number = $this->_numbers_start - 1; + } + + $numbers = ''; + + $nlines = substr_count($html_output,"\n")+1; + for ($i=1; $i <= $nlines; $i++) { + $numbers .= ($start_number + $i) . "\n"; + } + $this->_output = '_getStyling('table', false) . ' width="100%">' . + '
    _getStyling('gutter', false) .' align="right" valign="top">' . + '
    ' . $numbers . '
    _getStyling('main', false) . + ' valign="top">
    ' .
    +                             $html_output . '
    '; + } + if (!$this->_numbers) { + $this->_output = '
    ' . $html_output . '
    '; + } + $this->_output = '
    _getStyling('main', false) . '>' . $this->_output . '
    '; + } + + + /** + * Provides additional formatting to a keyword + * + * @param string $content Keyword + * @return string Keyword with additional formatting + * @access public + * + */ + function _decorate($content, $key) + { + // links to online documentation + if (!empty($this->_doclinks) && + !empty($this->_doclinks['url']) && + in_array($key, $this->_doclinks['elements']) + ) { + + $link = '_doclinks['target'])) { + $link.= ' target="' . $this->_doclinks['target'] . '"'; + } + $link .= '>'; + $link.= $content; + $link.= ''; + + $content = $link; + + } + + return $content; + } + + /** + * Returns class and/or style attribute, + * optionally enclosed in a span tag + * + * @param string $class Class name + * @paran boolean $span_tag Whether or not to return styling attributes in a >span< tag + * @return string span tag or just a class and/or style attributes + * @access private + */ + function _getStyling($class, $span_tag = true) + { + $attrib = ''; + if (!empty($this->_style_map) && + !empty($this->_style_map[$class]) + ) { + $attrib = 'style="'. $this->_style_map[$class] .'"'; + } + if (!empty($this->_class_map) && + !empty($this->_class_map[$class]) + ) { + if ($attrib) { + $attrib .= ' '; + } + $attrib .= 'class="'. $this->_getFullClassName($this->_class_map[$class]) .'"'; + } + + if ($span_tag) { + $span = '%s'; + return $span; + } else { + return $attrib; + } + + } +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ + ?> \ No newline at end of file diff --git a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/HtmlTags.php b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/HtmlTags.php index a75e659e..b085d535 100644 --- a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/HtmlTags.php +++ b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/HtmlTags.php @@ -1,187 +1,187 @@ - - * @copyright 2005 Stoyan Stefanov - * @license http://www.php.net/license/3_0.txt PHP License - * @version CVS: $Id: HtmlTags.php,v 1.1 2007/06/03 02:37:09 ssttoo Exp $ - * @link http://pear.php.net/package/Text_Highlighter - */ - -/** - * @ignore - */ - -require_once dirname(__FILE__).'/../Renderer.php'; -require_once dirname(__FILE__).'/../Renderer/Array.php'; - -/** - * HTML basic tags renderer, based on Andrey Demenev's HTML renderer. - * - * Elements of $options argument of constructor (each being optional): - * - * - 'numbers' - Line numbering TRUE or FALSE. Default is FALSE. - * - 'tabsize' - Tab size, default is 4. - * - 'tags' - Array, containing the tags to be used for highlighting - * - * Here's the listing of the default tags: - * - 'default' => '', - * - 'code' => '', - * - 'brackets' => 'b', - * - 'comment' => 'i', - * - 'mlcomment' => 'i', - * - 'quotes' => '', - * - 'string' => 'i', - * - 'identifier' => 'b', - * - 'builtin' => 'b', - * - 'reserved' => 'u', - * - 'inlinedoc' => 'i', - * - 'var' => 'b', - * - 'url' => 'i', - * - 'special' => '', - * - 'number' => '', - * - 'inlinetags' => '' - * - * @author Stoyan Stefanov - * @category Text - * @package Text_Highlighter - * @copyright 2005 Stoyan Stefanov - * @license http://www.php.net/license/3_0.txt PHP License - * @version Release: 0.5.0 - * @link http://pear.php.net/package/Text_Highlighter - */ - -class Text_Highlighter_Renderer_HtmlTags extends Text_Highlighter_Renderer_Array -{ - - /**#@+ - * @access private - */ - - /** - * Line numbering - will use 'ol' tag - * - * @var boolean - */ - var $_numbers = false; - - /** - * HTML tags map - * - * @var array - */ - var $_hilite_tags = array( - 'default' => '', - 'code' => '', - 'brackets' => 'b', - 'comment' => 'i', - 'mlcomment' => 'i', - 'quotes' => '', - 'string' => 'i', - 'identifier' => 'b', - 'builtin' => 'b', - 'reserved' => 'u', - 'inlinedoc' => 'i', - 'var' => 'b', - 'url' => 'i', - 'special' => '', - 'number' => '', - 'inlinetags' => '', - ); - - /**#@-*/ - - /** - * Resets renderer state - * - * @access protected - * - * - * Descendents of Text_Highlighter call this method from the constructor, - * passing $options they get as parameter. - */ - function reset() - { - parent::reset(); - if (isset($this->_options['numbers'])) { - $this->_numbers = $this->_options['numbers']; - } - if (isset($this->_options['tags'])) { - $this->_hilite_tags = array_merge($this->_tags, $this->_options['tags']); - } - } - - - /** - * Signals that no more tokens are available - * - * @abstract - * @access public - * - */ - function finalize() - { - - // get parent's output - parent::finalize(); - $output = parent::getOutput(); - - $html_output = ''; - - // loop through each class=>content pair - foreach ($output AS $token) { - - if ($this->_enumerated) { - $class = $token[0]; - $content = $token[1]; - } else { - $key = key($token); - $class = $key; - $content = $token[$key]; - } - - $iswhitespace = ctype_space($content); - if (!$iswhitespace && !empty($this->_hilite_tags[$class])) { - $html_output .= '<'. $this->_hilite_tags[$class] . '>' . $content . '_hilite_tags[$class] . '>'; - } else { - $html_output .= $content; - } - } - - - if ($this->_numbers) { - /* additional whitespace for browsers that do not display - empty list items correctly */ - $html_output = '
  •  ' . str_replace("\n", "
  • \n
  •  ", $html_output) . '
  • '; - $this->_output = '
      ' . str_replace(' ', ' ', $html_output) . '
    '; - } else { - $this->_output = '
    ' . $html_output . '
    '; - } - } - - -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ - + + * @copyright 2005 Stoyan Stefanov + * @license http://www.php.net/license/3_0.txt PHP License + * @version CVS: $Id: HtmlTags.php,v 1.1 2007/06/03 02:37:09 ssttoo Exp $ + * @link http://pear.php.net/package/Text_Highlighter + */ + +/** + * @ignore + */ + +require_once dirname(__FILE__).'/../Renderer.php'; +require_once dirname(__FILE__).'/../Renderer/Array.php'; + +/** + * HTML basic tags renderer, based on Andrey Demenev's HTML renderer. + * + * Elements of $options argument of constructor (each being optional): + * + * - 'numbers' - Line numbering TRUE or FALSE. Default is FALSE. + * - 'tabsize' - Tab size, default is 4. + * - 'tags' - Array, containing the tags to be used for highlighting + * + * Here's the listing of the default tags: + * - 'default' => '', + * - 'code' => '', + * - 'brackets' => 'b', + * - 'comment' => 'i', + * - 'mlcomment' => 'i', + * - 'quotes' => '', + * - 'string' => 'i', + * - 'identifier' => 'b', + * - 'builtin' => 'b', + * - 'reserved' => 'u', + * - 'inlinedoc' => 'i', + * - 'var' => 'b', + * - 'url' => 'i', + * - 'special' => '', + * - 'number' => '', + * - 'inlinetags' => '' + * + * @author Stoyan Stefanov + * @category Text + * @package Text_Highlighter + * @copyright 2005 Stoyan Stefanov + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.5.0 + * @link http://pear.php.net/package/Text_Highlighter + */ + +class Text_Highlighter_Renderer_HtmlTags extends Text_Highlighter_Renderer_Array +{ + + /**#@+ + * @access private + */ + + /** + * Line numbering - will use 'ol' tag + * + * @var boolean + */ + var $_numbers = false; + + /** + * HTML tags map + * + * @var array + */ + var $_hilite_tags = array( + 'default' => '', + 'code' => '', + 'brackets' => 'b', + 'comment' => 'i', + 'mlcomment' => 'i', + 'quotes' => '', + 'string' => 'i', + 'identifier' => 'b', + 'builtin' => 'b', + 'reserved' => 'u', + 'inlinedoc' => 'i', + 'var' => 'b', + 'url' => 'i', + 'special' => '', + 'number' => '', + 'inlinetags' => '', + ); + + /**#@-*/ + + /** + * Resets renderer state + * + * @access protected + * + * + * Descendents of Text_Highlighter call this method from the constructor, + * passing $options they get as parameter. + */ + function reset() + { + parent::reset(); + if (isset($this->_options['numbers'])) { + $this->_numbers = $this->_options['numbers']; + } + if (isset($this->_options['tags'])) { + $this->_hilite_tags = array_merge($this->_tags, $this->_options['tags']); + } + } + + + /** + * Signals that no more tokens are available + * + * @abstract + * @access public + * + */ + function finalize() + { + + // get parent's output + parent::finalize(); + $output = parent::getOutput(); + + $html_output = ''; + + // loop through each class=>content pair + foreach ($output AS $token) { + + if ($this->_enumerated) { + $class = $token[0]; + $content = $token[1]; + } else { + $key = key($token); + $class = $key; + $content = $token[$key]; + } + + $iswhitespace = ctype_space($content); + if (!$iswhitespace && !empty($this->_hilite_tags[$class])) { + $html_output .= '<'. $this->_hilite_tags[$class] . '>' . $content . '_hilite_tags[$class] . '>'; + } else { + $html_output .= $content; + } + } + + + if ($this->_numbers) { + /* additional whitespace for browsers that do not display + empty list items correctly */ + $html_output = '
  •  ' . str_replace("\n", "
  • \n
  •  ", $html_output) . '
  • '; + $this->_output = '
      ' . str_replace(' ', ' ', $html_output) . '
    '; + } else { + $this->_output = '
    ' . $html_output . '
    '; + } + } + + +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ + ?> \ No newline at end of file diff --git a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/JSON.php b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/JSON.php index 7f1158fb..6a6ff71e 100644 --- a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/JSON.php +++ b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/JSON.php @@ -1,86 +1,86 @@ - - * @copyright 2006 Stoyan Stefanov - * @license http://www.php.net/license/3_0.txt PHP License - * @version CVS: $Id: JSON.php,v 1.1 2007/06/03 02:37:09 ssttoo Exp $ - * @link http://pear.php.net/package/Text_Highlighter - */ - -/** - * @ignore - */ - -require_once dirname(__FILE__).'/../Renderer.php'; -require_once dirname(__FILE__).'/../Renderer/Array.php'; - -/** - * JSON renderer, based on Andrey Demenev's HTML renderer. - * - * @author Stoyan Stefanov - * @category Text - * @package Text_Highlighter - * @copyright 2006 Stoyan Stefanov - * @license http://www.php.net/license/3_0.txt PHP License - * @version Release: 0.5.0 - * @link http://pear.php.net/package/Text_Highlighter - */ - -class Text_Highlighter_Renderer_JSON extends Text_Highlighter_Renderer_Array -{ - - /** - * Signals that no more tokens are available - * - * @abstract - * @access public - */ - function finalize() - { - - parent::finalize(); - $output = parent::getOutput(); - - $json_array = array(); - - foreach ($output AS $token) { - - if ($this->_enumerated) { - $json_array[] = '["' . $token[0] . '","' . $token[1] . '"]'; - } else { - $key = key($token); - $json_array[] = '{"class": "' . $key . '","content":"' . $token[$key] . '"}'; - } - - } - - $this->_output = '['. implode(',', $json_array) .']'; - $this->_output = str_replace("\n", '\n', $this->_output); - - } - - -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ - + + * @copyright 2006 Stoyan Stefanov + * @license http://www.php.net/license/3_0.txt PHP License + * @version CVS: $Id: JSON.php,v 1.1 2007/06/03 02:37:09 ssttoo Exp $ + * @link http://pear.php.net/package/Text_Highlighter + */ + +/** + * @ignore + */ + +require_once dirname(__FILE__).'/../Renderer.php'; +require_once dirname(__FILE__).'/../Renderer/Array.php'; + +/** + * JSON renderer, based on Andrey Demenev's HTML renderer. + * + * @author Stoyan Stefanov + * @category Text + * @package Text_Highlighter + * @copyright 2006 Stoyan Stefanov + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.5.0 + * @link http://pear.php.net/package/Text_Highlighter + */ + +class Text_Highlighter_Renderer_JSON extends Text_Highlighter_Renderer_Array +{ + + /** + * Signals that no more tokens are available + * + * @abstract + * @access public + */ + function finalize() + { + + parent::finalize(); + $output = parent::getOutput(); + + $json_array = array(); + + foreach ($output AS $token) { + + if ($this->_enumerated) { + $json_array[] = '["' . $token[0] . '","' . $token[1] . '"]'; + } else { + $key = key($token); + $json_array[] = '{"class": "' . $key . '","content":"' . $token[$key] . '"}'; + } + + } + + $this->_output = '['. implode(',', $json_array) .']'; + $this->_output = str_replace("\n", '\n', $this->_output); + + } + + +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ + ?> \ No newline at end of file diff --git a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/XML.php b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/XML.php index e86f620a..ab8a4e3e 100644 --- a/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/XML.php +++ b/framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer/XML.php @@ -1,103 +1,103 @@ - - * @copyright 2006 Stoyan Stefanov - * @license http://www.php.net/license/3_0.txt PHP License - * @version CVS: $Id: XML.php,v 1.1 2007/06/03 02:37:09 ssttoo Exp $ - * @link http://pear.php.net/package/Text_Highlighter - */ - -/** - * @ignore - */ - -require_once dirname(__FILE__).'/../Renderer.php'; -require_once dirname(__FILE__).'/../Renderer/Array.php'; - -/** - * XML renderer, based on Andrey Demenev's HTML renderer. - * - * @author Stoyan Stefanov - * @category Text - * @package Text_Highlighter - * @copyright 2006 Stoyan Stefanov - * @license http://www.php.net/license/3_0.txt PHP License - * @version Release: 0.5.0 - * @link http://pear.php.net/package/Text_Highlighter - */ - -class Text_Highlighter_Renderer_XML extends Text_Highlighter_Renderer_Array -{ - - - /** - * Options for XML_Serializer - * - * @access private - * @var array - */ - var $_serializer_options = array(); - - - /** - * Resets renderer state - * - * Descendents of Text_Highlighter call this method from the constructor, - * passing $options they get as parameter. - * - * @access protected - */ - function reset() - { - parent::reset(); - if (isset($this->_options['xml_serializer'])) { - $this->_serializer_options = $this->_options['xml_serializer']; - } - } - - - /** - * Signals that no more tokens are available - * - * @abstract - * @access public - */ - function finalize() - { - - // call parent's finalize(), then serialize array into XML - parent::finalize(); - $output = parent::getOutput(); - - $serializer = new XML_Serializer($this->_serializer_options); - $result = $serializer->serialize($output); - if ($result === true) { - $this->_output = $serializer->getSerializedData(); - } - } - - -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * c-hanging-comment-ender-p: nil - * End: - */ - + + * @copyright 2006 Stoyan Stefanov + * @license http://www.php.net/license/3_0.txt PHP License + * @version CVS: $Id: XML.php,v 1.1 2007/06/03 02:37:09 ssttoo Exp $ + * @link http://pear.php.net/package/Text_Highlighter + */ + +/** + * @ignore + */ + +require_once dirname(__FILE__).'/../Renderer.php'; +require_once dirname(__FILE__).'/../Renderer/Array.php'; + +/** + * XML renderer, based on Andrey Demenev's HTML renderer. + * + * @author Stoyan Stefanov + * @category Text + * @package Text_Highlighter + * @copyright 2006 Stoyan Stefanov + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.5.0 + * @link http://pear.php.net/package/Text_Highlighter + */ + +class Text_Highlighter_Renderer_XML extends Text_Highlighter_Renderer_Array +{ + + + /** + * Options for XML_Serializer + * + * @access private + * @var array + */ + var $_serializer_options = array(); + + + /** + * Resets renderer state + * + * Descendents of Text_Highlighter call this method from the constructor, + * passing $options they get as parameter. + * + * @access protected + */ + function reset() + { + parent::reset(); + if (isset($this->_options['xml_serializer'])) { + $this->_serializer_options = $this->_options['xml_serializer']; + } + } + + + /** + * Signals that no more tokens are available + * + * @abstract + * @access public + */ + function finalize() + { + + // call parent's finalize(), then serialize array into XML + parent::finalize(); + $output = parent::getOutput(); + + $serializer = new XML_Serializer($this->_serializer_options); + $result = $serializer->serialize($output); + if ($result === true) { + $this->_output = $serializer->getSerializedData(); + } + } + + +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ + ?> \ No newline at end of file -- cgit v1.2.3