require_once 'File/MimeType.php';
$y = new File_MimeType();
$this->mimetype = $y->fromFilename($this->file->name);
-
+ $ext = strtolower(array_pop(explode('.', $this->file->name)));
//$this->mimetype = mtrack_mime_detect($location, $this->file->name);
-
+ // special cases..
list($major) = explode('/', $this->mimetype, 2);
+ switch ($ext) {
+ case 'sql':
+ $major = 'text';
+ break;
+
+
+ }
+
// Obscure-ish special cases for mime types;
// some .y files look like old image format data
switch ($this->mimetype) {
case 'text':
fseek($t, 0);
+ // this should be a json query..
//$this->ann = array_values($this->file->annotate());
// echo '<PRE>';print_R($this->ann);exit;
-
+ if (!empty($_REQUEST['annotate'])) {
+
+ $ann = array_values($this->file->annotate());
+ $this->jdata($ann);
+ }
$this->ann = array();
if ($this->ann === 'DELETED') {
}
$this->tmpfile = $t;
- $this->nlines = count($this->ann);
+
require_once 'MTrack/SyntaxHighlight.php';
- $this->data = MTrack_SyntaxHighlight::highlightSource(
- stream_get_contents($this->tmpfile), null, $this->file->name
+ $contents = stream_get_contents($this->tmpfile);
+ $this->nlines = count(explode("\n", $contents));
+
+ if (!empty($_REQUEST['markup'])) {
+ // we do a late version call for markup..
+ echo MTrack_SyntaxHighlight::highlightSource(
+ $contents , null, $this->file->name
+ );
+ exit;
+
+ }
+
+
+ $this->data = htmlspecialchars($contents); /* MTrack_SyntaxHighlight::highlightSource(
+ $contents , null, $this->file->name
);
+ */
//var_dump($this->data);
- for ($i =0; $i < count(explode("\n", $this->data)); $i++ ) {
+ for ($i =0; $i < $this->nlines; $i++ ) {
$this->ann[] = (object) array(
'rev' => '',
'lineno' => ($i + 1)
);
}
- <td
+
default:
break; // download only..
}
-
+ if (!empty($_REQUEST['markup'])) {
+ $this->jerr("invalid request");
+ }
//
//$this->renderEvents();