Adding language settings to config.php so that people can control the language output...
[viewsvn.git] / view.php
index a6be9bbbde0a4eab435fccb7ab747f5fb520e736..b2aa13bebb64c89a75deab12832f804b1f674d0e 100644 (file)
--- a/view.php
+++ b/view.php
 <?php
 /*=====================================================================*\
-|| ################################################################### ||
+|| ###################################################################
 || # ViewSVN [#]version[#]
-|| # --------------------------------------------------------------- # ||
-|| # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
-|| # This file may not be reproduced in any way without permission.  # ||
-|| # --------------------------------------------------------------- # ||
-|| # User License Agreement at http://www.iris-studios.com/license/  # ||
-|| ################################################################### ||
+|| # Copyright ©2002-[#]year[#] Blue Static
+|| #
+|| # This program is free software; you can redistribute it and/or modify
+|| # it under the terms of the GNU General Public License as published by
+|| # the Free Software Foundation; version [#]gpl[#] of the License.
+|| #
+|| # This program is distributed in the hope that it will be useful, but
+|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+|| # more details.
+|| #
+|| # You should have received a copy of the GNU General Public License along
+|| # with this program; if not, write to the Free Software Foundation, Inc.,
+|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+|| ###################################################################
 \*=====================================================================*/
 
+$fetchtemplates = array(
+       'view',
+       'property'
+);
+
+define('SVN', '$Id$');
+
 require_once('./global.php');
 
-$navbar = $viewsvn->paths->construct_breadcrumb($path);
+$navbar = ConstructNavbar();
 
 // ###################################################################
 
-$link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->fetch_rev_str(), $path);
-
-$show['head'] = ($viewsvn->svn->common->fetch_head_rev($path) != $viewsvn->paths->fetch_rev_num() AND $viewsvn->paths->fetch_rev_num() != 'HEAD');
-if ($show['head'])
+$revision = $headRev = new Revision($input->in['repos'], $input->in['rev'], $input->in['path']);
+if ($input->in['rev'])
 {
-       $link['gohead'] = $viewsvn->paths->out('browse.php' . $viewsvn->paths->fetch_rev_str(false, 'HEAD'), $path);
-       $link['diffhead'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, 'HEAD', $viewsvn->paths->fetch_rev_num()), $path);
+       $headRev = new Revision($input->in['repos'], 0, $input->in['path']);
+       if ($headRev->revision != $revision->revision)
+       {
+               $show['head'] = true;
+               $link['gohead'] = ConstructLink('view', $input->in['repos'], $input->in['path'], 0);
+       }
 }
 
-$show['prev'] = (($prev = $viewsvn->svn->common->fetch_prev_rev($path, $viewsvn->paths->fetch_rev_num())) != -1 ? true : false);
-if ($show['prev'])
+if ($revision->revision - 1 > 0)
 {
-       $link['diffprev'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $viewsvn->paths->fetch_rev_num(), $prev), $path);
+       $show['diff'] = true;
+       $link['diff'] = ConstructLink('diff', $input->in['repos'], $input->in['path'], $revision->revision);
 }
 
+$link['log'] = ConstructLink('log', $input->in['repos'], $input->in['path'], 0);
+
+// ###################################################################
+
+$revision->getRevisionInfo();
+
+$catdata = $lib->run('cat -r' . $revision->revision . ' ' . $lib->arg($repos->fetchPath($input->in['repos']) . $input->in['path']), true);
+
+// ###################################################################
+
+$props = $revision->getPropsForPath($input->in['path']);
+$show['props'] = (sizeof($props) > 0);
+$proplist = FormatPropList($props);
+
 // ###################################################################
 
-$logmsg = $viewsvn->svn->common->fetch_log($path, $viewsvn->paths->fetch_rev_num());
-unset($logmsg['files']);
+// get language information
+require_once('./includes/file_types.php');
+$extension = BSFunctions::FetchExtension($input->in['path']);
+$language = (isset($filetypes["$extension"]) ? $filetypes["$extension"] : null);
+
+// initialize GeSHi
+$mtstart = microtime();
+require_once('./includes/geshi/geshi.php');
+$geshi = new Geshi($catdata, $language[MIMES_GESHI_LANGUAGE]);
+
+// use CSS
+$geshi->enable_classes();
+
+// header
+$geshi->set_header_type(GESHI_HEADER_DIV);
+
+// disable links
+$urls = (isset($geshi->language_data['URLS']) ? array_keys($geshi->language_data['URLS']) : array());
+foreach ($urls AS $key)
+{
+       $geshi->set_url_for_keyword_group($key, '');
+}
+
+// don't do anything stupid
+$geshi->set_case_keywords(GESHI_CAPS_NO_CHANGE);
+
+// encoding
+$geshi->set_encoding('UTF-8');
+
+// tab width
+$geshi->set_tab_width(5);
 
-$logmsg = print_r($logmsg, true);
+// parse the code
+$catdata = $geshi->parse_code();
 
-$catdata = $viewsvn->svn->format(implode("\n", $viewsvn->svn->cat($repos, $relpath, $viewsvn->paths->fetch_rev_num())));
+BSRegister::Debug("time in GeSHi = " . BSFunctions::FetchMicrotimeDiff($mtstart));
 
 // ###################################################################