예제 #1
0
 public function testUserList()
 {
     $userlist = new GitPHP_UserList();
     $this->assertEquals(0, $userlist->GetCount());
     $user = new GitPHP_User('username', 'password');
     $userlist->AddUser($user);
     $this->assertEquals(1, $userlist->GetCount());
     $user2 = $userlist->GetUser('username');
     $this->assertInstanceOf('GitPHP_User', $user2);
     $this->assertEquals('username', $user2->GetUsername());
     $this->assertEquals('password', $user2->GetPassword());
     $userlist->RemoveUser('username');
     $this->assertNull($userlist->GetUser('username'));
     $this->assertEquals(0, $userlist->GetCount());
 }
예제 #2
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);
     }
 }