From cff3c0c965c5f22918abe736432bd73a40bae5b2 Mon Sep 17 00:00:00 2001 From: wei <> Date: Wed, 1 Feb 2006 07:12:14 +0000 Subject: Update syntax highlighter with Copy Code option. --- framework/3rdParty/geshi/highlight.css | 19 ++++++++++++++++++- framework/Web/UI/TClientScriptManager.php | 5 +++++ framework/Web/UI/WebControls/TTextHighlighter.php | 10 ++++++++++ tests/FunctionalTests/protected/pages/Home.page | 3 +++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/framework/3rdParty/geshi/highlight.css b/framework/3rdParty/geshi/highlight.css index be000a83..00a53f41 100644 --- a/framework/3rdParty/geshi/highlight.css +++ b/framework/3rdParty/geshi/highlight.css @@ -93,4 +93,21 @@ .javascript .st0 {color: #3366CC;} .javascript .nu0 {color: #CC0000;} .javascript .me1 {color: #006600;} -.javascript .re0 {color: #0066FF;} \ No newline at end of file +.javascript .re0 {color: #0066FF;} + +.source .copycode +{ + text-align: right; + float: right; +} + +.source .copycode a +{ + cursor: pointer; + color: blue; +} + +.source .copycode_hover a +{ + color: red; +} diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index be6611cd..7b85dbab 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -463,6 +463,11 @@ class TClientScriptManager extends TComponent } */ + public function renderJavascriptBlock($code) + { + return ""; + } + public function renderStyleSheetFiles($writer) { $str=''; diff --git a/framework/Web/UI/WebControls/TTextHighlighter.php b/framework/Web/UI/WebControls/TTextHighlighter.php index 35f3cc23..de34b652 100644 --- a/framework/Web/UI/WebControls/TTextHighlighter.php +++ b/framework/Web/UI/WebControls/TTextHighlighter.php @@ -85,6 +85,7 @@ class TTextHighlighter extends TWebControl { parent::onPreRender($writer); $this->registerHighlightStyleSheet(); + $this->getPage()->getClientScript()->registerClientScript('prado'); } /** @@ -138,7 +139,16 @@ class TTextHighlighter extends TWebControl if($this->getShowLineNumbers()) $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->enable_classes(); + $geshi->set_header_content($this->getHeaderTemplate()); + return $geshi->parse_code(); } + + function getHeaderTemplate() + { + $id = $this->getClientID(); + $cs = $this->getPage()->getClientScript(); + return $cs->renderJavascriptBlock("new Prado.WebUI.TTextHighlighter('{$id}');"); + } } ?> \ No newline at end of file diff --git a/tests/FunctionalTests/protected/pages/Home.page b/tests/FunctionalTests/protected/pages/Home.page index 9a49e3a2..bf2830d6 100644 --- a/tests/FunctionalTests/protected/pages/Home.page +++ b/tests/FunctionalTests/protected/pages/Home.page @@ -1,3 +1,6 @@ +

Prado Functional Tests

+ +
\ No newline at end of file -- cgit v1.2.3