Basic enscript processing is now working
[viewsvn.git] / view.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 $fetchtemplates = array(
23 'view'
24 );
25
26 require_once('./global.php');
27
28 $navbar = $viewsvn->paths->construct_breadcrumb($path);
29
30 // ###################################################################
31
32 $link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path);
33
34 $show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD');
35 if ($show['head'])
36 {
37 $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path);
38 $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path);
39 }
40
41 $show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false);
42 if ($show['prev'])
43 {
44 $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path);
45 }
46
47 // ###################################################################
48
49 $logmsg = $viewsvn->svn->common->fetch_log($path, $viewsvn->paths->fetch_rev_num());
50 unset($logmsg['files']);
51
52 $logmsg['message_clean'] = nl2br(htmlspecialchars($logmsg['message']));
53
54 $catdata = $data = implode("\n", $viewsvn->svn->cat($repos, $relpath, $viewsvn->paths->fetch_rev_num()));
55
56 $f = fopen(($name = '/tmp/enscript-write-viewsvn-temp-' . time()), 'w');
57 fwrite($f, $catdata);
58 fclose($f);
59
60 $catdata = implode("\n", $viewsvn->shell->exec($viewsvn->paths->enscript . ' --color -h -q --language=html -p - --pretty-print=html ' . $name));
61
62 $colors = array(
63 'comment' => 'B22222',
64 'keyword' => '5F9EA0',
65 'type' => '228B22',
66 'string' => 'BC8F8F',
67 'func' => '0000FF',
68 'prep' => 'B8860B',
69 'lang' => 'A020F0',
70 'var' => 'DA706D'
71 );
72
73 foreach ($colors AS $class => $color)
74 {
75 $catdata = preg_replace('#<font color="\#' . $color . '">#i', '<span class="code-' . $class . '">', $catdata);
76 }
77 $catdata = preg_replace('#</font>#i', '</span>', $catdata);
78 $catdata = preg_replace('#<(/?)b>#i', '<\1strong>', $catdata);
79
80 $catdata = substr($catdata, strpos($catdata, '</H1>'), strpos($catdata, '</PRE>') - strpos($catdata, '</H1>'));
81
82 unlink($name);
83
84 // ###################################################################
85
86 eval('$template->flush("' . $template->fetch('view') . '");');
87
88 /*=====================================================================*\
89 || ###################################################################
90 || # $HeadURL$
91 || # $Id$
92 || ###################################################################
93 \*=====================================================================*/
94 ?>