From 2b6e8d301068d81636ea4002ec9099d1cfb7074b Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 13 Apr 2012 20:03:54 +0200 Subject: [PATCH] highlighting of errorneous lines in from tool output --- data/templates/display-file.htm | 2 +- src/phorkie/File.php | 4 ++-- src/phorkie/Renderer/Geshi.php | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/data/templates/display-file.htm b/data/templates/display-file.htm index d06c365..1049abb 100644 --- a/data/templates/display-file.htm +++ b/data/templates/display-file.htm @@ -7,6 +7,6 @@

{{file.getFilename}}

- {{file.getHighlightedContent|raw}} + {{file.getHighlightedContent(toolres)|raw}}
diff --git a/src/phorkie/File.php b/src/phorkie/File.php index 869aa80..de8bde0 100644 --- a/src/phorkie/File.php +++ b/src/phorkie/File.php @@ -58,7 +58,7 @@ class File return file_get_contents($this->path); } - public function getHighlightedContent() + public function getHighlightedContent(Tool_Result $res = null) { $ext = $this->getExt(); if (isset($GLOBALS['phorkie']['languages'][$ext]['renderer'])) { @@ -67,7 +67,7 @@ class File $class = '\\phorkie\\Renderer_Geshi'; } $rend = new $class(); - return $rend->toHtml($this); + return $rend->toHtml($this, $res); } /** diff --git a/src/phorkie/Renderer/Geshi.php b/src/phorkie/Renderer/Geshi.php index 1a79e16..d2d3430 100644 --- a/src/phorkie/Renderer/Geshi.php +++ b/src/phorkie/Renderer/Geshi.php @@ -6,11 +6,12 @@ class Renderer_Geshi /** * Converts the code to HTML * - * @param File $file File to render + * @param File $file File to render + * @param Tool_Result $res Tool result to integrate * * @return string HTML */ - public function toHtml(File $file) + public function toHtml(File $file, Tool_Result $res = null) { /** * Yes, geshi needs to be in your include path @@ -20,6 +21,12 @@ class Renderer_Geshi $geshi = new \GeSHi($file->getContent(), $this->getType($file)); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->set_header_type(GESHI_HEADER_DIV); + + if ($res !== null) { + $geshi->highlight_lines_extra(array_keys($res->annotations)); + $geshi->set_highlight_lines_extra_style('background-color: #F2DEDE'); + } + return $geshi->parse_code(); } -- 2.30.2