return file_get_contents($this->path);
}
- public function getHighlightedContent()
+ public function getRenderedContent(Tool_Result $res = null)
{
- /**
- * Yes, geshi needs to be in your include path
- * We use the mediawiki geshi extension package.
- */
- require_once 'MediaWiki/geshi/geshi/geshi.php';
- $geshi = new \GeSHi($this->getContent(), $this->getGeshiType());
- $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
- $geshi->set_header_type(GESHI_HEADER_DIV);
- return $geshi->parse_code();
+ $ext = $this->getExt();
+ $class = '\\phorkie\\Renderer_Unknown';
+
+ if (isset($GLOBALS['phorkie']['languages'][$ext]['renderer'])) {
+ $class = $GLOBALS['phorkie']['languages'][$ext]['renderer'];
+ } else if (isset($GLOBALS['phorkie']['languages'][$ext]['mime'])) {
+ $type = $GLOBALS['phorkie']['languages'][$ext]['mime'];
+ if (substr($type, 0, 5) == 'text/') {
+ $class = '\\phorkie\\Renderer_Geshi';
+ } else if (substr($type, 0, 6) == 'image/') {
+ $class = '\\phorkie\\Renderer_Image';
+ }
+ }
+
+ $rend = new $class();
+ return $rend->toHtml($this, $res);
}
/**
*
* @param string $type Link type. Supported are:
* - "raw"
- * - "display"
+ * - "tool"
+ * @param string $option
*
* @return string
*/
- public function getLink($type)
+ public function getLink($type, $option = null)
{
if ($type == 'raw') {
return '/' . $this->repo->id . '/raw/' . $this->getFilename();
+ } else if ($type == 'tool') {
+ return '/' . $this->repo->id . '/tool/' . $option . '/' . $this->getFilename();
}
throw new Exception('Unknown type');
}
- /**
- * Returns the type of the file, as used by Geshi
- *
- * @return string
- */
- public function getGeshiType()
- {
- $ext = $this->getExt();
- if (isset($GLOBALS['phorkie']['languages'][$ext]['geshi'])) {
- $ext = $GLOBALS['phorkie']['languages'][$ext]['geshi'];
- }
-
- return $ext;
- }
-
public function getMimeType()
{
$ext = $this->getExt();
}
return $GLOBALS['phorkie']['languages'][$ext]['mime'];
}
+
+ /**
+ * @return array Array of Tool_Info objects
+ */
+ public function getToolInfos()
+ {
+ $tm = new Tool_Manager();
+ return $tm->getSuitable($this);
+ }
}
?>
\ No newline at end of file