diff options
Diffstat (limited to 'demos/quickstart/protected/controls/TTextHighlighter.php')
-rw-r--r-- | demos/quickstart/protected/controls/TTextHighlighter.php | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/demos/quickstart/protected/controls/TTextHighlighter.php b/demos/quickstart/protected/controls/TTextHighlighter.php deleted file mode 100644 index bc74b5af..00000000 --- a/demos/quickstart/protected/controls/TTextHighlighter.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php
-
-require_once(dirname(__FILE__).'/Highlighter/geshi.php');
-
-Prado::using('System.IO.TTextWriter');
-
-/**
- * ${classname}
- *
- * ${description}
- *
- * @author Wei Zhuo<weizhuo[at]gmail[dot]com>
- * @version $Revision: 1.66 $ $Date: ${DATE} ${TIME} $
- * @package ${package}
- */
-class TTextHighlighter extends TWebControl
-{
- /**
- * @return string tag name of the panel
- */
- protected function getTagName()
- {
- return 'div';
- }
-
- public function getLanguage()
- {
- return $this->getViewState('Language', 'php');
- }
-
- public function setLanguage($value)
- {
- $this->setViewState('Language', $value, 'php');
- }
-
- public function setEnableLineNumbers($value)
- {
- $this->setViewState('LineNumbers', TPropertyValue::ensureBoolean($value), false);
- }
-
- public function getEnableLineNumbers()
- {
- return $this->getViewState('LineNumbers', false);
- }
-
- protected function onPreRender($writer)
- {
- parent::onPreRender($writer);
- $this->registerTextHighlightStyleSheet();
- }
-
- public function addParsedObject($object)
- {
- if(is_string($object))
- $object=html_entity_decode($object);
- parent::addParsedObject($object);
- }
-
- protected function renderContents($writer)
- {
- $textWriter=new TTextWriter;
- parent::renderContents(new THtmlWriter($textWriter));
- $writer->write($this->highlightText($textWriter->flush()));
- }
-
- /**
- * Register CSS style sheet file.
- */
- protected function registerTextHighlightStyleSheet()
- {
- $cs = $this->getPage()->getClientScript();
- if(!$cs->isStyleSheetFileRegistered(get_class($this)))
- {
- $styleSheet = $this->getAsset('Highlighter/code_highlight.css');
- $cs->registerStyleSheetFile(get_class($this), $styleSheet);
- }
- }
-
- /**
- * Returns the highlighted text.
- * @param string text to highlight.
- * @return string highlighted text.
- */
- protected function highlightText($text)
- {
- $geshi = new GeSHi(trim($text), $this->getLanguage());
- if($this->getEnableLineNumbers())
- $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
- $geshi->enable_classes();
- return $geshi->parse_code();
- }
-}
-?>
\ No newline at end of file |