Example #1
0
 /**
  * Instantiate
  *
  * Instantiates the singleton instance
  *
  * @access private
  * @static
  * @param string $file config file with git projects
  * @param boolean $legacy true if this is the legacy project config
  * @throws Exception if there was an error reading the file
  */
 public static function Instantiate($file = null, $legacy = false)
 {
     if (self::$instance) {
         return;
     }
     if (!empty($file) && is_file($file) && (include $file)) {
         if (isset($git_projects)) {
             if (is_string($git_projects)) {
                 if (function_exists('simplexml_load_file') && GitPHP_ProjectListScmManager::IsSCMManager($git_projects)) {
                     self::$instance = new GitPHP_ProjectListScmManager($git_projects);
                 } else {
                     self::$instance = new GitPHP_ProjectListFile($git_projects);
                 }
             } else {
                 if (is_array($git_projects)) {
                     if ($legacy) {
                         self::$instance = new GitPHP_ProjectListArrayLegacy($git_projects);
                     } else {
                         self::$instance = new GitPHP_ProjectListArray($git_projects);
                     }
                 }
             }
         }
     }
     if (!self::$instance) {
         self::$instance = new GitPHP_ProjectListDirectory(GitPHP_Config::GetInstance()->GetValue('projectroot'));
     }
     if (isset($git_projects_settings) && !$legacy) {
         self::$instance->ApplySettings($git_projects_settings);
     }
 }
 /**
  * __construct
  *
  * Constructor
  *
  * @access public
  * @return controller
  */
 public function __construct()
 {
     if (isset($_GET['p'])) {
         $this->project = GitPHP_ProjectList::GetInstance()->GetProject(str_replace(chr(0), '', $_GET['p']));
         if (!$this->project) {
             throw new GitPHP_MessageException(sprintf(__('Invalid project %1$s'), $_GET['p']), true);
         }
     }
     if (!$this->project) {
         throw new GitPHP_MessageException(__('Project is required'), true);
     }
     $this->preserveWhitespace = true;
     $this->ReadQuery();
 }
 /**
  * LoadData
  *
  * Loads data for this template
  *
  * @access protected
  */
 protected function LoadData()
 {
     $this->tpl->assign('order', $this->params['order']);
     $projectList = GitPHP_ProjectList::GetInstance();
     $projectList->Sort($this->params['order']);
     if ((empty($this->params['opml']) || $this->params['opml'] !== true) && (empty($this->params['txt']) || $this->params['txt'] !== true) && !empty($this->params['search'])) {
         $this->tpl->assign('search', $this->params['search']);
         $matches = $projectList->Filter($this->params['search']);
         if (count($matches) > 0) {
             $this->tpl->assign('projectlist', $matches);
         }
     } else {
         if ($projectList->Count() > 0) {
             $this->tpl->assign('projectlist', $projectList);
         }
     }
 }
Example #4
0
 /**
  * DereferenceProject
  *
  * Turns the project reference pointer back into an object
  *
  * @access private
  */
 private function DereferenceProject()
 {
     if (!$this->projectReferenced) {
         return;
     }
     $this->project = GitPHP_ProjectList::GetInstance()->GetProject($this->project);
     $this->projectReferenced = false;
 }
Example #5
0
        			throw new GitPHP_MessageException(sprintf(__('Could not run the diff executable "%1$s".  You may need to set the "%2$s" config value.'), $exe->GetBinary(), 'diffbin'), true, 500);
        		}*/
    }
    unset($exe);
    /*
     * Authentification
     */
    $auth = new GitPHP_Authentication();
    $auth->authenticate();
    /*
     * Project list
     */
    if (file_exists(GITPHP_CONFIGDIR . 'projects.conf.php')) {
        GitPHP_ProjectList::Instantiate(GITPHP_CONFIGDIR . 'projects.conf.php', false);
    } else {
        GitPHP_ProjectList::Instantiate(GITPHP_CONFIGDIR . 'gitphp.conf.php', true);
    }
    $controller = GitPHP_Controller::GetController(isset($_GET['a']) ? $_GET['a'] : null);
    if ($controller) {
        $controller->RenderHeaders();
        $controller->Render();
    }
} catch (Exception $e) {
    if (GitPHP_Config::GetInstance()->GetValue('debug', false)) {
        throw $e;
    }
    if (!GitPHP_Resource::Instantiated()) {
        /*
         * In case an error was thrown before instantiating
         * the resource manager
         */
 /**
  * Initialize project list
  */
 protected function InitializeProjectList()
 {
     if (file_exists(GITPHP_CONFIGDIR . 'projects.conf.php')) {
         $this->projectList = GitPHP_ProjectList::Instantiate($this->config, GITPHP_CONFIGDIR . 'projects.conf.php', false);
     } else {
         $this->projectList = GitPHP_ProjectList::Instantiate($this->config, GITPHP_CONFIGDIR . 'gitphp.conf.php', true);
     }
     $this->projectList->SetMemoryCache(new GitPHP_MemoryCache($this->config->GetValue('objectmemory')));
     if ($this->config->GetValue('objectcache')) {
         $strategy = null;
         $servers = $this->config->GetValue('memcache');
         if ($servers) {
             if (class_exists('Memcached')) {
                 $strategy = new GitPHP_Cache_Memcached($servers);
             } else {
                 if (class_exists('Memcache')) {
                     $strategy = new GitPHP_Cache_Memcache($servers);
                 } else {
                     throw new GitPHP_MissingMemcacheException();
                 }
             }
         } else {
             $strategy = new GitPHP_Cache_File(GITPHP_CACHEDIR . 'objects', $this->config->GetValue('objectcachecompress'));
         }
         $cache = new GitPHP_Cache($strategy);
         $cache->SetLifetime($this->config->GetValue('objectcachelifetime'));
         $this->projectList->SetCache($cache);
     }
     $this->projectList->SetExe($this->exe);
     if ($this->log) {
         $this->projectList->AddObserver($this->log);
     }
 }
 /**
  * GetCacheKeyPrefix
  *
  * Get the prefix for all cache keys
  *
  * @access private
  * @param string $projectKeys include project-specific key pieces
  * @return string cache key prefix
  */
 private function GetCacheKeyPrefix($projectKeys = true)
 {
     $cacheKeyPrefix = GitPHP_Resource::GetLocale();
     $projList = GitPHP_ProjectList::GetInstance();
     if ($projList) {
         $cacheKeyPrefix .= '|' . sha1(serialize($projList->GetConfig())) . '|' . sha1(serialize($projList->GetSettings()));
         unset($projList);
     }
     if ($this->project && $projectKeys) {
         $cacheKeyPrefix .= '|' . sha1($this->project->GetProject());
     }
     return $cacheKeyPrefix;
 }