Make search a config option
Make search a config option

<?php <?php
/* /*
* config.inc.php * config.inc.php
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Configuration * Component: Configuration
* *
* Copyright (C) 2006 Christopher Han <xiphux@gmail.com> * Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
*/ */
   
/* /*
* stylesheet * stylesheet
* Path to page stylesheet * Path to page stylesheet
*/ */
$gitphp_conf['stylesheet'] = "gitphp.css"; $gitphp_conf['stylesheet'] = "gitphp.css";
   
/* /*
* projectroot * projectroot
* Absolute filesystem path prepended to project paths * Absolute filesystem path prepended to project paths
* (don't forget trailing slash!) * (don't forget trailing slash!)
*/ */
$gitphp_conf['projectroot'] = "/git/"; $gitphp_conf['projectroot'] = "/git/";
   
/* /*
* gitbin * gitbin
* Path to git binary * Path to git binary
* For example, /usr/bin/git on Linux * For example, /usr/bin/git on Linux
* or C:\\Program Files\\Git\\bin\\git.exe on Windows * or C:\\Program Files\\Git\\bin\\git.exe on Windows
* with msysgit. You can also omit the full path and just * with msysgit. You can also omit the full path and just
* use the executable name to search the user's $PATH. * use the executable name to search the user's $PATH.
* Note: Versions of PHP below 5.2 have buggy handling of spaces * Note: Versions of PHP below 5.2 have buggy handling of spaces
* in paths. Use the 8.3 version of the filename if you're * in paths. Use the 8.3 version of the filename if you're
* having trouble, e.g. C:\\Progra~1\\Git\\bin\\git.exe * having trouble, e.g. C:\\Progra~1\\Git\\bin\\git.exe
*/ */
$gitphp_conf['gitbin'] = "/usr/bin/git"; $gitphp_conf['gitbin'] = "/usr/bin/git";
   
/* /*
* diffbin * diffbin
* Path to diff binary * Path to diff binary
* Same rules as gitbin * Same rules as gitbin
* Windows (msysgit): C:\\Progra~1\\Git\\bin\\diff.exe * Windows (msysgit): C:\\Progra~1\\Git\\bin\\diff.exe
*/ */
$gitphp_conf['diffbin'] = "/usr/bin/diff"; $gitphp_conf['diffbin'] = "/usr/bin/diff";
   
/* /*
* gittmp * gittmp
* Location for temporary files for diffs * Location for temporary files for diffs
* (don't forget trailing slash!) * (don't forget trailing slash!)
*/ */
$gitphp_conf['gittmp'] = "/tmp/gitphp/"; $gitphp_conf['gittmp'] = "/tmp/gitphp/";
   
/* /*
* title * title
* The string that will be used as the page title * The string that will be used as the page title
* The variable '$gitphp_appstring' will expand to * The variable '$gitphp_appstring' will expand to
* the name (gitphp) and version * the name (gitphp) and version
* The variable '$gitphp_version' will expand to the * The variable '$gitphp_version' will expand to the
* version number only * version number only
*/ */
$gitphp_conf['title'] = "$gitphp_appstring"; $gitphp_conf['title'] = "$gitphp_appstring";
   
/* /*
* self * self
* This is the path to the script that will be inserted * This is the path to the script that will be inserted
* in urls. If you leave this blank/commented the script * in urls. If you leave this blank/commented the script
* will try to guess the correct URL, but you can override * will try to guess the correct URL, but you can override
* it here if it's not being guessed correctly. * it here if it's not being guessed correctly.
* *
* If only specifying the directory path (and omitting the * If only specifying the directory path (and omitting the
* index.php filename), make sure to include the trailing * index.php filename), make sure to include the trailing
* slash! * slash!
*/ */
//$gitphp_conf['self'] = "http://localhost/gitphp/"; //$gitphp_conf['self'] = "http://localhost/gitphp/";
   
/* /*
* smarty_prefix * smarty_prefix
* This is the prefix where smarty is installed. * This is the prefix where smarty is installed.
* (including trailing slash) * (including trailing slash)
* If an absolute (starts with /) path is given, * If an absolute (starts with /) path is given,
* Smarty.class.php will be searched for in that directory. * Smarty.class.php will be searched for in that directory.
* If a relative (doesn't start with /) path is given, * If a relative (doesn't start with /) path is given,
* that subdirectory inside the php include dirs will be * that subdirectory inside the php include dirs will be
* searched. So, for example, if you specify the path as * searched. So, for example, if you specify the path as
* "/usr/share/Smarty/" then the script will look for * "/usr/share/Smarty/" then the script will look for
* /usr/share/Smarty/Smarty.class.php. * /usr/share/Smarty/Smarty.class.php.
* If you specify the path as "smarty/" then it will search * If you specify the path as "smarty/" then it will search
* the include directories in php.ini's include_path directive, * the include directories in php.ini's include_path directive,
* so it would search in places like /usr/share/php and /usr/lib/php: * so it would search in places like /usr/share/php and /usr/lib/php:
* /usr/share/php/smarty/Smarty.class.php, * /usr/share/php/smarty/Smarty.class.php,
* /usr/lib/php/smarty/Smarty.class.php, etc. * /usr/lib/php/smarty/Smarty.class.php, etc.
* Leave blank to just search in the root of the php include directories * Leave blank to just search in the root of the php include directories
* like /usr/share/php/Smarty.class.php, /usr/lib/php/Smarty.class.php, etc. * like /usr/share/php/Smarty.class.php, /usr/lib/php/Smarty.class.php, etc.
*/ */
$gitphp_conf['smarty_prefix'] = "smarty/"; $gitphp_conf['smarty_prefix'] = "smarty/";
   
/* /*
* bzsnapshots * bzsnapshots
* If set to true, will bzcompress snapshot tars before sending them. * If set to true, will bzcompress snapshot tars before sending them.
* Your PHP must have been compiled with bzip2 support! * Your PHP must have been compiled with bzip2 support!
*/ */
$gitphp_conf['bzsnapshots'] = TRUE; $gitphp_conf['bzsnapshots'] = TRUE;
   
/* /*
* bzblocksize * bzblocksize
* Sets the compression level for bzip2. Ranges from 1-9, with * Sets the compression level for bzip2. Ranges from 1-9, with
* 9 being the most compression but requiring the most processing * 9 being the most compression but requiring the most processing
* (bzip defaults to 4) * (bzip defaults to 4)
*/ */
$gitphp_conf['bzblocksize'] = 9; $gitphp_conf['bzblocksize'] = 9;
   
/* /*
* geshi * geshi
* Run blob output through geshi syntax highlighting * Run blob output through geshi syntax highlighting
* and line numbering * and line numbering
*/ */
$gitphp_conf['geshi'] = FALSE; $gitphp_conf['geshi'] = FALSE;
   
/* /*
* geshiroot * geshiroot
* Directory where geshi is installed * Directory where geshi is installed
* NOTE: this is the path to the base geshi.php file to include, * NOTE: this is the path to the base geshi.php file to include,
* NOT the various other geshi php source files! * NOT the various other geshi php source files!
* Leave blank if geshi.php is in the gitphp root * Leave blank if geshi.php is in the gitphp root
* (don't forget trailing slash!) * (don't forget trailing slash!)
*/ */
$gitphp_conf['geshiroot'] = "geshi/"; $gitphp_conf['geshiroot'] = "geshi/";
   
/* /*
* filemimetype * filemimetype
* Attempt to read the file's mimetype when displaying * Attempt to read the file's mimetype when displaying
* (for example, displaying an image as an actual image * (for example, displaying an image as an actual image
* in a browser) * in a browser)
* This requires either PHP >= 5.3.0, PECL fileinfo, or * This requires either PHP >= 5.3.0, PECL fileinfo, or
* Linux * Linux
*/ */
$gitphp_conf['filemimetype'] = TRUE; $gitphp_conf['filemimetype'] = TRUE;
   
/* /*
* magicdb * magicdb
* Path to the libmagic db used to read mimetype * Path to the libmagic db used to read mimetype
* You can leave this as null and let the system * You can leave this as null and let the system
* try to find the database for you, but that method * try to find the database for you, but that method
* is known to have issues * is known to have issues
* If the path is correct but it's still not working, * If the path is correct but it's still not working,
* try removing the file extension if you have it on, * try removing the file extension if you have it on,
* or vice versa * or vice versa
*/ */
$gitphp_conf['magicdb'] = "/usr/share/misc/magic.mgc"; $gitphp_conf['magicdb'] = "/usr/share/misc/magic.mgc";
//$gitphp_conf['magicdb'] = "C:\\wamp\\php\\extras\\magic"; // Windows //$gitphp_conf['magicdb'] = "C:\\wamp\\php\\extras\\magic"; // Windows
   
/* /*
  * search
  * Set this to false or comment it out to disable searching
  */
  $gitphp_conf['search'] = TRUE;
   
  /*
* git_projects * git_projects
* Two-dimensional array list of projects * Two-dimensional array list of projects
* First array index is the name of the category the projects * First array index is the name of the category the projects
* belong to, and the second array index is a human-readable * belong to, and the second array index is a human-readable
* name for the project (not used, just for organizational * name for the project (not used, just for organizational
* purposes), and the value is the path to the project * purposes), and the value is the path to the project
* (minus the projectroot). * (minus the projectroot).
* Any projects belonging to the special category "none" * Any projects belonging to the special category "none"
* will be listed without a category. * will be listed without a category.
* Comment out $git_projects (leave null) to attempt to read all * Comment out $git_projects (leave null) to attempt to read all
* projects in the projectroot. * projects in the projectroot.
*/ */
//$git_projects['Core']['FBX'] = "core/fbx.git"; //$git_projects['Core']['FBX'] = "core/fbx.git";
//$git_projects['PHP']['gitphp'] = "php/gitphp.git"; //$git_projects['PHP']['gitphp'] = "php/gitphp.git";
//$git_projects['PHP']['MDB'] = "php/mdb.git"; //$git_projects['PHP']['MDB'] = "php/mdb.git";
//$git_projects['PHP']['xxcache'] = "php/xxcache.git"; //$git_projects['PHP']['xxcache'] = "php/xxcache.git";
//$git_projects['Websites']['bth'] = "websites/bth.git"; //$git_projects['Websites']['bth'] = "websites/bth.git";
   
?> ?>
   
<?php <?php
/* /*
* display.git_search.php * display.git_search.php
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Display - search * Component: Display - search
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*/ */
   
include_once('gitutil.git_read_commit.php'); include_once('gitutil.git_read_commit.php');
include_once('gitutil.git_rev_list.php'); include_once('gitutil.git_rev_list.php');
   
function git_search($projectroot, $project, $hash, $search, $searchtype, $page = 0) function git_search($projectroot, $project, $hash, $search, $searchtype, $page = 0)
{ {
global $tpl; global $tpl,$gitphp_conf;
   
  if (!$gitphp_conf['search']) {
  $tpl->clear_all_assign();
  $tpl->assign("message","Search has been disabled");
  $tpl->display("message.tpl");
  return;
  }
   
if (!isset($search) || (strlen($search) < 2)) { if (!isset($search) || (strlen($search) < 2)) {
$tpl->clear_all_assign(); $tpl->clear_all_assign();
$tpl->assign("error",TRUE); $tpl->assign("error",TRUE);
$tpl->assign("message","You must enter search text of at least 2 characters"); $tpl->assign("message","You must enter search text of at least 2 characters");
$tpl->display("message.tpl"); $tpl->display("message.tpl");
return; return;
} }
if (!isset($hash)) { if (!isset($hash)) {
//$hash = git_read_head($projectroot . $project); //$hash = git_read_head($projectroot . $project);
$hash = "HEAD"; $hash = "HEAD";
} }
   
$co = git_read_commit($projectroot . $project, $hash); $co = git_read_commit($projectroot . $project, $hash);
   
$revlist = explode("\n",trim(git_rev_list($projectroot . $project, $hash, 101, ($page * 100), FALSE, FALSE, $searchtype, $search))); $revlist = explode("\n",trim(git_rev_list($projectroot . $project, $hash, 101, ($page * 100), FALSE, FALSE, $searchtype, $search)));
   
if (count($revlist) < 1 || (strlen($revlist[0]) < 1)) { if (count($revlist) < 1 || (strlen($revlist[0]) < 1)) {
$tpl->clear_all_assign(); $tpl->clear_all_assign();
$tpl->assign("message","No matches for '" . $search . "'."); $tpl->assign("message","No matches for '" . $search . "'.");
$tpl->display("message.tpl"); $tpl->display("message.tpl");
return; return;
} }
   
$tpl->clear_all_assign(); $tpl->clear_all_assign();
$tpl->assign("project",$project); $tpl->assign("project",$project);
$tpl->assign("hash",$hash); $tpl->assign("hash",$hash);
$tpl->assign("treehash",$co['tree']); $tpl->assign("treehash",$co['tree']);
$tpl->display("search_nav.tpl"); $tpl->display("search_nav.tpl");
   
$tpl->assign("search",$search); $tpl->assign("search",$search);
$tpl->assign("searchtype",$searchtype); $tpl->assign("searchtype",$searchtype);
if ($page > 0) { if ($page > 0) {
$tpl->assign("firstlink",TRUE); $tpl->assign("firstlink",TRUE);
$tpl->assign("prevlink",TRUE); $tpl->assign("prevlink",TRUE);
if ($page > 1) if ($page > 1)
$tpl->assign("prevpage",$page-1); $tpl->assign("prevpage",$page-1);
} }
if (count($revlist) > 100) { if (count($revlist) > 100) {
$tpl->assign("nextlink",TRUE); $tpl->assign("nextlink",TRUE);
$tpl->assign("nextpage",$page+1); $tpl->assign("nextpage",$page+1);
} }
$tpl->display("search_pagenav.tpl"); $tpl->display("search_pagenav.tpl");
   
$tpl->assign("title",$co['title']); $tpl->assign("title",$co['title']);
$tpl->display("search_header.tpl"); $tpl->display("search_header.tpl");
   
$alternate = FALSE; $alternate = FALSE;
for ($i = 0; $i <= 100; $i++) { for ($i = 0; $i <= 100; $i++) {
$tpl->clear_all_assign(); $tpl->clear_all_assign();
$commit = $revlist[$i]; $commit = $revlist[$i];
if (strlen(trim($commit)) > 0) { if (strlen(trim($commit)) > 0) {
$co2 = git_read_commit($projectroot . $project, $commit); $co2 = git_read_commit($projectroot . $project, $commit);
if ($alternate) if ($alternate)
$tpl->assign("class","dark"); $tpl->assign("class","dark");
else else
$tpl->assign("class","light"); $tpl->assign("class","light");
$alternate = !$alternate; $alternate = !$alternate;
$tpl->assign("project",$project); $tpl->assign("project",$project);
$tpl->assign("commit",$commit); $tpl->assign("commit",$commit);
$tpl->assign("agestringage",$co2['age_string_age']); $tpl->assign("agestringage",$co2['age_string_age']);
$tpl->assign("agestringdate",$co2['age_string_date']); $tpl->assign("agestringdate",$co2['age_string_date']);
$tpl->assign("authorname",$co2['author_name']); $tpl->assign("authorname",$co2['author_name']);
$tpl->assign("title_short",$co2['title_short']); $tpl->assign("title_short",$co2['title_short']);
if (strlen($co2['title_short']) < strlen($co2['title'])) if (strlen($co2['title_short']) < strlen($co2['title']))
$tpl->assign("title",$co2['title']); $tpl->assign("title",$co2['title']);
$tpl->assign("committree",$co2['tree']); $tpl->assign("committree",$co2['tree']);
$matches = array(); $matches = array();
foreach ($co2['comment'] as $comline) { foreach ($co2['comment'] as $comline) {
if (eregi("(.*)(" . quotemeta($search) . ")(.*)",$comline,$regs)) { if (eregi("(.*)(" . quotemeta($search) . ")(.*)",$comline,$regs)) {
$maxlen = 50; $maxlen = 50;
$linelen = strlen($regs[0]); $linelen = strlen($regs[0]);
if ($linelen > $maxlen) { if ($linelen > $maxlen) {
$matchlen = strlen($regs[2]); $matchlen = strlen($regs[2]);
$remain = floor(($maxlen - $matchlen) / 2); $remain = floor(($maxlen - $matchlen) / 2);
$leftlen = strlen($regs[1]); $leftlen = strlen($regs[1]);
$rightlen = strlen($regs[3]); $rightlen = strlen($regs[3]);
if ($leftlen > $remain) { if ($leftlen > $remain) {
$leftremain = $remain; $leftremain = $remain;
if ($rightlen < $remain) if ($rightlen < $remain)
$leftremain += ($remain - $rightlen); $leftremain += ($remain - $rightlen);
$regs[1] = "..." . substr($regs[1], ($leftlen - ($leftremain - 3))); $regs[1] = "..." . substr($regs[1], ($leftlen - ($leftremain - 3)));
} }
if ($rightlen > $remain) { if ($rightlen > $remain) {
$rightremain = $remain; $rightremain = $remain;
if ($leftlen < $remain) if ($leftlen < $remain)
$rightremain += ($remain - $leftlen); $rightremain += ($remain - $leftlen);
$regs[3] = substr($regs[3],0,$rightremain-3) . "..."; $regs[3] = substr($regs[3],0,$rightremain-3) . "...";
} }
} }
$matches[] = $regs[1] . "<span class=\"searchmatch\">" . $regs[2] . "</span>" . $regs[3]; $matches[] = $regs[1] . "<span class=\"searchmatch\">" . $regs[2] . "</span>" . $regs[3];
} }
} }
$tpl->assign("matches",$matches); $tpl->assign("matches",$matches);
$tpl->display("search_item.tpl"); $tpl->display("search_item.tpl");
} }
} }
   
$tpl->clear_all_assign(); $tpl->clear_all_assign();
$tpl->assign("project",$project); $tpl->assign("project",$project);
$tpl->assign("hash",$hash); $tpl->assign("hash",$hash);
$tpl->assign("search",$search); $tpl->assign("search",$search);
$tpl->assign("searchtype",$searchtype); $tpl->assign("searchtype",$searchtype);
if (count($revlist) > 100) { if (count($revlist) > 100) {
$tpl->assign("nextlink",TRUE); $tpl->assign("nextlink",TRUE);
$tpl->assign("nextpage",$page+1); $tpl->assign("nextpage",$page+1);
} }
$tpl->display("search_footer.tpl"); $tpl->display("search_footer.tpl");
} }
   
?> ?>
   
file:a/index.php -> file:b/index.php
<?php <?php
/* /*
* index.php * index.php
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Index script * Component: Index script
* *
* Copyright (C) 2006 Christopher Han <xiphux@gmail.com> * Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
*/ */
ob_start(); ob_start();
   
/* /*
* Version * Version
*/ */
include_once('include/version.php'); include_once('include/version.php');
   
/* /*
* Configuration * Configuration
*/ */
include_once('config/gitphp.conf.php'); include_once('config/gitphp.conf.php');
   
/* /*
* Instantiate Smarty * Instantiate Smarty
*/ */
include_once($gitphp_conf['smarty_prefix'] . "Smarty.class.php"); include_once($gitphp_conf['smarty_prefix'] . "Smarty.class.php");
$tpl =& new Smarty; $tpl =& new Smarty;
$tpl->load_filter('output','trimwhitespace'); $tpl->load_filter('output','trimwhitespace');
   
$rss_link = FALSE; $rss_link = FALSE;
$suppress_headers = FALSE; $suppress_headers = FALSE;
   
ob_start(); ob_start();
if (isset($_GET['a']) && $_GET['a'] == "opml") { if (isset($_GET['a']) && $_GET['a'] == "opml") {
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_opml.php'); include_once('include/display.git_opml.php');
git_opml($gitphp_conf['projectroot'],$git_projects); git_opml($gitphp_conf['projectroot'],$git_projects);
} else if (isset($_GET['a']) && $_GET['a'] == "project_index") { } else if (isset($_GET['a']) && $_GET['a'] == "project_index") {
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_project_index.php'); include_once('include/display.git_project_index.php');
git_project_index($gitphp_conf['projectroot'],$git_projects); git_project_index($gitphp_conf['projectroot'],$git_projects);
} else if (isset($_GET['p'])) { } else if (isset($_GET['p'])) {
if (!is_dir($gitphp_conf['projectroot'] . $_GET['p'])) if (!is_dir($gitphp_conf['projectroot'] . $_GET['p']))
echo "No such directory"; echo "No such directory";
else if (!is_file($gitphp_conf['projectroot'] . $_GET['p'] . "/HEAD")) else if (!is_file($gitphp_conf['projectroot'] . $_GET['p'] . "/HEAD"))
echo "No such project"; echo "No such project";
else { else {
$rss_link = TRUE; $rss_link = TRUE;
if (!isset($_GET['a'])) { if (!isset($_GET['a'])) {
include_once('include/display.git_summary.php'); include_once('include/display.git_summary.php');
git_summary($gitphp_conf['projectroot'],$_GET['p']); git_summary($gitphp_conf['projectroot'],$_GET['p']);
} else { } else {
switch ($_GET['a']) { switch ($_GET['a']) {
case "summary": case "summary":
include_once('include/display.git_summary.php'); include_once('include/display.git_summary.php');
git_summary($gitphp_conf['projectroot'],$_GET['p']); git_summary($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "tree": case "tree":
include_once('include/display.git_tree.php'); include_once('include/display.git_tree.php');
git_tree($gitphp_conf['projectroot'], $_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['f']) ? $_GET['f'] : NULL), (isset($_GET['hb']) ? $_GET['hb'] : NULL)); git_tree($gitphp_conf['projectroot'], $_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['f']) ? $_GET['f'] : NULL), (isset($_GET['hb']) ? $_GET['hb'] : NULL));
break; break;
case "shortlog": case "shortlog":
include_once('include/display.git_shortlog.php'); include_once('include/display.git_shortlog.php');
git_shortlog($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['pg']) ? $_GET['pg'] : NULL)); git_shortlog($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['pg']) ? $_GET['pg'] : NULL));
break; break;
case "log": case "log":
include_once('include/display.git_log.php'); include_once('include/display.git_log.php');
git_log($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['pg']) ? $_GET['pg'] : NULL)); git_log($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['pg']) ? $_GET['pg'] : NULL));
break; break;
case "commit": case "commit":
include_once('include/display.git_commit.php'); include_once('include/display.git_commit.php');
git_commit($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']); git_commit($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']);
break; break;
case "commitdiff": case "commitdiff":
include_once('include/display.git_commitdiff.php'); include_once('include/display.git_commitdiff.php');
git_commitdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'], (isset($_GET['hp']) ? $_GET['hp'] : NULL)); git_commitdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'], (isset($_GET['hp']) ? $_GET['hp'] : NULL));
break; break;
case "commitdiff_plain": case "commitdiff_plain":
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_commitdiff_plain.php'); include_once('include/display.git_commitdiff_plain.php');
git_commitdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],(isset($_GET['hp']) ? $_GET['hp'] : NULL)); git_commitdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],(isset($_GET['hp']) ? $_GET['hp'] : NULL));
break; break;
case "heads": case "heads":
include_once('include/display.git_heads.php'); include_once('include/display.git_heads.php');
git_heads($gitphp_conf['projectroot'],$_GET['p']); git_heads($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "tags": case "tags":
include_once('include/display.git_tags.php'); include_once('include/display.git_tags.php');
git_tags($gitphp_conf['projectroot'],$_GET['p']); git_tags($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "rss": case "rss":
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_rss.php'); include_once('include/display.git_rss.php');
git_rss($gitphp_conf['projectroot'],$_GET['p']); git_rss($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "blob": case "blob":
include_once('include/display.git_blob.php'); include_once('include/display.git_blob.php');
git_blob($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['f']) ? $_GET['f'] : NULL), (isset($_GET['hb']) ? $_GET['hb'] : NULL)); git_blob($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['f']) ? $_GET['f'] : NULL), (isset($_GET['hb']) ? $_GET['hb'] : NULL));
break; break;
case "blob_plain": case "blob_plain":
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_blob_plain.php'); include_once('include/display.git_blob_plain.php');
git_blob_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],(isset($_GET['f']) ? $_GET['f'] : NULL)); git_blob_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],(isset($_GET['f']) ? $_GET['f'] : NULL));
break; break;
case "blobdiff": case "blobdiff":
include_once('include/display.git_blobdiff.php'); include_once('include/display.git_blobdiff.php');
git_blobdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'],(isset($_GET['f']) ? $_GET['f'] : NULL)); git_blobdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'],(isset($_GET['f']) ? $_GET['f'] : NULL));
break; break;
case "blobdiff_plain": case "blobdiff_plain":
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_blobdiff_plain.php'); include_once('include/display.git_blobdiff_plain.php');
git_blobdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'], (isset($_GET['f']) ? $_GET['f'] : NULL)); git_blobdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'], (isset($_GET['f']) ? $_GET['f'] : NULL));
break; break;
case "snapshot": case "snapshot":
$suppress_headers = TRUE; $suppress_headers = TRUE;
include_once('include/display.git_snapshot.php'); include_once('include/display.git_snapshot.php');
git_snapshot($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL)); git_snapshot($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL));
break; break;
case "history": case "history":
include_once('include/display.git_history.php'); include_once('include/display.git_history.php');
git_history($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL),$_GET['f']); git_history($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL),$_GET['f']);
break; break;
case "search": case "search":
include_once('include/display.git_search.php'); include_once('include/display.git_search.php');
git_search($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL),(isset($_GET['s']) ? $_GET['s'] : NULL),(isset($_GET['st']) ? $_GET['st'] : "commit"),(isset($_GET['pg']) ? $_GET['pg'] : 0)); git_search($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL),(isset($_GET['s']) ? $_GET['s'] : NULL),(isset($_GET['st']) ? $_GET['st'] : "commit"),(isset($_GET['pg']) ? $_GET['pg'] : 0));
break; break;
default: default:
echo "Unknown action"; echo "Unknown action";
break; break;
} }
} }
} }
} else { } else {
$tpl->display("hometext.tpl"); $tpl->display("hometext.tpl");
include_once('include/display.git_project_list.php'); include_once('include/display.git_project_list.php');
git_project_list($gitphp_conf['projectroot'],$git_projects,(isset($_GET['o']) ? $_GET['o'] : "project")); git_project_list($gitphp_conf['projectroot'],$git_projects,(isset($_GET['o']) ? $_GET['o'] : "project"));
} }
$main = ob_get_contents(); $main = ob_get_contents();
ob_end_clean(); ob_end_clean();
   
if (!$suppress_headers) { if (!$suppress_headers) {
$tpl->clear_all_assign(); $tpl->clear_all_assign();
$tpl->assign("stylesheet",$gitphp_conf['stylesheet']); $tpl->assign("stylesheet",$gitphp_conf['stylesheet']);
$tpl->assign("version",$gitphp_version); $tpl->assign("version",$gitphp_version);
$title = $gitphp_conf['title']; $title = $gitphp_conf['title'];
if ($rss_link) { if ($rss_link) {
$tpl->assign("rss_link",TRUE); $tpl->assign("rss_link",TRUE);
$tpl->assign("project",$_GET['p']); $tpl->assign("project",$_GET['p']);
$title .= " :: " . $_GET['p']; $title .= " :: " . $_GET['p'];
if (isset($_GET['a'])) { if (isset($_GET['a'])) {
$tpl->assign("action",$_GET['a']); $tpl->assign("action",$_GET['a']);
$title .= "/" . $_GET['a']; $title .= "/" . $_GET['a'];
} }
} }
$tpl->assign("title",$title); $tpl->assign("title",$title);
if (isset($_GET['st'])) if (isset($_GET['st']))
$tpl->assign("searchtype",$_GET['st']); $tpl->assign("searchtype",$_GET['st']);
else else
$tpl->assign("searchtype","commit"); $tpl->assign("searchtype","commit");
if (isset($_GET['s'])) if (isset($_GET['s']))
$tpl->assign("search",$_GET['s']); $tpl->assign("search",$_GET['s']);
if (isset($_GET['hb'])) if (isset($_GET['hb']))
$tpl->assign("hash",$_GET['hb']); $tpl->assign("hash",$_GET['hb']);
else if (isset($_GET['h'])) else if (isset($_GET['h']))
$tpl->assign("hash",$_GET['h']); $tpl->assign("hash",$_GET['h']);
  if ($gitphp_conf['search'])
  $tpl->assign("enablesearch",TRUE);
$tpl->display("header.tpl"); $tpl->display("header.tpl");
} }
   
echo $main; echo $main;
   
if (!$suppress_headers) { if (!$suppress_headers) {
if ($rss_link) { if ($rss_link) {
$tpl->assign("project",$_GET['p']); $tpl->assign("project",$_GET['p']);
include_once('include/gitutil.git_project_descr.php'); include_once('include/gitutil.git_project_descr.php');
$tpl->assign("descr",git_project_descr($gitphp_conf['projectroot'],$_GET['p'])); $tpl->assign("descr",git_project_descr($gitphp_conf['projectroot'],$_GET['p']));
} }
$tpl->display("footer.tpl"); $tpl->display("footer.tpl");
} }
   
ob_end_flush(); ob_end_flush();
   
?> ?>
   
{* {*
* header.tpl * header.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Page header template * Component: Page header template
* *
* Copyright (C) 2006 Christopher Han <xiphux@gmail.com> * Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
*} *}
{* $contentType = strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') === false ? 'text/html' : 'application/xhtml+xml'; {* $contentType = strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') === false ? 'text/html' : 'application/xhtml+xml';
header("Content-Type: $contentType; charset=utf-8"); *} header("Content-Type: $contentType; charset=utf-8"); *}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<!-- gitphp web interface {$version}, (C) 2006 Christopher Han <xiphux@gmail.com> --> <!-- gitphp web interface {$version}, (C) 2006 Christopher Han <xiphux@gmail.com> -->
<head> <head>
<title>{$title}</title> <title>{$title}</title>
{if $rss_link} {if $rss_link}
<link rel="alternate" title="{$project} log" href="{$SCRIPT_NAME}?p={$project}&a=rss" type="application/rss+xml" /> <link rel="alternate" title="{$project} log" href="{$SCRIPT_NAME}?p={$project}&a=rss" type="application/rss+xml" />
{/if} {/if}
<link rel="stylesheet" href="{$stylesheet}" type="text/css" /> <link rel="stylesheet" href="{$stylesheet}" type="text/css" />
{$smarty.capture.header} {$smarty.capture.header}
</head> </head>
<body> <body>
<div class="page_header"> <div class="page_header">
<a href="http://www.kernel.org/pub/software/scm/git/docs/" title="git documentation"> <a href="http://www.kernel.org/pub/software/scm/git/docs/" title="git documentation">
<img src="git-logo.png" width="72" height="27" alt="git" class="logo" /> <img src="git-logo.png" width="72" height="27" alt="git" class="logo" />
</a> </a>
<a href="index.php">projects</a> / <a href="index.php">projects</a> /
{if $project} {if $project}
<a href="{$SCRIPT_NAME}?p={$project}&a=summary">{$project}</a> <a href="{$SCRIPT_NAME}?p={$project}&a=summary">{$project}</a>
{if $action} {if $action}
/ {$action} / {$action}
{/if} {/if}
  {if $enablesearch}
<form method="get" action="index.php" enctype="application/x-www-form-urlencoded"> <form method="get" action="index.php" enctype="application/x-www-form-urlencoded">
<div class="search"> <div class="search">
<input type="hidden" name="p" value="{$project}" /> <input type="hidden" name="p" value="{$project}" />
<input type="hidden" name="a" value="search" /> <input type="hidden" name="a" value="search" />
<input type="hidden" name="h" value="{if $hash}{$hash}{else}HEAD{/if}" /> <input type="hidden" name="h" value="{if $hash}{$hash}{else}HEAD{/if}" />
<select name="st"> <select name="st">
<option {if $searchtype == 'commit'}selected="selected"{/if} value="commit">commit</option> <option {if $searchtype == 'commit'}selected="selected"{/if} value="commit">commit</option>
<option {if $searchtype == 'author'}selected="selected"{/if} value="author">author</option> <option {if $searchtype == 'author'}selected="selected"{/if} value="author">author</option>
<option {if $searchtype == 'committer'}selected="selected"{/if} value="committer">committer</option> <option {if $searchtype == 'committer'}selected="selected"{/if} value="committer">committer</option>
</select> search: <input type="text" name="s" {if $search}value="{$search}"{/if} /> </select> search: <input type="text" name="s" {if $search}value="{$search}"{/if} />
</div> </div>
</form> </form>
  {/if}
{/if} {/if}
</div> </div>
   
comments