Switch to gettext for i18n
Switch to gettext for i18n

<?php <?php
/** /**
* GitPHP ControllerBase * GitPHP ControllerBase
* *
* Base class that all controllers extend * Base class that all controllers extend
* *
* @author Christopher Han <xiphux@gmail.com * @author Christopher Han <xiphux@gmail.com
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* ControllerBase class * ControllerBase class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
* @abstract * @abstract
*/ */
abstract class GitPHP_ControllerBase abstract class GitPHP_ControllerBase
{ {
   
/** /**
* tpl * tpl
* *
* Smarty instance * Smarty instance
* *
* @access protected * @access protected
*/ */
protected $tpl; protected $tpl;
   
/** /**
* project * project
* *
* Current project * Current project
* *
* @access protected * @access protected
*/ */
protected $project; protected $project;
   
/** /**
* params * params
* *
* Parameters * Parameters
* *
* @access protected * @access protected
*/ */
protected $params = array(); protected $params = array();
   
/** /**
* headers * headers
* *
* Headers * Headers
* *
* @access protected * @access protected
*/ */
protected $headers = array(); protected $headers = array();
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return mixed controller object * @return mixed controller object
* @throws Exception on invalid project * @throws Exception on invalid project
*/ */
public function __construct() public function __construct()
{ {
require_once(GitPHP_Config::GetInstance()->GetValue('smarty_prefix', 'lib/smarty/libs/') . 'Smarty.class.php'); require_once(GitPHP_Config::GetInstance()->GetValue('smarty_prefix', 'lib/smarty/libs/') . 'Smarty.class.php');
$this->tpl = new Smarty; $this->tpl = new Smarty;
$this->tpl->plugins_dir[] = GITPHP_INCLUDEDIR . 'smartyplugins'; $this->tpl->plugins_dir[] = GITPHP_INCLUDEDIR . 'smartyplugins';
   
if (GitPHP_Config::GetInstance()->GetValue('cache', false)) { if (GitPHP_Config::GetInstance()->GetValue('cache', false)) {
$this->tpl->caching = 2; $this->tpl->caching = 2;
if (GitPHP_Config::GetInstance()->HasKey('cachelifetime')) { if (GitPHP_Config::GetInstance()->HasKey('cachelifetime')) {
$this->tpl->cache_lifetime = GitPHP_Config::GetInstance()->GetValue('cachelifetime'); $this->tpl->cache_lifetime = GitPHP_Config::GetInstance()->GetValue('cachelifetime');
} }
} }
   
if (isset($_GET['p'])) { if (isset($_GET['p'])) {
$this->project = GitPHP_ProjectList::GetInstance()->GetProject(str_replace(chr(0), '', $_GET['p'])); $this->project = GitPHP_ProjectList::GetInstance()->GetProject(str_replace(chr(0), '', $_GET['p']));
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->Format('Invalid project %1$s', $_GET['p']), true); throw new GitPHP_MessageException(sprintf(GitPHP_Resource::GetInstance()->translate('Invalid project %1$s'), $_GET['p']), true);
} }
} }
   
if (isset($_GET['s'])) if (isset($_GET['s']))
$this->params['search'] = $_GET['s']; $this->params['search'] = $_GET['s'];
if (isset($_GET['st'])) if (isset($_GET['st']))
$this->params['searchtype'] = $_GET['st']; $this->params['searchtype'] = $_GET['st'];
   
$this->ReadQuery(); $this->ReadQuery();
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @abstract * @abstract
* @return string template filename * @return string template filename
*/ */
protected abstract function GetTemplate(); protected abstract function GetTemplate();
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @abstract * @abstract
* @return string cache key * @return string cache key
*/ */
protected abstract function GetCacheKey(); protected abstract function GetCacheKey();
   
/** /**
* GetCacheKeyPrefix * GetCacheKeyPrefix
* *
* Get the prefix for all cache keys * Get the prefix for all cache keys
* *
* @access private * @access private
* @return string cache key prefix * @return string cache key prefix
*/ */
private function GetCacheKeyPrefix() private function GetCacheKeyPrefix()
{ {
$cacheKeyPrefix = ''; $cacheKeyPrefix = '';
   
$projList = GitPHP_ProjectList::GetInstance(); $projList = GitPHP_ProjectList::GetInstance();
if ($projList) { if ($projList) {
$cacheKeyPrefix = sha1(serialize($projList->GetConfig())); $cacheKeyPrefix = sha1(serialize($projList->GetConfig()));
unset($projList); unset($projList);
} }
if ($this->project) { if ($this->project) {
$cacheKeyPrefix .= '|' . sha1($this->project->GetProject()); $cacheKeyPrefix .= '|' . sha1($this->project->GetProject());
} }
return $cacheKeyPrefix; return $cacheKeyPrefix;
} }
   
/** /**
* GetFullCacheKey * GetFullCacheKey
* *
* Get the full cache key * Get the full cache key
* *
* @access protected * @access protected
* @return string full cache key * @return string full cache key
*/ */
protected function GetFullCacheKey() protected function GetFullCacheKey()
{ {
$cacheKey = $this->GetCacheKeyPrefix(); $cacheKey = $this->GetCacheKeyPrefix();
   
$subCacheKey = $this->GetCacheKey(); $subCacheKey = $this->GetCacheKey();
   
if (!empty($subCacheKey)) if (!empty($subCacheKey))
$cacheKey .= '|' . $subCacheKey; $cacheKey .= '|' . $subCacheKey;
   
return $cacheKey; return $cacheKey;
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @abstract * @abstract
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public abstract function GetName(); public abstract function GetName($local);
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @abstract * @abstract
* @access prtected * @access prtected
*/ */
protected abstract function ReadQuery(); protected abstract function ReadQuery();
   
/** /**
* SetParam * SetParam
* *
* Set a parameter * Set a parameter
* *
* @access protected * @access protected
* @param string $key key to set * @param string $key key to set
* @param mixed $value value to set * @param mixed $value value to set
*/ */
public function SetParam($key, $value) public function SetParam($key, $value)
{ {
if (empty($key)) if (empty($key))
return; return;
   
if (empty($value)) if (empty($value))
unset($this->params[$key]); unset($this->params[$key]);
   
$this->params[$key] = $value; $this->params[$key] = $value;
} }
   
/** /**
* LoadHeaders * LoadHeaders
* *
* Loads headers for this template * Loads headers for this template
* *
* @access protected * @access protected
*/ */
protected function LoadHeaders() protected function LoadHeaders()
{ {
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
* @abstract * @abstract
*/ */
protected abstract function LoadData(); protected abstract function LoadData();
   
/** /**
* LoadCommonData * LoadCommonData
* *
* Loads common data used by all templates * Loads common data used by all templates
* *
* @access private * @access private
*/ */
private function LoadCommonData() private function LoadCommonData()
{ {
global $gitphp_version, $gitphp_appstring; global $gitphp_version, $gitphp_appstring;
   
$this->tpl->assign('version', $gitphp_version); $this->tpl->assign('version', $gitphp_version);
$this->tpl->assign('stylesheet', GitPHP_Config::GetInstance()->GetValue('stylesheet', 'gitphp.css')); $this->tpl->assign('stylesheet', GitPHP_Config::GetInstance()->GetValue('stylesheet', 'gitphp.css'));
$this->tpl->assign('javascript', GitPHP_Config::GetInstance()->GetValue('javascript', true)); $this->tpl->assign('javascript', GitPHP_Config::GetInstance()->GetValue('javascript', true));
$this->tpl->assign('pagetitle', GitPHP_Config::GetInstance()->GetValue('title', $gitphp_appstring)); $this->tpl->assign('pagetitle', GitPHP_Config::GetInstance()->GetValue('title', $gitphp_appstring));
$this->tpl->assign('action', $this->GetName()); $this->tpl->assign('action', $this->GetName());
  $this->tpl->assign('actionlocal', $this->GetName(true));
if ($this->project) if ($this->project)
$this->tpl->assign('project', $this->project); $this->tpl->assign('project', $this->project);
if (GitPHP_Config::GetInstance()->GetValue('search', true)) if (GitPHP_Config::GetInstance()->GetValue('search', true))
$this->tpl->assign('enablesearch', true); $this->tpl->assign('enablesearch', true);
if (GitPHP_Config::GetInstance()->GetValue('filesearch', true)) if (GitPHP_Config::GetInstance()->GetValue('filesearch', true))
$this->tpl->assign('filesearch', true); $this->tpl->assign('filesearch', true);
if (isset($this->params['search'])) if (isset($this->params['search']))
$this->tpl->assign('search', $this->params['search']); $this->tpl->assign('search', $this->params['search']);
if (isset($this->params['searchtype'])) if (isset($this->params['searchtype']))
$this->tpl->assign('searchtype', $this->params['searchtype']); $this->tpl->assign('searchtype', $this->params['searchtype']);
$this->tpl->assign('resources', GitPHP_Resource::GetInstance()); $this->tpl->assign('resources', GitPHP_Resource::GetInstance());
} }
   
/** /**
* RenderHeaders * RenderHeaders
* *
* Renders any special headers * Renders any special headers
* *
* @access public * @access public
*/ */
public function RenderHeaders() public function RenderHeaders()
{ {
$this->LoadHeaders(); $this->LoadHeaders();
   
if (count($this->headers) > 0) { if (count($this->headers) > 0) {
foreach ($this->headers as $hdr) { foreach ($this->headers as $hdr) {
header($hdr); header($hdr);
} }
} }
} }
   
/** /**
* Render * Render
* *
* Renders the output * Renders the output
* *
* @access public * @access public
*/ */
public function Render() public function Render()
{ {
if ((GitPHP_Config::GetInstance()->GetValue('cache', false) == true) && (GitPHP_Config::GetInstance()->GetValue('cacheexpire', true) === true)) if ((GitPHP_Config::GetInstance()->GetValue('cache', false) == true) && (GitPHP_Config::GetInstance()->GetValue('cacheexpire', true) === true))
$this->CacheExpire(); $this->CacheExpire();
   
if (!$this->tpl->is_cached($this->GetTemplate(), $this->GetFullCacheKey())) { if (!$this->tpl->is_cached($this->GetTemplate(), $this->GetFullCacheKey())) {
$this->tpl->clear_all_assign(); $this->tpl->clear_all_assign();
$this->LoadCommonData(); $this->LoadCommonData();
$this->LoadData(); $this->LoadData();
} }
   
$this->tpl->display($this->GetTemplate(), $this->GetFullCacheKey()); $this->tpl->display($this->GetTemplate(), $this->GetFullCacheKey());
} }
   
/** /**
* CacheExpire * CacheExpire
* *
* Expires the cache * Expires the cache
* *
* @access public * @access public
* @param boolean $expireAll expire the whole cache * @param boolean $expireAll expire the whole cache
*/ */
public function CacheExpire($expireAll = false) public function CacheExpire($expireAll = false)
{ {
if ($expireAll) { if ($expireAll) {
$this->tpl->clear_all_cache(); $this->tpl->clear_all_cache();
return; return;
} }
   
if (!$this->project) if (!$this->project)
return; return;
   
$headList = $this->project->GetHeads(); $headList = $this->project->GetHeads();
   
if (count($headList) > 0) { if (count($headList) > 0) {
$age = $headList[0]->GetCommit()->GetAge(); $age = $headList[0]->GetCommit()->GetAge();
   
$this->tpl->clear_cache(null, $this->GetCacheKeyPrefix(), null, $age); $this->tpl->clear_cache(null, $this->GetCacheKeyPrefix(), null, $age);
$this->tpl->clear_cache('projectlist.tpl', sha1(serialize(GitPHP_ProjectList::GetInstance()->GetConfig())), null, $age); $this->tpl->clear_cache('projectlist.tpl', sha1(serialize(GitPHP_ProjectList::GetInstance()->GetConfig())), null, $age);
} }
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Blame * GitPHP Controller Blame
* *
* Controller for displaying blame * Controller for displaying blame
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Blame controller class * Blame controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Blame extends GitPHP_ControllerBase class GitPHP_Controller_Blame extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
if (isset($this->params['js']) && $this->params['js']) { if (isset($this->params['js']) && $this->params['js']) {
return 'blamedata.tpl'; return 'blamedata.tpl';
} }
return 'blame.tpl'; return 'blame.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return (isset($this->params['hashbase']) ? $this->params['hashbase'] : '') . '|' . (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : ''); return (isset($this->params['hashbase']) ? $this->params['hashbase'] : '') . '|' . (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : '');
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('blame');
  }
return 'blame'; return 'blame';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['hb'])) if (isset($_GET['hb']))
$this->params['hashbase'] = $_GET['hb']; $this->params['hashbase'] = $_GET['hb'];
else else
$this->params['hashbase'] = 'HEAD'; $this->params['hashbase'] = 'HEAD';
if (isset($_GET['f'])) if (isset($_GET['f']))
$this->params['file'] = $_GET['f']; $this->params['file'] = $_GET['f'];
if (isset($_GET['h'])) { if (isset($_GET['h'])) {
$this->params['hash'] = $_GET['h']; $this->params['hash'] = $_GET['h'];
} }
if (isset($_GET['o']) && ($_GET['o'] == 'js')) { if (isset($_GET['o']) && ($_GET['o'] == 'js')) {
$this->params['js'] = true; $this->params['js'] = true;
GitPHP_Log::GetInstance()->SetEnabled(false); GitPHP_Log::GetInstance()->SetEnabled(false);
} }
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$head = $this->project->GetHeadCommit(); $head = $this->project->GetHeadCommit();
$this->tpl->assign('head', $head); $this->tpl->assign('head', $head);
   
$commit = $this->project->GetCommit($this->params['hashbase']); $commit = $this->project->GetCommit($this->params['hashbase']);
$this->tpl->assign('commit', $commit); $this->tpl->assign('commit', $commit);
   
if ((!isset($this->params['hash'])) && (isset($this->params['file']))) { if ((!isset($this->params['hash'])) && (isset($this->params['file']))) {
$this->params['hash'] = $commit->PathToHash($this->params['file']); $this->params['hash'] = $commit->PathToHash($this->params['file']);
} }
$blob = $this->project->GetBlob($this->params['hash']); $blob = $this->project->GetBlob($this->params['hash']);
if ($this->params['file']) if ($this->params['file'])
$blob->SetPath($this->params['file']); $blob->SetPath($this->params['file']);
$blob->SetCommit($commit); $blob->SetCommit($commit);
$this->tpl->assign('blob', $blob); $this->tpl->assign('blob', $blob);
   
$blame = $blob->GetBlame(); $blame = $blob->GetBlame();
$this->tpl->assign('blame', $blob->GetBlame()); $this->tpl->assign('blame', $blob->GetBlame());
   
if (isset($this->params['js']) && $this->params['js']) { if (isset($this->params['js']) && $this->params['js']) {
return; return;
} }
   
$this->tpl->assign('tree', $commit->GetTree()); $this->tpl->assign('tree', $commit->GetTree());
   
if (GitPHP_Config::GetInstance()->GetValue('geshi', true)) { if (GitPHP_Config::GetInstance()->GetValue('geshi', true)) {
include_once(GitPHP_Config::GetInstance()->GetValue('geshiroot', 'lib/geshi/') . "geshi.php"); include_once(GitPHP_Config::GetInstance()->GetValue('geshiroot', 'lib/geshi/') . "geshi.php");
if (class_exists('GeSHi')) { if (class_exists('GeSHi')) {
$geshi = new GeSHi("",'php'); $geshi = new GeSHi("",'php');
if ($geshi) { if ($geshi) {
$lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(),'.'),1)); $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(),'.'),1));
if (!empty($lang)) { if (!empty($lang)) {
$geshi->enable_classes(); $geshi->enable_classes();
$geshi->enable_strict_mode(GESHI_MAYBE); $geshi->enable_strict_mode(GESHI_MAYBE);
$geshi->set_source($blob->GetData()); $geshi->set_source($blob->GetData());
$geshi->set_language($lang); $geshi->set_language($lang);
$geshi->set_header_type(GESHI_HEADER_PRE_TABLE); $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$output = $geshi->parse_code(); $output = $geshi->parse_code();
   
$bodystart = strpos($output, '<td'); $bodystart = strpos($output, '<td');
$bodyend = strrpos($output, '</tr>'); $bodyend = strrpos($output, '</tr>');
   
if (($bodystart !== false) && ($bodyend !== false)) { if (($bodystart !== false) && ($bodyend !== false)) {
$geshihead = substr($output, 0, $bodystart); $geshihead = substr($output, 0, $bodystart);
$geshifoot = substr($output, $bodyend); $geshifoot = substr($output, $bodyend);
$geshibody = substr($output, $bodystart, $bodyend); $geshibody = substr($output, $bodystart, $bodyend);
   
$this->tpl->assign('geshihead', $geshihead); $this->tpl->assign('geshihead', $geshihead);
$this->tpl->assign('geshibody', $geshibody); $this->tpl->assign('geshibody', $geshibody);
$this->tpl->assign('geshifoot', $geshifoot); $this->tpl->assign('geshifoot', $geshifoot);
$this->tpl->assign('extracss', $geshi->get_stylesheet()); $this->tpl->assign('extracss', $geshi->get_stylesheet());
$this->tpl->assign('geshi', true); $this->tpl->assign('geshi', true);
} }
} }
} }
} }
} }
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Blob * GitPHP Controller Blob
* *
* Controller for displaying a blob * Controller for displaying a blob
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Blob controller class * Blob controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Blob extends GitPHP_ControllerBase class GitPHP_Controller_Blob extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
if (isset($this->params['plain']) && $this->params['plain']) if (isset($this->params['plain']) && $this->params['plain'])
return 'blobplain.tpl'; return 'blobplain.tpl';
return 'blob.tpl'; return 'blob.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return (isset($this->params['hashbase']) ? $this->params['hashbase'] : '') . '|' . (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : ''); return (isset($this->params['hashbase']) ? $this->params['hashbase'] : '') . '|' . (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : '');
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('blob');
  }
return 'blob'; return 'blob';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['hb'])) if (isset($_GET['hb']))
$this->params['hashbase'] = $_GET['hb']; $this->params['hashbase'] = $_GET['hb'];
else else
$this->params['hashbase'] = 'HEAD'; $this->params['hashbase'] = 'HEAD';
if (isset($_GET['f'])) if (isset($_GET['f']))
$this->params['file'] = $_GET['f']; $this->params['file'] = $_GET['f'];
if (isset($_GET['h'])) { if (isset($_GET['h'])) {
$this->params['hash'] = $_GET['h']; $this->params['hash'] = $_GET['h'];
} }
} }
   
/** /**
* LoadHeaders * LoadHeaders
* *
* Loads headers for this template * Loads headers for this template
* *
* @access protected * @access protected
*/ */
protected function LoadHeaders() protected function LoadHeaders()
{ {
if (isset($this->params['plain']) && $this->params['plain']) { if (isset($this->params['plain']) && $this->params['plain']) {
   
GitPHP_Log::GetInstance()->SetEnabled(false); GitPHP_Log::GetInstance()->SetEnabled(false);
   
// XXX: Nasty hack to cache headers // XXX: Nasty hack to cache headers
if (!$this->tpl->is_cached('blobheaders.tpl', $this->GetFullCacheKey())) { if (!$this->tpl->is_cached('blobheaders.tpl', $this->GetFullCacheKey())) {
if (isset($this->params['file'])) if (isset($this->params['file']))
$saveas = $this->params['file']; $saveas = $this->params['file'];
else else
$saveas = $this->params['hash'] . ".txt"; $saveas = $this->params['hash'] . ".txt";
   
$blob = $this->project->GetBlob($this->params['hash']); $blob = $this->project->GetBlob($this->params['hash']);
$blob->SetPath($this->params['file']); $blob->SetPath($this->params['file']);
   
$headers = array(); $headers = array();
   
if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true)) if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true))
$mime = $blob->FileMime(); $mime = $blob->FileMime();
   
if ($mime) if ($mime)
$headers[] = "Content-type: " . $mime; $headers[] = "Content-type: " . $mime;
else else
$headers[] = "Content-type: text/plain; charset=UTF-8"; $headers[] = "Content-type: text/plain; charset=UTF-8";
   
$headers[] = "Content-disposition: inline; filename=\"" . $saveas . "\""; $headers[] = "Content-disposition: inline; filename=\"" . $saveas . "\"";
   
$this->tpl->assign("blobheaders", serialize($headers)); $this->tpl->assign("blobheaders", serialize($headers));
} }
$out = $this->tpl->fetch('blobheaders.tpl', $this->GetFullCacheKey()); $out = $this->tpl->fetch('blobheaders.tpl', $this->GetFullCacheKey());
   
$this->headers = unserialize($out); $this->headers = unserialize($out);
} }
   
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$commit = $this->project->GetCommit($this->params['hashbase']); $commit = $this->project->GetCommit($this->params['hashbase']);
$this->tpl->assign('commit', $commit); $this->tpl->assign('commit', $commit);
   
if ((!isset($this->params['hash'])) && (isset($this->params['file']))) { if ((!isset($this->params['hash'])) && (isset($this->params['file']))) {
$this->params['hash'] = $commit->PathToHash($this->params['file']); $this->params['hash'] = $commit->PathToHash($this->params['file']);
} }
   
$blob = $this->project->GetBlob($this->params['hash']); $blob = $this->project->GetBlob($this->params['hash']);
if ($this->params['file']) if ($this->params['file'])
$blob->SetPath($this->params['file']); $blob->SetPath($this->params['file']);
$blob->SetCommit($commit); $blob->SetCommit($commit);
$this->tpl->assign('blob', $blob); $this->tpl->assign('blob', $blob);
   
if (isset($this->params['plain']) && $this->params['plain']) { if (isset($this->params['plain']) && $this->params['plain']) {
return; return;
} }
   
$head = $this->project->GetHeadCommit(); $head = $this->project->GetHeadCommit();
$this->tpl->assign('head', $head); $this->tpl->assign('head', $head);
   
$this->tpl->assign('tree', $commit->GetTree()); $this->tpl->assign('tree', $commit->GetTree());
   
if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true)) { if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true)) {
$mime = $blob->FileMime(); $mime = $blob->FileMime();
if ($mime) if ($mime)
$mimetype = strtok($mime, '/'); $mimetype = strtok($mime, '/');
} }
   
if ($mime && (strtok($mime, '/') == 'image')) { if ($mime && (strtok($mime, '/') == 'image')) {
$this->tpl->assign('datatag', true); $this->tpl->assign('datatag', true);
$this->tpl->assign('mime', $mime); $this->tpl->assign('mime', $mime);
$this->tpl->assign('data', base64_encode($blob->GetData())); $this->tpl->assign('data', base64_encode($blob->GetData()));
return; return;
} }
   
$this->tpl->assign('extrascripts', array('js/blame.js')); $this->tpl->assign('extrascripts', array('js/blame.js'));
   
if (GitPHP_Config::GetInstance()->GetValue('geshi', true)) { if (GitPHP_Config::GetInstance()->GetValue('geshi', true)) {
include_once(GitPHP_Config::GetInstance()->GetValue('geshiroot', 'lib/geshi/') . "geshi.php"); include_once(GitPHP_Config::GetInstance()->GetValue('geshiroot', 'lib/geshi/') . "geshi.php");
if (class_exists('GeSHi')) { if (class_exists('GeSHi')) {
$geshi = new GeSHi("",'php'); $geshi = new GeSHi("",'php');
if ($geshi) { if ($geshi) {
$lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(),'.'),1)); $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(),'.'),1));
if (!empty($lang)) { if (!empty($lang)) {
$geshi->enable_classes(); $geshi->enable_classes();
$geshi->enable_strict_mode(GESHI_MAYBE); $geshi->enable_strict_mode(GESHI_MAYBE);
$geshi->set_source($blob->GetData()); $geshi->set_source($blob->GetData());
$geshi->set_language($lang); $geshi->set_language($lang);
$geshi->set_header_type(GESHI_HEADER_PRE_TABLE); $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$geshi->set_overall_id('blobData'); $geshi->set_overall_id('blobData');
$this->tpl->assign('geshiout', $geshi->parse_code()); $this->tpl->assign('geshiout', $geshi->parse_code());
$this->tpl->assign('extracss', $geshi->get_stylesheet()); $this->tpl->assign('extracss', $geshi->get_stylesheet());
$this->tpl->assign('geshi', true); $this->tpl->assign('geshi', true);
return; return;
} }
} }
} }
} }
   
$this->tpl->assign('bloblines', $blob->GetData(true)); $this->tpl->assign('bloblines', $blob->GetData(true));
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Blobdiff * GitPHP Controller Blobdiff
* *
* Controller for displaying a blobdiff * Controller for displaying a blobdiff
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Blobdiff controller class * Blobdiff controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Blobdiff extends GitPHP_ControllerBase class GitPHP_Controller_Blobdiff extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
if (isset($this->params['plain']) && ($this->params['plain'] === true)) { if (isset($this->params['plain']) && ($this->params['plain'] === true)) {
return 'blobdiffplain.tpl'; return 'blobdiffplain.tpl';
} }
return 'blobdiff.tpl'; return 'blobdiff.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return (isset($this->params['hashbase']) ? $this->params['hashbase'] : '') . '|' . (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['hashparent']) ? $this->params['hashparent'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : ''); return (isset($this->params['hashbase']) ? $this->params['hashbase'] : '') . '|' . (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['hashparent']) ? $this->params['hashparent'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : '');
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('blobdiff');
  }
return 'blobdiff'; return 'blobdiff';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['f'])) if (isset($_GET['f']))
$this->params['file'] = $_GET['f']; $this->params['file'] = $_GET['f'];
if (isset($_GET['h'])) if (isset($_GET['h']))
$this->params['hash'] = $_GET['h']; $this->params['hash'] = $_GET['h'];
if (isset($_GET['hb'])) if (isset($_GET['hb']))
$this->params['hashbase'] = $_GET['hb']; $this->params['hashbase'] = $_GET['hb'];
if (isset($_GET['hp'])) if (isset($_GET['hp']))
$this->params['hashparent'] = $_GET['hp']; $this->params['hashparent'] = $_GET['hp'];
} }
   
/** /**
* LoadHeaders * LoadHeaders
* *
* Loads headers for this template * Loads headers for this template
* *
* @access protected * @access protected
*/ */
protected function LoadHeaders() protected function LoadHeaders()
{ {
if (isset($this->params['plain']) && ($this->params['plain'] === true)) { if (isset($this->params['plain']) && ($this->params['plain'] === true)) {
$this->headers[] = 'Content-type: text/plain; charset=UTF-8'; $this->headers[] = 'Content-type: text/plain; charset=UTF-8';
} }
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
if (isset($this->params['file'])) if (isset($this->params['file']))
$this->tpl->assign('file', $this->params['file']); $this->tpl->assign('file', $this->params['file']);
   
$filediff = new GitPHP_FileDiff($this->project, $this->params['hashparent'], $this->params['hash']); $filediff = new GitPHP_FileDiff($this->project, $this->params['hashparent'], $this->params['hash']);
$this->tpl->assign('filediff', $filediff); $this->tpl->assign('filediff', $filediff);
   
if (isset($this->params['plain']) && ($this->params['plain'] === true)) { if (isset($this->params['plain']) && ($this->params['plain'] === true)) {
return; return;
} }
   
$commit = $this->project->GetCommit($this->params['hashbase']); $commit = $this->project->GetCommit($this->params['hashbase']);
$this->tpl->assign('commit', $commit); $this->tpl->assign('commit', $commit);
   
$blobparent = $this->project->GetBlob($this->params['hashparent']); $blobparent = $this->project->GetBlob($this->params['hashparent']);
$blobparent->SetCommit($commit); $blobparent->SetCommit($commit);
$blobparent->SetPath($this->params['file']); $blobparent->SetPath($this->params['file']);
$this->tpl->assign('blobparent', $blobparent); $this->tpl->assign('blobparent', $blobparent);
   
$blob = $this->project->GetBlob($this->params['hash']); $blob = $this->project->GetBlob($this->params['hash']);
$blob->SetPath($this->params['file']); $blob->SetPath($this->params['file']);
$this->tpl->assign('blob', $blob); $this->tpl->assign('blob', $blob);
   
$tree = $commit->GetTree(); $tree = $commit->GetTree();
$this->tpl->assign('tree', $tree); $this->tpl->assign('tree', $tree);
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Commit * GitPHP Controller Commit
* *
* Controller for displaying a commit * Controller for displaying a commit
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Commit controller class * Commit controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Commit extends GitPHP_ControllerBase class GitPHP_Controller_Commit extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
if (isset($this->params['jstip']) && $this->params['jstip']) { if (isset($this->params['jstip']) && $this->params['jstip']) {
return 'committip.tpl'; return 'committip.tpl';
} }
return 'commit.tpl'; return 'commit.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return $this->params['hash']; return $this->params['hash'];
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('commit');
  }
return 'commit'; return 'commit';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['h'])) if (isset($_GET['h']))
$this->params['hash'] = $_GET['h']; $this->params['hash'] = $_GET['h'];
else else
$this->params['hash'] = 'HEAD'; $this->params['hash'] = 'HEAD';
   
if (isset($_GET['o']) && ($_GET['o'] == 'jstip')) { if (isset($_GET['o']) && ($_GET['o'] == 'jstip')) {
$this->params['jstip'] = true; $this->params['jstip'] = true;
GitPHP_Log::GetInstance()->SetEnabled(false); GitPHP_Log::GetInstance()->SetEnabled(false);
} }
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$commit = $this->project->GetCommit($this->params['hash']); $commit = $this->project->GetCommit($this->params['hash']);
$this->tpl->assign('commit', $commit); $this->tpl->assign('commit', $commit);
$this->tpl->assign('tree', $commit->GetTree()); $this->tpl->assign('tree', $commit->GetTree());
$treediff = $commit->DiffToParent(); $treediff = $commit->DiffToParent();
$treediff->SetRenames(true); $treediff->SetRenames(true);
$this->tpl->assign('treediff', $treediff); $this->tpl->assign('treediff', $treediff);
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Commitdiff * GitPHP Controller Commitdiff
* *
* Controller for displaying a commitdiff * Controller for displaying a commitdiff
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Commitdiff controller class * Commitdiff controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Commitdiff extends GitPHP_ControllerBase class GitPHP_Controller_Commitdiff extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
if (isset($this->params['plain']) && ($this->params['plain'] === true)) { if (isset($this->params['plain']) && ($this->params['plain'] === true)) {
return 'commitdiffplain.tpl'; return 'commitdiffplain.tpl';
} }
return 'commitdiff.tpl'; return 'commitdiff.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['hashparent']) ? $this->params['hashparent'] : ''); return (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['hashparent']) ? $this->params['hashparent'] : '');
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('commitdiff');
  }
return 'commitdiff'; return 'commitdiff';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['h'])) if (isset($_GET['h']))
$this->params['hash'] = $_GET['h']; $this->params['hash'] = $_GET['h'];
if (isset($_GET['hp'])) if (isset($_GET['hp']))
$this->params['hashparent'] = $_GET['hp']; $this->params['hashparent'] = $_GET['hp'];
} }
   
/** /**
* LoadHeaders * LoadHeaders
* *
* Loads headers for this template * Loads headers for this template
* *
* @access protected * @access protected
*/ */
protected function LoadHeaders() protected function LoadHeaders()
{ {
if (isset($this->params['plain']) && ($this->params['plain'] === true)) { if (isset($this->params['plain']) && ($this->params['plain'] === true)) {
GitPHP_Log::GetInstance()->SetEnabled(false); GitPHP_Log::GetInstance()->SetEnabled(false);
   
$this->headers[] = 'Content-type: text/plain; charset=UTF-8'; $this->headers[] = 'Content-type: text/plain; charset=UTF-8';
$this->headers[] = 'Content-disposition: inline; filename="git-' . $this->params['hash'] . '.patch"'; $this->headers[] = 'Content-disposition: inline; filename="git-' . $this->params['hash'] . '.patch"';
} }
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$co = $this->project->GetCommit($this->params['hash']); $co = $this->project->GetCommit($this->params['hash']);
$this->tpl->assign('commit', $co); $this->tpl->assign('commit', $co);
   
if (isset($this->params['hashparent'])) { if (isset($this->params['hashparent'])) {
$this->tpl->assign("hashparent", $this->params['hashparent']); $this->tpl->assign("hashparent", $this->params['hashparent']);
} }
   
$treediff = new GitPHP_TreeDiff($this->project, $this->params['hash'], (isset($this->params['hashparent']) ? $this->params['hashparent'] : '')); $treediff = new GitPHP_TreeDiff($this->project, $this->params['hash'], (isset($this->params['hashparent']) ? $this->params['hashparent'] : ''));
$this->tpl->assign('treediff', $treediff); $this->tpl->assign('treediff', $treediff);
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Heads * GitPHP Controller Heads
* *
* Controller for displaying heads * Controller for displaying heads
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Heads controller class * Heads controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Heads extends GitPHP_ControllerBase class GitPHP_Controller_Heads extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
return 'heads.tpl'; return 'heads.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return ''; return '';
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('heads');
  }
return 'heads'; return 'heads';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$head = $this->project->GetHeadCommit(); $head = $this->project->GetHeadCommit();
$this->tpl->assign("head",$head); $this->tpl->assign("head",$head);
   
$headlist = $this->project->GetHeads(); $headlist = $this->project->GetHeads();
if (isset($headlist) && (count($headlist) > 0)) { if (isset($headlist) && (count($headlist) > 0)) {
$this->tpl->assign("headlist",$headlist); $this->tpl->assign("headlist",$headlist);
} }
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller History * GitPHP Controller History
* *
* Controller for displaying file history * Controller for displaying file history
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* History controller class * History controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_History extends GitPHP_ControllerBase class GitPHP_Controller_History extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
return 'history.tpl'; return 'history.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : ''); return (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : '');
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('history');
  }
return 'history'; return 'history';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['f'])) if (isset($_GET['f']))
$this->params['file'] = $_GET['f']; $this->params['file'] = $_GET['f'];
if (isset($_GET['h'])) { if (isset($_GET['h'])) {
$this->params['hash'] = $_GET['h']; $this->params['hash'] = $_GET['h'];
} else { } else {
$this->params['hash'] = 'HEAD'; $this->params['hash'] = 'HEAD';
} }
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$co = $this->project->GetCommit($this->params['hash']); $co = $this->project->GetCommit($this->params['hash']);
$this->tpl->assign('commit', $co); $this->tpl->assign('commit', $co);
$this->tpl->assign('tree', $co->GetTree()); $this->tpl->assign('tree', $co->GetTree());
   
$blobhash = $co->PathToHash($this->params['file']); $blobhash = $co->PathToHash($this->params['file']);
$blob = $this->project->GetBlob($blobhash); $blob = $this->project->GetBlob($blobhash);
$blob->SetCommit($co); $blob->SetCommit($co);
$blob->SetPath($this->params['file']); $blob->SetPath($this->params['file']);
$this->tpl->assign('blob', $blob); $this->tpl->assign('blob', $blob);
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Log * GitPHP Controller Log
* *
* Controller for displaying a log * Controller for displaying a log
* *
* @author Christopher Han * @author Christopher Han
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Log controller class * Log controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Log extends GitPHP_ControllerBase class GitPHP_Controller_Log extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
if (isset($this->params['short']) && ($this->params['short'] === true)) { if (isset($this->params['short']) && ($this->params['short'] === true)) {
return 'shortlog.tpl'; return 'shortlog.tpl';
} }
return 'log.tpl'; return 'log.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return $this->params['hash'] . '|' . $this->params['page']; return $this->params['hash'] . '|' . $this->params['page'];
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
if (isset($this->params['short']) && ($this->params['short'] === true)) { if (isset($this->params['short']) && ($this->params['short'] === true)) {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('shortlog');
  }
return 'shortlog'; return 'shortlog';
  }
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('log');
} }
return 'log'; return 'log';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['h'])) if (isset($_GET['h']))
$this->params['hash'] = $_GET['h']; $this->params['hash'] = $_GET['h'];
else else
$this->params['hash'] = 'HEAD'; $this->params['hash'] = 'HEAD';
if (isset($_GET['pg'])) if (isset($_GET['pg']))
$this->params['page'] = $_GET['pg']; $this->params['page'] = $_GET['pg'];
else else
$this->params['page'] = 0; $this->params['page'] = 0;
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$this->tpl->assign('commit', $this->project->GetCommit($this->params['hash'])); $this->tpl->assign('commit', $this->project->GetCommit($this->params['hash']));
$this->tpl->assign('head', $this->project->GetHeadCommit()); $this->tpl->assign('head', $this->project->GetHeadCommit());
$this->tpl->assign('page',$this->params['page']); $this->tpl->assign('page',$this->params['page']);
   
$revlist = $this->project->GetLog($this->params['hash'], 101, ($this->params['page'] * 100)); $revlist = $this->project->GetLog($this->params['hash'], 101, ($this->params['page'] * 100));
if ($revlist) { if ($revlist) {
if (count($revlist) > 100) { if (count($revlist) > 100) {
$this->tpl->assign('hasmorerevs', true); $this->tpl->assign('hasmorerevs', true);
$revlist = array_slice($revlist, 0, 100); $revlist = array_slice($revlist, 0, 100);
} }
$this->tpl->assign('revlist', $revlist); $this->tpl->assign('revlist', $revlist);
} }
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Message * GitPHP Controller Message
* *
* Controller for displaying a message page * Controller for displaying a message page
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Message controller class * Message controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Message extends GitPHP_ControllerBase class GitPHP_Controller_Message extends GitPHP_ControllerBase
{ {
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
try { try {
parent::__construct(); parent::__construct();
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
return 'message.tpl'; return 'message.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return sha1($this->params['message']) . '|' . ($this->params['error'] ? '1' : '0');; return sha1($this->params['message']) . '|' . ($this->params['error'] ? '1' : '0');;
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
// This isn't a real controller // This isn't a real controller
return ''; return '';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$this->tpl->assign('message', $this->params['message']); $this->tpl->assign('message', $this->params['message']);
if (isset($this->params['error']) && ($this->params['error'])) { if (isset($this->params['error']) && ($this->params['error'])) {
$this->tpl->assign('error', true); $this->tpl->assign('error', true);
} }
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Project * GitPHP Controller Project
* *
* Controller for displaying a project summary * Controller for displaying a project summary
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Project controller class * Project controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Project extends GitPHP_ControllerBase class GitPHP_Controller_Project extends GitPHP_ControllerBase
{ {
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
return 'project.tpl'; return 'project.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return ''; return '';
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('summary');
  }
return 'summary'; return 'summary';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$this->tpl->assign('head', $this->project->GetHeadCommit()); $this->tpl->assign('head', $this->project->GetHeadCommit());
   
$revlist = $this->project->GetLog('HEAD', 17); $revlist = $this->project->GetLog('HEAD', 17);
if ($revlist) { if ($revlist) {
if (count($revlist) > 16) { if (count($revlist) > 16) {
$this->tpl->assign('hasmorerevs', true); $this->tpl->assign('hasmorerevs', true);
$revlist = array_slice($revlist, 0, 16); $revlist = array_slice($revlist, 0, 16);
} }
$this->tpl->assign('revlist', $revlist); $this->tpl->assign('revlist', $revlist);
} }
   
$taglist = $this->project->GetTags(); $taglist = $this->project->GetTags();
if (isset($taglist) && (count($taglist) > 0)) { if (isset($taglist) && (count($taglist) > 0)) {
$this->tpl->assign("taglist",$taglist); $this->tpl->assign("taglist",$taglist);
} }
   
$headlist = $this->project->GetHeads(); $headlist = $this->project->GetHeads();
if (isset($headlist) && (count($headlist) > 0)) { if (isset($headlist) && (count($headlist) > 0)) {
$this->tpl->assign("headlist",$headlist); $this->tpl->assign("headlist",$headlist);
} }
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller ProjectList * GitPHP Controller ProjectList
* *
* Controller for listing projects * Controller for listing projects
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* ProjectList controller class * ProjectList controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_ProjectList extends GitPHP_ControllerBase class GitPHP_Controller_ProjectList extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
if (isset($this->params['opml']) && ($this->params['opml'] === true)) { if (isset($this->params['opml']) && ($this->params['opml'] === true)) {
return 'opml.tpl'; return 'opml.tpl';
} else if (isset($this->params['txt']) && ($this->params['txt'] === true)) { } else if (isset($this->params['txt']) && ($this->params['txt'] === true)) {
return 'projectindex.tpl'; return 'projectindex.tpl';
} }
return 'projectlist.tpl'; return 'projectlist.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
if (isset($this->params['opml']) && ($this->params['opml'] === true)) { if (isset($this->params['opml']) && ($this->params['opml'] === true)) {
return ''; return '';
} else if (isset($this->params['txt']) && ($this->params['txt'] === true)) { } else if (isset($this->params['txt']) && ($this->params['txt'] === true)) {
return ''; return '';
} }
return $this->params['order']; return $this->params['order'];
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
if (isset($this->params['opml']) && ($this->params['opml'] === true)) { if (isset($this->params['opml']) && ($this->params['opml'] === true)) {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('opml');
  }
return 'opml'; return 'opml';
} else if (isset($this->params['txt']) && ($this->params['txt'] === true)) { } else if (isset($this->params['txt']) && ($this->params['txt'] === true)) {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('project index');
  }
return 'project index'; return 'project index';
  }
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('projects');
} }
return 'projects'; return 'projects';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['o'])) if (isset($_GET['o']))
$this->params['order'] = $_GET['o']; $this->params['order'] = $_GET['o'];
else else
$this->params['order'] = 'project'; $this->params['order'] = 'project';
} }
   
/** /**
* LoadHeaders * LoadHeaders
* *
* Loads headers for this template * Loads headers for this template
* *
* @access protected * @access protected
*/ */
protected function LoadHeaders() protected function LoadHeaders()
{ {
if (isset($this->params['opml']) && ($this->params['opml'] === true)) { if (isset($this->params['opml']) && ($this->params['opml'] === true)) {
$this->headers[] = "Content-type: text/xml; charset=UTF-8"; $this->headers[] = "Content-type: text/xml; charset=UTF-8";
GitPHP_Log::GetInstance()->SetEnabled(false); GitPHP_Log::GetInstance()->SetEnabled(false);
} else if (isset($this->params['txt']) && ($this->params['txt'] === true)) { } else if (isset($this->params['txt']) && ($this->params['txt'] === true)) {
$this->headers[] = "Content-type: text/plain; charset=utf-8"; $this->headers[] = "Content-type: text/plain; charset=utf-8";
$this->headers[] = "Content-Disposition: inline; filename=\"index.aux\""; $this->headers[] = "Content-Disposition: inline; filename=\"index.aux\"";
GitPHP_Log::GetInstance()->SetEnabled(false); GitPHP_Log::GetInstance()->SetEnabled(false);
} }
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$this->tpl->assign('order', $this->params['order']); $this->tpl->assign('order', $this->params['order']);
$projectList = GitPHP_ProjectList::GetInstance(); $projectList = GitPHP_ProjectList::GetInstance();
$projectList->Sort($this->params['order']); $projectList->Sort($this->params['order']);
if ($projectList->Count() > 0) if ($projectList->Count() > 0)
$this->tpl->assign('projectlist', $projectList); $this->tpl->assign('projectlist', $projectList);
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller RSS * GitPHP Controller RSS
* *
* Controller for displaying a project's RSS * Controller for displaying a project's RSS
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
define('GITPHP_RSS_ITEMS', 150); define('GITPHP_RSS_ITEMS', 150);
   
/** /**
* RSS controller class * RSS controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Rss extends GitPHP_ControllerBase class GitPHP_Controller_Rss extends GitPHP_ControllerBase
{ {
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
return 'rss.tpl'; return 'rss.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return ''; return '';
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('rss');
  }
return 'rss'; return 'rss';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
GitPHP_Log::GetInstance()->SetEnabled(false); GitPHP_Log::GetInstance()->SetEnabled(false);
} }
   
/** /**
* LoadHeaders * LoadHeaders
* *
* Loads headers for this template * Loads headers for this template
* *
* @access protected * @access protected
*/ */
protected function LoadHeaders() protected function LoadHeaders()
{ {
$this->headers[] = "Content-type: text/xml; charset=UTF-8"; $this->headers[] = "Content-type: text/xml; charset=UTF-8";
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$log = $this->project->GetLog('HEAD', GITPHP_RSS_ITEMS); $log = $this->project->GetLog('HEAD', GITPHP_RSS_ITEMS);
   
$entries = count($log); $entries = count($log);
   
if ($entries > 20) { if ($entries > 20) {
/* /*
* Don't show commits older than 48 hours, * Don't show commits older than 48 hours,
* but show a minimum of 20 entries * but show a minimum of 20 entries
*/ */
for ($i = 20; $i < $entries; ++$i) { for ($i = 20; $i < $entries; ++$i) {
if ((time() - $log[$i]->GetCommitterEpoch()) > 48*60*60) { if ((time() - $log[$i]->GetCommitterEpoch()) > 48*60*60) {
$log = array_slice($log, 0, $i); $log = array_slice($log, 0, $i);
break; break;
} }
} }
} }
   
$this->tpl->assign('log', $log); $this->tpl->assign('log', $log);
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Search * GitPHP Controller Search
* *
* Controller for running a search * Controller for running a search
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
define('GITPHP_SEARCH_COMMIT', 'commit'); define('GITPHP_SEARCH_COMMIT', 'commit');
define('GITPHP_SEARCH_AUTHOR', 'author'); define('GITPHP_SEARCH_AUTHOR', 'author');
define('GITPHP_SEARCH_COMMITTER', 'committer'); define('GITPHP_SEARCH_COMMITTER', 'committer');
define('GITPHP_SEARCH_FILE', 'file'); define('GITPHP_SEARCH_FILE', 'file');
   
/** /**
* Search controller class * Search controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Search extends GitPHP_ControllerBase class GitPHP_Controller_Search extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
if (!GitPHP_Config::GetInstance()->GetValue('search', true)) { if (!GitPHP_Config::GetInstance()->GetValue('search', true)) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Search has been disabled'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Search has been disabled'), true);
} }
   
parent::__construct(); parent::__construct();
   
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
   
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
if ($this->params['searchtype'] == GITPHP_SEARCH_FILE) { if ($this->params['searchtype'] == GITPHP_SEARCH_FILE) {
return 'searchfiles.tpl'; return 'searchfiles.tpl';
} }
return 'search.tpl'; return 'search.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['searchtype']) ? sha1($this->params['searchtype']) : '') . '|' . (isset($this->params['search']) ? sha1($this->params['search']) : '') . '|' . (isset($this->params['page']) ? $this->params['page'] : 0); return (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['searchtype']) ? sha1($this->params['searchtype']) : '') . '|' . (isset($this->params['search']) ? sha1($this->params['search']) : '') . '|' . (isset($this->params['page']) ? $this->params['page'] : 0);
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('search');
  }
return 'search'; return 'search';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (!isset($this->params['searchtype'])) if (!isset($this->params['searchtype']))
$this->params['searchtype'] = GITPHP_SEARCH_COMMIT; $this->params['searchtype'] = GITPHP_SEARCH_COMMIT;
   
if ($this->params['searchtype'] == GITPHP_SEARCH_FILE) { if ($this->params['searchtype'] == GITPHP_SEARCH_FILE) {
if (!GitPHP_Config::GetInstance()->GetValue('filesearch', true)) { if (!GitPHP_Config::GetInstance()->GetValue('filesearch', true)) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('File search has been disabled'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('File search has been disabled'), true);
} }
   
} }
   
if ((!isset($this->params['search'])) || (strlen($this->params['search']) < 2)) { if ((!isset($this->params['search'])) || (strlen($this->params['search']) < 2)) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->Format('You must enter search text of at least %1$d characters', 2), true); throw new GitPHP_MessageException(sprintf(GitPHP_Resource::GetInstance()->ngettext('You must enter search text of at least %1$d character', 'You must enter search text of at least %1$d characters', 2), 2), true);
} }
   
if (isset($_GET['h'])) if (isset($_GET['h']))
$this->params['hash'] = $_GET['h']; $this->params['hash'] = $_GET['h'];
else else
$this->params['hash'] = 'HEAD'; $this->params['hash'] = 'HEAD';
if (isset($_GET['pg'])) if (isset($_GET['pg']))
$this->params['page'] = $_GET['pg']; $this->params['page'] = $_GET['pg'];
else else
$this->params['page'] = 0; $this->params['page'] = 0;
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$co = $this->project->GetCommit($this->params['hash']); $co = $this->project->GetCommit($this->params['hash']);
$this->tpl->assign('commit', $co); $this->tpl->assign('commit', $co);
   
$results = array(); $results = array();
if ($co) { if ($co) {
switch ($this->params['searchtype']) { switch ($this->params['searchtype']) {
   
case GITPHP_SEARCH_COMMIT: case GITPHP_SEARCH_COMMIT:
$results = $this->project->SearchCommit($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100)); $results = $this->project->SearchCommit($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100));
break; break;
   
case GITPHP_SEARCH_AUTHOR: case GITPHP_SEARCH_AUTHOR:
$results = $this->project->SearchAuthor($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100)); $results = $this->project->SearchAuthor($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100));
break; break;
   
case GITPHP_SEARCH_COMMITTER: case GITPHP_SEARCH_COMMITTER:
$results = $this->project->SearchCommitter($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100)); $results = $this->project->SearchCommitter($this->params['search'], $co->GetHash(), 101, ($this->params['page'] * 100));
break; break;
case GITPHP_SEARCH_FILE: case GITPHP_SEARCH_FILE:
$results = $co->SearchFiles($this->params['search'], 101, ($this->params['page'] * 100)); $results = $co->SearchFiles($this->params['search'], 101, ($this->params['page'] * 100));
break; break;
default: default:
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Invalid search type')); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Invalid search type'));
   
} }
} }
   
if (count($results) < 1) { if (count($results) < 1) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->Format('No matches for "%1$s"', $this->params['search']), false); throw new GitPHP_MessageException(sprintf(GitPHP_Resource::GetInstance()->translate('No matches for "%1$s"'), $this->params['search']), false);
} }
   
if (count($results) > 100) { if (count($results) > 100) {
$this->tpl->assign('hasmore', true); $this->tpl->assign('hasmore', true);
$results = array_slice($results, 0, 100, true); $results = array_slice($results, 0, 100, true);
} }
$this->tpl->assign('results', $results); $this->tpl->assign('results', $results);
   
$this->tpl->assign('tree', $co->GetTree()); $this->tpl->assign('tree', $co->GetTree());
   
$this->tpl->assign('page', $this->params['page']); $this->tpl->assign('page', $this->params['page']);
   
} }
} }
   
<?php <?php
/** /**
* GitPHP Controller Snapshot * GitPHP Controller Snapshot
* *
* Controller for getting a snapshot * Controller for getting a snapshot
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Snapshot controller class * Snapshot controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Snapshot extends GitPHP_ControllerBase class GitPHP_Controller_Snapshot extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
return 'snapshot.tpl'; return 'snapshot.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['path']) ? $this->params['path'] : '') . '|' . (isset($this->params['prefix']) ? $this->params['prefix'] : ''); return (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['path']) ? $this->params['path'] : '') . '|' . (isset($this->params['prefix']) ? $this->params['prefix'] : '');
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('snapshot');
  }
return 'snapshot'; return 'snapshot';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['h'])) $this->params['hash'] = $_GET['h']; if (isset($_GET['h'])) $this->params['hash'] = $_GET['h'];
if (isset($_GET['f'])) $this->params['path'] = $_GET['f']; if (isset($_GET['f'])) $this->params['path'] = $_GET['f'];
if (isset($_GET['prefix'])) $this->params['prefix'] = $_GET['prefix']; if (isset($_GET['prefix'])) $this->params['prefix'] = $_GET['prefix'];
GitPHP_Log::GetInstance()->SetEnabled(false); GitPHP_Log::GetInstance()->SetEnabled(false);
} }
   
/** /**
* LoadHeaders * LoadHeaders
* *
* Loads headers for this template * Loads headers for this template
* *
* @access protected * @access protected
*/ */
protected function LoadHeaders() protected function LoadHeaders()
{ {
$this->params['compressformat'] = GitPHP_Config::GetInstance()->GetValue('compressformat', GITPHP_COMPRESS_ZIP); $this->params['compressformat'] = GitPHP_Config::GetInstance()->GetValue('compressformat', GITPHP_COMPRESS_ZIP);
$rname = $this->project->GetSlug(); $rname = $this->project->GetSlug();
   
if ($this->params['compressformat'] == GITPHP_COMPRESS_ZIP) { if ($this->params['compressformat'] == GITPHP_COMPRESS_ZIP) {
$this->headers[] = 'Content-Type: application/x-zip'; $this->headers[] = 'Content-Type: application/x-zip';
$this->headers[] = 'Content-Disposition: attachment; filename=' . $rname . '.zip'; $this->headers[] = 'Content-Disposition: attachment; filename=' . $rname . '.zip';
} else if (($this->params['compressformat'] == GITPHP_COMPRESS_BZ2) && function_exists('bzcompress')) { } else if (($this->params['compressformat'] == GITPHP_COMPRESS_BZ2) && function_exists('bzcompress')) {
$this->headers[] = 'Content-Type: application/x-bzip2'; $this->headers[] = 'Content-Type: application/x-bzip2';
$this->headers[] = 'Content-Disposition: attachment; filename=' . $rname . '.tar.bz2'; $this->headers[] = 'Content-Disposition: attachment; filename=' . $rname . '.tar.bz2';
} else if (($this->params['compressformat'] == GITPHP_COMPRESS_GZ) && function_exists('gzencode')) { } else if (($this->params['compressformat'] == GITPHP_COMPRESS_GZ) && function_exists('gzencode')) {
$this->headers[] = 'Content-Type: application/x-gzip'; $this->headers[] = 'Content-Type: application/x-gzip';
$this->headers[] = 'Content-Disposition: attachment; filename=' . $rname . '.tar.gz'; $this->headers[] = 'Content-Disposition: attachment; filename=' . $rname . '.tar.gz';
} else { } else {
$this->headers[] = 'Content-Type: application/x-tar'; $this->headers[] = 'Content-Type: application/x-tar';
$this->headers[] = 'Content-Disposition: attachment; filename=' . $rname . '.tar'; $this->headers[] = 'Content-Disposition: attachment; filename=' . $rname . '.tar';
} }
   
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$commit = null; $commit = null;
   
if (!isset($this->params['hash'])) if (!isset($this->params['hash']))
$commit = $this->project->GetHeadCommit(); $commit = $this->project->GetHeadCommit();
else else
$commit = $this->project->GetCommit($this->params['hash']); $commit = $this->project->GetCommit($this->params['hash']);
   
$this->tpl->assign("archive", $commit->GetArchive($this->params['compressformat'], (isset($this->params['path']) ? $this->params['path'] : null), (isset($this->params['prefix']) ? $this->params['prefix'] : null))); $this->tpl->assign("archive", $commit->GetArchive($this->params['compressformat'], (isset($this->params['path']) ? $this->params['path'] : null), (isset($this->params['prefix']) ? $this->params['prefix'] : null)));
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Tag * GitPHP Controller Tag
* *
* Controller for displaying a tag * Controller for displaying a tag
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Tag controller class * Tag controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Tag extends GitPHP_ControllerBase class GitPHP_Controller_Tag extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
if (isset($this->params['jstip']) && $this->params['jstip']) { if (isset($this->params['jstip']) && $this->params['jstip']) {
return 'tagtip.tpl'; return 'tagtip.tpl';
} }
return 'tag.tpl'; return 'tag.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return isset($this->params['hash']) ? sha1($this->params['hash']) : ''; return isset($this->params['hash']) ? sha1($this->params['hash']) : '';
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('tag');
  }
return 'tag'; return 'tag';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['h'])) { if (isset($_GET['h'])) {
$this->params['hash'] = $_GET['h']; $this->params['hash'] = $_GET['h'];
} }
   
if (isset($_GET['o']) && ($_GET['o'] == 'jstip')) { if (isset($_GET['o']) && ($_GET['o'] == 'jstip')) {
$this->params['jstip'] = true; $this->params['jstip'] = true;
GitPHP_Log::GetInstance()->SetEnabled(false); GitPHP_Log::GetInstance()->SetEnabled(false);
} }
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$head = $this->project->GetHeadCommit(); $head = $this->project->GetHeadCommit();
$this->tpl->assign('head', $head); $this->tpl->assign('head', $head);
   
$tag = new GitPHP_Tag($this->project, $this->params['hash']); $tag = new GitPHP_Tag($this->project, $this->params['hash']);
   
$this->tpl->assign("tag", $tag); $this->tpl->assign("tag", $tag);
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Tags * GitPHP Controller Tags
* *
* Controller for displaying tags * Controller for displaying tags
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Tags controller class * Tags controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Tags extends GitPHP_ControllerBase class GitPHP_Controller_Tags extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
return 'tags.tpl'; return 'tags.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return ''; return '';
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('tags');
  }
return 'tags'; return 'tags';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
$head = $this->project->GetHeadCommit(); $head = $this->project->GetHeadCommit();
$this->tpl->assign("head",$head); $this->tpl->assign("head",$head);
   
$taglist = $this->project->GetTags(); $taglist = $this->project->GetTags();
if (isset($taglist) && (count($taglist) > 0)) { if (isset($taglist) && (count($taglist) > 0)) {
$this->tpl->assign("taglist",$taglist); $this->tpl->assign("taglist",$taglist);
} }
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Controller Tree * GitPHP Controller Tree
* *
* Controller for displaying a tree * Controller for displaying a tree
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
   
/** /**
* Tree controller class * Tree controller class
* *
* @package GitPHP * @package GitPHP
* @subpackage Controller * @subpackage Controller
*/ */
class GitPHP_Controller_Tree extends GitPHP_ControllerBase class GitPHP_Controller_Tree extends GitPHP_ControllerBase
{ {
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @return controller * @return controller
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
if (!$this->project) { if (!$this->project) {
throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->GetResource('Project is required'), true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('Project is required'), true);
} }
} }
   
/** /**
* GetTemplate * GetTemplate
* *
* Gets the template for this controller * Gets the template for this controller
* *
* @access protected * @access protected
* @return string template filename * @return string template filename
*/ */
protected function GetTemplate() protected function GetTemplate()
{ {
return 'tree.tpl'; return 'tree.tpl';
} }
   
/** /**
* GetCacheKey * GetCacheKey
* *
* Gets the cache key for this controller * Gets the cache key for this controller
* *
* @access protected * @access protected
* @return string cache key * @return string cache key
*/ */
protected function GetCacheKey() protected function GetCacheKey()
{ {
return (isset($this->params['hashbase']) ? $this->params['hashbase'] : '') . '|' . (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : ''); return (isset($this->params['hashbase']) ? $this->params['hashbase'] : '') . '|' . (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : '');
} }
   
/** /**
* GetName * GetName
* *
* Gets the name of this controller's action * Gets the name of this controller's action
* *
* @access public * @access public
  * @param boolean $local true if caller wants the localized action name
* @return string action name * @return string action name
*/ */
public function GetName() public function GetName($local = false)
{ {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('tree');
  }
return 'tree'; return 'tree';
} }
   
/** /**
* ReadQuery * ReadQuery
* *
* Read query into parameters * Read query into parameters
* *
* @access protected * @access protected
*/ */
protected function ReadQuery() protected function ReadQuery()
{ {
if (isset($_GET['f'])) if (isset($_GET['f']))
$this->params['file'] = $_GET['f']; $this->params['file'] = $_GET['f'];
if (isset($_GET['h'])) if (isset($_GET['h']))
$this->params['hash'] = $_GET['h']; $this->params['hash'] = $_GET['h'];
if (isset($_GET['hb'])) if (isset($_GET['hb']))
$this->params['hashbase'] = $_GET['hb']; $this->params['hashbase'] = $_GET['hb'];
   
if (!(isset($this->params['hashbase']) || isset($this->params['hash']))) { if (!(isset($this->params['hashbase']) || isset($this->params['hash']))) {
$this->params['hashbase'] = 'HEAD'; $this->params['hashbase'] = 'HEAD';
} }
} }
   
/** /**
* LoadData * LoadData
* *
* Loads data for this template * Loads data for this template
* *
* @access protected * @access protected
*/ */
protected function LoadData() protected function LoadData()
{ {
if (!isset($this->params['hashbase'])) { if (!isset($this->params['hashbase'])) {
// TODO: write a lookup for hash (tree) -> hashbase (commithash) and remove this // TODO: write a lookup for hash (tree) -> hashbase (commithash) and remove this
throw new Exception('Hashbase is required'); throw new Exception('Hashbase is required');
} }
   
$commit = $this->project->GetCommit($this->params['hashbase']); $commit = $this->project->GetCommit($this->params['hashbase']);
   
$this->tpl->assign('commit', $commit); $this->tpl->assign('commit', $commit);
   
if (!isset($this->params['hash'])) { if (!isset($this->params['hash'])) {
if (isset($this->params['file'])) { if (isset($this->params['file'])) {
$this->params['hash'] = $commit->PathToHash($this->params['file']); $this->params['hash'] = $commit->PathToHash($this->params['file']);
} else { } else {
$this->params['hash'] = $commit->GetTree()->GetHash(); $this->params['hash'] = $commit->GetTree()->GetHash();
} }
} }
   
$tree = $this->project->GetTree($this->params['hash']); $tree = $this->project->GetTree($this->params['hash']);
if (!$tree->GetCommit()) { if (!$tree->GetCommit()) {
$tree->SetCommit($commit); $tree->SetCommit($commit);
} }
if (isset($this->params['file'])) { if (isset($this->params['file'])) {
$tree->SetPath($this->params['file']); $tree->SetPath($this->params['file']);
} }
$this->tpl->assign('tree', $tree); $this->tpl->assign('tree', $tree);
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Blob * GitPHP Blob
* *
* Represents a single blob * Represents a single blob
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
   
require_once(GITPHP_GITOBJECTDIR . 'FilesystemObject.class.php'); require_once(GITPHP_GITOBJECTDIR . 'FilesystemObject.class.php');
require_once(GITPHP_GITOBJECTDIR . 'GitExe.class.php'); require_once(GITPHP_GITOBJECTDIR . 'GitExe.class.php');
   
/** /**
* Commit class * Commit class
* *
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
class GitPHP_Blob extends GitPHP_FilesystemObject class GitPHP_Blob extends GitPHP_FilesystemObject
{ {
   
/** /**
* data * data
* *
* Stores the file data * Stores the file data
* *
* @access protected * @access protected
*/ */
protected $data; protected $data;
   
/** /**
* dataRead * dataRead
* *
* Stores whether data has been read * Stores whether data has been read
* *
* @access protected * @access protected
*/ */
protected $dataRead = false; protected $dataRead = false;
   
/** /**
* size * size
* *
* Stores the size * Stores the size
* *
* @access protected * @access protected
*/ */
protected $size; protected $size;
   
/** /**
* history * history
* *
* Stores the history * Stores the history
* *
* @access protected * @access protected
*/ */
protected $history = array(); protected $history = array();
   
/** /**
* historyRead * historyRead
* *
* Stores whether the history has been read * Stores whether the history has been read
* *
* @access protected * @access protected
*/ */
protected $historyRead = false; protected $historyRead = false;
   
/** /**
* blame * blame
* *
* Stores blame info * Stores blame info
* *
* @access protected * @access protected
*/ */
protected $blame = array(); protected $blame = array();
   
/** /**
* blameRead * blameRead
* *
* Stores whether blame was read * Stores whether blame was read
* *
* @access protected * @access protected
*/ */
protected $blameRead = false; protected $blameRead = false;
   
/** /**
* __construct * __construct
* *
* Instantiates object * Instantiates object
* *
* @access public * @access public
* @param mixed $project the project * @param mixed $project the project
* @param string $hash object hash * @param string $hash object hash
* @return mixed blob object * @return mixed blob object
* @throws Exception exception on invalid hash * @throws Exception exception on invalid hash
*/ */
public function __construct($project, $hash) public function __construct($project, $hash)
{ {
parent::__construct($project, $hash); parent::__construct($project, $hash);
} }
   
/** /**
* GetData * GetData
* *
* Gets the blob data * Gets the blob data
* *
* @access public * @access public
* @param boolean $explode true to explode data into an array of lines * @param boolean $explode true to explode data into an array of lines
* @return string blob data * @return string blob data
*/ */
public function GetData($explode = false) public function GetData($explode = false)
{ {
if (!$this->dataRead) if (!$this->dataRead)
$this->ReadData(); $this->ReadData();
   
if ($explode) if ($explode)
return explode("\n", $this->data); return explode("\n", $this->data);
else else
return $this->data; return $this->data;
} }
   
/** /**
* PipeData * PipeData
* *
* Pipes the blob data to a file * Pipes the blob data to a file
* *
* @access public * @access public
* @param string $file file to pipe to * @param string $file file to pipe to
*/ */
public function PipeData($file) public function PipeData($file)
{ {
if (empty($file)) if (empty($file))
return; return;
   
if (!$this->dataRead) if (!$this->dataRead)
$this->ReadData(); $this->ReadData();
   
file_put_contents($file, $this->data); file_put_contents($file, $this->data);
} }
   
/** /**
* ReadData * ReadData
* *
* Reads the blob data * Reads the blob data
* *
* @access private * @access private
*/ */
private function ReadData() private function ReadData()
{ {
$this->dataRead = true; $this->dataRead = true;
   
$exe = new GitPHP_GitExe($this->project); $exe = new GitPHP_GitExe($this->project);
   
$args = array(); $args = array();
$args[] = 'blob'; $args[] = 'blob';
$args[] = $this->hash; $args[] = $this->hash;
   
$this->data = $exe->Execute(GIT_CAT_FILE, $args); $this->data = $exe->Execute(GIT_CAT_FILE, $args);
} }
   
/** /**
* FileType * FileType
* *
* Gets a file type from its octal mode * Gets a file type from its octal mode
* *
* @access public * @access public
* @static * @static
* @param string $octMode octal mode * @param string $octMode octal mode
  * @param boolean $local true if caller wants localized type
* @return string file type * @return string file type
*/ */
public static function FileType($octMode) public static function FileType($octMode, $local = false)
{ {
$mode = octdec($octMode); $mode = octdec($octMode);
if (($mode & 0x4000) == 0x4000) if (($mode & 0x4000) == 0x4000) {
return 'directory'; if ($local) {
else if (($mode & 0xA000) == 0xA000) return GitPHP_Resource::GetInstance()->translate('directory');
return 'symlink'; } else {
else if (($mode & 0x8000) == 0x8000) return 'directory';
return 'file'; }
return 'unknown'; } else if (($mode & 0xA000) == 0xA000) {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('symlink');
  } else {
  return 'symlink';
  }
  } else if (($mode & 0x8000) == 0x8000) {
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('file');
  } else {
  return 'file';
  }
  }
   
  if ($local) {
  return GitPHP_Resource::GetInstance()->translate('unknown');
  } else {
  return 'unknown';
  }
} }
   
/** /**
* GetSize * GetSize
* *
* Gets the blob size * Gets the blob size
* *
* @access public * @access public
* @return integer size * @return integer size
*/ */
public function GetSize() public function GetSize()
{ {
return $this->size; return $this->size;
} }
   
/** /**
* SetSize * SetSize
* *
* Sets the blob size * Sets the blob size
* *
* @access public * @access public
* @param integer $size size * @param integer $size size
*/ */
public function SetSize($size) public function SetSize($size)
{ {
$this->size = $size; $this->size = $size;
} }
   
/** /**
* FileMime * FileMime
* *
* Get the file mimetype * Get the file mimetype
* *
* @access public * @access public
* @param boolean $short true to only the type group * @param boolean $short true to only the type group
* @return string mime * @return string mime
*/ */
public function FileMime($short = false) public function FileMime($short = false)
{ {
$mime = $this->FileMime_Fileinfo(); $mime = $this->FileMime_Fileinfo();
   
if (empty($mime)) if (empty($mime))
$mime = $this->FileMime_File(); $mime = $this->FileMime_File();
   
if (empty($mime)) if (empty($mime))
$mime = $this->FileMime_Extension(); $mime = $this->FileMime_Extension();
   
if ((!empty($mime)) && $short) { if ((!empty($mime)) && $short) {
$mime = strtok($mime, '/'); $mime = strtok($mime, '/');
} }
   
return $mime; return $mime;
} }
   
/** /**
* FileMime_Fileinfo * FileMime_Fileinfo
* *
* Get the file mimetype using fileinfo * Get the file mimetype using fileinfo
* *
* @access private * @access private
* @return string mimetype * @return string mimetype
*/ */
private function FileMime_Fileinfo() private function FileMime_Fileinfo()
{ {
if (!function_exists('finfo_buffer')) if (!function_exists('finfo_buffer'))
return ''; return '';
   
if (!$this->dataRead) if (!$this->dataRead)
$this->ReadData(); $this->ReadData();
   
if (!$this->data) if (!$this->data)
return ''; return '';
   
$mime = ''; $mime = '';
   
$magicdb = GitPHP_Config::GetInstance()->GetValue('magicdb', null); $magicdb = GitPHP_Config::GetInstance()->GetValue('magicdb', null);
if (empty($magicdb)) { if (empty($magicdb)) {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$magicdb = 'C:\\wamp\\php\\extras\\magic'; $magicdb = 'C:\\wamp\\php\\extras\\magic';
} else { } else {
$magicdb = '/usr/share/misc/magic'; $magicdb = '/usr/share/misc/magic';
} }
} }
   
$finfo = finfo_open(FILEINFO_MIME, $magicdb); $finfo = finfo_open(FILEINFO_MIME, $magicdb);
if ($finfo) { if ($finfo) {
$mime = finfo_buffer($finfo, $this->data, FILEINFO_MIME); $mime = finfo_buffer($finfo, $this->data, FILEINFO_MIME);
if ($mime && strpos($mime, '/')) { if ($mime && strpos($mime, '/')) {
if (strpos($mime, ';')) { if (strpos($mime, ';')) {
$mime = strtok($mime, ';'); $mime = strtok($mime, ';');
} }
} }
finfo_close($finfo); finfo_close($finfo);
} }
   
return $mime; return $mime;
} }
   
/** /**
* FileMime_File * FileMime_File
* *
* Get the file mimetype using file command * Get the file mimetype using file command
* *
* @access private * @access private
* @return string mimetype * @return string mimetype
*/ */
private function FileMime_File() private function FileMime_File()
{ {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
return ''; return '';
} }
   
if (!$this->dataRead) if (!$this->dataRead)
$this->ReadData(); $this->ReadData();
   
if (!$this->data) if (!$this->data)
return ''; return '';
   
$descspec = array( $descspec = array(
0 => array('pipe', 'r'), 0 => array('pipe', 'r'),
1 => array('pipe', 'w') 1 => array('pipe', 'w')
); );
   
$proc = proc_open('file -b --mime -', $descspec, $pipes); $proc = proc_open('file -b --mime -', $descspec, $pipes);
if (is_resource($proc)) { if (is_resource($proc)) {
fwrite($pipes[0], $this->data); fwrite($pipes[0], $this->data);
fclose($pipes[0]); fclose($pipes[0]);
$mime = stream_get_contents($pipes[1]); $mime = stream_get_contents($pipes[1]);
fclose($pipes[1]); fclose($pipes[1]);
proc_close($proc); proc_close($proc);
   
if ($mime && strpos($mime, '/')) { if ($mime && strpos($mime, '/')) {
if (strpos($mime, ';')) { if (strpos($mime, ';')) {
$mime = strtok($mime, ';'); $mime = strtok($mime, ';');
} }
return $mime; return $mime;
} }
} }
   
return ''; return '';
} }
   
/** /**
* FileMime_Extension * FileMime_Extension
* *
* Get the file mimetype using the file extension * Get the file mimetype using the file extension
* *
* @access private * @access private
* @return string mimetype * @return string mimetype
*/ */
private function FileMime_Extension() private function FileMime_Extension()
{ {
$file = $this->GetName(); $file = $this->GetName();
   
if (empty($file)) if (empty($file))
return ''; return '';
   
$dotpos = strrpos($file, '.'); $dotpos = strrpos($file, '.');
if ($dotpos !== FALSE) if ($dotpos !== FALSE)
$file = substr($file, $dotpos+1); $file = substr($file, $dotpos+1);
switch ($file) { switch ($file) {
case 'jpg': case 'jpg':
case 'jpeg': case 'jpeg':
case 'jpe': case 'jpe':
return 'image/jpeg'; return 'image/jpeg';
break; break;
case 'gif': case 'gif':
return 'image/gif'; return 'image/gif';
break; break;
case 'png'; case 'png';
return 'image/png'; return 'image/png';
break; break;
} }
   
return ''; return '';
} }
   
/** /**
* GetHistory * GetHistory
* *
* Gets the history of this file * Gets the history of this file
* *
* @access public * @access public
* @return array array of filediff changes * @return array array of filediff changes
*/ */
public function GetHistory() public function GetHistory()
{ {
if (!$this->historyRead) if (!$this->historyRead)
$this->ReadHistory(); $this->ReadHistory();
   
return $this->history; return $this->history;
} }
   
/** /**
* ReadHistory * ReadHistory
* *
* Reads the file history * Reads the file history
* *
* @access private * @access private
*/ */
private function ReadHistory() private function ReadHistory()
{ {
$this->historyRead = true; $this->historyRead = true;
   
$exe = new GitPHP_GitExe($this->project); $exe = new GitPHP_GitExe($this->project);
$args = array(); $args = array();
if (isset($this->commit)) if (isset($this->commit))
$args[] = $this->commit->GetHash(); $args[] = $this->commit->GetHash();
else else
$args[] = 'HEAD'; $args[] = 'HEAD';
$args[] = '|'; $args[] = '|';
$args[] = $exe->GetBinary(); $args[] = $exe->GetBinary();
$args[] = '--git-dir=' . $this->project->GetPath(); $args[] = '--git-dir=' . $this->project->GetPath();
$args[] = GIT_DIFF_TREE; $args[] = GIT_DIFF_TREE;
$args[] = '-r'; $args[] = '-r';
$args[] = '--stdin'; $args[] = '--stdin';
$args[] = '--'; $args[] = '--';
$args[] = $this->GetPath(); $args[] = $this->GetPath();
$historylines = explode("\n", $exe->Execute(GIT_REV_LIST, $args)); $historylines = explode("\n", $exe->Execute(GIT_REV_LIST, $args));
   
$commit = null; $commit = null;
foreach ($historylines as $line) { foreach ($historylines as $line) {
if (preg_match('/^([0-9a-fA-F]{40})/', $line, $regs)) { if (preg_match('/^([0-9a-fA-F]{40})/', $line, $regs)) {
$commit = $this->project->GetCommit($regs[1]); $commit = $this->project->GetCommit($regs[1]);
} else if ($commit) { } else if ($commit) {
try { try {
$history = new GitPHP_FileDiff($this->project, $line); $history = new GitPHP_FileDiff($this->project, $line);
$history->SetCommit($commit); $history->SetCommit($commit);
$this->history[] = $history; $this->history[] = $history;
} catch (Exception $e) { } catch (Exception $e) {
} }
unset ($commit); unset ($commit);
} }
} }
} }
   
/** /**
* GetBlame * GetBlame
* *
* Gets blame info * Gets blame info
* *
* @access public * @access public
* @return array blame array (line to commit mapping) * @return array blame array (line to commit mapping)
*/ */
public function GetBlame() public function GetBlame()
{ {
if (!$this->blameRead) if (!$this->blameRead)
$this->ReadBlame(); $this->ReadBlame();
   
return $this->blame; return $this->blame;
} }
   
/** /**
* ReadBlame * ReadBlame
* *
* Read blame info * Read blame info
* *
* @access private * @access private
*/ */
private function ReadBlame() private function ReadBlame()
{ {
$this->blameRead = true; $this->blameRead = true;
   
$exe = new GitPHP_GitExe($this->project); $exe = new GitPHP_GitExe($this->project);
   
$args = array(); $args = array();
$args[] = '-s'; $args[] = '-s';
$args[] = '-l'; $args[] = '-l';
if ($this->commit) if ($this->commit)
$args[] = $this->commit->GetHash(); $args[] = $this->commit->GetHash();
else else
$args[] = 'HEAD'; $args[] = 'HEAD';
$args[] = '--'; $args[] = '--';
$args[] = $this->GetPath(); $args[] = $this->GetPath();
   
$blamelines = explode("\n", $exe->Execute(GIT_BLAME, $args)); $blamelines = explode("\n", $exe->Execute(GIT_BLAME, $args));
   
$lastcommit = ''; $lastcommit = '';
foreach ($blamelines as $line) { foreach ($blamelines as $line) {
if (preg_match('/^([0-9a-fA-F]{40})(\s+.+)?\s+([0-9]+)\)/', $line, $regs)) { if (preg_match('/^([0-9a-fA-F]{40})(\s+.+)?\s+([0-9]+)\)/', $line, $regs)) {
if ($regs[1] != $lastcommit) { if ($regs[1] != $lastcommit) {
$this->blame[(int)($regs[3])] = $this->project->GetCommit($regs[1]); $this->blame[(int)($regs[3])] = $this->project->GetCommit($regs[1]);
$lastcommit = $regs[1]; $lastcommit = $regs[1];
} }
} }
} }
} }
   
} }
   
<?php <?php
/** /**
* GitPHP File Diff * GitPHP File Diff
* *
* Represents a single file difference * Represents a single file difference
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
   
require_once(GITPHP_GITOBJECTDIR . 'Blob.class.php'); require_once(GITPHP_GITOBJECTDIR . 'Blob.class.php');
   
/** /**
* Commit class * Commit class
* *
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
class GitPHP_FileDiff class GitPHP_FileDiff
{ {
/** /**
* diffInfoRead * diffInfoRead
* *
* Stores whether diff info has been read * Stores whether diff info has been read
* *
* @access protected * @access protected
*/ */
protected $diffInfoRead = false; protected $diffInfoRead = false;
   
/** /**
* diffDataRead * diffDataRead
* *
* Stores whether diff data has been read * Stores whether diff data has been read
* *
* @access protected * @access protected
*/ */
protected $diffDataRead = false; protected $diffDataRead = false;
   
/** /**
* diffData * diffData
* *
* Stores the diff data * Stores the diff data
* *
* @access protected * @access protected
*/ */
protected $diffData; protected $diffData;
   
/** /**
* diffDataName * diffDataName
* *
* Filename used on last data diff * Filename used on last data diff
* *
* @access protected * @access protected
*/ */
protected $diffDataName; protected $diffDataName;
   
/** /**
* fromMode * fromMode
* *
* Stores the from file mode * Stores the from file mode
* *
* @access protected * @access protected
*/ */
protected $fromMode; protected $fromMode;
   
/** /**
* toMode * toMode
* *
* Stores the to file mode * Stores the to file mode
* *
* @access protected * @access protected
*/ */
protected $toMode; protected $toMode;
   
/** /**
* fromHash * fromHash
* *
* Stores the from hash * Stores the from hash
* *
* @access protected * @access protected
*/ */
protected $fromHash; protected $fromHash;
   
/** /**
* toHash * toHash
* *
* Stores the to hash * Stores the to hash
* *
* @access protected * @access protected
*/ */
protected $toHash; protected $toHash;
   
/** /**
* status * status
* *
* Stores the status * Stores the status
* *
* @access protected * @access protected
*/ */
protected $status; protected $status;
   
/** /**
* similarity * similarity
* *
* Stores the similarity * Stores the similarity
* *
* @access protected * @access protected
*/ */
protected $similarity; protected $similarity;
   
/** /**
* fromFile * fromFile
* *
* Stores the from filename * Stores the from filename
* *
* @access protected * @access protected
*/ */
protected $fromFile; protected $fromFile;
   
/** /**
* toFile * toFile
* *
* Stores the to filename * Stores the to filename
* *
* @access protected * @access protected
*/ */
protected $toFile; protected $toFile;
   
/** /**
* fromFileType * fromFileType
* *
* Stores the from file type * Stores the from file type
* *
* @access protected * @access protected
*/ */
protected $fromFileType; protected $fromFileType;
   
/** /**
* toFileType * toFileType
* *
* Stores the to file type * Stores the to file type
* *
* @access protected * @access protected
*/ */
protected $toFileType; protected $toFileType;
   
/** /**
* project * project
* *
* Stores the project * Stores the project
* *
* @access protected * @access protected
*/ */
protected $project; protected $project;
   
/** /**
* commit * commit
* *
* Stores the commit that caused this filediff * Stores the commit that caused this filediff
* *
* @access protected * @access protected
*/ */
protected $commit; protected $commit;
   
/** /**
* __construct * __construct
* *
* Constructor * Constructor
* *
* @access public * @access public
* @param mixed $project project * @param mixed $project project
* @param string $fromHash source hash, can also be a diff-tree info line * @param string $fromHash source hash, can also be a diff-tree info line
* @param string $toHash target hash, required if $fromHash is a hash * @param string $toHash target hash, required if $fromHash is a hash
* @return mixed FileDiff object * @return mixed FileDiff object
* @throws Exception on invalid parameters * @throws Exception on invalid parameters
*/ */
public function __construct($project, $fromHash, $toHash = '') public function __construct($project, $fromHash, $toHash = '')
{ {
$this->project = $project; $this->project = $project;
   
if ($this->ParseDiffTreeLine($fromHash)) if ($this->ParseDiffTreeLine($fromHash))
return; return;
   
if (!(preg_match('/^[0-9a-fA-F]{40}$/', $fromHash) && preg_match('/^[0-9a-fA-F]{40}$/', $toHash))) { if (!(preg_match('/^[0-9a-fA-F]{40}$/', $fromHash) && preg_match('/^[0-9a-fA-F]{40}$/', $toHash))) {
throw new Exception('Invalid parameters for FileDiff'); throw new Exception('Invalid parameters for FileDiff');
} }
   
$this->fromHash = $fromHash; $this->fromHash = $fromHash;
$this->toHash = $toHash; $this->toHash = $toHash;
} }
   
/** /**
* ParseDiffTreeLine * ParseDiffTreeLine
* *
* @access private * @access private
* @param string $diffTreeLine line from difftree * @param string $diffTreeLine line from difftree
* @return boolean true if data was read from line * @return boolean true if data was read from line
*/ */
private function ParseDiffTreeLine($diffTreeLine) private function ParseDiffTreeLine($diffTreeLine)
{ {
if (preg_match('/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/', $diffTreeLine, $regs)) { if (preg_match('/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/', $diffTreeLine, $regs)) {
$this->diffInfoRead = true; $this->diffInfoRead = true;
   
$this->fromMode = $regs[1]; $this->fromMode = $regs[1];
$this->toMode = $regs[2]; $this->toMode = $regs[2];
$this->fromHash = $regs[3]; $this->fromHash = $regs[3];
$this->toHash = $regs[4]; $this->toHash = $regs[4];
$this->status = $regs[5]; $this->status = $regs[5];
$this->similarity = ltrim($regs[6], '0'); $this->similarity = ltrim($regs[6], '0');
$this->fromFile = strtok($regs[7], "\t"); $this->fromFile = strtok($regs[7], "\t");
$this->toFile = strtok("\t"); $this->toFile = strtok("\t");
if ($this->toFile === false) { if ($this->toFile === false) {
/* no filename change */ /* no filename change */
$this->toFile = $this->fromFile; $this->toFile = $this->fromFile;
} }
   
return true; return true;
} }
   
return false; return false;
} }
   
/** /**
* ReadDiffInfo * ReadDiffInfo
* *
* Reads file diff info * Reads file diff info
* *
* @access protected * @access protected
*/ */
protected function ReadDiffInfo() protected function ReadDiffInfo()
{ {
$this->diffInfoRead = true; $this->diffInfoRead = true;
   
/* TODO: read a single difftree line on-demand */ /* TODO: read a single difftree line on-demand */
} }
   
/** /**
* GetFromMode * GetFromMode
* *
* Gets the from file mode * Gets the from file mode
* (full a/u/g/o) * (full a/u/g/o)
* *
* @access public * @access public
* @return string from file mode * @return string from file mode
*/ */
public function GetFromMode() public function GetFromMode()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return $this->fromMode; return $this->fromMode;
} }
   
/** /**
* GetFromModeShort * GetFromModeShort
* *
* Gets the from file mode in short form * Gets the from file mode in short form
* (standard u/g/o) * (standard u/g/o)
* *
* @access public * @access public
* @return string short from file mode * @return string short from file mode
*/ */
public function GetFromModeShort() public function GetFromModeShort()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return substr($this->fromMode, -4); return substr($this->fromMode, -4);
} }
   
/** /**
* GetToMode * GetToMode
* *
* Gets the to file mode * Gets the to file mode
* (full a/u/g/o) * (full a/u/g/o)
* *
* @access public * @access public
* @return string to file mode * @return string to file mode
*/ */
public function GetToMode() public function GetToMode()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return $this->toMode; return $this->toMode;
} }
   
/** /**
* GetToModeShort * GetToModeShort
* *
* Gets the to file mode in short form * Gets the to file mode in short form
* (standard u/g/o) * (standard u/g/o)
* *
* @access public * @access public
* @return string short to file mode * @return string short to file mode
*/ */
public function GetToModeShort() public function GetToModeShort()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return substr($this->toMode, -4); return substr($this->toMode, -4);
} }
   
/** /**
* GetFromHash * GetFromHash
* *
* Gets the from hash * Gets the from hash
* *
* @access public * @access public
* @return string from hash * @return string from hash
*/ */
public function GetFromHash() public function GetFromHash()
{ {
return $this->fromHash; return $this->fromHash;
} }
   
/** /**
* GetToHash * GetToHash
* *
* Gets the to hash * Gets the to hash
* *
* @access public * @access public
* @return string to hash * @return string to hash
*/ */
public function GetToHash() public function GetToHash()
{ {
return $this->toHash; return $this->toHash;
} }
   
/** /**
* GetStatus * GetStatus
* *
* Gets the status of the change * Gets the status of the change
* *
* @access public * @access public
* @return string status * @return string status
*/ */
public function GetStatus() public function GetStatus()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return $this->status; return $this->status;
} }
   
/** /**
* GetSimilarity * GetSimilarity
* *
* Gets the similarity * Gets the similarity
* *
* @access public * @access public
* @return string similarity * @return string similarity
*/ */
public function GetSimilarity() public function GetSimilarity()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return $this->similarity; return $this->similarity;
} }
   
/** /**
* GetFromFile * GetFromFile
* *
* Gets the from file name * Gets the from file name
* *
* @access public * @access public
* @return string from file * @return string from file
*/ */
public function GetFromFile() public function GetFromFile()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return $this->fromFile; return $this->fromFile;
} }
   
/** /**
* GetToFile * GetToFile
* *
* Gets the to file name * Gets the to file name
* *
* @access public * @access public
* @return string to file * @return string to file
*/ */
public function GetToFile() public function GetToFile()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return $this->toFile; return $this->toFile;
} }
   
/** /**
* GetFromFileType * GetFromFileType
* *
* Gets the from file type * Gets the from file type
* *
* @access public * @access public
  * @param boolean $local true if caller wants localized type
* @return string from file type * @return string from file type
*/ */
public function GetFromFileType() public function GetFromFileType($local = false)
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return GitPHP_Blob::FileType($this->fromMode); return GitPHP_Blob::FileType($this->fromMode, $local);
} }
   
/** /**
* GetToFileType * GetToFileType
* *
* Gets the to file type * Gets the to file type
* *
* @access public * @access public
  * @param boolean $local true if caller wants localized type
* @return string to file type * @return string to file type
*/ */
public function GetToFileType() public function GetToFileType($local = false)
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return GitPHP_Blob::FileType($this->toMode); return GitPHP_Blob::FileType($this->toMode, $local);
} }
   
/** /**
* FileTypeChanged * FileTypeChanged
* *
* Tests if filetype changed * Tests if filetype changed
* *
* @access public * @access public
* @return boolean true if file type changed * @return boolean true if file type changed
*/ */
public function FileTypeChanged() public function FileTypeChanged()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return (octdec($this->fromMode) & 0x17000) != (octdec($this->toMode) & 0x17000); return (octdec($this->fromMode) & 0x17000) != (octdec($this->toMode) & 0x17000);
} }
   
/** /**
* FileModeChanged * FileModeChanged
* *
* Tests if file mode changed * Tests if file mode changed
* *
* @access public * @access public
* @return boolean true if file mode changed * @return boolean true if file mode changed
*/ */
public function FileModeChanged() public function FileModeChanged()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return (octdec($this->fromMode) & 0777) != (octdec($this->toMode) & 0777); return (octdec($this->fromMode) & 0777) != (octdec($this->toMode) & 0777);
} }
   
/** /**
* FromFileIsRegular * FromFileIsRegular
* *
* Tests if the from file is a regular file * Tests if the from file is a regular file
* *
* @access public * @access public
* @return boolean true if from file is regular * @return boolean true if from file is regular
*/ */
public function FromFileIsRegular() public function FromFileIsRegular()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return (octdec($this->fromMode) & 0x8000) == 0x8000; return (octdec($this->fromMode) & 0x8000) == 0x8000;
} }
   
/** /**
* ToFileIsRegular * ToFileIsRegular
* *
* Tests if the to file is a regular file * Tests if the to file is a regular file
* *
* @access public * @access public
* @return boolean true if to file is regular * @return boolean true if to file is regular
*/ */
public function ToFileIsRegular() public function ToFileIsRegular()
{ {
if (!$this->diffInfoRead) if (!$this->diffInfoRead)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
return (octdec($this->toMode) & 0x8000) == 0x8000; return (octdec($this->toMode) & 0x8000) == 0x8000;
} }
   
/** /**
* GetDiff * GetDiff
* *
* Gets the diff output * Gets the diff output
* *
* @access public * @access public
* @param string $file override the filename on the diff * @param string $file override the filename on the diff
* @return string diff output * @return string diff output
*/ */
public function GetDiff($file = '', $readFileData = true, $explode = false) public function GetDiff($file = '', $readFileData = true, $explode = false)
{ {
if ($this->diffDataRead && ($file == $this->diffDataName)) { if ($this->diffDataRead && ($file == $this->diffDataName)) {
if ($explode) if ($explode)
return explode("\n", $this->diffData); return explode("\n", $this->diffData);
else else
return $this->diffData; return $this->diffData;
} }
   
if ((!$this->diffInfoRead) && $readFileData) if ((!$this->diffInfoRead) && $readFileData)
$this->ReadDiffInfo(); $this->ReadDiffInfo();
   
$this->diffDataName = $file; $this->diffDataName = $file;
$this->diffDataRead = true; $this->diffDataRead = true;
   
if ((!empty($this->status)) && ($this->status != 'A') && ($this->status != 'D') && ($this->status != 'M')) { if ((!empty($this->status)) && ($this->status != 'A') && ($this->status != 'D') && ($this->status != 'M')) {
$this->diffData = ''; $this->diffData = '';
return; return;
} }
   
if (!GitPHP_Config::GetInstance()->GetValue('tmpdirprepared')) if (!GitPHP_Config::GetInstance()->GetValue('tmpdirprepared'))
GitPHP_FileDiff::PrepareTempDir(); GitPHP_FileDiff::PrepareTempDir();
   
$tmpdir = GitPHP_Config::GetInstance()->GetValue('gittmp', '/tmp/gitphp/'); $tmpdir = GitPHP_Config::GetInstance()->GetValue('gittmp', '/tmp/gitphp/');
   
$pid = 0; $pid = 0;
if (function_exists('posix_getpid')) if (function_exists('posix_getpid'))
$pid = posix_getpid(); $pid = posix_getpid();
else else
$pid = rand(); $pid = rand();
   
$fromFile = '/dev/null'; $fromFile = '/dev/null';
$hasFrom = false; $hasFrom = false;
$toFile = '/dev/null'; $toFile = '/dev/null';
$hasTo = false; $hasTo = false;
   
$fromName = '/dev/null'; $fromName = '/dev/null';
$toName = '/dev/null'; $toName = '/dev/null';
   
if ((empty($this->status)) || ($this->status == 'D') || ($this->status == 'M')) { if ((empty($this->status)) || ($this->status == 'D') || ($this->status == 'M')) {
$fromBlob = $this->project->GetBlob($this->fromHash); $fromBlob = $this->project->GetBlob($this->fromHash);
$fromFile = $tmpdir . 'gitphp_' . $pid . '_from'; $fromFile = $tmpdir . 'gitphp_' . $pid . '_from';
$fromBlob->PipeData($fromFile); $fromBlob->PipeData($fromFile);
$hasFrom = true; $hasFrom = true;
   
$fromName = 'a/'; $fromName = 'a/';
if (!empty($file)) { if (!empty($file)) {
$fromName .= $file; $fromName .= $file;
} else if (!empty($this->fromFile)) { } else if (!empty($this->fromFile)) {
$fromName .= $this->fromFile; $fromName .= $this->fromFile;
} else { } else {
$fromName .= $this->fromHash; $fromName .= $this->fromHash;
} }
} }
   
if ((empty($this->status)) || ($this->status == 'A') || ($this->status == 'M')) { if ((empty($this->status)) || ($this->status == 'A') || ($this->status == 'M')) {
$toBlob = $this->project->GetBlob($this->toHash); $toBlob = $this->project->GetBlob($this->toHash);
$toFile = $tmpdir . 'gitphp_' . $pid . '_to'; $toFile = $tmpdir . 'gitphp_' . $pid . '_to';
$toBlob->PipeData($toFile); $toBlob->PipeData($toFile);
$hasTo = true; $hasTo = true;
   
$toName = 'b/'; $toName = 'b/';
if (!empty($file)) { if (!empty($file)) {
$toName .= $file; $toName .= $file;
} else if (!empty($this->toFile)) { } else if (!empty($this->toFile)) {
$toName .= $this->toFile; $toName .= $this->toFile;
} else { } else {
$toName .= $this->toHash; $toName .= $this->toHash;
} }
} }
   
$diffExe = GitPHP_Config::GetInstance()->GetValue('diffbin'); $diffExe = GitPHP_Config::GetInstance()->GetValue('diffbin');
if (empty($diffExe)) { if (empty($diffExe)) {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$diffExe = 'C:\\Progra~1\\Git\\bin\\diff.exe'; $diffExe = 'C:\\Progra~1\\Git\\bin\\diff.exe';
} else { } else {
$diffExe = 'diff'; $diffExe = 'diff';
} }
} }
   
$this->diffData = shell_exec($diffExe . ' -u -p -L "' . $fromName . '" -L "' . $toName . '" ' . $fromFile . ' ' . $toFile); $this->diffData = shell_exec($diffExe . ' -u -p -L "' . $fromName . '" -L "' . $toName . '" ' . $fromFile . ' ' . $toFile);
   
if ($hasFrom) { if ($hasFrom) {
unlink($fromFile); unlink($fromFile);
} }
   
if ($hasTo) { if ($hasTo) {
unlink($toFile); unlink($toFile);
} }
   
if ($explode) if ($explode)
return explode("\n", $this->diffData); return explode("\n", $this->diffData);
else else
return $this->diffData; return $this->diffData;
} }
   
/** /**
* PrepareTempDir * PrepareTempDir
* *
* Prepares the temporary directory * Prepares the temporary directory
* *
* @access private * @access private
* @static * @static
* @throws Exception exception on error * @throws Exception exception on error
*/ */
private static function PrepareTempDir() private static function PrepareTempDir()
{ {
GitPHP_Config::GetInstance()->SetValue('tmpdirprepared', true); GitPHP_Config::GetInstance()->SetValue('tmpdirprepared', true);
   
$tmpdir = GitPHP_Config::GetInstance()->GetValue('gittmp', '/tmp/gitphp/'); $tmpdir = GitPHP_Config::GetInstance()->GetValue('gittmp', '/tmp/gitphp/');
   
if (empty($tmpdir)) { if (empty($tmpdir)) {
throw new Exception(GitPHP_Resource::GetInstance()->GetResource('No tmpdir defined')); throw new Exception(GitPHP_Resource::GetInstance()->translate('No tmpdir defined'));
} }
   
if (file_exists($tmpdir)) { if (file_exists($tmpdir)) {
if (is_dir($tmpdir)) { if (is_dir($tmpdir)) {
if (!is_writeable($tmpdir)) { if (!is_writeable($tmpdir)) {
throw new Exception(GitPHP_Resource::GetInstance()->Format('Specified tmpdir %1$s is not writeable', $tmpdir)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('Specified tmpdir %1$s is not writable'), $tmpdir));
} }
} else { } else {
throw new Exception(GitPHP_Resource::GetInstance()->Format('Specified tmpdir %1$s is not a directory', $tmpdir)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('Specified tmpdir %1$s is not a directory'), $tmpdir));
} }
} else if (!mkdir($tmpdir, 0700)) { } else if (!mkdir($tmpdir, 0700)) {
throw new Exception(GitPHP_Resource::GetInstance()->Format('Could not create tmpdir %1$s', $tmpdir)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('Could not create tmpdir %1$s'), $tmpdir));
} }
} }
   
/** /**
* GetCommit * GetCommit
* *
* Gets the commit for this filediff * Gets the commit for this filediff
* *
* @access public * @access public
* @return commit object * @return commit object
*/ */
public function GetCommit() public function GetCommit()
{ {
return $this->commit; return $this->commit;
} }
   
/** /**
* SetCommit * SetCommit
* *
* Sets the commit for this filediff * Sets the commit for this filediff
* *
* @access public * @access public
* @param mixed $commit commit object * @param mixed $commit commit object
*/ */
public function SetCommit($commit) public function SetCommit($commit)
{ {
$this->commit = $commit; $this->commit = $commit;
} }
} }
   
<?php <?php
/** /**
* GitPHP GitObject * GitPHP GitObject
* *
* Base class for all hash objects in a git repository * Base class for all hash objects in a git repository
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
   
/** /**
* Git Object class * Git Object class
* *
* @abstract * @abstract
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
abstract class GitPHP_GitObject abstract class GitPHP_GitObject
{ {
/** /**
* project * project
* *
* Stores the project internally * Stores the project internally
* *
* @access protected * @access protected
*/ */
protected $project; protected $project;
   
/** /**
* hash * hash
* *
* Stores the hash of the object internally * Stores the hash of the object internally
* *
* @access protected * @access protected
*/ */
protected $hash; protected $hash;
   
/** /**
* __construct * __construct
* *
* Instantiates object * Instantiates object
* *
* @access public * @access public
* @param mixed $project the project * @param mixed $project the project
* @param string $hash object hash * @param string $hash object hash
* @return mixed git object * @return mixed git object
* @throws Exception exception on invalid hash * @throws Exception exception on invalid hash
*/ */
public function __construct($project, $hash) public function __construct($project, $hash)
{ {
$this->project = $project; $this->project = $project;
$this->SetHash($hash); $this->SetHash($hash);
} }
   
/** /**
* GetProject * GetProject
* *
* Gets the project * Gets the project
* *
* @access public * @access public
* @return mixed project * @return mixed project
*/ */
public function GetProject() public function GetProject()
{ {
return $this->project; return $this->project;
} }
   
/** /**
* GetHash * GetHash
* *
* Gets the hash * Gets the hash
* *
* @access public * @access public
* @return string object hash * @return string object hash
*/ */
public function GetHash() public function GetHash()
{ {
return $this->hash; return $this->hash;
} }
   
/** /**
* SetHash * SetHash
* *
* Attempts to set the hash of this object * Attempts to set the hash of this object
* *
* @param string $hash the hash to set * @param string $hash the hash to set
* @throws Exception on invalid hash * @throws Exception on invalid hash
* @access protected * @access protected
*/ */
protected function SetHash($hash) protected function SetHash($hash)
{ {
if (!(preg_match('/[0-9a-f]{40}/i', $hash))) { if (!(preg_match('/[0-9a-f]{40}/i', $hash))) {
throw new Exception(GitPHP_Resource::GetInstance()->Format('Invalid hash %1$s', $hash)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('Invalid hash %1$s'), $hash));
} }
$this->hash = $hash; $this->hash = $hash;
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Project * GitPHP Project
* *
* Represents a single git project * Represents a single git project
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
   
require_once(GITPHP_GITOBJECTDIR . 'GitExe.class.php'); require_once(GITPHP_GITOBJECTDIR . 'GitExe.class.php');
require_once(GITPHP_GITOBJECTDIR . 'Commit.class.php'); require_once(GITPHP_GITOBJECTDIR . 'Commit.class.php');
require_once(GITPHP_GITOBJECTDIR . 'Head.class.php'); require_once(GITPHP_GITOBJECTDIR . 'Head.class.php');
require_once(GITPHP_GITOBJECTDIR . 'Tag.class.php'); require_once(GITPHP_GITOBJECTDIR . 'Tag.class.php');
   
/** /**
* Project class * Project class
* *
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
class GitPHP_Project class GitPHP_Project
{ {
   
/** /**
* project * project
* *
* Stores the project internally * Stores the project internally
* *
* @access protected * @access protected
*/ */
protected $project; protected $project;
   
/** /**
* owner * owner
* *
* Stores the owner internally * Stores the owner internally
* *
* @access protected * @access protected
*/ */
protected $owner = ""; protected $owner = "";
   
/** /**
* readOwner * readOwner
* *
* Stores whether the file owner has been read * Stores whether the file owner has been read
* *
* @access protected * @access protected
*/ */
protected $readOwner = false; protected $readOwner = false;
   
/** /**
* description * description
* *
* Stores the description internally * Stores the description internally
* *
* @access protected * @access protected
*/ */
protected $description; protected $description;
   
/** /**
* readDescription * readDescription
* *
* Stores whether the description has been * Stores whether the description has been
* read from the file yet * read from the file yet
* *
* @access protected * @access protected
*/ */
protected $readDescription = false; protected $readDescription = false;
   
/** /**
* category * category
* *
* Stores the category internally * Stores the category internally
* *
* @access protected * @access protected
*/ */
protected $category = ''; protected $category = '';
   
/** /**
* head * head
* *
* Stores the head hash internally * Stores the head hash internally
* *
* @access protected * @access protected
*/ */
protected $head; protected $head;
   
/** /**
* readHeadRef * readHeadRef
* *
* Stores whether the head ref has been read yet * Stores whether the head ref has been read yet
* *
* @access protected * @access protected
*/ */
protected $readHeadRef = false; protected $readHeadRef = false;
   
/** /**
* heads * heads
* *
* Stores the heads for the project * Stores the heads for the project
* *
* @access protected * @access protected
*/ */
protected $heads = array(); protected $heads = array();
   
/** /**
* readHeads * readHeads
* *
* Stores whether heads have been read yet * Stores whether heads have been read yet
* *
* @access protected * @access protected
*/ */
protected $readHeads = false; protected $readHeads = false;
   
/** /**
* tags * tags
* *
* Stores the tags for the project * Stores the tags for the project
* *
* @access protected * @access protected
*/ */
protected $tags = array(); protected $tags = array();
   
/** /**
* readTags * readTags
* *
* Stores whether tags have been read yet * Stores whether tags have been read yet
* *
* @access protected * @access protected
*/ */
protected $readTags = false; protected $readTags = false;
   
/** /**
* commitCache * commitCache
* *
* Caches fetched commit objects in case of * Caches fetched commit objects in case of
* repeated requests for the same object * repeated requests for the same object
* *
* @access protected * @access protected
*/ */
protected $commitCache = array(); protected $commitCache = array();
   
/** /**
* blobCache * blobCache
* *
* Caches blob objects in case of * Caches blob objects in case of
* repeated requests * repeated requests
* *
* @access protected * @access protected
*/ */
protected $blobCache = array(); protected $blobCache = array();
   
/** /**
* treeCache * treeCache
* *
* Caches tree objects in case of repeated requests * Caches tree objects in case of repeated requests
* *
* @access protected * @access protected
*/ */
protected $treeCache = array(); protected $treeCache = array();
   
/** /**
* __construct * __construct
* *
* Class constructor * Class constructor
* *
* @access public * @access public
* @throws Exception if project is invalid or outside of projectroot * @throws Exception if project is invalid or outside of projectroot
*/ */
public function __construct($project) public function __construct($project)
{ {
$this->SetProject($project); $this->SetProject($project);
} }
   
/** /**
* SetProject * SetProject
* *
* Attempts to set the project * Attempts to set the project
* *
* @access private * @access private
* @throws Exception if project is invalid or outside of projectroot * @throws Exception if project is invalid or outside of projectroot
*/ */
private function SetProject($project) private function SetProject($project)
{ {
$projectRoot = GitPHP_Config::GetInstance()->GetValue('projectroot'); $projectRoot = GitPHP_Config::GetInstance()->GetValue('projectroot');
$realProjectRoot = realpath($projectRoot); $realProjectRoot = realpath($projectRoot);
$path = $projectRoot . $project; $path = $projectRoot . $project;
$fullPath = realpath($path); $fullPath = realpath($path);
   
if (!is_dir($fullPath)) { if (!is_dir($fullPath)) {
throw new Exception(GitPHP_Resource::GetInstance()->Format('%1$s is not a directory', $project)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('%1$s is not a directory'), $project));
} }
   
if (!is_file($fullPath . '/HEAD')) { if (!is_file($fullPath . '/HEAD')) {
throw new Exception(GitPHP_Resource::GetInstance()->Format('%1$s is not a git repository', $project)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('%1$s is not a git repository'), $project));
} }
   
if (preg_match('/(^|\/)\.{0,2}(\/|$)/', $project)) { if (preg_match('/(^|\/)\.{0,2}(\/|$)/', $project)) {
throw new Exception(GitPHP_Resource::GetInstance()->Format('%1$s is attempting directory traversal', $project)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('%1$s is attempting directory traversal'), $project));
} }
   
$pathPiece = substr($fullPath, 0, strlen($realProjectRoot)); $pathPiece = substr($fullPath, 0, strlen($realProjectRoot));
   
if ((!is_link($path)) && (strcmp($pathPiece, $realProjectRoot) !== 0)) { if ((!is_link($path)) && (strcmp($pathPiece, $realProjectRoot) !== 0)) {
throw new Exception(GitPHP_Resource::GetInstance()->Format('%1$s is outside of the projectroot', $project)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('%1$s is outside of the projectroot'), $project));
} }
   
$this->project = $project; $this->project = $project;
   
} }
   
/** /**
* GetOwner * GetOwner
* *
* Gets the project's owner * Gets the project's owner
* *
* @access public * @access public
* @return string project owner * @return string project owner
*/ */
public function GetOwner() public function GetOwner()
{ {
if (empty($this->owner) && !$this->readOwner) { if (empty($this->owner) && !$this->readOwner) {
$uid = fileowner($this->GetPath()); $uid = fileowner($this->GetPath());
if ($uid > 0) { if ($uid > 0) {
$data = posix_getpwuid($uid); $data = posix_getpwuid($uid);
if (isset($data['gecos']) && !empty($data['gecos'])) { if (isset($data['gecos']) && !empty($data['gecos'])) {
$this->owner = $data['gecos']; $this->owner = $data['gecos'];
} elseif (isset($data['name']) && !empty($data['name'])) { } elseif (isset($data['name']) && !empty($data['name'])) {
$this->owner = $data['name']; $this->owner = $data['name'];
} }
} }
$this->readOwner = true; $this->readOwner = true;
} }
return $this->owner; return $this->owner;
} }
   
/** /**
* SetOwner * SetOwner
* *
* Sets the project's owner (from an external source) * Sets the project's owner (from an external source)
* *
* @access public * @access public
* @param string $owner the owner * @param string $owner the owner
*/ */
public function SetOwner($owner) public function SetOwner($owner)
{ {
$this->owner = $owner; $this->owner = $owner;
} }
   
/** /**
* GetProject * GetProject
* *
* Gets the project * Gets the project
* *
* @access public * @access public
* @return string the project * @return string the project
*/ */
public function GetProject() public function GetProject()
{ {
return $this->project; return $this->project;
} }
   
/** /**
* GetSlug * GetSlug
* *
* Gets the project as a filename/url friendly slug * Gets the project as a filename/url friendly slug
* *
* @access public * @access public
* @return string the slug * @return string the slug
*/ */
public function GetSlug() public function GetSlug()
{ {
$from = array( $from = array(
'/', '/',
'.git' '.git'
); );
$to = array( $to = array(
'-', '-',
'' ''
); );
return str_replace($from, $to, $this->project); return str_replace($from, $to, $this->project);
} }
   
/** /**
* GetPath * GetPath
* *
* Gets the full project path * Gets the full project path
* *
* @access public * @access public
* @return string project path * @return string project path
*/ */
public function GetPath() public function GetPath()
{ {
return GitPHP_Config::GetInstance()->GetValue('projectroot') . $this->project; return GitPHP_Config::GetInstance()->GetValue('projectroot') . $this->project;
} }
   
/** /**
* GetDescription * GetDescription
* *
* Gets the project description * Gets the project description
* *
* @access public * @access public
* @param $trim length to trim description to (0 for no trim) * @param $trim length to trim description to (0 for no trim)
* @return string project description * @return string project description
*/ */
public function GetDescription($trim = 0) public function GetDescription($trim = 0)
{ {
if (!$this->readDescription) { if (!$this->readDescription) {
$this->description = file_get_contents($this->GetPath() . '/description'); $this->description = file_get_contents($this->GetPath() . '/description');
} }
if (($trim > 0) && (strlen($this->description) > $trim)) { if (($trim > 0) && (strlen($this->description) > $trim)) {
return substr($this->description, 0, $trim) . '...'; return substr($this->description, 0, $trim) . '...';
} }
   
return $this->description; return $this->description;
} }
   
/** /**
* GetDaemonEnabled * GetDaemonEnabled
* *
* Returns whether gitdaemon is allowed for this project * Returns whether gitdaemon is allowed for this project
* *
* @access public * @access public
* @return boolean git-daemon-export-ok? * @return boolean git-daemon-export-ok?
*/ */
public function GetDaemonEnabled() public function GetDaemonEnabled()
{ {
return file_exists($this->GetPath() . '/git-daemon-export-ok'); return file_exists($this->GetPath() . '/git-daemon-export-ok');
} }
   
/** /**
* GetCategory * GetCategory
* *
* Gets the project's category * Gets the project's category
* *
* @access public * @access public
* @return string category * @return string category
*/ */
public function GetCategory() public function GetCategory()
{ {
return $this->category; return $this->category;
} }
   
/** /**
* SetCategory * SetCategory
* *
* Sets the project's category * Sets the project's category
* *
* @access public * @access public
* @param string $category category * @param string $category category
*/ */
public function SetCategory($category) public function SetCategory($category)
{ {
$this->category = $category; $this->category = $category;
} }
   
/** /**
* GetCloneUrl * GetCloneUrl
* *
* Gets the clone URL for this repository, if specified * Gets the clone URL for this repository, if specified
* *
* @access public * @access public
* @return string clone url * @return string clone url
*/ */
public function GetCloneUrl() public function GetCloneUrl()
{ {
$cloneurl = GitPHP_Config::GetInstance()->GetValue('cloneurl', ''); $cloneurl = GitPHP_Config::GetInstance()->GetValue('cloneurl', '');
if (!empty($cloneurl)) if (!empty($cloneurl))
$cloneurl .= $this->project; $cloneurl .= $this->project;
return $cloneurl; return $cloneurl;
} }
   
/** /**
* GetPushUrl * GetPushUrl
* *
* Gets the push URL for this repository, if specified * Gets the push URL for this repository, if specified
* *
* @access public * @access public
* @return string push url * @return string push url
*/ */
public function GetPushUrl() public function GetPushUrl()
{ {
$pushurl = GitPHP_Config::GetInstance()->GetValue('pushurl', ''); $pushurl = GitPHP_Config::GetInstance()->GetValue('pushurl', '');
if (!empty($pushurl)) if (!empty($pushurl))
$pushurl .= $this->project; $pushurl .= $this->project;
return $pushurl; return $pushurl;
} }
   
/** /**
* GetHeadCommit * GetHeadCommit
* *
* Gets the head commit for this project * Gets the head commit for this project
* Shortcut for getting the tip commit of the HEAD branch * Shortcut for getting the tip commit of the HEAD branch
* *
* @access public * @access public
* @return mixed head commit * @return mixed head commit
*/ */
public function GetHeadCommit() public function GetHeadCommit()
{ {
if (!$this->readHeadRef) if (!$this->readHeadRef)
$this->ReadHeadCommit(); $this->ReadHeadCommit();
   
return $this->GetCommit($this->head); return $this->GetCommit($this->head);
} }
   
/** /**
* ReadHeadCommit * ReadHeadCommit
* *
* Reads the head commit hash * Reads the head commit hash
* *
* @access protected * @access protected
*/ */
public function ReadHeadCommit() public function ReadHeadCommit()
{ {
$this->readHeadRef = true; $this->readHeadRef = true;
   
$exe = new GitPHP_GitExe($this); $exe = new GitPHP_GitExe($this);
$args = array(); $args = array();
$args[] = '--verify'; $args[] = '--verify';
$args[] = 'HEAD'; $args[] = 'HEAD';
$this->head = trim($exe->Execute(GIT_REV_PARSE, $args)); $this->head = trim($exe->Execute(GIT_REV_PARSE, $args));
} }
   
/** /**
* GetCommit * GetCommit
* *
* Get a commit for this project * Get a commit for this project
* *
* @access public * @access public
*/ */
public function GetCommit($hash) public function GetCommit($hash)
{ {
if (empty($hash)) if (empty($hash))
return null; return null;
   
if ($hash === 'HEAD') if ($hash === 'HEAD')
return $this->GetHeadCommit(); return $this->GetHeadCommit();
   
if (substr_compare($hash, 'refs/heads/', 0, 11) === 0) { if (substr_compare($hash, 'refs/heads/', 0, 11) === 0) {
$head = $this->GetHead(substr($hash, 11)); $head = $this->GetHead(substr($hash, 11));
if ($head != null) if ($head != null)
return $head->GetCommit(); return $head->GetCommit();
} else if (substr_compare($hash, 'refs/tags/', 0, 10) === 0) { } else if (substr_compare($hash, 'refs/tags/', 0, 10) === 0) {
$tag = $this->GetTag(substr($hash, 10)); $tag = $this->GetTag(substr($hash, 10));
if ($tag != null) { if ($tag != null) {
$obj = $tag->GetObject(); $obj = $tag->GetObject();
if ($obj != null) { if ($obj != null) {
return $obj; return $obj;
} }
} }
} }
   
if (!isset($this->commitCache[$hash])) if (!isset($this->commitCache[$hash]))
$this->commitCache[$hash] = new GitPHP_Commit($this, $hash); $this->commitCache[$hash] = new GitPHP_Commit($this, $hash);
   
return $this->commitCache[$hash]; return $this->commitCache[$hash];
} }
   
/** /**
* CompareProject * CompareProject
* *
* Compares two projects by project name * Compares two projects by project name
* *
* @access public * @access public
* @static * @static
* @param mixed $a first project * @param mixed $a first project
* @param mixed $b second project * @param mixed $b second project
* @return integer comparison result * @return integer comparison result
*/ */
public static function CompareProject($a, $b) public static function CompareProject($a, $b)
{ {
$catCmp = strcmp($a->GetCategory(), $b->GetCategory()); $catCmp = strcmp($a->GetCategory(), $b->GetCategory());
if ($catCmp !== 0) if ($catCmp !== 0)
return $catCmp; return $catCmp;
   
return strcmp($a->GetProject(), $b->GetProject()); return strcmp($a->GetProject(), $b->GetProject());
} }
   
/** /**
* CompareDescription * CompareDescription
* *
* Compares two projects by description * Compares two projects by description
* *
* @access public * @access public
* @static * @static
* @param mixed $a first project * @param mixed $a first project
* @param mixed $b second project * @param mixed $b second project
* @return integer comparison result * @return integer comparison result
*/ */
public static function CompareDescription($a, $b) public static function CompareDescription($a, $b)
{ {
$catCmp = strcmp($a->GetCategory(), $b->GetCategory()); $catCmp = strcmp($a->GetCategory(), $b->GetCategory());
if ($catCmp !== 0) if ($catCmp !== 0)
return $catCmp; return $catCmp;
   
return strcmp($a->GetDescription(), $b->GetDescription()); return strcmp($a->GetDescription(), $b->GetDescription());
} }
   
/** /**
* CompareOwner * CompareOwner
* *
* Compares two projects by owner * Compares two projects by owner
* *
* @access public * @access public
* @static * @static
* @param mixed $a first project * @param mixed $a first project
* @param mixed $b second project * @param mixed $b second project
* @return integer comparison result * @return integer comparison result
*/ */
public static function CompareOwner($a, $b) public static function CompareOwner($a, $b)
{ {
$catCmp = strcmp($a->GetCategory(), $b->GetCategory()); $catCmp = strcmp($a->GetCategory(), $b->GetCategory());
if ($catCmp !== 0) if ($catCmp !== 0)
return $catCmp; return $catCmp;
   
return strcmp($a->GetOwner(), $b->GetOwner()); return strcmp($a->GetOwner(), $b->GetOwner());
} }
   
/** /**
* CompareAge * CompareAge
* *
* Compares two projects by age * Compares two projects by age
* *
* @access public * @access public
* @static * @static
* @param mixed $a first project * @param mixed $a first project
* @param mixed $b second project * @param mixed $b second project
* @return integer comparison result * @return integer comparison result
*/ */
public static function CompareAge($a, $b) public static function CompareAge($a, $b)
{ {
$catCmp = strcmp($a->GetCategory(), $b->GetCategory()); $catCmp = strcmp($a->GetCategory(), $b->GetCategory());
if ($catCmp !== 0) if ($catCmp !== 0)
return $catCmp; return $catCmp;
   
$aCommit = $a->GetHeadCommit(); $aCommit = $a->GetHeadCommit();
$bCommit = $b->GetHeadCommit(); $bCommit = $b->GetHeadCommit();
   
if (($aCommit == null) && ($bCommit == null)) if (($aCommit == null) && ($bCommit == null))
return 0; return 0;
else if ($aCommit == null) else if ($aCommit == null)
return 1; return 1;
else if ($bCommit == null) else if ($bCommit == null)
return -1; return -1;
   
if ($aCommit->GetAge() === $bCommit->GetAge()) if ($aCommit->GetAge() === $bCommit->GetAge())
return 0; return 0;
return ($aCommit->GetAge() < $bCommit->GetAge() ? -1 : 1); return ($aCommit->GetAge() < $bCommit->GetAge() ? -1 : 1);
} }
   
/** /**
* GetTags * GetTags
* *
* Gets list of tags for this project * Gets list of tags for this project
* *
* @access public * @access public
* @return array array of tags * @return array array of tags
*/ */
public function GetTags() public function GetTags()
{ {
if (!$this->readTags) if (!$this->readTags)
$this->ReadTagList(); $this->ReadTagList();
   
return $this->tags; return $this->tags;
} }
   
/** /**
* GetTag * GetTag
* *
* Gets a single tag * Gets a single tag
* *
* @access public * @access public
* @param string $tag tag to find * @param string $tag tag to find
* @return mixed tag object * @return mixed tag object
*/ */
public function GetTag($tag) public function GetTag($tag)
{ {
if (empty($tag)) if (empty($tag))
return null; return null;
   
if (!$this->readTags) if (!$this->readTags)
$this->ReadTagList(); $this->ReadTagList();
   
if (isset($this->tags[$tag])) if (isset($this->tags[$tag]))
return $this->tags[$tag]; return $this->tags[$tag];
   
return null; return null;
} }
   
/** /**
* ReadTagList * ReadTagList
* *
* Reads tag list * Reads tag list
* *
* @access protected * @access protected
*/ */
protected function ReadTagList() protected function ReadTagList()
{ {
$this->readTags = true; $this->readTags = true;
   
$exe = new GitPHP_GitExe($this); $exe = new GitPHP_GitExe($this);
$args = array(); $args = array();
$args[] = '--tags'; $args[] = '--tags';
$args[] = '--dereference'; $args[] = '--dereference';
$ret = $exe->Execute(GIT_SHOW_REF, $args); $ret = $exe->Execute(GIT_SHOW_REF, $args);
unset($exe); unset($exe);
   
$lines = explode("\n", $ret); $lines = explode("\n", $ret);
   
foreach ($lines as $line) { foreach ($lines as $line) {
if (preg_match('/^([0-9a-fA-F]{40}) refs\/tags\/([^^]+)(\^{})?$/', $line, $regs)) { if (preg_match('/^([0-9a-fA-F]{40}) refs\/tags\/([^^]+)(\^{})?$/', $line, $regs)) {
try { try {
if ((!empty($regs[3])) && ($regs[3] == '^{}')) { if ((!empty($regs[3])) && ($regs[3] == '^{}')) {
$derefCommit = $this->GetCommit($regs[1]); $derefCommit = $this->GetCommit($regs[1]);
if ($derefCommit && isset($this->tags[$regs[2]])) { if ($derefCommit && isset($this->tags[$regs[2]])) {
$this->tags[$regs[2]]->SetCommit($derefCommit); $this->tags[$regs[2]]->SetCommit($derefCommit);
} }
} else { } else {
$this->tags[$regs[2]] = new GitPHP_Tag($this, $regs[2], $regs[1]); $this->tags[$regs[2]] = new GitPHP_Tag($this, $regs[2], $regs[1]);
} }
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
} }
   
uasort($this->tags, array('GitPHP_Tag', 'CompareAge')); uasort($this->tags, array('GitPHP_Tag', 'CompareAge'));
} }
   
/** /**
* GetHeads * GetHeads
* *
* Gets list of heads for this project * Gets list of heads for this project
* *
* @access public * @access public
* @return array array of heads * @return array array of heads
*/ */
public function GetHeads() public function GetHeads()
{ {
if (!$this->readHeads) if (!$this->readHeads)
$this->ReadHeadList(); $this->ReadHeadList();
   
return $this->heads; return $this->heads;
} }
   
/** /**
* GetHead * GetHead
* *
* Gets a single head * Gets a single head
* *
* @access public * @access public
* @param string $head head to find * @param string $head head to find
* @return mixed head object * @return mixed head object
*/ */
public function GetHead($head) public function GetHead($head)
{ {
if (empty($head)) if (empty($head))
return null; return null;
   
if (!$this->readHeads) if (!$this->readHeads)
$this->ReadHeadList(); $this->ReadHeadList();
   
foreach ($this->heads as $h) { foreach ($this->heads as $h) {
if ($h->GetName() === $head) { if ($h->GetName() === $head) {
return $h; return $h;
} }
} }
return null; return null;
} }
   
/** /**
* ReadHeadList * ReadHeadList
* *
* Reads head list * Reads head list
* *
* @access protected * @access protected
*/ */
protected function ReadHeadList() protected function ReadHeadList()
{ {
$this->readHeads = true; $this->readHeads = true;
   
$exe = new GitPHP_GitExe($this); $exe = new GitPHP_GitExe($this);
$args = array(); $args = array();
$args[] = '--heads'; $args[] = '--heads';
$ret = $exe->Execute(GIT_SHOW_REF, $args); $ret = $exe->Execute(GIT_SHOW_REF, $args);
unset($exe); unset($exe);
   
$lines = explode("\n", $ret); $lines = explode("\n", $ret);
   
foreach ($lines as $line) { foreach ($lines as $line) {
if (preg_match('/^([0-9a-fA-F]{40}) refs\/heads\/(.+)$/', $line, $regs)) { if (preg_match('/^([0-9a-fA-F]{40}) refs\/heads\/(.+)$/', $line, $regs)) {
try { try {
$this->heads[] = new GitPHP_Head($this, $regs[2], $regs[1]); $this->heads[] = new GitPHP_Head($this, $regs[2], $regs[1]);
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
} }
   
usort($this->heads, array('GitPHP_Head', 'CompareAge')); usort($this->heads, array('GitPHP_Head', 'CompareAge'));
   
} }
   
/** /**
* GetLogHash * GetLogHash
* *
* Gets log entries as an array of hashes * Gets log entries as an array of hashes
* *
* @access public * @access public
* @param string $hash hash to start the log at * @param string $hash hash to start the log at
* @param integer $count number of entries to get * @param integer $count number of entries to get
* @param integer $skip number of entries to skip * @param integer $skip number of entries to skip
* @return array array of hashes * @return array array of hashes
*/ */
public function GetLogHash($hash, $count = 50, $skip = 0) public function GetLogHash($hash, $count = 50, $skip = 0)
{ {
return $this->RevList($hash, $count, $skip); return $this->RevList($hash, $count, $skip);
} }
   
/** /**
* GetLog * GetLog
* *
* Gets log entries as an array of commit objects * Gets log entries as an array of commit objects
* *
* @access public * @access public
* @param string $hash hash to start the log at * @param string $hash hash to start the log at
* @param integer $count number of entries to get * @param integer $count number of entries to get
* @param integer $skip number of entries to skip * @param integer $skip number of entries to skip
* @return array array of commit objects * @return array array of commit objects
*/ */
public function GetLog($hash, $count = 50, $skip = 0) public function GetLog($hash, $count = 50, $skip = 0)
{ {
$log = $this->GetLogHash($hash, $count, $skip); $log = $this->GetLogHash($hash, $count, $skip);
$len = count($log); $len = count($log);
for ($i = 0; $i < $len; ++$i) { for ($i = 0; $i < $len; ++$i) {
$log[$i] = $this->GetCommit($log[$i]); $log[$i] = $this->GetCommit($log[$i]);
} }
return $log; return $log;
} }
   
/** /**
* GetBlob * GetBlob
* *
* Gets a blob from this project * Gets a blob from this project
* *
* @access public * @access public
* @param string $hash blob hash * @param string $hash blob hash
*/ */
public function GetBlob($hash) public function GetBlob($hash)
{ {
if (empty($hash)) if (empty($hash))
return null; return null;
   
if (!isset($this->blobCache[$hash])) if (!isset($this->blobCache[$hash]))
$this->blobCache[$hash] = new GitPHP_Blob($this, $hash); $this->blobCache[$hash] = new GitPHP_Blob($this, $hash);
   
return $this->blobCache[$hash]; return $this->blobCache[$hash];
} }
   
/** /**
* GetTree * GetTree
* *
* Gets a tree from this project * Gets a tree from this project
* *
* @access public * @access public
* @param string $hash tree hash * @param string $hash tree hash
*/ */
public function GetTree($hash) public function GetTree($hash)
{ {
if (empty($hash)) if (empty($hash))
return null; return null;
   
if (!isset($this->treeCache[$hash])) if (!isset($this->treeCache[$hash]))
$this->treeCache[$hash] = new GitPHP_Tree($this, $hash); $this->treeCache[$hash] = new GitPHP_Tree($this, $hash);
   
return $this->treeCache[$hash]; return $this->treeCache[$hash];
} }
   
/** /**
* SearchCommit * SearchCommit
* *
* Gets a list of commits with commit messages matching the given pattern * Gets a list of commits with commit messages matching the given pattern
* *
* @access public * @access public
* @param string $pattern search pattern * @param string $pattern search pattern
* @param string $hash hash to start searching from * @param string $hash hash to start searching from
* @param integer $count number of results to get * @param integer $count number of results to get
* @param integer $skip number of results to skip * @param integer $skip number of results to skip
* @return array array of matching commits * @return array array of matching commits
*/ */
public function SearchCommit($pattern, $hash = 'HEAD', $count = 50, $skip = 0) public function SearchCommit($pattern, $hash = 'HEAD', $count = 50, $skip = 0)
{ {
if (empty($pattern)) if (empty($pattern))
return; return;
   
$args = array(); $args = array();
$args[] = '--regexp-ignore-case'; $args[] = '--regexp-ignore-case';
$args[] = '--grep=\'' . $pattern . '\''; $args[] = '--grep=\'' . $pattern . '\'';
   
$ret = $this->RevList($hash, $count, $skip, $args); $ret = $this->RevList($hash, $count, $skip, $args);
$len = count($ret); $len = count($ret);
   
for ($i = 0; $i < $len; ++$i) { for ($i = 0; $i < $len; ++$i) {
$ret[$i] = $this->GetCommit($ret[$i]); $ret[$i] = $this->GetCommit($ret[$i]);
} }
return $ret; return $ret;
} }
   
/** /**
* SearchAuthor * SearchAuthor
* *
* Gets a list of commits with authors matching the given pattern * Gets a list of commits with authors matching the given pattern
* *
* @access public * @access public
* @param string $pattern search pattern * @param string $pattern search pattern
* @param string $hash hash to start searching from * @param string $hash hash to start searching from
* @param integer $count number of results to get * @param integer $count number of results to get
* @param integer $skip number of results to skip * @param integer $skip number of results to skip
* @return array array of matching commits * @return array array of matching commits
*/ */
public function SearchAuthor($pattern, $hash = 'HEAD', $count = 50, $skip = 0) public function SearchAuthor($pattern, $hash = 'HEAD', $count = 50, $skip = 0)
{ {
if (empty($pattern)) if (empty($pattern))
return; return;
   
$args = array(); $args = array();
$args[] = '--regexp-ignore-case'; $args[] = '--regexp-ignore-case';
$args[] = '--author=\'' . $pattern . '\''; $args[] = '--author=\'' . $pattern . '\'';
   
$ret = $this->RevList($hash, $count, $skip, $args); $ret = $this->RevList($hash, $count, $skip, $args);
$len = count($ret); $len = count($ret);
   
for ($i = 0; $i < $len; ++$i) { for ($i = 0; $i < $len; ++$i) {
$ret[$i] = $this->GetCommit($ret[$i]); $ret[$i] = $this->GetCommit($ret[$i]);
} }
return $ret; return $ret;
} }
   
/** /**
* SearchCommitter * SearchCommitter
* *
* Gets a list of commits with committers matching the given pattern * Gets a list of commits with committers matching the given pattern
* *
* @access public * @access public
* @param string $pattern search pattern * @param string $pattern search pattern
* @param string $hash hash to start searching from * @param string $hash hash to start searching from
* @param integer $count number of results to get * @param integer $count number of results to get
* @param integer $skip number of results to skip * @param integer $skip number of results to skip
* @return array array of matching commits * @return array array of matching commits
*/ */
public function SearchCommitter($pattern, $hash = 'HEAD', $count = 50, $skip = 0) public function SearchCommitter($pattern, $hash = 'HEAD', $count = 50, $skip = 0)
{ {
if (empty($pattern)) if (empty($pattern))
return; return;
   
$args = array(); $args = array();
$args[] = '--regexp-ignore-case'; $args[] = '--regexp-ignore-case';
$args[] = '--committer=\'' . $pattern . '\''; $args[] = '--committer=\'' . $pattern . '\'';
   
$ret = $this->RevList($hash, $count, $skip, $args); $ret = $this->RevList($hash, $count, $skip, $args);
$len = count($ret); $len = count($ret);
   
for ($i = 0; $i < $len; ++$i) { for ($i = 0; $i < $len; ++$i) {
$ret[$i] = $this->GetCommit($ret[$i]); $ret[$i] = $this->GetCommit($ret[$i]);
} }
return $ret; return $ret;
} }
   
/** /**
* RevList * RevList
* *
* Common code for using rev-list command * Common code for using rev-list command
* *
* @access private * @access private
* @param string $hash hash to list from * @param string $hash hash to list from
* @param integer $count number of results to get * @param integer $count number of results to get
* @param integer $skip number of results to skip * @param integer $skip number of results to skip
* @param array $args args to give to rev-list * @param array $args args to give to rev-list
* @return array array of hashes * @return array array of hashes
*/ */
private function RevList($hash, $count = 50, $skip = 0, $args = array()) private function RevList($hash, $count = 50, $skip = 0, $args = array())
{ {
if ($count < 1) if ($count < 1)
return; return;
   
$exe = new GitPHP_GitExe($this); $exe = new GitPHP_GitExe($this);
   
$canSkip = true; $canSkip = true;
if ($skip > 0) if ($skip > 0)
$canSkip = $exe->CanSkip(); $canSkip = $exe->CanSkip();
   
if ($canSkip) { if ($canSkip) {
$args[] = '--max-count=' . $count; $args[] = '--max-count=' . $count;
if ($skip > 0) { if ($skip > 0) {
$args[] = '--skip=' . $skip; $args[] = '--skip=' . $skip;
} }
} else { } else {
$args[] = '--max-count=' . ($count + $skip); $args[] = '--max-count=' . ($count + $skip);
} }
   
$args[] = $hash; $args[] = $hash;
   
$revlist = explode("\n", $exe->Execute(GIT_REV_LIST, $args)); $revlist = explode("\n", $exe->Execute(GIT_REV_LIST, $args));
   
if (!$revlist[count($revlist)-1]) { if (!$revlist[count($revlist)-1]) {
/* the last newline creates a null entry */ /* the last newline creates a null entry */
array_splice($revlist, -1, 1); array_splice($revlist, -1, 1);
} }
   
if (($skip > 0) && (!$exe->CanSkip())) { if (($skip > 0) && (!$exe->CanSkip())) {
return array_slice($revlist, $skip, $count); return array_slice($revlist, $skip, $count);
} }
   
return $revlist; return $revlist;
} }
   
} }
   
<?php <?php
/** /**
* GitPHP ProjectListDirectory * GitPHP ProjectListDirectory
* *
* Lists all projects in a given directory * Lists all projects in a given directory
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
   
require_once(GITPHP_INCLUDEDIR . 'Config.class.php'); require_once(GITPHP_INCLUDEDIR . 'Config.class.php');
require_once(GITPHP_GITOBJECTDIR . 'ProjectListBase.class.php'); require_once(GITPHP_GITOBJECTDIR . 'ProjectListBase.class.php');
require_once(GITPHP_GITOBJECTDIR . 'Project.class.php'); require_once(GITPHP_GITOBJECTDIR . 'Project.class.php');
   
/** /**
* ProjectListDirectory class * ProjectListDirectory class
* *
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
class GitPHP_ProjectListDirectory extends GitPHP_ProjectListBase class GitPHP_ProjectListDirectory extends GitPHP_ProjectListBase
{ {
/** /**
* projectDir * projectDir
* *
* Stores projectlist directory internally * Stores projectlist directory internally
* *
* @access protected * @access protected
*/ */
protected $projectDir; protected $projectDir;
   
/** /**
* __construct * __construct
* *
* constructor * constructor
* *
* @param string $projectDir directory to search * @param string $projectDir directory to search
* @throws Exception if parameter is not a directory * @throws Exception if parameter is not a directory
* @access public * @access public
*/ */
public function __construct($projectDir) public function __construct($projectDir)
{ {
if (!is_dir($projectDir)) { if (!is_dir($projectDir)) {
throw new Exception(GitPHP_Resource::GetInstance()->Format('%1$s is not a directory', $projectDir)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('%1$s is not a directory'), $projectDir));
} }
   
$this->projectDir = $projectDir; $this->projectDir = $projectDir;
   
parent::__construct(); parent::__construct();
} }
   
/** /**
* PopulateProjects * PopulateProjects
* *
* Populates the internal list of projects * Populates the internal list of projects
* *
* @access protected * @access protected
*/ */
protected function PopulateProjects() protected function PopulateProjects()
{ {
$this->RecurseDir($this->projectDir); $this->RecurseDir($this->projectDir);
} }
   
/** /**
* RecurseDir * RecurseDir
* *
* Recursively searches for projects * Recursively searches for projects
* *
* @param string $dir directory to recurse into * @param string $dir directory to recurse into
*/ */
private function RecurseDir($dir) private function RecurseDir($dir)
{ {
if (!is_dir($dir)) if (!is_dir($dir))
return; return;
   
if ($dh = opendir($dir)) { if ($dh = opendir($dir)) {
$trimlen = strlen(GitPHP_Config::GetInstance()->GetValue('projectroot')) + 1; $trimlen = strlen(GitPHP_Config::GetInstance()->GetValue('projectroot')) + 1;
while (($file = readdir($dh)) !== false) { while (($file = readdir($dh)) !== false) {
$fullPath = $dir . '/' . $file; $fullPath = $dir . '/' . $file;
if ((strpos($file, '.') !== 0) && is_dir($fullPath)) { if ((strpos($file, '.') !== 0) && is_dir($fullPath)) {
if (is_file($fullPath . '/HEAD')) { if (is_file($fullPath . '/HEAD')) {
$projectPath = substr($fullPath, $trimlen); $projectPath = substr($fullPath, $trimlen);
try { try {
$proj = new GitPHP_Project($projectPath); $proj = new GitPHP_Project($projectPath);
$proj->SetCategory(trim(substr($dir, strlen($this->projectDir)), '/')); $proj->SetCategory(trim(substr($dir, strlen($this->projectDir)), '/'));
if ((!GitPHP_Config::GetInstance()->GetValue('exportedonly', false)) || $proj->GetDaemonEnabled()) { if ((!GitPHP_Config::GetInstance()->GetValue('exportedonly', false)) || $proj->GetDaemonEnabled()) {
$this->projects[] = $proj; $this->projects[] = $proj;
} }
} catch (Exception $e) { } catch (Exception $e) {
} }
} else { } else {
$this->RecurseDir($fullPath); $this->RecurseDir($fullPath);
} }
} }
} }
closedir($dh); closedir($dh);
} }
} }
   
} }
   
<?php <?php
/** /**
* GitPHP ProjectListFile * GitPHP ProjectListFile
* *
* Lists all projects in a given file * Lists all projects in a given file
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
   
require_once(GITPHP_INCLUDEDIR . 'Config.class.php'); require_once(GITPHP_INCLUDEDIR . 'Config.class.php');
require_once(GITPHP_GITOBJECTDIR . 'ProjectListBase.class.php'); require_once(GITPHP_GITOBJECTDIR . 'ProjectListBase.class.php');
require_once(GITPHP_GITOBJECTDIR . 'Project.class.php'); require_once(GITPHP_GITOBJECTDIR . 'Project.class.php');
   
/** /**
* ProjectListFile class * ProjectListFile class
* *
* @package GitPHP * @package GitPHP
* @subpackage Git * @subpackage Git
*/ */
class GitPHP_ProjectListFile extends GitPHP_ProjectListBase class GitPHP_ProjectListFile extends GitPHP_ProjectListBase
{ {
/** /**
* __construct * __construct
* *
* constructor * constructor
* *
* @param string $projectFile file to read * @param string $projectFile file to read
* @throws Exception if parameter is not a readable file * @throws Exception if parameter is not a readable file
* @access public * @access public
*/ */
public function __construct($projectFile) public function __construct($projectFile)
{ {
if (!(is_string($projectFile) && is_file($projectFile))) { if (!(is_string($projectFile) && is_file($projectFile))) {
throw new Exception(GitPHP_Resource::GetInstance()->Format('%1$s is not a file', $projectFile)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('%1$s is not a file'), $projectFile));
} }
   
$this->projectConfig = $projectFile; $this->projectConfig = $projectFile;
   
parent::__construct(); parent::__construct();
} }
   
/** /**
* PopulateProjects * PopulateProjects
* *
* Populates the internal list of projects * Populates the internal list of projects
* *
* @access protected * @access protected
* @throws Exception if file cannot be read * @throws Exception if file cannot be read
*/ */
protected function PopulateProjects() protected function PopulateProjects()
{ {
if (!($fp = fopen($this->projectConfig, 'r'))) { if (!($fp = fopen($this->projectConfig, 'r'))) {
throw new Exception(GitPHP_Resource::GetInstance()->Format('Failed to open project list file %1$s', $this->projectConfig)); throw new Exception(sprintf(GitPHP_Resource::GetInstance()->translate('Failed to open project list file %1$s'), $this->projectConfig));
} }
   
$projectRoot = GitPHP_Config::GetInstance()->GetValue('projectroot'); $projectRoot = GitPHP_Config::GetInstance()->GetValue('projectroot');
   
while (!feof($fp) && ($line = fgets($fp))) { while (!feof($fp) && ($line = fgets($fp))) {
if (preg_match('/^([^\s]+)(\s.+)?$/', $line, $regs)) { if (preg_match('/^([^\s]+)(\s.+)?$/', $line, $regs)) {
if (is_file($projectRoot . $regs[1] . '/HEAD')) { if (is_file($projectRoot . $regs[1] . '/HEAD')) {
try { try {
$projObj = new GitPHP_Project($regs[1]); $projObj = new GitPHP_Project($regs[1]);
if (isset($regs[2]) && !empty($regs[2])) { if (isset($regs[2]) && !empty($regs[2])) {
$projOwner = trim($regs[2]); $projOwner = trim($regs[2]);
if (!empty($projOwner)) { if (!empty($projOwner)) {
$projObj->SetOwner($projOwner); $projObj->SetOwner($projOwner);
} }
} }
$this->projects[] = $projObj; $this->projects[] = $projObj;
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
} }
} }
   
fclose($fp); fclose($fp);
} }
   
} }
   
<?php <?php
/** /**
* GitPHP Resource * GitPHP Resource
* *
* Resource factory * Resource factory
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Resource * @subpackage Resource
*/ */
   
require_once(GITPHP_RESOURCEDIR . 'ResourceBase.class.php'); require_once(GITPHP_BASEDIR . 'lib/php-gettext/streams.php');
  require_once(GITPHP_BASEDIR . 'lib/php-gettext/gettext.php');
   
/** /**
* Resource * Resource
* *
* @package GitPHP * @package GitPHP
* @subpackage Resource * @subpackage Resource
*/ */
class GitPHP_Resource class GitPHP_Resource
{ {
/** /**
* instance * instance
* *
* Stores the singleton instance of the resource provider * Stores the singleton instance of the resource provider
* *
* @access protected * @access protected
* @static * @static
*/ */
protected static $instance = null; protected static $instance = null;
   
/** /**
* GetInstance * GetInstance
* *
* Returns the singleton instance * Returns the singleton instance
* *
* @access public * @access public
* @static * @static
* @return mixed instance of resource class * @return mixed instance of resource class
* @throws Exception if resource provider has not been instantiated yet * @throws Exception if resource provider has not been instantiated yet
*/ */
public static function GetInstance() public static function GetInstance()
{ {
return self::$instance; return self::$instance;
} }
   
/** /**
* Instantiate * Instantiate
* *
* Instantiates the singleton instance * Instantiates the singleton instance
* *
* @access public * @access public
* @static * @static
* @param string $locale locale to instantiate * @param string $locale locale to instantiate
* @throws Exception on invalid locale * @throws Exception on invalid locale
*/ */
public static function Instantiate($locale) public static function Instantiate($locale)
{ {
switch ($locale) { $reader = null;
case 'en_US':  
require_once(GITPHP_LOCALEDIR . 'en_US.class.php'); if (!(($locale == 'en_US') || ($locale == 'en'))) {
self::$instance = new GitPHP_Resource_en_US(); $reader = new FileReader(GITPHP_LOCALEDIR . $locale . '/LC_MESSAGES/gitphp.mo');
break;  
case 'zz_Debug':  
require_once(GITPHP_LOCALEDIR . 'zz_Debug.class.php');  
self::$instance = new GitPHP_Resource_zz_Debug();  
break;  
default:  
throw new Exception('Invalid locale: ' . $locale);  
break;  
} }
   
  self::$instance = new gettext_reader($reader);
} }
   
} }
   
<?php <?php
/* /*
* modifier.agestring.php * modifier.agestring.php
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Utility - convert age to a readable string * Component: Utility - convert age to a readable string
* *
* Copyright (C) 2008 Christopher Han <xiphux@gmail.com> * Copyright (C) 2008 Christopher Han <xiphux@gmail.com>
*/ */
   
function smarty_modifier_agestring($age) function smarty_modifier_agestring($age)
{ {
if ($age > 60*60*24*365*2) $resource = GitPHP_Resource::GetInstance();
return sprintf(GitPHP_Resource::GetInstance()->GetResource('%1$d years ago'), (int)($age/60/60/24/365));  
else if ($age > 60*60*24*(365/12)*2) if ($age > 60*60*24*365*2) {
return sprintf(GitPHP_Resource::GetInstance()->GetResource('%1$d months ago'), (int)($age/60/60/24/(365/12)));  
else if ($age > 60*60*24*7*2) $years = (int)($age/60/60/24/365);
return sprintf(GitPHP_Resource::GetInstance()->GetResource('%1$d weeks ago'), (int)($age/60/60/24/7)); return sprintf($resource->ngettext('%1$d year ago', '%1$d years ago', $years), $years);
else if ($age > 60*60*24*2)  
return sprintf(GitPHP_Resource::GetInstance()->GetResource('%1$d days ago'), (int)($age/60/60/24)); } else if ($age > 60*60*24*(365/12)*2) {
else if ($age > 60*60*2)  
return sprintf(GitPHP_Resource::GetInstance()->GetResource('%1$d hours ago'), (int)($age/60/60)); $months = (int)($age/60/60/24/(365/12));
else if ($age > 60*2) return sprintf($resource->ngettext('%1$d month ago', '%1$d months ago', $months), $months);
return sprintf(GitPHP_Resource::GetInstance()->GetResource('%1$d min ago'), (int)($age/60));  
else if ($age > 2) } else if ($age > 60*60*24*7*2) {
return sprintf(GitPHP_Resource::GetInstance()->GetResource('%1$d sec ago'), (int)$age);  
return GitPHP_Resource::GetInstance()->GetResource('right now'); $weeks = (int)($age/60/60/24/7);
  return sprintf($resource->ngettext('%1$d week ago', '%1$d weeks ago', $weeks), $weeks);
   
  } else if ($age > 60*60*24*2) {
   
  $days = (int)($age/60/60/24);
  return sprintf($resource->ngettext('%1$d day ago', '%1$d days ago', $days), $days);
   
  } else if ($age > 60*60*2) {
   
  $hours = (int)($age/60/60);
  return sprintf($resource->ngettext('%1$d hour ago', '%1$d hours ago', $hours), $hours);
   
  } else if ($age > 60*2) {
   
  $min = (int)($age/60);
  return sprintf($resource->ngettext('%1$d min ago', '%1$d min ago', $min), $min);
   
  } else if ($age > 2) {
   
  $sec = (int)$age;
  return sprintf($resource->ngettext('%1$d sec ago', '%1$d sec ago', $sec), $sec);
   
  }
   
  return $resource->translate('right now');
} }
   
?> ?>
   
file:a/index.php -> file:b/index.php
<?php <?php
/** /**
* GitPHP * GitPHP
* *
* Index * Index
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
*/ */
   
define('GITPHP_START_TIME', microtime(true)); define('GITPHP_START_TIME', microtime(true));
define('GITPHP_START_MEM', memory_get_usage()); define('GITPHP_START_MEM', memory_get_usage());
   
/** /**
* Define some paths * Define some paths
*/ */
define('GITPHP_BASEDIR', dirname(__FILE__) . '/'); define('GITPHP_BASEDIR', dirname(__FILE__) . '/');
define('GITPHP_CONFIGDIR', GITPHP_BASEDIR . 'config/'); define('GITPHP_CONFIGDIR', GITPHP_BASEDIR . 'config/');
define('GITPHP_INCLUDEDIR', GITPHP_BASEDIR . 'include/'); define('GITPHP_INCLUDEDIR', GITPHP_BASEDIR . 'include/');
define('GITPHP_GITOBJECTDIR', GITPHP_INCLUDEDIR . 'git/'); define('GITPHP_GITOBJECTDIR', GITPHP_INCLUDEDIR . 'git/');
define('GITPHP_CONTROLLERDIR', GITPHP_INCLUDEDIR . 'controller/'); define('GITPHP_CONTROLLERDIR', GITPHP_INCLUDEDIR . 'controller/');
define('GITPHP_RESOURCEDIR', GITPHP_INCLUDEDIR . 'resource/'); define('GITPHP_RESOURCEDIR', GITPHP_INCLUDEDIR . 'resource/');
define('GITPHP_LOCALEDIR', GITPHP_RESOURCEDIR . 'locale/'); define('GITPHP_LOCALEDIR', GITPHP_BASEDIR . 'locale/');
   
include_once(GITPHP_INCLUDEDIR . 'version.php'); include_once(GITPHP_INCLUDEDIR . 'version.php');
   
require_once(GITPHP_INCLUDEDIR . 'Config.class.php'); require_once(GITPHP_INCLUDEDIR . 'Config.class.php');
   
require_once(GITPHP_RESOURCEDIR . 'Resource.class.php'); require_once(GITPHP_RESOURCEDIR . 'Resource.class.php');
   
require_once(GITPHP_INCLUDEDIR . 'Log.class.php'); require_once(GITPHP_INCLUDEDIR . 'Log.class.php');
   
require_once(GITPHP_GITOBJECTDIR . 'ProjectList.class.php'); require_once(GITPHP_GITOBJECTDIR . 'ProjectList.class.php');
   
require_once(GITPHP_INCLUDEDIR . 'MessageException.class.php'); require_once(GITPHP_INCLUDEDIR . 'MessageException.class.php');
   
require_once(GITPHP_CONTROLLERDIR . 'Controller.class.php'); require_once(GITPHP_CONTROLLERDIR . 'Controller.class.php');
   
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
   
try { try {
   
// Define these here because these get used in the config file // Define these here because these get used in the config file
define('GITPHP_COMPRESS_BZ2', 1); define('GITPHP_COMPRESS_BZ2', 1);
define('GITPHP_COMPRESS_GZ', 2); define('GITPHP_COMPRESS_GZ', 2);
define('GITPHP_COMPRESS_ZIP', 3); define('GITPHP_COMPRESS_ZIP', 3);
   
/* /*
* Configuration * Configuration
*/ */
GitPHP_Config::GetInstance()->LoadConfig(GITPHP_CONFIGDIR . 'gitphp.conf.php'); GitPHP_Config::GetInstance()->LoadConfig(GITPHP_CONFIGDIR . 'gitphp.conf.php');
   
/* /*
* Resource * Resource
*/ */
GitPHP_Resource::Instantiate(GitPHP_Config::GetInstance()->GetValue('locale', 'en_US')); GitPHP_Resource::Instantiate(GitPHP_Config::GetInstance()->GetValue('locale', 'en_US'));
   
/* /*
* Debug * Debug
*/ */
if (GitPHP_Log::GetInstance()->GetEnabled()) { if (GitPHP_Log::GetInstance()->GetEnabled()) {
GitPHP_Log::GetInstance()->SetStartTime(GITPHP_START_TIME); GitPHP_Log::GetInstance()->SetStartTime(GITPHP_START_TIME);
GitPHP_Log::GetInstance()->SetStartMemory(GITPHP_START_MEM); GitPHP_Log::GetInstance()->SetStartMemory(GITPHP_START_MEM);
} }
   
if (!GitPHP_Config::GetInstance()->GetValue('projectroot', null)) { if (!GitPHP_Config::GetInstance()->GetValue('projectroot', null)) {
throw new GitPHP_MessageException('A projectroot must be set in the config', true); throw new GitPHP_MessageException(GitPHP_Resource::GetInstance()->translate('A projectroot must be set in the config'), true);
} }
   
/* /*
* Project list * Project list
*/ */
if (file_exists(GITPHP_CONFIGDIR . 'projects.conf.php')) { if (file_exists(GITPHP_CONFIGDIR . 'projects.conf.php')) {
GitPHP_ProjectList::Instantiate(GITPHP_CONFIGDIR . 'projects.conf.php', false); GitPHP_ProjectList::Instantiate(GITPHP_CONFIGDIR . 'projects.conf.php', false);
} else { } else {
GitPHP_ProjectList::Instantiate(GITPHP_CONFIGDIR . 'gitphp.conf.php', true); GitPHP_ProjectList::Instantiate(GITPHP_CONFIGDIR . 'gitphp.conf.php', true);
} }
   
$controller = GitPHP_Controller::GetController((isset($_GET['a']) ? $_GET['a'] : null)); $controller = GitPHP_Controller::GetController((isset($_GET['a']) ? $_GET['a'] : null));
if ($controller) { if ($controller) {
$controller->RenderHeaders(); $controller->RenderHeaders();
$controller->Render(); $controller->Render();
} }
   
} catch (Exception $e) { } catch (Exception $e) {
   
if (GitPHP_Config::GetInstance()->GetValue('debug', false)) { if (GitPHP_Config::GetInstance()->GetValue('debug', false)) {
throw $e; throw $e;
} }
   
if (GitPHP_Resource::GetInstance() == null) { if (GitPHP_Resource::GetInstance() == null) {
/* /*
* In case an error was thrown before instantiating * In case an error was thrown before instantiating
* the resource manager * the resource manager
*/ */
GitPHP_Resource::Instantiate('en_US'); GitPHP_Resource::Instantiate('en_US');
} }
   
require_once(GITPHP_CONTROLLERDIR . 'Controller_Message.class.php'); require_once(GITPHP_CONTROLLERDIR . 'Controller_Message.class.php');
$controller = new GitPHP_Controller_Message(); $controller = new GitPHP_Controller_Message();
$controller->SetParam('message', $e->getMessage()); $controller->SetParam('message', $e->getMessage());
if ($e instanceof GitPHP_MessageException) { if ($e instanceof GitPHP_MessageException) {
$controller->SetParam('error', $e->Error); $controller->SetParam('error', $e->Error);
} else { } else {
$controller->SetParam('error', true); $controller->SetParam('error', true);
} }
$controller->Render(); $controller->Render();
   
} }
   
if (GitPHP_Log::GetInstance()->GetEnabled()) { if (GitPHP_Log::GetInstance()->GetEnabled()) {
$entries = GitPHP_Log::GetInstance()->GetEntries(); $entries = GitPHP_Log::GetInstance()->GetEntries();
foreach ($entries as $logline) { foreach ($entries as $logline) {
echo "\n" . $logline; echo "\n" . $logline;
} }
} }
   
?> ?>
   
{* {*
* blame.tpl * blame.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Blame view template * Component: Blame view template
* *
* Copyright (C) 2010 Christopher Han <xiphux@gmail.com> * Copyright (C) 2010 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' treecommit=$commit} {include file='nav.tpl' treecommit=$commit}
<br /> <br />
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob_plain&h={$blob->GetHash()}&f={$blob->GetPath()}">{$resources->GetResource('plain')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob_plain&h={$blob->GetHash()}&f={$blob->GetPath()}">{t}plain{/t}</a> |
{if $commit->GetHash() != $head->GetHash()} {if $commit->GetHash() != $head->GetHash()}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blame&hb=HEAD&f={$blob->GetPath()}">{$resources->GetResource('HEAD')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blame&hb=HEAD&f={$blob->GetPath()}">{t}HEAD{/t}</a>
{else} {else}
{$resources->GetResource('HEAD')} {t}HEAD{/t}
{/if} {/if}
| blame | blame
<br /> <br />
</div> </div>
   
{include file='title.tpl' titlecommit=$commit} {include file='title.tpl' titlecommit=$commit}
   
{include file='path.tpl' pathobject=$blob target='blob'} {include file='path.tpl' pathobject=$blob target='blob'}
<div class="page_body"> <div class="page_body">
{if $geshi} {if $geshi}
{$geshihead} {$geshihead}
<td class="ln de1" id="blameData"> <td class="ln de1" id="blameData">
{include file='blamedata.tpl'} {include file='blamedata.tpl'}
</td> </td>
{$geshibody} {$geshibody}
{$geshifoot} {$geshifoot}
{else} {else}
<table class="code"> <table class="code">
{foreach from=$blob->GetData(true) item=blobline name=blob} {foreach from=$blob->GetData(true) item=blobline name=blob}
{assign var=blamecommit value=$blame[$smarty.foreach.blob.iteration]} {assign var=blamecommit value=$blame[$smarty.foreach.blob.iteration]}
{if $blamecommit} {if $blamecommit}
{cycle values="light,dark" assign=rowclass} {cycle values="light,dark" assign=rowclass}
{/if} {/if}
<tr class="{$rowclass}"> <tr class="{$rowclass}">
<td class="date"> <td class="date">
{if $blamecommit} {if $blamecommit}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$blamecommit->GetHash()}" title="{$blamecommit->GetTitle()}" class="commitTip">{$blamecommit->GetAuthorEpoch()|date_format:"%F %X"}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$blamecommit->GetHash()}" title="{$blamecommit->GetTitle()}" class="commitTip">{$blamecommit->GetAuthorEpoch()|date_format:"%F %X"}</a>
{/if} {/if}
</td> </td>
<td class="author"> <td class="author">
{if $blamecommit} {if $blamecommit}
{$blamecommit->GetAuthor()} {$blamecommit->GetAuthor()}
{/if} {/if}
</td> </td>
<td class="num"><a id="l{$smarty.foreach.blob.iteration}" href="#l{$smarty.foreach.blob.iteration}" class="linenr">{$smarty.foreach.blob.iteration}</a></td> <td class="num"><a id="l{$smarty.foreach.blob.iteration}" href="#l{$smarty.foreach.blob.iteration}" class="linenr">{$smarty.foreach.blob.iteration}</a></td>
<td class="codeline">{$blobline|escape}</td> <td class="codeline">{$blobline|escape}</td>
</tr> </tr>
{/foreach} {/foreach}
</table> </table>
{/if} {/if}
</div> </div>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
{* {*
* blob.tpl * blob.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Blob view template * Component: Blob view template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' treecommit=$commit} {include file='nav.tpl' treecommit=$commit}
<br /> <br />
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob_plain&h={$blob->GetHash()}&f={$blob->GetPath()}">{$resources->GetResource('plain')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob_plain&h={$blob->GetHash()}&f={$blob->GetPath()}">{t}plain{/t}</a> |
{if ($commit->GetHash() != $head->GetHash()) && ($head->PathToHash($blob->GetPath()))} {if ($commit->GetHash() != $head->GetHash()) && ($head->PathToHash($blob->GetPath()))}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&hb=HEAD&f={$blob->GetPath()}">{$resources->GetResource('HEAD')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&hb=HEAD&f={$blob->GetPath()}">{t}HEAD{/t}</a>
{else} {else}
{$resources->GetResource('HEAD')} {t}HEAD{/t}
{/if} {/if}
{if !$datatag} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blame&h={$blob->GetHash()}&f={$blob->GetPath()}&hb={$commit->GetHash()}" id="blameLink">{$resources->GetResource('blame')}</a>{/if} {if !$datatag} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blame&h={$blob->GetHash()}&f={$blob->GetPath()}&hb={$commit->GetHash()}" id="blameLink">{t}blame{/t}</a>{/if}
<br /> <br />
</div> </div>
   
{include file='title.tpl' titlecommit=$commit} {include file='title.tpl' titlecommit=$commit}
   
{include file='path.tpl' pathobject=$blob target='blobplain'} {include file='path.tpl' pathobject=$blob target='blobplain'}
   
<div class="page_body"> <div class="page_body">
{if $datatag} {if $datatag}
{* We're trying to display an image *} {* We're trying to display an image *}
<div> <div>
<img src="data:{$mime};base64,{$data}" /> <img src="data:{$mime};base64,{$data}" />
</div> </div>
{elseif $geshi} {elseif $geshi}
{* We're using the highlighted output from geshi *} {* We're using the highlighted output from geshi *}
{$geshiout} {$geshiout}
{else} {else}
{* Just plain display *} {* Just plain display *}
<table class="code" id="blobData"> <table class="code" id="blobData">
<tbody> <tbody>
<tr class="li1"> <tr class="li1">
<td class="ln"> <td class="ln">
<pre class="de1"> <pre class="de1">
{foreach from=$bloblines item=line name=bloblines} {foreach from=$bloblines item=line name=bloblines}
<a id="l{$smarty.foreach.bloblines.iteration}" href="#1{$smarty.foreach.bloblines.iteration}" class="linenr">{$smarty.foreach.bloblines.iteration}</a> <a id="l{$smarty.foreach.bloblines.iteration}" href="#1{$smarty.foreach.bloblines.iteration}" class="linenr">{$smarty.foreach.bloblines.iteration}</a>
{/foreach} {/foreach}
</pre></td> </pre></td>
<td class="de1"> <td class="de1">
<pre class="de1"> <pre class="de1">
{foreach from=$bloblines item=line name=bloblines} {foreach from=$bloblines item=line name=bloblines}
{$line|escape} {$line|escape}
{/foreach} {/foreach}
</pre> </pre>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
{/if} {/if}
</div> </div>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
{* {*
* blobdiff.tpl * blobdiff.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Blobdiff view template * Component: Blobdiff view template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' treecommit=$commit} {include file='nav.tpl' treecommit=$commit}
<br /> <br />
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff_plain&h={$blob->GetHash()}&hp={$blobparent->GetHash()}&f={$file}">{$resources->GetResource('plain')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff_plain&h={$blob->GetHash()}&hp={$blobparent->GetHash()}&f={$file}">{t}plain{/t}</a>
</div> </div>
   
{include file='title.tpl' titlecommit=$commit} {include file='title.tpl' titlecommit=$commit}
   
{include file='path.tpl' pathobject=$blobparent target='blob'} {include file='path.tpl' pathobject=$blobparent target='blob'}
<div class="page_body"> <div class="page_body">
<div class="diff_info"> <div class="diff_info">
{* Display the from -> to diff header *} {* Display the from -> to diff header *}
{$resources->GetResource('blob')}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$blobparent->GetHash()}&hb={$commit->GetHash()}&f={$file}">{if $file}a/{$file}{else}{$blobparent->GetHash()}{/if}</a> -&gt; {$resources->GetResource('blob')}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$blob->GetHash()}&hb={$commit->GetHash()}&f={$file}">{if $file}b/{$file}{else}{$blob->GetHash()}{/if}</a> {t}blob{/t}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$blobparent->GetHash()}&hb={$commit->GetHash()}&f={$file}">{if $file}a/{$file}{else}{$blobparent->GetHash()}{/if}</a> -&gt; {t}blob{/t}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$blob->GetHash()}&hb={$commit->GetHash()}&f={$file}">{if $file}b/{$file}{else}{$blob->GetHash()}{/if}</a>
</div> </div>
{* Display the diff *} {* Display the diff *}
{include file='filediff.tpl' diff=$filediff->GetDiff($file, false, true)} {include file='filediff.tpl' diff=$filediff->GetDiff($file, false, true)}
</div> </div>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* commit.tpl * commit.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Commit view template * Component: Commit view template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' logcommit=$commit treecommit=$commit current='commit'} {include file='nav.tpl' logcommit=$commit treecommit=$commit current='commit'}
<br /><br /> <br /><br />
</div> </div>
   
{if $commit->GetParent()} {if $commit->GetParent()}
{include file='title.tpl' titlecommit=$commit target='commitdiff'} {include file='title.tpl' titlecommit=$commit target='commitdiff'}
{else} {else}
{include file='title.tpl' titlecommit=$commit titletree=$tree target='tree'} {include file='title.tpl' titlecommit=$commit titletree=$tree target='tree'}
{/if} {/if}
<div class="title_text"> <div class="title_text">
{* Commit data *} {* Commit data *}
<table cellspacing="0"> <table cellspacing="0">
<tr> <tr>
<td>{$resources->GetResource('author')}</td> <td>{t}author{/t}</td>
<td>{$commit->GetAuthorName()}</td> <td>{$commit->GetAuthorName()}</td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td> {$commit->GetAuthorEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"} <td> {$commit->GetAuthorEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"}
{assign var=hourlocal value=$commit->GetAuthorLocalEpoch()|date_format:"%H"} {assign var=hourlocal value=$commit->GetAuthorLocalEpoch()|date_format:"%H"}
{if $hourlocal < 6} {if $hourlocal < 6}
(<span class="latenight">{$commit->GetAuthorLocalEpoch()|date_format:"%R"}</span> {$commit->GetAuthorTimezone()})</td> (<span class="latenight">{$commit->GetAuthorLocalEpoch()|date_format:"%R"}</span> {$commit->GetAuthorTimezone()})</td>
{else} {else}
({$commit->GetAuthorLocalEpoch()|date_format:"%R"} {$commit->GetAuthorTimezone()})</td> ({$commit->GetAuthorLocalEpoch()|date_format:"%R"} {$commit->GetAuthorTimezone()})</td>
{/if} {/if}
</tr> </tr>
<tr> <tr>
<td>{$resources->GetResource('committer')}</td> <td>{t}committer{/t}</td>
<td>{$commit->GetCommitterName()}</td> <td>{$commit->GetCommitterName()}</td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td> {$commit->GetCommitterEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"} ({$commit->GetCommitterLocalEpoch()|date_format:"%R"} {$commit->GetCommitterTimezone()})</td> <td> {$commit->GetCommitterEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"} ({$commit->GetCommitterLocalEpoch()|date_format:"%R"} {$commit->GetCommitterTimezone()})</td>
</tr> </tr>
<tr> <tr>
<td>{$resources->GetResource('commit')}</td> <td>{t}commit{/t}</td>
<td class="monospace">{$commit->GetHash()}</td> <td class="monospace">{$commit->GetHash()}</td>
<tr> <tr>
<tr> <tr>
<td>{$resources->GetResource('tree')}</td> <td>{t}tree{/t}</td>
<td class="monospace"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}" class="list">{$tree->GetHash()}</a></td> <td class="monospace"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}" class="list">{$tree->GetHash()}</a></td>
<td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">{$resources->GetResource('tree')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$commit->GetHash()}">{$resources->GetResource('snapshot')}</a></td> <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">{t}tree{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$commit->GetHash()}">{t}snapshot{/t}</a></td>
</tr> </tr>
{foreach from=$commit->GetParents() item=par} {foreach from=$commit->GetParents() item=par}
<tr> <tr>
<td>{$resources->GetResource('parent')}</td> <td>{t}parent{/t}</td>
<td class="monospace"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$par->GetHash()}" class="list">{$par->GetHash()}</a></td> <td class="monospace"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$par->GetHash()}" class="list">{$par->GetHash()}</a></td>
<td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$par->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}&hp={$par->GetHash()}">{$resources->GetResource('commitdiff')}</a></td> <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$par->GetHash()}">{t}commit{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}&hp={$par->GetHash()}">{t}commitdiff{/t}</a></td>
</tr> </tr>
{/foreach} {/foreach}
</table> </table>
</div> </div>
<div class="page_body"> <div class="page_body">
{foreach from=$commit->GetComment() item=line} {foreach from=$commit->GetComment() item=line}
{$line}<br /> {$line}<br />
{/foreach} {/foreach}
</div> </div>
<div class="list_head"> <div class="list_head">
{if $treediff->Count() > 10} {if $treediff->Count() > 10}
{$resources->Format('%1$d files changed:', $treediff->Count())|escape} {t count=$treediff->Count() 1=$treediff->Count() plural="%1 files changed:"}%1 file changed:{/t}
{/if} {/if}
</div> </div>
<table cellspacing="0"> <table cellspacing="0">
{* Loop and show files changed *} {* Loop and show files changed *}
{foreach from=$treediff item=diffline} {foreach from=$treediff item=diffline}
<tr class="{cycle values="light,dark"}"> <tr class="{cycle values="light,dark"}">
{if $diffline->GetStatus() == "A"} {if $diffline->GetStatus() == "A"}
<td> <td>
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetFromFile()}" class="list"> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetFromFile()}" class="list">
{$diffline->GetFromFile()} {$diffline->GetFromFile()}
</a> </a>
</td> </td>
<td> <td>
<span class="newfile"> <span class="newfile">
{assign var=localtotype value=$resources->GetResource($diffline->GetToFileType())} {assign var=localtotype value=$diffline->GetToFileType(1)}
[ [
{if $diffline->ToFileIsRegular()} {if $diffline->ToFileIsRegular()}
{$resources->Format('new %1$s with mode %2$s', $localtotype, $diffline->GetToModeShort())|escape} {assign var=tomode value=$diffline->GetToModeShort()}
  {t 1=$localtotype 2=$tomode}new %1 with mode %2{/t}
{else} {else}
{$resources->Format('new %1$s', $localtotype)|escape} {t 1=$localtotype}new %1{/t}
{/if} {/if}
] ]
</span> </span>
</td> </td>
<td class="link"> <td class="link">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetFromFile()}">{$resources->GetResource('blob')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetFromFile()}">{t}blob{/t}</a>
</td> </td>
{elseif $diffline->GetStatus() == "D"} {elseif $diffline->GetStatus() == "D"}
<td> <td>
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetFromHash()}&hb={$commit->GetHash()}&f={$diffline->GetFromFile()}" class="list"> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetFromHash()}&hb={$commit->GetHash()}&f={$diffline->GetFromFile()}" class="list">
{$diffline->GetFromFile()} {$diffline->GetFromFile()}
</a> </a>
</td> </td>
<td> <td>
<span class="deletedfile"> <span class="deletedfile">
{assign var=localfromtype value=$resources->GetResource($diffline->GetFromFileType())} {assign var=localfromtype value=$diffline->GetFromFileType(1)}
[ {$resources->Format('deleted %1$s', $localfromtype)|escape} ] [ {t 1=$localfromtype}deleted %1{/t} ]
</span> </span>
</td> </td>
<td class="link"> <td class="link">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetFromHash()}&hb={$commit->GetHash()}&f={$diffline->GetFromFile()}">{$resources->GetResource('blob')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=history&h={$commit->GetHash()}&f={$diffline->GetFromFile()}">{$resources->GetResource('history')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetFromHash()}&hb={$commit->GetHash()}&f={$diffline->GetFromFile()}">{t}blob{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=history&h={$commit->GetHash()}&f={$diffline->GetFromFile()}">{t}history{/t}</a>
</td> </td>
{elseif $diffline->GetStatus() == "M" || $diffline->GetStatus() == "T"} {elseif $diffline->GetStatus() == "M" || $diffline->GetStatus() == "T"}
<td> <td>
{if $diffline->GetToHash() != $diffline->GetFromHash()} {if $diffline->GetToHash() != $diffline->GetFromHash()}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff&h={$diffline->GetToHash()}&hp={$diffline->GetFromHash()}&hb={$par->GetHash()}&f={$diffline->GetToFile()}" class="list"> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff&h={$diffline->GetToHash()}&hp={$diffline->GetFromHash()}&hb={$par->GetHash()}&f={$diffline->GetToFile()}" class="list">
{$diffline->GetToFile()} {$diffline->GetToFile()}
</a> </a>
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetToFile()}" class="list"> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetToFile()}" class="list">
{$diffline->GetToFile()} {$diffline->GetToFile()}
</a> </a>
{/if} {/if}
</td> </td>
<td> <td>
{if $diffline->GetFromMode() != $diffline->GetToMode()} {if $diffline->GetFromMode() != $diffline->GetToMode()}
<span class="changedfile"> <span class="changedfile">
[ [
{if $diffline->FileTypeChanged()} {if $diffline->FileTypeChanged()}
{assign var=localfromtype value=$resources->GetResource($diffline->GetFromFileType())} {assign var=localfromtype value=$diffline->GetFromFileType(1)}
{assign var=localtotype value=$resources->GetResource($diffline->GetToFileType())} {assign var=localtotype value=$diffline->GetToFileType(1)}
{if $diffline->FileModeChanged()} {if $diffline->FileModeChanged()}
{if $diffline->FromFileIsRegular() && $diffline->ToFileIsRegular()} {if $diffline->FromFileIsRegular() && $diffline->ToFileIsRegular()}
{$resources->Format('changed from %1$s to %2$s mode: %3$s -> %4$s', $localfromtype, $localtotype, $diffline->GetFromModeShort(), $diffline->GetToModeShort())|escape} {assign var=frommode value=$diffline->GetFromModeShort()}
  {assign var=tomode value=$diffline->GetToModeShort()}
  {t 1=$localfromtype 2=$localtotype 3=$frommode 4=$tomode}changed from %1 to %2 mode: %3 -> %4{/t}
{elseif $diffline->ToFileIsRegular()} {elseif $diffline->ToFileIsRegular()}
{$resources->Format('changed from %1$s to %2$s mode: %3$s', $localfromtype, $localtotype, $diffline->GetToModeShort())|escape} {assign var=tomode value=$diffline->GetToModeShort()}
  {t 1=$localfromtype 2=$localtotype 3=$tomode}changed from %1 to %2 mode: %3{/t}
{else} {else}
{$resources->Format('changed from %1$s to %2$s', $localfromtype, $localtotype)|escape} {t 1=$localfromtype 2=$localtotype}changed from %1 to %2{/t}
{/if} {/if}
{else} {else}
{$resources->Format('changed from %1$s to %2$s', $localfromtype, $localtotype)|escape} {t 1=$localfromtype 2=$localtotype}changed from %1 to %2{/t}
{/if} {/if}
{else} {else}
{if $diffline->FileModeChanged()} {if $diffline->FileModeChanged()}
{if $diffline->FromFileIsRegular() && $diffline->ToFileIsRegular()} {if $diffline->FromFileIsRegular() && $diffline->ToFileIsRegular()}
{$resources->Format('changed mode: %1$s -> %2$s', $diffline->GetFromModeShort(), $diffline->GetToModeShort())|escape} {assign var=frommode value=$diffline->GetFromModeShort()}
  {assign var=tomode value=$diffline->GetToModeShort()}
  {t 1=$frommode 2=$tomode}changed mode: %1 -> %2{/t}
{elseif $diffline->ToFileIsRegular()} {elseif $diffline->ToFileIsRegular()}
{$resources->Format('changed mode: %1$s', $diffline->GetToModeShort())|escape} {assign var=tomode value=$diffline->GetToModeShort()}
  {t 1=$tomode}changed mode: %1{/t}
{else} {else}
{$resources->GetResource('changed')} {t}changed{/t}
{/if} {/if}
{else} {else}
{$resources->GetResource('changed')} {t}changed{/t}
{/if} {/if}
{/if} {/if}
] ]
</span> </span>
{/if} {/if}
</td> </td>
<td class="link"> <td class="link">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetToFile()}">{$resources->GetResource('blob')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetToFile()}">{t}blob{/t}</a>
{if $diffline->GetToHash() != $diffline->GetFromHash()} {if $diffline->GetToHash() != $diffline->GetFromHash()}
| <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff&h={$diffline->GetToHash()}&hp={$diffline->GetFromHash()}&hb={$par->GetHash()}&f={$diffline->GetToFile()}">{$resources->GetResource('diff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff&h={$diffline->GetToHash()}&hp={$diffline->GetFromHash()}&hb={$par->GetHash()}&f={$diffline->GetToFile()}">{t}diff{/t}</a>
{/if} {/if}
| <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=history&h={$commit->GetHash()}&f={$diffline->GetFromFile()}">{$resources->GetResource('history')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=history&h={$commit->GetHash()}&f={$diffline->GetFromFile()}">{t}history{/t}</a>
</td> </td>
{elseif $diffline->GetStatus() == "R"} {elseif $diffline->GetStatus() == "R"}
<td> <td>
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetToFile()}" class="list"> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetToFile()}" class="list">
{$diffline->GetToFile()}</a> {$diffline->GetToFile()}</a>
</td> </td>
<td> <td>
<span class="movedfile"> <span class="movedfile">
{capture assign=fromfilelink} {capture assign=fromfilelink}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetFromHash()}&hb={$commit->GetHash()}&f={$diffline->GetFromFile()}" class="list">{$diffline->GetFromFile()}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetFromHash()}&hb={$commit->GetHash()}&f={$diffline->GetFromFile()}" class="list">{$diffline->GetFromFile()}</a>
{/capture} {/capture}
[ [
  {assign var=similarity value=$diffline->GetSimilarity()}
{if $diffline->GetFromMode() != $diffline->GetToMode()} {if $diffline->GetFromMode() != $diffline->GetToMode()}
{$resources->Format('moved from %1$s with %2$d%% similarity, mode: %3$s', $fromfilelink, $diffline->GetSimilarity(), $diffline->GetToModeShort())} {assign var=tomode value=$diffline->GetToModeShort()}
  {t escape=0 1=$fromfilelink 2=$similarity 3=$tomode}moved from %1 with %2%% similarity, mode: %3{/t}
{else} {else}
{$resources->Format('moved from %1$s with %2$d%% similarity', $fromfilelink, $diffline->GetSimilarity())} {t escape=0 1=$fromfilelink 2=$similarity}moved from %1 with %2%% similarity{/t}
{/if} {/if}
] ]
</span> </span>
</td> </td>
<td class="link"> <td class="link">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetToFile()}">{$resources->GetResource('blob')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$diffline->GetToHash()}&hb={$commit->GetHash()}&f={$diffline->GetToFile()}">{t}blob{/t}</a>
{if $diffline->GetToHash() != $diffline->GetFromHash()} {if $diffline->GetToHash() != $diffline->GetFromHash()}
| <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff&h={$diffline->GetToHash()}&hp={$diffline->GetFromHash()}&hb={$par->GetHash()}&f={$diffline->GetToFile()}">{$resources->GetResource('diff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff&h={$diffline->GetToHash()}&hp={$diffline->GetFromHash()}&hb={$par->GetHash()}&f={$diffline->GetToFile()}">{t}diff{/t}</a>
{/if} {/if}
</td> </td>
{/if} {/if}
   
</tr> </tr>
{/foreach} {/foreach}
</table> </table>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* commitdiff.tpl * commitdiff.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Commitdiff view template * Component: Commitdiff view template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
{* Nav *} {* Nav *}
<div class="page_nav"> <div class="page_nav">
{if $commit} {if $commit}
{assign var=tree value=$commit->GetTree()} {assign var=tree value=$commit->GetTree()}
{/if} {/if}
{include file='nav.tpl' current='commitdiff' logcommit=$commit treecommit=$commit} {include file='nav.tpl' current='commitdiff' logcommit=$commit treecommit=$commit}
<br /> <br />
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff_plain&h={$commit->GetHash()}{if $hashparent}&hp={$hashparent}{/if}">{$resources->GetResource('plain')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff_plain&h={$commit->GetHash()}{if $hashparent}&hp={$hashparent}{/if}">{t}plain{/t}</a>
</div> </div>
   
{include file='title.tpl' titlecommit=$commit} {include file='title.tpl' titlecommit=$commit}
<div class="page_body"> <div class="page_body">
{foreach from=$commit->GetComment() item=line} {foreach from=$commit->GetComment() item=line}
{$line}<br /> {$line}<br />
{/foreach} {/foreach}
<br /> <br />
{* Diff each file changed *} {* Diff each file changed *}
{foreach from=$treediff item=filediff} {foreach from=$treediff item=filediff}
<div class="diff_info"> <div class="diff_info">
{if ($filediff->GetStatus() == 'D') || ($filediff->GetStatus() == 'M')} {if ($filediff->GetStatus() == 'D') || ($filediff->GetStatus() == 'M')}
{assign var=localfromtype value=$resources->GetResource($filediff->GetFromFileType())} {assign var=localfromtype value=$filediff->GetFromFileType(1)}
{$localfromtype}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$filediff->GetFromHash()}&hb={$commit->GetHash()}{if $filediff->GetFromFile()}&f={$filediff->GetFromFile()}{/if}">{if $filediff->GetFromFile()}{$filediff->GetFromFile()}{else}{$filediff->GetFromHash()}{/if}</a> {$localfromtype}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$filediff->GetFromHash()}&hb={$commit->GetHash()}{if $filediff->GetFromFile()}&f={$filediff->GetFromFile()}{/if}">{if $filediff->GetFromFile()}{$filediff->GetFromFile()}{else}{$filediff->GetFromHash()}{/if}</a>
{if $filediff->GetStatus() == 'D'} {if $filediff->GetStatus() == 'D'}
{$resources->GetResource('(deleted)')} {t}(deleted){/t}
{/if} {/if}
{/if} {/if}
   
{if $filediff->GetStatus() == 'M'} {if $filediff->GetStatus() == 'M'}
-&gt; -&gt;
{/if} {/if}
   
{if ($filediff->GetStatus() == 'A') || ($filediff->GetStatus() == 'M')} {if ($filediff->GetStatus() == 'A') || ($filediff->GetStatus() == 'M')}
{assign var=localtotype value=$resources->GetResource($filediff->GetToFileType())} {assign var=localtotype value=$filediff->GetToFileType(1)}
{$localtotype}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$filediff->GetToHash()}&hb={$commit->GetHash()}{if $filediff->GetToFile()}&f={$filediff->GetToFile()}{/if}">{if $filediff->GetToFile()}b/{$filediff->GetToFile()}{else}{$filediff->GetToHash()}{/if}</a> {$localtotype}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$filediff->GetToHash()}&hb={$commit->GetHash()}{if $filediff->GetToFile()}&f={$filediff->GetToFile()}{/if}">{if $filediff->GetToFile()}b/{$filediff->GetToFile()}{else}{$filediff->GetToHash()}{/if}</a>
   
{if $filediff->GetStatus() == 'A'} {if $filediff->GetStatus() == 'A'}
{$resources->GetResource('(new)')} {t}(new){/t}
{/if} {/if}
{/if} {/if}
</div> </div>
{include file='filediff.tpl' diff=$filediff->GetDiff('', true, true)} {include file='filediff.tpl' diff=$filediff->GetDiff('', true, true)}
{/foreach} {/foreach}
</div> </div>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* committip.tpl * committip.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Commit tooltip template * Component: Commit tooltip template
* *
* Copyright (C) 2010 Christopher Han <xiphux@gmail.com> * Copyright (C) 2010 Christopher Han <xiphux@gmail.com>
*} *}
<div> <div>
{$resources->GetResource('author')}: {$commit->GetAuthor()} ({$commit->GetAuthorEpoch()|date_format:"%F %X"}) {t}author{/t}: {$commit->GetAuthor()} ({$commit->GetAuthorEpoch()|date_format:"%F %X"})
<br /> <br />
{$resources->GetResource('committer')}: {$commit->GetCommitter()} ({$commit->GetCommitterEpoch()|date_format:"%F %X"}) {t}committer{/t}: {$commit->GetCommitter()} ({$commit->GetCommitterEpoch()|date_format:"%F %X"})
<br /><br /> <br /><br />
{foreach from=$commit->GetComment() item=line} {foreach from=$commit->GetComment() item=line}
{$line}<br /> {$line}<br />
{/foreach} {/foreach}
</div> </div>
   
{* {*
* 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>
*} *}
<?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-2010 Christopher Han <xiphux@gmail.com> --> <!-- gitphp web interface {$version}, (C) 2006-2010 Christopher Han <xiphux@gmail.com> -->
<head> <head>
<title>{$pagetitle}{if $project} :: {$project->GetProject()}{if $action}/{$action}{/if}{/if}</title> <title>{$pagetitle}{if $project} :: {$project->GetProject()}{if $actionlocal}/{$actionlocal}{/if}{/if}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
{if $project} {if $project}
<link rel="alternate" title="{$project->GetProject()} log" href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=rss" type="application/rss+xml" /> <link rel="alternate" title="{$project->GetProject()} log" href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=rss" type="application/rss+xml" />
{/if} {/if}
<link rel="stylesheet" href="css/{$stylesheet}" type="text/css" /> <link rel="stylesheet" href="css/{$stylesheet}" type="text/css" />
{if $extracss} {if $extracss}
<style type="text/css"> <style type="text/css">
<!-- <!--
{$extracss} {$extracss}
--> -->
</style> </style>
{/if} {/if}
{if $javascript} {if $javascript}
<script language="javascript"> <script language="javascript">
var GITPHP_RES_LOADING="{$resources->GetResource('Loading...')}"; var GITPHP_RES_LOADING="{t escape='js'}Loading...{/t}";
var GITPHP_RES_LOADING_BLAME_DATA="{$resources->GetResource('Loading blame data...')}"; var GITPHP_RES_LOADING_BLAME_DATA="{t escape='js'}Loading blame data...{/t}";
</script> </script>
<link rel="stylesheet" href="css/ext/jquery.qtip.css" type="text/css" /> <link rel="stylesheet" href="css/ext/jquery.qtip.css" type="text/css" />
<script language="javascript" src="js/ext/jquery-1.4.2.min.js"></script> <script language="javascript" src="js/ext/jquery-1.4.2.min.js"></script>
<script language="javascript" src="js/ext/jquery.qtip.min.js"></script> <script language="javascript" src="js/ext/jquery.qtip.min.js"></script>
<script language="javascript" src="js/tooltips.js"></script> <script language="javascript" src="js/tooltips.js"></script>
{foreach from=$extrascripts item=script} {foreach from=$extrascripts item=script}
<script language="javascript" src="{$script}"></script> <script language="javascript" src="{$script}"></script>
{/foreach} {/foreach}
{/if} {/if}
{$smarty.capture.header} {$smarty.capture.header}
</head> </head>
<body> <body>
<div class="page_header"> <div class="page_header">
<a href="http://git-scm.com" title="git homepage"> <a href="http://git-scm.com" title="git homepage">
<img src="images/git-logo.png" width="72" height="27" alt="git" class="logo" /> <img src="images/git-logo.png" width="72" height="27" alt="git" class="logo" />
</a> </a>
<a href="index.php">{$resources->GetResource('projects')}</a> / <a href="index.php">{t}projects{/t}</a> /
{if $project} {if $project}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$project->GetProject()}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$project->GetProject()}</a>
{if $action} {if $actionlocal}
/ {$resources->GetResource($action)} / {$actionlocal}
{/if} {/if}
{if $enablesearch} {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->GetProject()}" /> <input type="hidden" name="p" value="{$project->GetProject()}" />
<input type="hidden" name="a" value="search" /> <input type="hidden" name="a" value="search" />
<input type ="hidden" name="h" value="{if $commit}{$commit->GetHash()}{else}HEAD{/if}" /> <input type ="hidden" name="h" value="{if $commit}{$commit->GetHash()}{else}HEAD{/if}" />
<select name="st"> <select name="st">
<option {if $searchtype == 'commit'}selected="selected"{/if} value="commit">{$resources->GetResource('commit')}</option> <option {if $searchtype == 'commit'}selected="selected"{/if} value="commit">{t}commit{/t}</option>
<option {if $searchtype == 'author'}selected="selected"{/if} value="author">{$resources->GetResource('author')}</option> <option {if $searchtype == 'author'}selected="selected"{/if} value="author">{t}author{/t}</option>
<option {if $searchtype == 'committer'}selected="selected"{/if} value="committer">{$resources->GetResource('committer')}</option> <option {if $searchtype == 'committer'}selected="selected"{/if} value="committer">{t}committer{/t}</option>
{if $filesearch} {if $filesearch}
<option {if $searchtype == 'file'}selected="selected"{/if} value="file">{$resources->GetResource('file')}</option> <option {if $searchtype == 'file'}selected="selected"{/if} value="file">{t}file{/t}</option>
{/if} {/if}
</select> {$resources->GetResource('search')}: <input type="text" name="s" {if $search}value="{$search}"{/if} /> </select> {t}search{/t}: <input type="text" name="s" {if $search}value="{$search}"{/if} />
</div> </div>
</form> </form>
{/if} {/if}
{/if} {/if}
</div> </div>
   
{* {*
* Headlist * Headlist
* *
* Head list template fragment * Head list template fragment
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @packge GitPHP * @packge GitPHP
* @subpackage Template * @subpackage Template
*} *}
   
<table cellspacing="0"> <table cellspacing="0">
{* Loop and display each head *} {* Loop and display each head *}
{foreach from=$headlist item=head name=heads} {foreach from=$headlist item=head name=heads}
{if ($max > 0) && ($smarty.foreach.heads.iteration == $max)} {if ($max > 0) && ($smarty.foreach.heads.iteration == $max)}
<td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=heads">...</a></td> <td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=heads">...</a></td>
{elseif ($max <= 0) || ($smarty.foreach.heads.iteration < $max)} {elseif ($max <= 0) || ($smarty.foreach.heads.iteration < $max)}
{assign var=headcommit value=$head->GetCommit()} {assign var=headcommit value=$head->GetCommit()}
<tr class="{cycle values="light,dark"}"> <tr class="{cycle values="light,dark"}">
<td><em>{$headcommit->GetAge()|agestring}</em></td> <td><em>{$headcommit->GetAge()|agestring}</em></td>
<td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h=refs/heads/{$head->GetName()}" class="list"><strong>{$head->GetName()}</strong></a></td> <td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h=refs/heads/{$head->GetName()}" class="list"><strong>{$head->GetName()}</strong></a></td>
<td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h=refs/heads/{$head->GetName()}">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h=refs/heads/{$head->GetName()}">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&hb={$headcommit->GetHash()}">{$resources->GetResource('tree')}</a></td> <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h=refs/heads/{$head->GetName()}">{t}shortlog{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h=refs/heads/{$head->GetName()}">{t}log{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&hb={$headcommit->GetHash()}">{t}tree{/t}</a></td>
</tr> </tr>
{/if} {/if}
{/foreach} {/foreach}
</table> </table>
   
   
{* {*
* history.tpl * history.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: History view template * Component: History view template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
{* Page header *} {* Page header *}
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' treecommit=$commit} {include file='nav.tpl' treecommit=$commit}
<br /><br /> <br /><br />
</div> </div>
   
{include file='title.tpl' titlecommit=$commit} {include file='title.tpl' titlecommit=$commit}
   
{include file='path.tpl' pathobject=$blob target='blob'} {include file='path.tpl' pathobject=$blob target='blob'}
<table cellspacing="0"> <table cellspacing="0">
{* Display each history line *} {* Display each history line *}
{foreach from=$blob->GetHistory() item=historyitem} {foreach from=$blob->GetHistory() item=historyitem}
{assign var=historycommit value=$historyitem->GetCommit()} {assign var=historycommit value=$historyitem->GetCommit()}
<tr class="{cycle values="light,dark"}"> <tr class="{cycle values="light,dark"}">
<td title="{if $historycommit->GetAge() > 60*60*24*7*2}{$historycommit->GetAge()|agestring}{else}{$historycommit->GetCommitterEpoch()|date_format:"%F"}{/if}"><em>{if $historycommit->GetAge() > 60*60*24*7*2}{$historycommit->GetCommitterEpoch()|date_format:"%F"}{else}{$historycommit->GetAge()|agestring}{/if}</em></td> <td title="{if $historycommit->GetAge() > 60*60*24*7*2}{$historycommit->GetAge()|agestring}{else}{$historycommit->GetCommitterEpoch()|date_format:"%F"}{/if}"><em>{if $historycommit->GetAge() > 60*60*24*7*2}{$historycommit->GetCommitterEpoch()|date_format:"%F"}{else}{$historycommit->GetAge()|agestring}{/if}</em></td>
<td><em>{$historycommit->GetAuthorName()}</em></td> <td><em>{$historycommit->GetAuthorName()}</em></td>
<td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$historycommit->GetHash()}" class="list commitTip" {if strlen($historycommit->GetTitle()) > 50}title="{$historycommit->GetTitle()}"{/if}><strong>{$historycommit->GetTitle(50)}</strong></a> <td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$historycommit->GetHash()}" class="list commitTip" {if strlen($historycommit->GetTitle()) > 50}title="{$historycommit->GetTitle()}"{/if}><strong>{$historycommit->GetTitle(50)}</strong></a>
{include file='refbadges.tpl' commit=$historycommit} {include file='refbadges.tpl' commit=$historycommit}
</td> </td>
<td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$historycommit->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$historycommit->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&hb={$historycommit->GetHash()}&f={$blob->GetPath()}">{$resources->GetResource('blob')}</a>{if $blob->GetHash() != $historyitem->GetToHash()} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff&h={$blob->GetHash()}&hp={$historyitem->GetToHash()}&hb={$historycommit->GetHash()}&f={$blob->GetPath()}">{$resources->GetResource('diff to current')}</a>{/if} <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$historycommit->GetHash()}">{t}commit{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$historycommit->GetHash()}">{t}commitdiff{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&hb={$historycommit->GetHash()}&f={$blob->GetPath()}">{t}blob{/t}</a>{if $blob->GetHash() != $historyitem->GetToHash()} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blobdiff&h={$blob->GetHash()}&hp={$historyitem->GetToHash()}&hb={$historycommit->GetHash()}&f={$blob->GetPath()}">{t}diff to current{/t}</a>{/if}
</td> </td>
</tr> </tr>
{/foreach} {/foreach}
</table> </table>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* log.tpl * log.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Log view template * Component: Log view template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
{* Nav *} {* Nav *}
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' current='log' logcommit=$commit treecommit=$commit} {include file='nav.tpl' current='log' logcommit=$commit treecommit=$commit}
<br /> <br />
{if ($commit && $head) && (($commit->GetHash() != $head->GetHash()) || ($page > 0))} {if ($commit && $head) && (($commit->GetHash() != $head->GetHash()) || ($page > 0))}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{$resources->GetResource('HEAD')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log">{t}HEAD{/t}</a>
{else} {else}
{$resources->GetResource('HEAD')} {t}HEAD{/t}
{/if} {/if}
&sdot; &sdot;
{if $page > 0} {if $page > 0}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$commit->GetHash()}&pg={$page-1}" accesskey="p" title="Alt-p">{$resources->GetResource('prev')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$commit->GetHash()}&pg={$page-1}" accesskey="p" title="Alt-p">{t}prev{/t}</a>
{else} {else}
{$resources->GetResource('prev')} {t}prev{/t}
{/if} {/if}
&sdot; &sdot;
{if $hasmorerevs} {if $hasmorerevs}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$commit->GetHash()}&pg={$page+1}" accesskey="n" title="Alt-n">{$resources->GetResource('next')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$commit->GetHash()}&pg={$page+1}" accesskey="n" title="Alt-n">{t}next{/t}</a>
{else} {else}
{$resources->GetResource('next')} {t}next{/t}
{/if} {/if}
<br /> <br />
</div> </div>
{foreach from=$revlist item=rev} {foreach from=$revlist item=rev}
<div class="title"> <div class="title">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$rev->GetHash()}" class="title"><span class="age">{$rev->GetAge()|agestring}</span>{$rev->GetTitle()}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$rev->GetHash()}" class="title"><span class="age">{$rev->GetAge()|agestring}</span>{$rev->GetTitle()}</a>
{include file='refbadges.tpl' commit=$rev} {include file='refbadges.tpl' commit=$rev}
</div> </div>
<div class="title_text"> <div class="title_text">
<div class="log_link"> <div class="log_link">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$rev->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$rev->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$rev->GetHash()}&hb={$rev->GetHash()}">{$resources->GetResource('tree')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$rev->GetHash()}">{t}commit{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$rev->GetHash()}">{t}commitdiff{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$rev->GetHash()}&hb={$rev->GetHash()}">{t}tree{/t}</a>
<br /> <br />
</div> </div>
<em>{$rev->GetAuthorName()} [{$rev->GetAuthorEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"}]</em><br /> <em>{$rev->GetAuthorName()} [{$rev->GetAuthorEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"}]</em><br />
</div> </div>
<div class="log_body"> <div class="log_body">
{foreach from=$rev->GetComment() item=line} {foreach from=$rev->GetComment() item=line}
{$line}<br /> {$line}<br />
{/foreach} {/foreach}
{if count($rev->GetComment()) > 0} {if count($rev->GetComment()) > 0}
<br /> <br />
{/if} {/if}
</div> </div>
{foreachelse} {foreachelse}
<div class="title"> <div class="title">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary" class="title">&nbsp</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary" class="title">&nbsp</a>
</div> </div>
<div class="page_body"> <div class="page_body">
{if $commit} {if $commit}
Last change {$commit->GetAge()|agestring} {assign var=commitage value=$commit->GetAge()|agestring}
  {t 1=$commitage}Last change %1{/t}
{else} {else}
<em>No commits</em> <em>{t}No commits{/t}</em>
{/if} {/if}
<br /><br /> <br /><br />
</div> </div>
{/foreach} {/foreach}
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* Nav * Nav
* *
* Nav links template fragment * Nav links template fragment
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Template * @subpackage Template
*} *}
   
{if $current=='summary'} {if $current=='summary'}
{$resources->GetResource('summary')} {t}summary{/t}
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary">{t}summary{/t}</a>
{/if} {/if}
| |
{if $current=='shortlog' || !$commit} {if $current=='shortlog' || !$commit}
{$resources->GetResource('shortlog')} {t}shortlog{/t}
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog{if $logcommit}&h={$logcommit->GetHash()}{/if}">{$resources->GetResource('shortlog')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog{if $logcommit}&h={$logcommit->GetHash()}{/if}">{t}shortlog{/t}</a>
{/if} {/if}
| |
{if $current=='log' || !$commit} {if $current=='log' || !$commit}
{$resources->GetResource('log')} {t}log{/t}
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log{if $logcommit}&h={$logcommit->GetHash()}{/if}">{$resources->GetResource('log')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log{if $logcommit}&h={$logcommit->GetHash()}{/if}">{t}log{/t}</a>
{/if} {/if}
| |
{if $current=='commit' || !$commit} {if $current=='commit' || !$commit}
{$resources->GetResource('commit')} {t}commit{/t}
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{$resources->GetResource('commit')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}">{t}commit{/t}</a>
{/if} {/if}
| |
{if $current=='commitdiff' || !$commit} {if $current=='commitdiff' || !$commit}
{$resources->GetResource('commitdiff')} {t}commitdiff{/t}
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{$resources->GetResource('commitdiff')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$commit->GetHash()}">{t}commitdiff{/t}</a>
{/if} {/if}
| |
{if $current=='tree' || !$commit} {if $current=='tree' || !$commit}
{$resources->GetResource('tree')} {t}tree{/t}
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree{if $treecommit}&hb={$treecommit->GetHash()}{/if}{if $tree}&h={$tree->GetHash()}{/if}">{$resources->GetResource('tree')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree{if $treecommit}&hb={$treecommit->GetHash()}{/if}{if $tree}&h={$tree->GetHash()}{/if}">{t}tree{/t}</a>
{/if} {/if}
   
{* {*
* project.tpl * project.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Project summary template * Component: Project summary template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' commit=$head current='summary'} {include file='nav.tpl' commit=$head current='summary'}
<br /><br /> <br /><br />
</div> </div>
   
{include file='title.tpl'} {include file='title.tpl'}
   
{* Project brief *} {* Project brief *}
<table cellspacing="0"> <table cellspacing="0">
<tr><td>{$resources->GetResource('description')}</td><td>{$project->GetDescription()}</td></tr> <tr><td>{t}description{/t}</td><td>{$project->GetDescription()}</td></tr>
<tr><td>{$resources->GetResource('owner')}</td><td>{$project->GetOwner()}</td></tr> <tr><td>{t}owner{/t}</td><td>{$project->GetOwner()}</td></tr>
{if $head} {if $head}
<tr><td>{$resources->GetResource('last change')}</td><td>{$head->GetCommitterEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"}</td></tr> <tr><td>{t}last change{/t}</td><td>{$head->GetCommitterEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"}</td></tr>
{/if} {/if}
{if $project->GetCloneUrl()} {if $project->GetCloneUrl()}
<tr><td>{$resources->GetResource('clone url')}</td><td>{$project->GetCloneUrl()}</td></tr> <tr><td>{t}clone url{/t}</td><td>{$project->GetCloneUrl()}</td></tr>
{/if} {/if}
{if $project->GetPushUrl()} {if $project->GetPushUrl()}
<tr><td>{$resources->GetResource('push url')}</td><td>{$project->GetPushUrl()}</td></tr> <tr><td>{t}push url{/t}</td><td>{$project->GetPushUrl()}</td></tr>
{/if} {/if}
</table> </table>
   
{if !$head} {if !$head}
{include file='title.tpl' target='shortlog' disablelink=true} {include file='title.tpl' target='shortlog' disablelink=true}
{else} {else}
{include file='title.tpl' target='shortlog'} {include file='title.tpl' target='shortlog'}
{/if} {/if}
   
{include file='shortloglist.tpl' source='summary'} {include file='shortloglist.tpl' source='summary'}
{if $taglist} {if $taglist}
{include file='title.tpl' target='tags'} {include file='title.tpl' target='tags'}
   
{include file='taglist.tpl' max=17} {include file='taglist.tpl' max=17}
{/if} {/if}
   
{if $headlist} {if $headlist}
   
{include file='title.tpl' target='heads'} {include file='title.tpl' target='heads'}
   
{include file='headlist.tpl' max=17} {include file='headlist.tpl' max=17}
   
{/if} {/if}
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* projectlist.tpl * projectlist.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Project list template * Component: Project list template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
{include file='hometext.tpl'} {include file='hometext.tpl'}
   
<table cellspacing="0"> <table cellspacing="0">
{foreach name=projects from=$projectlist item=proj} {foreach name=projects from=$projectlist item=proj}
{if $smarty.foreach.projects.first} {if $smarty.foreach.projects.first}
{* Header *} {* Header *}
<tr> <tr>
{if $order == "project"} {if $order == "project"}
<th>{$resources->GetResource('Project', 'Header')}</th> <th>{t}Project{/t}</th>
{else} {else}
<th><a class="header" href="{$SCRIPT_NAME}?o=project">{$resources->GetResource('Project', 'Header')}</a></th> <th><a class="header" href="{$SCRIPT_NAME}?o=project">{t}Project{/t}</a></th>
{/if} {/if}
{if $order == "descr"} {if $order == "descr"}
<th>{$resources->GetResource('Description', 'Header')}</th> <th>{t}Description{/t}</th>
{else} {else}
<th><a class="header" href="{$SCRIPT_NAME}?o=descr">{$resources->GetResource('Description', 'Header')}</a></th> <th><a class="header" href="{$SCRIPT_NAME}?o=descr">{t}Description{/t}</a></th>
{/if} {/if}
{if $order == "owner"} {if $order == "owner"}
<th>{$resources->GetResource('Owner', 'Header')}</th> <th>{t}Owner{/t}</th>
{else} {else}
<th><a class="header" href="{$SCRIPT_NAME}?o=owner">{$resources->GetResource('Owner', 'Header')}</a></th> <th><a class="header" href="{$SCRIPT_NAME}?o=owner">{t}Owner{/t}</a></th>
{/if} {/if}
{if $order == "age"} {if $order == "age"}
<th>{$resources->GetResource('Last Change', 'Header')}</th> <th>{t}Last Change{/t}</th>
{else} {else}
<th><a class="header" href="{$SCRIPT_NAME}?o=age">{$resources->GetResource('Last Change', 'Header')}</a></th> <th><a class="header" href="{$SCRIPT_NAME}?o=age">{t}Last Change{/t}</a></th>
{/if} {/if}
<th>{$resources->GetResource('Actions', 'Header')}</th> <th>{t}Actions{/t}</th>
</tr> </tr>
{/if} {/if}
   
{if $currentcategory != $proj->GetCategory()} {if $currentcategory != $proj->GetCategory()}
{assign var=currentcategory value=$proj->GetCategory()} {assign var=currentcategory value=$proj->GetCategory()}
{if $currentcategory != ''} {if $currentcategory != ''}
<tr class="light"> <tr class="light">
<th>{$currentcategory}</th> <th>{$currentcategory}</th>
<th></th> <th></th>
<th></th> <th></th>
<th></th> <th></th>
<th></th> <th></th>
</tr> </tr>
{/if} {/if}
{/if} {/if}
   
<tr class="{cycle values="light,dark"}"> <tr class="{cycle values="light,dark"}">
<td> <td>
<a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=summary" class="list {if $currentcategory != ''}indent{/if}">{$proj->GetProject()}</a> <a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=summary" class="list {if $currentcategory != ''}indent{/if}">{$proj->GetProject()}</a>
</td> </td>
<td><a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=summary" class="list">{$proj->GetDescription()}</a></td> <td><a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=summary" class="list">{$proj->GetDescription()}</a></td>
<td><em>{$proj->GetOwner()}</em></td> <td><em>{$proj->GetOwner()}</em></td>
<td> <td>
{assign var=projecthead value=$proj->GetHeadCommit()} {assign var=projecthead value=$proj->GetHeadCommit()}
{if $projecthead} {if $projecthead}
{if $projecthead->GetAge() < 7200} {* 60*60*2, or 2 hours *} {if $projecthead->GetAge() < 7200} {* 60*60*2, or 2 hours *}
<span class="agehighlight"><strong><em>{$projecthead->GetAge()|agestring}</em></strong></span> <span class="agehighlight"><strong><em>{$projecthead->GetAge()|agestring}</em></strong></span>
{elseif $projecthead->GetAge() < 172800} {* 60*60*24*2, or 2 days *} {elseif $projecthead->GetAge() < 172800} {* 60*60*24*2, or 2 days *}
<span class="agehighlight"><em>{$projecthead->GetAge()|agestring}</em></span> <span class="agehighlight"><em>{$projecthead->GetAge()|agestring}</em></span>
{else} {else}
<em>{$projecthead->GetAge()|agestring}</em> <em>{$projecthead->GetAge()|agestring}</em>
{/if} {/if}
{/if} {/if}
</td> </td>
<td class="link"> <td class="link">
<a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=summary">{$resources->GetResource('summary')}</a> <a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=summary">{t}summary{/t}</a>
{if $projecthead} {if $projecthead}
| |
<a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=shortlog">{t}shortlog{/t}</a> |
<a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=log">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=log">{t}log{/t}</a> |
<a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=tree">{$resources->GetResource('tree')}</a> | <a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=tree">{t}tree{/t}</a> |
<a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=snapshot&h=HEAD">{$resources->GetResource('snapshot')}</a> <a href="{$SCRIPT_NAME}?p={$proj->GetProject()|urlencode}&a=snapshot&h=HEAD">{t}snapshot{/t}</a>
{/if} {/if}
</td> </td>
</tr> </tr>
{foreachelse} {foreachelse}
<div class="message">No projects found</div> <div class="message">{t}No projects found{/t}</div>
{/foreach} {/foreach}
   
</table> </table>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* search.tpl * search.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Search view template * Component: Search view template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
{* Nav *} {* Nav *}
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' logcommit=$commit treecommit=$commit} {include file='nav.tpl' logcommit=$commit treecommit=$commit}
<br /> <br />
{if $page > 0} {if $page > 0}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}">{$resources->GetResource('first')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}">{t}first{/t}</a>
{else} {else}
{$resources->GetResource('first')} {t}first{/t}
{/if} {/if}
&sdot; &sdot;
{if $page > 0} {if $page > 0}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}{if $page > 1}&pg={$page-1}{/if}" accesskey="p" title="Alt-p">{$resources->GetResource('prev')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}{if $page > 1}&pg={$page-1}{/if}" accesskey="p" title="Alt-p">{t}prev{/t}</a>
{else} {else}
{$resources->GetResource('prev')} {t}prev{/t}
{/if} {/if}
&sdot; &sdot;
{if $hasmore} {if $hasmore}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}&pg={$page+1}" accesskey="n" title="Alt-n">{$resources->GetResource('next')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}&pg={$page+1}" accesskey="n" title="Alt-n">{t}next{/t}</a>
{else} {else}
{$resources->GetResource('next')} {t}next{/t}
{/if} {/if}
<br /> <br />
</div> </div>
   
{include file='title.tpl' titlecommit=$commit} {include file='title.tpl' titlecommit=$commit}
   
<table cellspacing="0"> <table cellspacing="0">
{* Print each match *} {* Print each match *}
{foreach from=$results item=result} {foreach from=$results item=result}
<tr class="{cycle values="light,dark"}"> <tr class="{cycle values="light,dark"}">
<td title="{if $result->GetAge() > 60*60*24*7*2}{$result->GetAge()|agestring}{else}{$result->GetCommitterEpoch()|date_format:"%F"}{/if}"><em>{if $result->GetAge() > 60*60*24*7*2}{$result->GetCommitterEpoch()|date_format:"%F"}{else}{$result->GetAge()|agestring}{/if}</em></td> <td title="{if $result->GetAge() > 60*60*24*7*2}{$result->GetAge()|agestring}{else}{$result->GetCommitterEpoch()|date_format:"%F"}{/if}"><em>{if $result->GetAge() > 60*60*24*7*2}{$result->GetCommitterEpoch()|date_format:"%F"}{else}{$result->GetAge()|agestring}{/if}</em></td>
<td> <td>
<em> <em>
{if $searchtype == 'author'} {if $searchtype == 'author'}
{$result->GetAuthorName()|highlight:$search} {$result->GetAuthorName()|highlight:$search}
{elseif $searchtype == 'committer'} {elseif $searchtype == 'committer'}
{$result->GetCommitterName()|highlight:$search} {$result->GetCommitterName()|highlight:$search}
{else} {else}
{$result->GetAuthorName()} {$result->GetAuthorName()}
{/if} {/if}
</em> </em>
</td> </td>
<td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$result->GetHash()}" class="list commitTip" {if strlen($result->GetTitle()) > 50}title="{$result->GetTitle()}"{/if}><strong>{$result->GetTitle(50)}</strong> <td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$result->GetHash()}" class="list commitTip" {if strlen($result->GetTitle()) > 50}title="{$result->GetTitle()}"{/if}><strong>{$result->GetTitle(50)}</strong>
{if $searchtype == 'commit'} {if $searchtype == 'commit'}
{foreach from=$result->SearchComment($search) item=line name=match} {foreach from=$result->SearchComment($search) item=line name=match}
<br />{$line|highlight:$search:50} <br />{$line|highlight:$search:50}
{/foreach} {/foreach}
{/if} {/if}
</td> </td>
{assign var=resulttree value=$result->GetTree()} {assign var=resulttree value=$result->GetTree()}
<td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$result->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$result->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$resulttree->GetHash()}&hb={$result->GetHash()}">{$resources->GetResource('tree')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$result->GetHash()}">{$resources->GetResource('snapshot')}</a> <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$result->GetHash()}">{t}commit{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$result->GetHash()}">{t}commitdiff{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$resulttree->GetHash()}&hb={$result->GetHash()}">{t}tree{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$result->GetHash()}">{t}snapshot{/t}</a>
</td> </td>
</tr> </tr>
{/foreach} {/foreach}
   
{if $hasmore} {if $hasmore}
<tr> <tr>
<td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}&pg={$page+1}" title="Alt-n">{$resources->GetResource('next')}</a></td> <td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}&pg={$page+1}" title="Alt-n">{t}next{/t}</a></td>
</tr> </tr>
{/if} {/if}
</table> </table>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* searchfiles.tpl * searchfiles.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Search files template * Component: Search files template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
{* Nav *} {* Nav *}
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' logcommit=$commit treecommit=$commit} {include file='nav.tpl' logcommit=$commit treecommit=$commit}
<br /> <br />
{if $page > 0} {if $page > 0}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}">{$resources->GetResource('first')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}">{t}first{/t}</a>
{else} {else}
{$resources->GetResource('first')} {t}first{/t}
{/if} {/if}
&sdot; &sdot;
{if $page > 0} {if $page > 0}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}{if $page > 1}&pg={$page-1}{/if}" accesskey="p" title="Alt-p">{$resources->GetResource('prev')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}{if $page > 1}&pg={$page-1}{/if}" accesskey="p" title="Alt-p">{t}prev{/t}</a>
{else} {else}
{$resources->GetResource('prev')} {t}prev{/t}
{/if} {/if}
&sdot; &sdot;
{if $hasmore} {if $hasmore}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}&pg={$page+1}" accesskey="n" title="Alt-n">{$resources->GetResource('next')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}&pg={$page+1}" accesskey="n" title="Alt-n">{t}next{/t}</a>
{else} {else}
{$resources->GetResource('next')} {t}next{/t}
{/if} {/if}
<br /> <br />
</div> </div>
<div class="title"> <div class="title">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}" class="title">{$commit->GetTitle()}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$commit->GetHash()}" class="title">{$commit->GetTitle()}</a>
</div> </div>
<table cellspacing="0"> <table cellspacing="0">
{* Print each match *} {* Print each match *}
{foreach from=$results item=result key=path} {foreach from=$results item=result key=path}
<tr class="{cycle values="light,dark"}"> <tr class="{cycle values="light,dark"}">
{assign var=resultobject value=$result.object} {assign var=resultobject value=$result.object}
{if $resultobject instanceof GitPHP_Tree} {if $resultobject instanceof GitPHP_Tree}
<td> <td>
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$resultobject->GetHash()}&hb={$commit->GetHash()}&f={$path}" class="list"><strong>{$path}</strong></a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$resultobject->GetHash()}&hb={$commit->GetHash()}&f={$path}" class="list"><strong>{$path}</strong></a>
</td> </td>
<td class="link"> <td class="link">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$resultobject->GetHash()}&hb={$commit->GetHash()}&f={$path}">{$resources->GetResource('tree')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$resultobject->GetHash()}&hb={$commit->GetHash()}&f={$path}">{t}tree{/t}</a>
</td> </td>
{else} {else}
<td> <td>
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$result.object->GetHash()}&hb={$commit->GetHash()}&f={$path}" class="list"><strong>{$path|highlight:$search}</strong></a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$result.object->GetHash()}&hb={$commit->GetHash()}&f={$path}" class="list"><strong>{$path|highlight:$search}</strong></a>
{foreach from=$result.lines item=line name=match key=lineno} {foreach from=$result.lines item=line name=match key=lineno}
{if $smarty.foreach.match.first}<br />{/if}<span class="respectwhitespace">{$lineno}. {$line|highlight:$search:50:true}</span><br /> {if $smarty.foreach.match.first}<br />{/if}<span class="respectwhitespace">{$lineno}. {$line|highlight:$search:50:true}</span><br />
{/foreach} {/foreach}
</td> </td>
<td class="link"> <td class="link">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$resultobject->GetHash()}&hb={$commit->GetHash()}&f={$path}">{$resources->GetResource('blob')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=history&h={$commit->GetHash()}&f={$path}">{$resources->GetResource('history')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$resultobject->GetHash()}&hb={$commit->GetHash()}&f={$path}">{t}blob{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=history&h={$commit->GetHash()}&f={$path}">{t}history{/t}</a>
</td> </td>
{/if} {/if}
</tr> </tr>
{/foreach} {/foreach}
   
{if $hasmore} {if $hasmore}
<tr> <tr>
<td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}&pg={$page+1}" title="Alt-n">{$resources->GetResource('next')}</a></td> <td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=search&h={$commit->GetHash()}&s={$search}&st={$searchtype}&pg={$page+1}" title="Alt-n">{t}next{/t}</a></td>
</tr> </tr>
{/if} {/if}
</table> </table>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* shortlog.tpl * shortlog.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Shortlog view template * Component: Shortlog view template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
{* Nav *} {* Nav *}
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' current='shortlog' logcommit=$commit treecommit=$commit} {include file='nav.tpl' current='shortlog' logcommit=$commit treecommit=$commit}
<br /> <br />
{if ($commit && $head) && (($commit->GetHash() != $head->GetHash()) || ($page > 0))} {if ($commit && $head) && (($commit->GetHash() != $head->GetHash()) || ($page > 0))}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{$resources->GetResource('HEAD')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">{t}HEAD{/t}</a>
{else} {else}
{$resources->GetResource('HEAD')} {t}HEAD{/t}
{/if} {/if}
&sdot; &sdot;
{if $page > 0} {if $page > 0}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}&pg={$page-1}" accesskey="p" title="Alt-p">{$resources->GetResource('prev')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}&pg={$page-1}" accesskey="p" title="Alt-p">{t}prev{/t}</a>
{else} {else}
{$resources->GetResource('prev')} {t}prev{/t}
{/if} {/if}
&sdot; &sdot;
{if $hasmorerevs} {if $hasmorerevs}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}&pg={$page+1}" accesskey="n" title="Alt-n">{$resources->GetResource('next')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}&pg={$page+1}" accesskey="n" title="Alt-n">{t}next{/t}</a>
{else} {else}
{$resources->GetResource('next')} {t}next{/t}
{/if} {/if}
<br /> <br />
</div> </div>
   
{include file='title.tpl' target='summary'} {include file='title.tpl' target='summary'}
   
{include file='shortloglist.tpl'} {include file='shortloglist.tpl'}
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* Shortlog List * Shortlog List
* *
* Shortlog list template fragment * Shortlog list template fragment
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @packge GitPHP * @packge GitPHP
* @subpackage Template * @subpackage Template
*} *}
   
<table cellspacing="0"> <table cellspacing="0">
{foreach from=$revlist item=rev} {foreach from=$revlist item=rev}
<tr class="{cycle values="light,dark"}"> <tr class="{cycle values="light,dark"}">
<td title="{if $rev->GetAge() > 60*60*24*7*2}{$rev->GetAge()|agestring}{else}{$rev->GetCommitterEpoch()|date_format:"%F"}{/if}"><em>{if $rev->GetAge() > 60*60*24*7*2}{$rev->GetCommitterEpoch()|date_format:"%F"}{else}{$rev->GetAge()|agestring}{/if}</em></td> <td title="{if $rev->GetAge() > 60*60*24*7*2}{$rev->GetAge()|agestring}{else}{$rev->GetCommitterEpoch()|date_format:"%F"}{/if}"><em>{if $rev->GetAge() > 60*60*24*7*2}{$rev->GetCommitterEpoch()|date_format:"%F"}{else}{$rev->GetAge()|agestring}{/if}</em></td>
<td><em>{$rev->GetAuthorName()}</em></td> <td><em>{$rev->GetAuthorName()}</em></td>
<td> <td>
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$rev->GetHash()}" class="list commitTip" {if strlen($rev->GetTitle()) > 50}title="{$rev->GetTitle()}"{/if}><strong>{$rev->GetTitle(50)}</strong></a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$rev->GetHash()}" class="list commitTip" {if strlen($rev->GetTitle()) > 50}title="{$rev->GetTitle()}"{/if}><strong>{$rev->GetTitle(50)}</strong></a>
{include file='refbadges.tpl' commit=$rev} {include file='refbadges.tpl' commit=$rev}
</td> </td>
<td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$rev->GetHash()}">{$resources->GetResource('commit')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$rev->GetHash()}">{$resources->GetResource('commitdiff')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$rev->GetHash()}&hb={$rev->GetHash()}">{$resources->GetResource('tree')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$rev->GetHash()}">{$resources->GetResource('snapshot')}</a> <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$rev->GetHash()}">{t}commit{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$rev->GetHash()}">{t}commitdiff{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$rev->GetHash()}&hb={$rev->GetHash()}">{t}tree{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$rev->GetHash()}">{t}snapshot{/t}</a>
</td> </td>
</tr> </tr>
{foreachelse} {foreachelse}
<tr><td><em>No commits</em></td></tr> <tr><td><em>{t}No commits{/t}</em></td></tr>
{/foreach} {/foreach}
   
{if $hasmorerevs} {if $hasmorerevs}
<tr> <tr>
{if $source == 'summary'} {if $source == 'summary'}
<td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">...</a></td> <td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog">...</a></td>
{else} {else}
<td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}&pg={$page+1}" title="Alt-n">{$resources->GetResource('next')}</a></td> <td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$commit->GetHash()}&pg={$page+1}" title="Alt-n">{t}next{/t}</a></td>
{/if} {/if}
</tr> </tr>
{/if} {/if}
</table> </table>
   
   
{* {*
* tag.tpl * tag.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Tag view template * Component: Tag view template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
{* Nav *} {* Nav *}
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' commit=$head treecommit=$head} {include file='nav.tpl' commit=$head treecommit=$head}
<br /><br /> <br /><br />
</div> </div>
{* Tag data *} {* Tag data *}
{assign var=object value=$tag->GetObject()} {assign var=object value=$tag->GetObject()}
{assign var=objtype value=$tag->GetType()} {assign var=objtype value=$tag->GetType()}
<div class="title"> <div class="title">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$object->GetHash()}" class="title">{$tag->GetName()}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$object->GetHash()}" class="title">{$tag->GetName()}</a>
</div> </div>
<div class="title_text"> <div class="title_text">
<table cellspacing="0"> <table cellspacing="0">
<tr> <tr>
<td>object</td> <td>{t}object{/t}</td>
{if $objtype == 'commit'} {if $objtype == 'commit'}
<td class="monospace"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$object->GetHash()}" class="list">{$object->GetHash()}</a></td> <td class="monospace"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$object->GetHash()}" class="list">{$object->GetHash()}</a></td>
<td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$object->GetHash()}">{$resources->GetResource('commit')}</a></td> <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$object->GetHash()}">{t}commit{/t}</a></td>
{elseif $objtype == 'tag'} {elseif $objtype == 'tag'}
<td class="monospace"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tag&h={$object->GetName()}" class="list">{$object->GetHash()}</a></td> <td class="monospace"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tag&h={$object->GetName()}" class="list">{$object->GetHash()}</a></td>
<td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tag&h={$object->GetName()}">{$resources->GetResource('tag')}</a></td> <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tag&h={$object->GetName()}">{t}tag{/t}</a></td>
{/if} {/if}
</tr> </tr>
{if $tag->GetTagger()} {if $tag->GetTagger()}
<tr> <tr>
<td>author</td> <td>{t}author{/t}</td>
<td>{$tag->GetTagger()}</td> <td>{$tag->GetTagger()}</td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td> {$tag->GetTaggerEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"} <td> {$tag->GetTaggerEpoch()|date_format:"%a, %d %b %Y %H:%M:%S %z"}
{assign var=hourlocal value=$tag->GetTaggerLocalEpoch()|date_format:"%H"} {assign var=hourlocal value=$tag->GetTaggerLocalEpoch()|date_format:"%H"}
{if $hourlocal < 6} {if $hourlocal < 6}
(<span class="latenight">{$tag->GetTaggerLocalEpoch()|date_format:"%R"}</span> {$tag->GetTaggerTimezone()}) (<span class="latenight">{$tag->GetTaggerLocalEpoch()|date_format:"%R"}</span> {$tag->GetTaggerTimezone()})
{else} {else}
({$tag->GetTaggerLocalEpoch()|date_format:"%R"} {$tag->GetTaggerTimezone()}) ({$tag->GetTaggerLocalEpoch()|date_format:"%R"} {$tag->GetTaggerTimezone()})
{/if} {/if}
</td> </td>
</tr> </tr>
{/if} {/if}
</table> </table>
</div> </div>
<div class="page_body"> <div class="page_body">
{foreach from=$tag->GetComment() item=line} {foreach from=$tag->GetComment() item=line}
{$line}<br /> {$line}<br />
{/foreach} {/foreach}
</div> </div>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
{* {*
* Taglist * Taglist
* *
* Tag list template fragment * Tag list template fragment
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @packge GitPHP * @packge GitPHP
* @subpackage Template * @subpackage Template
*} *}
   
<table cellspacing="0"> <table cellspacing="0">
{foreach from=$taglist item=tag name=tag} {foreach from=$taglist item=tag name=tag}
<tr class="{cycle name=tags values="light,dark"}"> <tr class="{cycle name=tags values="light,dark"}">
{if ($max > 0) && ($smarty.foreach.tag.iteration == $max)} {if ($max > 0) && ($smarty.foreach.tag.iteration == $max)}
<td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tags">...</a></td> <td><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tags">...</a></td>
{elseif ($max <= 0) || ($smarty.foreach.tag.iteration < $max)} {elseif ($max <= 0) || ($smarty.foreach.tag.iteration < $max)}
{assign var=object value=$tag->GetObject()} {assign var=object value=$tag->GetObject()}
{assign var=tagcommit value=$tag->GetCommit()} {assign var=tagcommit value=$tag->GetCommit()}
{assign var=objtype value=$tag->GetType()} {assign var=objtype value=$tag->GetType()}
<td><em>{$tagcommit->GetAge()|agestring}</em></td> <td><em>{$tagcommit->GetAge()|agestring}</em></td>
<td> <td>
{if $objtype == 'commit'} {if $objtype == 'commit'}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$object->GetHash()}" class="list"><strong>{$tag->GetName()}</strong></a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$object->GetHash()}" class="list"><strong>{$tag->GetName()}</strong></a>
{elseif $objtype == 'tag'} {elseif $objtype == 'tag'}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tag&h={$tag->GetName()}" class="list"><strong>{$tag->GetName()}</strong></a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tag&h={$tag->GetName()}" class="list"><strong>{$tag->GetName()}</strong></a>
{/if} {/if}
</td> </td>
<td> <td>
{assign var=comment value=$tag->GetComment()} {assign var=comment value=$tag->GetComment()}
{if count($comment) > 0} {if count($comment) > 0}
<a class="list {if !$tag->LightTag()}tagTip{/if}" href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tag&h={$tag->GetName()}">{$comment[0]}</a> <a class="list {if !$tag->LightTag()}tagTip{/if}" href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tag&h={$tag->GetName()}">{$comment[0]}</a>
{/if} {/if}
</td> </td>
<td class="link"> <td class="link">
{if !$tag->LightTag()} {if !$tag->LightTag()}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tag&h={$tag->GetName()}">{$resources->GetResource('tag')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tag&h={$tag->GetName()}">{t}tag{/t}</a> |
{/if} {/if}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$tagcommit->GetHash()}">{$resources->GetResource('commit')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$tagcommit->GetHash()}">{t}commit{/t}</a>
| <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$tagcommit->GetHash()}">{$resources->GetResource('shortlog')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$tagcommit->GetHash()}">{$resources->GetResource('log')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$tagcommit->GetHash()}">{$resources->GetResource('snapshot')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog&h={$tagcommit->GetHash()}">{t}shortlog{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=log&h={$tagcommit->GetHash()}">{t}log{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$tagcommit->GetHash()}">{t}snapshot{/t}</a>
</td> </td>
{/if} {/if}
</tr> </tr>
{/foreach} {/foreach}
</table> </table>
   
{* {*
* Tagtip * Tagtip
* *
* Tag tooltip template * Tag tooltip template
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Template * @subpackage Template
*} *}
   
<div> <div>
{$resources->GetResource('tag')}: {$tag->GetName()} {t}tag{/t}: {$tag->GetName()}
<br /> <br />
{foreach from=$tag->GetComment() item=line} {foreach from=$tag->GetComment() item=line}
<br />{$line} <br />{$line}
{/foreach} {/foreach}
</div> </div>
   
{* {*
* Title * Title
* *
* Title template * Title template
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Template * @subpackage Template
*} *}
   
<div class="title"> <div class="title">
{if $titlecommit} {if $titlecommit}
{if $target == 'commitdiff'} {if $target == 'commitdiff'}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$titlecommit->GetHash()}" class="title">{$titlecommit->GetTitle()}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commitdiff&h={$titlecommit->GetHash()}" class="title">{$titlecommit->GetTitle()}</a>
{elseif $target == 'tree'} {elseif $target == 'tree'}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$titletree->GetHash()}&hb={$titlecommit->GetHash()}" class="title">{$titlecommit->GetTitle()}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$titletree->GetHash()}&hb={$titlecommit->GetHash()}" class="title">{$titlecommit->GetTitle()}</a>
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$titlecommit->GetHash()}" class="title">{$titlecommit->GetTitle()}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=commit&h={$titlecommit->GetHash()}" class="title">{$titlecommit->GetTitle()}</a>
{/if} {/if}
{include file='refbadges.tpl' commit=$titlecommit} {include file='refbadges.tpl' commit=$titlecommit}
{else} {else}
{if $target == 'summary'} {if $target == 'summary'}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary" class="title">&nbsp;</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=summary" class="title">&nbsp;</a>
{elseif $target == 'shortlog'} {elseif $target == 'shortlog'}
{if $disablelink} {if $disablelink}
{$resources->GetResource('shortlog')} {t}shortlog{/t}
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog" class="title">{$resources->GetResource('shortlog')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=shortlog" class="title">{t}shortlog{/t}</a>
{/if} {/if}
{elseif $target == 'tags'} {elseif $target == 'tags'}
{if $disablelink} {if $disablelink}
{$resources->GetResource('tags')} {t}tags{/t}
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tags" class="title">{$resources->GetResource('tags')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tags" class="title">{t}tags{/t}</a>
{/if} {/if}
{elseif $target == 'heads'} {elseif $target == 'heads'}
{if $disablelink} {if $disablelink}
{$resources->GetResource('heads')} {t}heads{/t}
{else} {else}
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=heads" class="title">{$resources->GetResource('heads')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=heads" class="title">{t}heads{/t}</a>
{/if} {/if}
{else} {else}
&nbsp; &nbsp;
{/if} {/if}
{/if} {/if}
</div> </div>
   
{* {*
* tree.tpl * tree.tpl
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Tree view template * Component: Tree view template
* *
* Copyright (C) 2009 Christopher Han <xiphux@gmail.com> * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
*} *}
   
{include file='header.tpl'} {include file='header.tpl'}
   
{* Nav *} {* Nav *}
<div class="page_nav"> <div class="page_nav">
{include file='nav.tpl' current='tree' logcommit=$commit} {include file='nav.tpl' current='tree' logcommit=$commit}
<br /><br /> <br /><br />
</div> </div>
   
{include file='title.tpl' titlecommit=$commit} {include file='title.tpl' titlecommit=$commit}
   
{include file='path.tpl' pathobject=$tree target='tree'} {include file='path.tpl' pathobject=$tree target='tree'}
<div class="page_body"> <div class="page_body">
{* List files *} {* List files *}
<table cellspacing="0"> <table cellspacing="0">
{foreach from=$tree->GetContents() item=treeitem} {foreach from=$tree->GetContents() item=treeitem}
<tr class="{cycle values="light,dark"}"> <tr class="{cycle values="light,dark"}">
<td class="monospace">{$treeitem->GetModeString()}</td> <td class="monospace">{$treeitem->GetModeString()}</td>
{if $treeitem instanceof GitPHP_Blob} {if $treeitem instanceof GitPHP_Blob}
<td class="filesize">{$treeitem->GetSize()}</td> <td class="filesize">{$treeitem->GetSize()}</td>
<td class="list"> <td class="list">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$treeitem->GetHash()}&hb={$commit->GetHash()}&f={$treeitem->GetPath()}" class="list">{$treeitem->GetName()}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$treeitem->GetHash()}&hb={$commit->GetHash()}&f={$treeitem->GetPath()}" class="list">{$treeitem->GetName()}</a>
</td> </td>
<td class="link"> <td class="link">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$treeitem->GetHash()}&hb={$commit->GetHash()}&f={$treeitem->GetPath()}">{$resources->GetResource('blob')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=history&h={$commit->GetHash()}&f={$treeitem->GetPath()}">{$resources->GetResource('history')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=blob&h={$treeitem->GetHash()}&hb={$commit->GetHash()}&f={$treeitem->GetPath()}">{t}blob{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=history&h={$commit->GetHash()}&f={$treeitem->GetPath()}">{t}history{/t}</a>
</td> </td>
{elseif $treeitem instanceof GitPHP_Tree} {elseif $treeitem instanceof GitPHP_Tree}
<td></td> <td></td>
<td class="list"> <td class="list">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$treeitem->GetHash()}&hb={$commit->GetHash()}&f={$treeitem->GetPath()}">{$treeitem->GetName()}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$treeitem->GetHash()}&hb={$commit->GetHash()}&f={$treeitem->GetPath()}">{$treeitem->GetName()}</a>
</td> </td>
<td class="link"> <td class="link">
<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$treeitem->GetHash()}&hb={$commit->GetHash()}&f={$treeitem->GetPath()}">{$resources->GetResource('tree')}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$commit->GetHash()}&f={$treeitem->GetPath()}">{$resources->GetResource('snapshot')}</a> <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=tree&h={$treeitem->GetHash()}&hb={$commit->GetHash()}&f={$treeitem->GetPath()}">{t}tree{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&a=snapshot&h={$commit->GetHash()}&f={$treeitem->GetPath()}">{t}snapshot{/t}</a>
</td> </td>
{/if} {/if}
</tr> </tr>
{/foreach} {/foreach}
</table> </table>
</div> </div>
   
{include file='footer.tpl'} {include file='footer.tpl'}
   
   
comments