format fixes
[phpgitweb.git] / htdocs / lib / ProjectLoader.class.php
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