aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2012-04-13 20:03:54 +0200
committerChristian Weiske <cweiske@cweiske.de>2012-04-13 20:03:54 +0200
commit2b6e8d301068d81636ea4002ec9099d1cfb7074b (patch)
treed34f40df6a0f707c8871000c3a1a9ded06ad26f3
parentd9f6b83ed6d8a4546e4119c64b639adda057d25e (diff)
downloadphorkie-2b6e8d301068d81636ea4002ec9099d1cfb7074b.tar.gz
phorkie-2b6e8d301068d81636ea4002ec9099d1cfb7074b.zip
highlighting of errorneous lines in from tool output
-rw-r--r--data/templates/display-file.htm2
-rw-r--r--src/phorkie/File.php4
-rw-r--r--src/phorkie/Renderer/Geshi.php11
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 @@
<h3 id="{{file.getFilename}}">{{file.getFilename}}<a class="anchorlink" href="#{{file.getFilename}}"></a></h3>
</div>
<div class="code">
- {{file.getHighlightedContent|raw}}
+ {{file.getHighlightedContent(toolres)|raw}}
</div>
</div>
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();
}