diff options
author | xue <> | 2005-12-29 12:20:57 +0000 |
---|---|---|
committer | xue <> | 2005-12-29 12:20:57 +0000 |
commit | 3126610fdab66c4e83de00d36a762af30199238d (patch) | |
tree | 96c0e41e404303eb95d0c29c3da728dac8c29336 /demos/quickstart/protected/controls/TTextHighlighter.php | |
parent | 658a7e1c4cf5a53dcd61ee196658090d00f2d64a (diff) |
Modified TTextHighlighter so that it can highlight its body content including output of its child controls.
Modified ViewSource to make use of TTextHighlighter.
Diffstat (limited to 'demos/quickstart/protected/controls/TTextHighlighter.php')
-rw-r--r-- | demos/quickstart/protected/controls/TTextHighlighter.php | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/demos/quickstart/protected/controls/TTextHighlighter.php b/demos/quickstart/protected/controls/TTextHighlighter.php index 19b54ad2..b89e5274 100644 --- a/demos/quickstart/protected/controls/TTextHighlighter.php +++ b/demos/quickstart/protected/controls/TTextHighlighter.php @@ -2,6 +2,8 @@ require_once(dirname(__FILE__).'/Highlighter/geshi.php');
+Prado::using('System.IO.TTextWriter');
+
/**
* ${classname}
*
@@ -51,18 +53,17 @@ class TTextHighlighter extends TWebControl $this->setViewState('Entities', TPropertyValue::ensureBoolean($value), false);
}
- /**
- * Parse the body string using GeSHi to highlight the contents.
- */
- public function addParsedObject($object)
+ protected function onPreRender($writer)
{
- if(is_string($object))
- {
- $this->registerTextHighlightStyleSheet();
- $this->getControls()->add($this->getTextHighlight($object));
- }
- else
- $this->getControls()->add($object);
+ parent::onPreRender($writer);
+ $this->registerTextHighlightStyleSheet();
+ }
+
+ protected function renderContents($writer)
+ {
+ $textWriter=new TTextWriter;
+ parent::renderContents(new THtmlWriter($textWriter));
+ $writer->write($this->highlightText($textWriter->flush()));
}
/**
@@ -83,7 +84,7 @@ class TTextHighlighter extends TWebControl * @param string text to highlight.
* @return string highlighted text.
*/
- protected function getTextHighlight($text)
+ protected function highlightText($text)
{
if(!$this->getEnableEntities())
$text = html_entity_decode($text);
|