highlighting of errorneous lines in from tool output
authorChristian Weiske <cweiske@cweiske.de>
Fri, 13 Apr 2012 18:03:54 +0000 (20:03 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 13 Apr 2012 18:03:54 +0000 (20:03 +0200)
data/templates/display-file.htm
src/phorkie/File.php
src/phorkie/Renderer/Geshi.php

index d06c365edf035eb6b68017ea8a159dea152e65e7..1049abb23896246c7143d85006552fd5bd1de206 100644 (file)
@@ -7,6 +7,6 @@
   <h3 id="{{file.getFilename}}">{{file.getFilename}}<a class="anchorlink" href="#{{file.getFilename}}"></a></h3>
  </div>
  <div class="code">
   <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>
  </div>
 </div>
index 869aa80a66984ec86d5224d0df538ab1407c357d..de8bde0f1eca272fe4704236dbf961380f7cc206 100644 (file)
@@ -58,7 +58,7 @@ class File
         return file_get_contents($this->path);
     }
 
         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'])) {
     {
         $ext = $this->getExt();
         if (isset($GLOBALS['phorkie']['languages'][$ext]['renderer'])) {
@@ -67,7 +67,7 @@ class File
             $class = '\\phorkie\\Renderer_Geshi';
         }
         $rend = new $class();
             $class = '\\phorkie\\Renderer_Geshi';
         }
         $rend = new $class();
-        return $rend->toHtml($this);
+        return $rend->toHtml($this, $res);
     }
 
     /**
     }
 
     /**
index 1a79e16d8790411cc232141388eae2a8a9ae3929..d2d34300b2c168fae60eb5941f193eec7e850167 100644 (file)
@@ -6,11 +6,12 @@ class Renderer_Geshi
     /**
      * Converts the code to HTML
      *
     /**
      * 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
      */
      *
      * @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
     {
         /**
          * 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);
         $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();
     }
 
         return $geshi->parse_code();
     }