format fixes
authorpk910 <philipp@zoelle1.de>
Sun, 10 Mar 2013 07:06:04 +0000 (08:06 +0100)
committerpk910 <philipp@zoelle1.de>
Sun, 10 Mar 2013 07:06:04 +0000 (08:06 +0100)
htdocs/config.example.php
htdocs/lib/ContentProvider.class.php
htdocs/lib/PHPGitWeb.class.php
htdocs/lib/ProjectLoader.class.php
htdocs/pages/commit.class.php
htdocs/pages/commitdiff.class.php
htdocs/pages/projects.class.php
htdocs/pages/shortlog.class.php
htdocs/pages/summary.class.php

index 0755ec8398473defba2ce04f2a1ad149b83c05d6..f1bb664093b03638ca488ede60caf0415e93d85c 100644 (file)
 
 /* GIT configuration */
 class GitConfig {
-    /* PHPGitWeb Title / Name */
+       /* PHPGitWeb Title / Name */
        const GITWEB_TITLE = "PHPGitWeb";
        
-    /* path to git projects (<project>.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 (<project>.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;
index e88b948ff3872115b925c2819a46976eb9360388..0fc9685b54c27f3b73ee29460506ee183f2b43c7 100644 (file)
  */
 
 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;
        }
index fc278afc2af1318a57b054a35b2c7c766a3d6784..b28f3d42a8799c63a24be50d91d657332e774d6e 100644 (file)
@@ -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 = "";
index 20ee218aa6a91a6aecdb301fa59c5bcae76afabc..332a6e4809d40a9a54e328334bca5d05502d99fb 100644 (file)
  */
 
 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
index 55ece54f49056402c5b6b5718c11dc8ed563e071..e01ccbfe833a420c18b21417f12c3c22dca9339e 100644 (file)
@@ -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');
index e8bb17f6999a3918434312ec41830b970950da0a..3bfc409c30bdad42f95716011dfd9c8306bcff87 100644 (file)
@@ -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');
index be0766b337a7b044c012690c44f501665ab31fab..9f6023e420df1c25b2e5bd94b1f568887e4cef30 100644 (file)
@@ -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);
index a3419bd337ed76d58aa2cb4f449e2af71719f5c2..a558faf4f9ea07a14bf383198760b156b7995edb 100644 (file)
@@ -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)
index 09bdb4caf7836bc4a06e43b45d059208bb79dd83..d7d17101050fa34618d1adb6ac5fec39b8619935 100644 (file)
@@ -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');