Clean up CSS stylesheets, split apart functional vs skin css
[gitphp.git] / include / controller / ControllerBase.class.php
blob:a/include/controller/ControllerBase.class.php -> blob:b/include/controller/ControllerBase.class.php
--- a/include/controller/ControllerBase.class.php
+++ b/include/controller/ControllerBase.class.php
@@ -1,7 +1,5 @@
 <?php
 /**
- * GitPHP ControllerBase
- *
  * Base class that all controllers extend
  *
  * @author Christopher Han <xiphux@gmail.com
@@ -9,152 +7,419 @@
  * @package GitPHP
  * @subpackage Controller
  */
-
-/**
- * ControllerBase class
- *
- * @package GitPHP
- * @subpackage Controller
- * @abstract
- */
 abstract class GitPHP_ControllerBase
 {
 
 	/**
-	 * tpl
-	 *
+	 * Config handler instance
+	 *
+	 * @var GitPHP_Config
+	 */
+	protected $config;
+
+	/**
+	 * User list instance
+	 *
+	 * @var GitPHP_UserList
+	 */
+	protected $userList;
+
+	/**
+	 * Resource handler instance
+	 *
+	 * @var GitPHP_Resource
+	 */
+	protected $resource;
+
+	/**
 	 * Smarty instance
 	 *
-	 * @access protected
+	 * @var Smarty
 	 */
 	protected $tpl;
 
 	/**
-	 * project
-	 *
+	 * Project list
+	 *
+	 * @var GitPHP_ProjectListBase
+	 */
+	protected $projectList;
+
+	/**
 	 * Current project
 	 *
-	 * @access protected
+	 * @var GitPHP_Project
 	 */
 	protected $project;
 
 	/**
-	 * params
-	 *
+	 * Flag if this is a multi project controller
+	 *
+	 * @var boolean
+	 */
+	protected $multiProject;
+
+	/**
 	 * Parameters
 	 *
-	 * @access protected
+	 * @var array
 	 */
 	protected $params = array();
 
 	/**
-	 * headers
-	 *
-	 * Headers
-	 *
-	 * @access protected
+	 * HTTP Headers
+	 *
+	 * @var string[]
 	 */
 	protected $headers = array();
 
 	/**
-	 * __construct
-	 *
-	 * Constructor
-	 *
-	 * @access public
-	 * @return mixed controller object
-	 * @throws Exception on invalid project
-	 */
-	public function __construct()
-	{
-		require_once(GitPHP_Util::AddSlash(GitPHP_Config::GetInstance()->GetValue('smarty_prefix', 'lib/smarty/libs/')) . 'Smarty.class.php');
+	 * Flag to preserve whitespace in output (for non-html output)
+	 *
+	 * @var boolean
+	 */
+	protected $preserveWhitespace = false;
+
+	/**
+	 * Logger instance
+	 *
+	 * @var GitPHP_DebugLog
+	 */
+	protected $log;
+
+	/**
+	 * Git executable instance
+	 *
+	 * @var GitPHP_GitExe
+	 */
+	protected $exe;
+
+	/**
+	 * Url router instance
+	 *
+	 * @var GitPHP_Router
+	 */
+	protected $router;
+
+	/**
+	 * Initialize controller
+	 */
+	public function Initialize()
+	{
+		$this->InitializeConfig();
+
+		$this->InitializeResource();
+
+		$this->InitializeUserList();
+
+		$this->EnableLogging();
+
+		$this->InitializeGitExe();
+
+		$this->InitializeProjectList();
+
+		$this->InitializeSmarty();
+
+		if ($this->multiProject) {
+			$this->projectList->LoadProjects();
+		}
+
+		if (!empty($this->params['project'])) {
+			$project = $this->projectList->GetProject($this->params['project']);
+			if (!$project) {
+				throw new GitPHP_InvalidProjectParameterException($this->params['project']);
+			}
+			$this->project = $project->GetProject();
+		}
+
+		if (!($this->project || $this->multiProject)) {
+			throw new GitPHP_MissingProjectParameterException();
+		}
+	}
+
+	/**
+	 * Initialize config
+	 */
+	protected function InitializeConfig()
+	{
+		$this->config = new GitPHP_Config();
+		$this->config->LoadConfig(GITPHP_CONFIGDIR . 'gitphp.conf.php');
+	}
+
+	/**
+	 * Initialize resource manager
+	 */
+	protected function InitializeResource()
+	{
+		$locale = null;
+
+		$baseurl = GitPHP_Util::BaseUrl();
+
+		if (!empty($this->params['lang'])) {
+			/*
+			 * User picked something
+			 */
+			setcookie(GitPHP_Resource::LocaleCookie, $this->params['lang'], time()+GitPHP_Resource::LocaleCookieLifetime, $baseurl);
+			$locale = $this->params['lang'];
+		} else if (!empty($_COOKIE[GitPHP_Resource::LocaleCookie])) {
+			/**
+			 * Returning user with a preference
+			 */
+			$locale = $_COOKIE[GITPHP_Resource::LocaleCookie];
+		} else {
+			/*
+			 * User's first time here, try by HTTP_ACCEPT_LANGUAGE
+			 */
+			if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
+				$httpAcceptLang = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
+				$locale = GitPHP_Resource::FindPreferredLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']);
+				if (!empty($locale)) {
+					setcookie(GitPHP_Resource::LocaleCookie, $locale, time()+GitPHP_Resource::LocaleCookieLifetime, $baseurl);
+				}
+			}
+		}
+
+		if (empty($locale) && $this->config) {
+			/*
+			 * No preference, fall back on setting
+			 */
+			$locale = $this->config->GetValue('locale');
+		}
+
+		if (!empty($locale) && ($locale != 'en_US')) {
+			try {
+				$this->resource = new GitPHP_Resource($locale);
+			} catch (Exception $e) {
+			}
+		}
+	}
+
+	/**
+	 * Initialize user list
+	 */
+	public function InitializeUserList()
+	{
+		$this->userList = new GitPHP_UserList();
+		$this->userList->LoadUsers(GITPHP_CONFIGDIR . 'users.conf.php');
+		if ($this->userList->GetCount() > 0) {
+			if (!isset($_SESSION))
+				session_start();
+		}
+	}
+
+	/**
+	 * Initialize executable
+	 *
+	 * @param boolean $validate whether the exe should be validated
+	 */
+	protected function InitializeGitExe($validate = true)
+	{
+		$this->exe = new GitPHP_GitExe($this->config->GetValue('gitbin'));
+		if ($this->log)
+			$this->exe->AddObserver($this->log);
+		if ($validate && !$this->exe->Valid()) {
+			throw new GitPHP_InvalidGitExecutableException($this->exe->GetBinary());
+		}
+	}
+
+	/**
+	 * 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);
+
+	}
+
+	/**
+	 * Initialize smarty
+	 */
+	protected function InitializeSmarty()
+	{
+		require_once(GITPHP_SMARTYDIR . 'Smarty.class.php');
 		$this->tpl = new Smarty;
-		$this->tpl->plugins_dir[] = GITPHP_INCLUDEDIR . 'smartyplugins';
-
-		if (GitPHP_Config::GetInstance()->GetValue('cache', false)) {
-			$this->tpl->caching = 2;
-			if (GitPHP_Config::GetInstance()->HasKey('cachelifetime')) {
-				$this->tpl->cache_lifetime = GitPHP_Config::GetInstance()->GetValue('cachelifetime');
-			}
-
-			$servers = GitPHP_Config::GetInstance()->GetValue('memcache', null);
+		$this->tpl->error_reporting = E_ALL & ~E_NOTICE;
+		$this->tpl->merge_compiled_includes = true;
+		$this->tpl->addPluginsDir(GITPHP_INCLUDEDIR . 'smartyplugins');
+
+		if ($this->config->GetValue('cache')) {
+			$cacheDir = GITPHP_CACHEDIR . 'templates';
+
+			if (file_exists($cacheDir)) {
+				if (!is_dir($cacheDir)) {
+					throw new Exception($cacheDir . ' exists but is not a directory');
+				} else if (!is_writable($cacheDir)) {
+					throw new Exception($cacheDir . ' is not writable');
+				}
+			} else {
+				if (!mkdir($cacheDir, 0777))
+					throw new Exception($cacheDir . ' could not be created');
+				chmod($cacheDir, 0777);
+			}
+			$this->tpl->setCacheDir($cacheDir);
+
+			$this->tpl->caching = Smarty::CACHING_LIFETIME_SAVED;
+			if ($this->config->HasKey('cachelifetime')) {
+				$this->tpl->cache_lifetime = $this->config->GetValue('cachelifetime');
+			}
+
+			$servers = $this->config->GetValue('memcache');
 			if (isset($servers) && is_array($servers) && (count($servers) > 0)) {
-				require_once(GITPHP_CACHEDIR . 'Memcache.class.php');
-				GitPHP_Memcache::GetInstance()->AddServers($servers);
-				require_once(GITPHP_CACHEDIR . 'memcache_cache_handler.php');
-				$this->tpl->cache_handler_func = 'memcache_cache_handler';
-			}
-
-		}
-
-		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 (isset($_GET['s']))
-			$this->params['search'] = $_GET['s'];
-		if (isset($_GET['st']))
-			$this->params['searchtype'] = $_GET['st'];
-
-		$this->ReadQuery();
-	}
-
-	/**
-	 * GetTemplate
-	 *
+				$this->tpl->registerCacheResource('memcache', new GitPHP_CacheResource_Memcache($servers));
+				$this->tpl->caching_type = 'memcache';
+			}
+
+		}
+
+	}
+
+	/**
+	 * Set router instance
+	 *
+	 * @param GitPHP_Router $router router
+	 */
+	public function SetRouter($router)
+	{
+		$this->router = $router;
+	}
+
+	/**
+	 * Get config instance
+	 *
+	 * @return GitPHP_Config
+	 */
+	public function GetConfig()
+	{
+		return $this->config;
+	}
+
+	/**
+	 * Get log instance
+	 *
+	 * @return GitPHP_DebugLog
+	 */
+	public function GetLog()
+	{
+		return $this->log;
+	}
+
+	/**
+	 * Enable logging
+	 */
+	public function EnableLogging()
+	{
+		if ($this->log)
+			return;
+
+		$debug = $this->config->GetValue('debug');
+		if ($debug) {
+			$this->log = new GitPHP_DebugLog($debug, $this->config->GetValue('benchmark'));
+			$this->log->SetStartTime(GITPHP_START_TIME);
+			$this->log->SetStartMemory(GITPHP_START_MEM);
+			if ($this->exe)
+				$this->exe->AddObserver($this->log);
+			if ($this->projectList)
+				$this->projectList->AddObserver($this->log);
+		}
+	}
+
+	/**
+	 * Disable logging
+	 */
+	protected function DisableLogging()
+	{
+		if (!$this->log)
+			return;
+
+		$this->projectList->RemoveObserver($this->log);
+		$this->exe->RemoveObserver($this->log);
+
+		$this->log->SetEnabled(false);
+
+		$this->log = null;
+	}
+
+	/**
+	 * Gets the project for this controller
+	 *
+	 * @return GitPHP_Project|null project
+	 */
+	public function GetProject()
+	{
+		if ($this->project)
+			return $this->projectList->GetProject($this->project);
+		return null;
+	}
+
+	/**
 	 * Gets the template for this controller
 	 *
-	 * @access protected
-	 * @abstract
 	 * @return string template filename
 	 */
 	protected abstract function GetTemplate();
 
 	/**
-	 * GetCacheKey
-	 *
 	 * Gets the cache key for this controller
 	 *
-	 * @access protected
-	 * @abstract
 	 * @return string cache key
 	 */
 	protected abstract function GetCacheKey();
 
 	/**
-	 * GetCacheKeyPrefix
-	 *
 	 * Get the prefix for all cache keys
 	 *
-	 * @access private
-	 * @param string $projectKeys include project-specific key pieces
+	 * @param boolean $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->resource)
+			$cacheKeyPrefix = $this->resource->GetLocale();
+		else
+			$cacheKeyPrefix = 'en_US';
+
+		if ($this->projectList) {
+			$cacheKeyPrefix .= '|' . sha1(serialize($this->projectList->GetProjectListConfig())) . '|' . sha1(serialize($this->projectList->GetProjectSettings()));
 		}
 		if ($this->project && $projectKeys) {
-			$cacheKeyPrefix .= '|' . sha1($this->project->GetProject());
+			$cacheKeyPrefix .= '|' . sha1($this->project);
 		}
 		
 		return $cacheKeyPrefix;
 	}
 
 	/** 
-	 * GetFullCacheKey
-	 *
 	 * Get the full cache key
 	 *
-	 * @access protected
 	 * @return string full cache key
 	 */
 	protected function GetFullCacheKey()
@@ -166,37 +431,24 @@
 		if (!empty($subCacheKey))
 			$cacheKey .= '|' . $subCacheKey;
 
+		if (strlen($cacheKey) > 100) {
+			$cacheKey = sha1($cacheKey);
+		}
+
 		return $cacheKey;
 	}
 
 	/**
-	 * GetName
-	 *
 	 * Gets the name of this controller's action
 	 *
-	 * @abstract
-	 * @access public
 	 * @param boolean $local true if caller wants the localized action name
 	 * @return string action name
 	 */
 	public abstract function GetName($local = false);
 
 	/**
-	 * ReadQuery
-	 *
-	 * Read query into parameters
-	 *
-	 * @abstract
-	 * @access protected
-	 */
-	protected abstract function ReadQuery();
-
-	/**
-	 * SetParam
-	 *
 	 * Set a parameter
 	 *
-	 * @access protected
 	 * @param string $key key to set
 	 * @param mixed $value value to set
 	 */
@@ -208,36 +460,27 @@
 		if (empty($value))
 			unset($this->params[$key]);
 
+		if (is_string($value))
+			$value = str_replace(chr(0), '', $value);
+
 		$this->params[$key] = $value;
 	}
 
 	/**
-	 * LoadHeaders
-	 *
 	 * Loads headers for this template
-	 *
-	 * @access protected
 	 */
 	protected function LoadHeaders()
 	{
-	}
-
-	/**
-	 * LoadData
-	 *
+		$this->headers[] = 'Content-Type: text/html; charset=UTF-8';
+	}
+
+	/**
 	 * Loads data for this template
-	 *
-	 * @access protected
-	 * @abstract
 	 */
 	protected abstract function LoadData();
 
 	/**
-	 * LoadCommonData
-	 *
 	 * Loads common data used by all templates
-	 *
-	 * @access private
 	 */
 	private function LoadCommonData()
 	{
@@ -245,30 +488,68 @@
 
 		$this->tpl->assign('version', $gitphp_version);
 
-		$stylesheet = GitPHP_Config::GetInstance()->GetValue('stylesheet', 'gitphpskin.css');
+		$stylesheet = $this->config->GetValue('stylesheet');
 		if ($stylesheet == 'gitphp.css') {
 			// backwards compatibility
 			$stylesheet = 'gitphpskin.css';
 		}
-		$this->tpl->assign('stylesheet', $stylesheet);
-
-		$this->tpl->assign('javascript', GitPHP_Config::GetInstance()->GetValue('javascript', true));
-		$this->tpl->assign('pagetitle', GitPHP_Config::GetInstance()->GetValue('title', $gitphp_appstring));
-		$this->tpl->assign('homelink', GitPHP_Config::GetInstance()->GetValue('homelink', __('projects')));
+		$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->project);
-		if (GitPHP_Config::GetInstance()->GetValue('search', true))
+			$this->tpl->assign('project', $this->GetProject());
+		if ($this->config->GetValue('search'))
 			$this->tpl->assign('enablesearch', true);
-		if (GitPHP_Config::GetInstance()->GetValue('filesearch', 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']);
-		$this->tpl->assign('currentlocale', GitPHP_Resource::GetLocale());
-		$this->tpl->assign('supportedlocales', GitPHP_Resource::SupportedLocales());
+		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->HasKey('self')) {
+				$this->router->SetBaseUrl($this->config->GetValue('self'));
+			}
+			$this->tpl->assign('router', $this->router);
+		}
 
 		$getvars = explode('&', $_SERVER['QUERY_STRING']);
 		$getvarsmapped = array();
@@ -277,7 +558,7 @@
 			if ($eqpos > 0) {
 				$var = substr($varstr, 0, $eqpos);
 				$val = substr($varstr, $eqpos + 1);
-				if (!(empty($var) || empty($val))) {
+				if (!(empty($var) || empty($val) || ($var == 'q'))) {
 					$getvarsmapped[$var] = urldecode($val);
 				}
 			}
@@ -285,73 +566,98 @@
 		$this->tpl->assign('requestvars', $getvarsmapped);
 
 		$this->tpl->assign('snapshotformats', GitPHP_Archive::SupportedFormats());
-	}
-
-	/**
-	 * RenderHeaders
-	 *
+
+		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());
+				}
+			}
+		}
+	}
+
+	/**
 	 * Renders any special headers
-	 *
-	 * @access public
 	 */
 	public function RenderHeaders()
 	{
 		$this->LoadHeaders();
 
 		if (count($this->headers) > 0) {
+			$hascontenttype = false;
 			foreach ($this->headers as $hdr) {
+				if (empty($hdr))
+					continue;
+
+				if (strncmp($hdr, 'Content-Type:', 13) === 0) {
+					if ($hascontenttype)
+						throw new Exception('Duplicate Content-Type header');
+					$hascontenttype = true;
+				}
 				header($hdr);
 			}
 		}
 	}
 
 	/**
-	 * Render
-	 *
 	 * Renders the output
-	 *
-	 * @access public
 	 */
 	public function Render()
 	{
-		if ((GitPHP_Config::GetInstance()->GetValue('cache', false) == true) && (GitPHP_Config::GetInstance()->GetValue('cacheexpire', true) === true))
+		if (($this->config->GetValue('cache') == true) && ($this->config->GetValue('cacheexpire') === true))
 			$this->CacheExpire();
 
-		if (!$this->tpl->is_cached($this->GetTemplate(), $this->GetFullCacheKey())) {
-			$this->tpl->clear_all_assign();
+		if (!$this->tpl->isCached($this->GetTemplate(), $this->GetFullCacheKey())) {
+			$this->tpl->clearAllAssign();
+			if ($this->log && $this->log->GetBenchmark())
+				$this->log->Log("Data load begin");
 			$this->LoadCommonData();
 			$this->LoadData();
-		}
-
+			if ($this->log && $this->log->GetBenchmark())
+				$this->log->Log("Data load end");
+		}
+
+		if (!$this->preserveWhitespace) {
+			//$this->tpl->loadFilter('output', 'trimwhitespace');
+		}
+
+		if ($this->log && $this->log->GetBenchmark())
+			$this->log->Log("Smarty render begin");
 		$this->tpl->display($this->GetTemplate(), $this->GetFullCacheKey());
-	}
-
-	/**
-	 * CacheExpire
-	 *
+		if ($this->log && $this->log->GetBenchmark())
+			$this->log->Log("Smarty render end");
+
+		$this->tpl->clearAllAssign();
+
+		if ($this->log && $this->projectList)
+			$this->log->Log('MemoryCache count: ' . $this->projectList->GetMemoryCache()->GetCount());
+	}
+
+	/**
 	 * Expires the cache
 	 *
-	 * @access public
 	 * @param boolean $expireAll expire the whole cache
 	 */
 	public function CacheExpire($expireAll = false)
 	{
 		if ($expireAll) {
-			$this->tpl->clear_all_cache();
+			$this->tpl->clearAllCache();
 			return;
 		}
 
 		if (!$this->project)
 			return;
 
-		$epoch = $this->project->GetEpoch();
+		$epoch = $this->GetProject()->GetEpoch();
 		if (empty($epoch))
 			return;
 
-		$age = $this->project->GetAge();
-
-		$this->tpl->clear_cache(null, $this->GetCacheKeyPrefix(), null, $age);
-		$this->tpl->clear_cache('projectlist.tpl', $this->GetCacheKeyPrefix(false), null, $age);
+		$age = $this->GetProject()->GetAge();
+
+		$this->tpl->clearCache(null, $this->GetCacheKeyPrefix(), null, $age);
+		$this->tpl->clearCache('projectlist.tpl', $this->GetCacheKeyPrefix(false), null, $age);
 	}
 
 }

comments