From cd7a55f7a23c5981e26ff410bcf27d9ded5a0d38 Mon Sep 17 00:00:00 2001 From: pk910 Date: Sun, 10 Mar 2013 08:06:04 +0100 Subject: [PATCH] format fixes --- htdocs/config.example.php | 28 +++---- htdocs/lib/ContentProvider.class.php | 6 +- htdocs/lib/PHPGitWeb.class.php | 14 ++-- htdocs/lib/ProjectLoader.class.php | 120 +++++++++++++-------------- htdocs/pages/commit.class.php | 4 +- htdocs/pages/commitdiff.class.php | 4 +- htdocs/pages/projects.class.php | 10 +-- htdocs/pages/shortlog.class.php | 4 +- htdocs/pages/summary.class.php | 4 +- 9 files changed, 97 insertions(+), 97 deletions(-) diff --git a/htdocs/config.example.php b/htdocs/config.example.php index 0755ec8..f1bb664 100644 --- a/htdocs/config.example.php +++ b/htdocs/config.example.php @@ -21,22 +21,22 @@ /* GIT configuration */ class GitConfig { - /* PHPGitWeb Title / Name */ + /* PHPGitWeb Title / Name */ const GITWEB_TITLE = "PHPGitWeb"; - /* path to git projects (.git) */ - const PROJECT_ROOT = "/srv/gitosis/repositories/"; - - /* Point to projects.list file generated by gitosis. */ - //const PROJECT_LIST = NULL; - const PROJECT_LIST = "/srv/gitosis/gitosis/projects.list"; - - /* Only allow Projects from PROJECT_LIST being viewed */ - const STRICT_EXPORT = true; - - /* Only allow Projects with this file within their PROJECT_ROOT being viewed */ - //const EXPORT_FILE = "export-ok"; - const EXPORT_FILE = NULL; + /* path to git projects (.git) */ + const PROJECT_ROOT = "/srv/gitosis/repositories/"; + + /* Point to projects.list file generated by gitosis. */ + //const PROJECT_LIST = NULL; + const PROJECT_LIST = "/srv/gitosis/gitosis/projects.list"; + + /* Only allow Projects from PROJECT_LIST being viewed */ + const STRICT_EXPORT = true; + + /* Only allow Projects with this file within their PROJECT_ROOT being viewed */ + //const EXPORT_FILE = "export-ok"; + const EXPORT_FILE = NULL; /* Override Project Owner to this one */ const PROJECT_OWNER = NULL; diff --git a/htdocs/lib/ContentProvider.class.php b/htdocs/lib/ContentProvider.class.php index e88b948..0fc9685 100644 --- a/htdocs/lib/ContentProvider.class.php +++ b/htdocs/lib/ContentProvider.class.php @@ -17,13 +17,13 @@ */ class ContentProvider { - private static $template_cache = array(); + private static $template_cache = array(); private static $overall_content = array(); private $template, $subtemplate; private $content = array(); - public function __construct($template, $subtemplate, $content = null) { + public function __construct($template, $subtemplate, $content = null) { $this->template = $template; $this->subtemplate = $subtemplate; @@ -31,7 +31,7 @@ class ContentProvider { $this->content = $content; } } - + public function set($name, $value) { $this->content[strtolower($name)] = $value; } diff --git a/htdocs/lib/PHPGitWeb.class.php b/htdocs/lib/PHPGitWeb.class.php index fc278af..b28f3d4 100644 --- a/htdocs/lib/PHPGitWeb.class.php +++ b/htdocs/lib/PHPGitWeb.class.php @@ -29,10 +29,10 @@ require_once("lib/PageClasses.diff.class.php"); require_once("lib/graph.class.php"); class PHPGitWeb { - private $page, $rendertime; + private $page, $rendertime; private $project, $project_loader, $project_header; - public function __construct() { + public function __construct() { $this->rendertime = microtime(true); session_start(); $this->page = new ContentProvider('main', 'main'); @@ -82,12 +82,12 @@ class PHPGitWeb { } else $this->page->append('content', file_get_contents('pages/404.html')); if($this->project_header) { - $this->project_header->set('nav_summary', new ContentProvider('main', ($page == 'summary' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "summary", 'link' => "summary", 'link_add' => ""))); + $this->project_header->set('nav_summary', new ContentProvider('main', ($page == 'summary' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "summary", 'link' => "summary", 'link_add' => ""))); $this->project_header->set('nav_shortlog', new ContentProvider('main', ($page == 'shortlog' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "shortlog", 'link' => "shortlog", 'link_add' => "&h=%commit_base_id%"))); - $this->project_header->set('nav_log', new ContentProvider('main', ($page == 'log' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "log", 'link' => "log", 'link_add' => "&h=%commit_base_id%"))); - $this->project_header->set('nav_commit', new ContentProvider('main', ($page == 'commit' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "commit", 'link' => "commit", 'link_add' => "&h=%commit_id%"))); + $this->project_header->set('nav_log', new ContentProvider('main', ($page == 'log' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "log", 'link' => "log", 'link_add' => "&h=%commit_base_id%"))); + $this->project_header->set('nav_commit', new ContentProvider('main', ($page == 'commit' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "commit", 'link' => "commit", 'link_add' => "&h=%commit_id%"))); $this->project_header->set('nav_commitdiff', new ContentProvider('main', ($page == 'commitdiff' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "commitdiff", 'link' => "commitdiff", 'link_add' => "&h=%commit_id%"))); - $this->project_header->set('nav_tree', new ContentProvider('main', ($page == 'tree' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "tree", 'link' => "tree", 'link_add' => "&h=%commit_id%"))); + $this->project_header->set('nav_tree', new ContentProvider('main', ($page == 'tree' ? 'project_header_nav_active' : 'project_header_nav_link'), array('name' => "tree", 'link' => "tree", 'link_add' => "&h=%commit_id%"))); } } @@ -126,7 +126,7 @@ class PHPGitWeb { $html = str_replace(array("%rendertime%"), array($rendertime), $html); return $html; } - + public function error_handler($errno, $errstr, $errfile, $errline) { $error = new ContentProvider('main', 'error'); $etype = ""; diff --git a/htdocs/lib/ProjectLoader.class.php b/htdocs/lib/ProjectLoader.class.php index 20ee218..332a6e4 100644 --- a/htdocs/lib/ProjectLoader.class.php +++ b/htdocs/lib/ProjectLoader.class.php @@ -17,66 +17,66 @@ */ class ProjectLoader { - private $projects = NULL; - - private function loadProjects($load_details = true) { - $this->projects = array(); - if(GitConfig::PROJECT_LIST) { - foreach(file(GitConfig::PROJECT_LIST) as $entry) { - $entry = explode(" ", $entry); - - if($load_details) { - //check if project really exists - $project = $this->loadProject($entry[0], false); + private $projects = NULL; + + private function loadProjects($load_details = true) { + $this->projects = array(); + if(GitConfig::PROJECT_LIST) { + foreach(file(GitConfig::PROJECT_LIST) as $entry) { + $entry = explode(" ", $entry); + + if($load_details) { + //check if project really exists + $project = $this->loadProject($entry[0], false); if($project === NULL) continue; - } else + } else $project['name'] = $entry[0]; - - $project['owner'] = $entry[1]; - $this->projects[] = $project; - } - } else { - //walk through PROJECT_ROOT - - } - } - - private function loadProject($name, $check_strict_export = true) { - $project = array(); + + $project['owner'] = $entry[1]; + $this->projects[] = $project; + } + } else { + //walk through PROJECT_ROOT + + } + } + + private function loadProject($name, $check_strict_export = true) { + $project = array(); $project['name'] = $name; - - $dir_seperator = (substr(GitConfig::PROJECT_ROOT, -1) == '/' ? '' : '/'); + + $dir_seperator = (substr(GitConfig::PROJECT_ROOT, -1) == '/' ? '' : '/'); if(!Validation::validate_path($name)) return NULL; - if(is_dir(GitConfig::PROJECT_ROOT.$dir_seperator.$name)) - $project['path'] = GitConfig::PROJECT_ROOT.$dir_seperator.$name; - else if(is_dir(GitConfig::PROJECT_ROOT.$dir_seperator.$name.".git")) - $project['path'] = GitConfig::PROJECT_ROOT.$dir_seperator.$name.".git"; - else - return NULL; + if(is_dir(GitConfig::PROJECT_ROOT.$dir_seperator.$name)) + $project['path'] = GitConfig::PROJECT_ROOT.$dir_seperator.$name; + else if(is_dir(GitConfig::PROJECT_ROOT.$dir_seperator.$name.".git")) + $project['path'] = GitConfig::PROJECT_ROOT.$dir_seperator.$name.".git"; + else + return NULL; if(is_dir($project['path'].'/.git')) $project['path'] .= '/.git'; - if(GitConfig::EXPORT_FILE && !file_exists($project['path'].'/'.GitConfig::EXPORT_FILE)) - return NULL; - - if(GitConfig::STRICT_EXPORT && $check_strict_export) { - if($this->projects === NULL) - $this->loadProjects(false); - $found = false; - foreach($this->projects as $p) { - if(strtolower($p['name']) == strtolower($name)) { - $found = true; + if(GitConfig::EXPORT_FILE && !file_exists($project['path'].'/'.GitConfig::EXPORT_FILE)) + return NULL; + + if(GitConfig::STRICT_EXPORT && $check_strict_export) { + if($this->projects === NULL) + $this->loadProjects(false); + $found = false; + foreach($this->projects as $p) { + if(strtolower($p['name']) == strtolower($name)) { + $found = true; $project['name'] = $p['name']; $project['owner'] = $p['owner']; - break; - } - } - if(!$found) - return NULL; - } - + break; + } + } + if(!$found) + return NULL; + } + if(file_exists($project['path'].'/description')) $project['description'] = file_get_contents($project['path'].'/description'); else @@ -93,17 +93,17 @@ class ProjectLoader { } } - return $project; - } - - public function getProjectList() { + return $project; + } + + public function getProjectList() { $this->loadProjects(); - return $this->projects; - } - - public function getProject($name) { - return $this->loadProject($name); - } + return $this->projects; + } + + public function getProject($name) { + return $this->loadProject($name); + } public function getLastChange($project) { if(!array_key_exists('last_activity', $project)) { @@ -137,7 +137,7 @@ class ProjectLoader { } } return $project['refs']; - } + } } ?> \ No newline at end of file diff --git a/htdocs/pages/commit.class.php b/htdocs/pages/commit.class.php index 55ece54..e01ccbf 100644 --- a/htdocs/pages/commit.class.php +++ b/htdocs/pages/commit.class.php @@ -17,9 +17,9 @@ */ class page_commit { - private $page, $phpgitweb; + private $page, $phpgitweb; - public function main($phpgitweb, $project) { + public function main($phpgitweb, $project) { $this->phpgitweb = $phpgitweb; if(!$project) return new ContentProvider('main', 'err400'); diff --git a/htdocs/pages/commitdiff.class.php b/htdocs/pages/commitdiff.class.php index e8bb17f..3bfc409 100644 --- a/htdocs/pages/commitdiff.class.php +++ b/htdocs/pages/commitdiff.class.php @@ -17,9 +17,9 @@ */ class page_commitdiff { - private $page, $phpgitweb; + private $page, $phpgitweb; - public function main($phpgitweb, $project) { + public function main($phpgitweb, $project) { $this->phpgitweb = $phpgitweb; if(!$project) return new ContentProvider('main', 'err400'); diff --git a/htdocs/pages/projects.class.php b/htdocs/pages/projects.class.php index be0766b..9f6023e 100644 --- a/htdocs/pages/projects.class.php +++ b/htdocs/pages/projects.class.php @@ -17,9 +17,9 @@ */ class page_projects { - private $page, $phpgitweb; + private $page, $phpgitweb; - public function main($phpgitweb, $project) { + public function main($phpgitweb, $project) { $this->phpgitweb = $phpgitweb; $this->page = new ContentProvider('projects', 'main'); @@ -38,9 +38,9 @@ class page_projects { else $order = 'project'; - $this->page->set('header_project', new ContentProvider('projects', ($order == 'project' ? 'head_order_active' : 'head_order_link'), array('name' => "Project", 'tag' => "project"))); + $this->page->set('header_project', new ContentProvider('projects', ($order == 'project' ? 'head_order_active' : 'head_order_link'), array('name' => "Project", 'tag' => "project"))); $this->page->set('header_description', new ContentProvider('projects', ($order == 'descr' ? 'head_order_active' : 'head_order_link'), array('name' => "Description", 'tag' => "descr"))); - $this->page->set('header_owner', new ContentProvider('projects', ($order == 'owner' ? 'head_order_active' : 'head_order_link'), array('name' => "Owner", 'tag' => "owner"))); + $this->page->set('header_owner', new ContentProvider('projects', ($order == 'owner' ? 'head_order_active' : 'head_order_link'), array('name' => "Owner", 'tag' => "owner"))); $this->page->set('header_age', new ContentProvider('projects', ($order == 'age' ? 'head_order_active' : 'head_order_link'), array('name' => "Last Change", 'tag' => "age"))); switch($order) { @@ -88,7 +88,7 @@ class page_projects { $ret = strcmp($a['name'], $b['name']); return $ret; } - + private function project($class, $project) { $entry = new ContentProvider('projects', 'project'); $entry->set('class', $class); diff --git a/htdocs/pages/shortlog.class.php b/htdocs/pages/shortlog.class.php index a3419bd..a558faf 100644 --- a/htdocs/pages/shortlog.class.php +++ b/htdocs/pages/shortlog.class.php @@ -17,9 +17,9 @@ */ class page_shortlog { - private $page, $phpgitweb; + private $page, $phpgitweb; - public function main($phpgitweb, $project) { + public function main($phpgitweb, $project) { $this->phpgitweb = $phpgitweb; $this->project = $project; if(!$this->project) diff --git a/htdocs/pages/summary.class.php b/htdocs/pages/summary.class.php index 09bdb4c..d7d1710 100644 --- a/htdocs/pages/summary.class.php +++ b/htdocs/pages/summary.class.php @@ -19,9 +19,9 @@ require_once('pages/shortlog.class.php'); class page_summary { - private $page, $phpgitweb; + private $page, $phpgitweb; - public function main($phpgitweb, $project) { + public function main($phpgitweb, $project) { $this->phpgitweb = $phpgitweb; if(!$project) return new ContentProvider('main', 'err400'); -- 2.20.1