Ejemplo n.º 1
0
 /**
  * Loads common data used by all templates
  */
 private function LoadCommonData()
 {
     global $gitphp_version, $gitphp_appstring;
     $this->tpl->assign('version', $gitphp_version);
     $stylesheet = $this->config->GetValue('stylesheet');
     if ($stylesheet == 'gitphp.css') {
         // backwards compatibility
         $stylesheet = 'gitphpskin.css';
     }
     $this->tpl->assign('stylesheet', preg_replace('/\\.css$/', '', $stylesheet));
     $this->tpl->assign('javascript', $this->config->GetValue('javascript'));
     $this->tpl->assign('googlejs', $this->config->GetValue('googlejs'));
     if ($this->config->HasKey('title')) {
         $this->tpl->assign('pagetitle', $this->config->GetValue('title'));
     } else {
         $this->tpl->assign('pagetitle', $gitphp_appstring);
     }
     if ($this->config->HasKey('homelink')) {
         $this->tpl->assign('homelink', $this->config->GetValue('homelink'));
     } else {
         if ($this->resource) {
             $this->tpl->assign('homelink', $this->resource->translate('projects'));
         } else {
             $this->tpl->assign('homelink', 'projects');
         }
     }
     $this->tpl->assign('action', $this->GetName());
     $this->tpl->assign('actionlocal', $this->GetName(true));
     if ($this->project) {
         $this->tpl->assign('project', $this->GetProject());
     }
     if ($this->config->GetValue('search')) {
         $this->tpl->assign('enablesearch', true);
     }
     if ($this->config->GetValue('filesearch')) {
         $this->tpl->assign('filesearch', true);
     }
     if (isset($this->params['search'])) {
         $this->tpl->assign('search', $this->params['search']);
     }
     if (isset($this->params['searchtype'])) {
         $this->tpl->assign('searchtype', $this->params['searchtype']);
     }
     if ($this->resource) {
         $this->tpl->assign('currentlocale', $this->resource->GetLocale());
         $this->tpl->assign('currentprimarylocale', $this->resource->GetPrimaryLocale());
         $this->tpl->assign('resource', $this->resource);
     } else {
         $this->tpl->assign('currentlocale', 'en_US');
         $this->tpl->assign('currentprimarylocale', 'en');
     }
     $this->tpl->assign('supportedlocales', GitPHP_Resource::SupportedLocales(true));
     if ($this->config->GetValue('graphs')) {
         $this->tpl->assign('enablegraphs', true);
     }
     $this->tpl->assign('baseurl', GitPHP_Util::BaseUrl());
     $requesturl = $_SERVER['REQUEST_URI'];
     $querypos = strpos($requesturl, '?');
     if ($querypos !== false) {
         $requesturl = substr($requesturl, 0, $querypos);
     }
     $this->tpl->assign('requesturl', $requesturl);
     if ($this->router) {
         $this->router->SetCleanUrl($this->config->GetValue('cleanurl') ? true : false);
         $this->router->SetAbbreviate($this->config->GetValue('abbreviateurl') ? true : false);
         if ($this->config->GetValue('self')) {
             $this->router->SetBaseUrl($this->config->GetValue('self'));
         }
         $this->tpl->assign('router', $this->router);
     }
     $getvars = array();
     if (isset($_SERVER['QUERY_STRING'])) {
         $getvars = explode('&', $_SERVER['QUERY_STRING']);
     }
     $getvarsmapped = array();
     foreach ($getvars as $varstr) {
         $eqpos = strpos($varstr, '=');
         if ($eqpos > 0) {
             $var = substr($varstr, 0, $eqpos);
             $val = substr($varstr, $eqpos + 1);
             if (!(empty($var) || empty($val) || $var == 'q')) {
                 $getvarsmapped[$var] = urldecode($val);
             }
         }
     }
     $this->tpl->assign('requestvars', $getvarsmapped);
     $this->tpl->assign('snapshotformats', GitPHP_Archive::SupportedFormats());
     if ($this->userList && $this->userList->GetCount() > 0) {
         $this->tpl->assign('loginenabled', true);
         if (!empty($_SESSION['gitphpuser'])) {
             $user = $this->userList->GetUser($_SESSION['gitphpuser']);
             if ($user) {
                 $this->tpl->assign('loggedinuser', $user->GetUsername());
             }
         }
     }
     if ($this->log && $this->log->GetEnabled()) {
         $this->tpl->assign('debug', true);
     }
 }
Ejemplo n.º 2
0
 /**
  * Applies global config settings to a project
  *
  * @param GitPHP_Project $project project
  */
 protected function ApplyGlobalConfig($project)
 {
     if (!$project) {
         return;
     }
     if (!$this->config) {
         return;
     }
     if ($this->config->GetValue('cloneurl')) {
         $project->SetCloneUrl(GitPHP_Util::AddSlash($this->config->GetValue('cloneurl'), false) . $project->GetProject());
     }
     if ($this->config->GetValue('pushurl')) {
         $project->SetPushUrl(GitPHP_Util::AddSlash($this->config->GetValue('pushurl'), false) . $project->GetProject());
     }
     if ($this->config->GetValue('bugpattern')) {
         $project->SetBugPattern($this->config->GetValue('bugpattern'));
     }
     if ($this->config->GetValue('bugurl')) {
         $project->SetBugUrl($this->config->GetValue('bugurl'));
     }
     if ($this->config->HasKey('compat')) {
         $project->SetCompat($this->config->GetValue('compat'));
     }
     if ($this->config->HasKey('uniqueabbrev')) {
         $project->SetUniqueAbbreviation($this->config->GetValue('uniqueabbrev'));
     }
     if ($this->config->GetValue('abbreviateurl')) {
         $project->SetUniqueAbbreviation(true);
     }
 }