diff options
Diffstat (limited to 'framework/Web/UI/WebControls/TTextHighlighter.php')
-rw-r--r-- | framework/Web/UI/WebControls/TTextHighlighter.php | 61 |
1 files changed, 19 insertions, 42 deletions
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())
|