From 112d86bb08a1dd4bde14005f757c95b0fc7a5a21 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 4 Jun 2006 20:51:27 +0000 Subject: Merge from 3.0 branch till 1140. --- framework/Web/UI/WebControls/TTextHighlighter.php | 61 +++++++---------------- 1 file changed, 19 insertions(+), 42 deletions(-) (limited to 'framework/Web/UI/WebControls/TTextHighlighter.php') diff --git a/framework/Web/UI/WebControls/TTextHighlighter.php b/framework/Web/UI/WebControls/TTextHighlighter.php index f5c3eca9..a9ccf5bb 100644 --- a/framework/Web/UI/WebControls/TTextHighlighter.php +++ b/framework/Web/UI/WebControls/TTextHighlighter.php @@ -11,9 +11,10 @@ */ /** - * Using GeSHi and TTextWriter classes + * Using GeSHi and TTextProcessor classes */ Prado::using('System.3rdParty.geshi.geshi'); +Prado::using('System.Web.UI.WebControls.TTextProcessor'); /** * TTextHighlighter class. @@ -31,7 +32,7 @@ Prado::using('System.3rdParty.geshi.geshi'); * @package System.Web.UI.WebControls * @since 3.0 */ -class TTextHighlighter extends TWebControl +class TTextHighlighter extends TTextProcessor { /** * @return string tag name of the panel @@ -77,39 +78,30 @@ class TTextHighlighter extends TWebControl } /** - * Registers css style for the highlighted result. - * This method overrides parent implementation. - * @param THtmlWriter writer + * @return boolean true will show "Copy Code" link. Defaults to false. */ - public function onPreRender($writer) + public function getEnableCopyCode() { - parent::onPreRender($writer); - $this->registerHighlightScripts(); + return $this->getViewState('CopyCode', false); } /** - * HTML-decodes static text. - * This method overrides parent implementation. - * @param mixed object to be added as body content + * @param boolean true to show the "Copy Code" link. */ - public function addParsedObject($object) + public function setEnableCopyCode($value) { - if(is_string($object)) - $object=html_entity_decode($object); - parent::addParsedObject($object); + $this->setViewState('CopyCode', TPropertyValue::ensureBoolean($value), false); } /** - * Renders body content. - * This method overrides parent implementation by replacing - * the body content with syntax highlighted result. + * Registers css style for the highlighted result. + * This method overrides parent implementation. * @param THtmlWriter writer */ - public function renderContents($writer) + public function onPreRender($writer) { - $textWriter=new TTextWriter; - parent::renderContents(new THtmlWriter($textWriter)); - $writer->write($this->highlightText($textWriter->flush())); + parent::onPreRender($writer); + $this->registerHighlightScripts(); } /** @@ -131,27 +123,12 @@ class TTextHighlighter extends TWebControl } /** - * @return boolean true will show "Copy Code" link. Defaults to false. - */ - public function getEnableCopyCode() - { - return $this->getViewState('CopyCode', false); - } - - /** - * @param boolean true to show the "Copy Code" link. - */ - public function setEnableCopyCode($value) - { - $this->setViewState('CopyCode', TPropertyValue::ensureBoolean($value), false); - } - - /** - * Returns the highlighted text. - * @param string text to highlight. - * @return string highlighted text. + * Processes a text string. + * This method is required by the parent class. + * @param string text string to be processed + * @return string the processed text result */ - protected function highlightText($text) + public function processText($text) { $geshi = new GeSHi(trim($text), $this->getLanguage()); if($this->getShowLineNumbers()) -- cgit v1.2.3