. // Copyright © 2007-2014 Erwan Briand // // This program is free software: you can redistribute it and/or modify it // under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, version 3 only. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public // License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . class ProjectMenu { private $ct_db, $lang, $ct_session, $page, $xmlmodule; public $notepadmenu, $pagemenu; function __construct($db, $lang, $session, $page, $xmlmodule) { // Acces to database $this->ct_db = $db; $this->lang = $lang; $this->ct_session = $session; $this->page = $page; $this->xmlmodule = $xmlmodule; $this->views = array(); foreach ($this->xmlmodule as $view) $this->views[(string) $view['name']] = (string) $view['active']; // Notepad menu $this->notepadmenu = ''; } function getNotepadMenu() { return $this->notepadmenu; } function getPageMenu($page_title) { // Project name if (!mb_ereg("^[0-9a-z_-]+$", $this->page[2])) exit('Error.'); $project = getClass('projects.projects', $this->ct_db); $projects = $project->load($this->page[2], 'dbname'); if ($projects) { $this->name = htmlspecialchars($project->getName()); $this->id = $project->getId(); $this->dbname = htmlspecialchars($project->getDbname()); $this->website = htmlspecialchars($project->getWebsite()); $txt = htmlspecialchars($project->getOneline()); $this->oneline = map_str($txt, 120); $this->logo = htmlspecialchars($project->getLogo()); $this->scm = $project->getSCM(); $this->features = $project->getFeatures(); foreach ($this->views as $key => $value) { if (!empty($this->features)) { $exp = explode('_', $this->features); if (!in_array($key, $exp)) $this->views[$key] = 'USERFALSE'; } } } else exit('Error.'); // Number of open tickets in the tasks manager $project_bugs = getClass('project.bugs', $this->ct_db); $all = $project_bugs->count(array('projectid' => $this->id)); $res = $project_bugs->count(array('projectid' => $this->id, 'status' => 'resolved')) + $project_bugs->count(array('projectid' => $this->id, 'status' => 'rejected')); $opentickets = $all - $res; // Number of topics in the forum $forum = getClass('project.forum', $this->ct_db); $messages_global = $forum->countTopics('global', $this->id); $messages_userscomments = $forum->countTopics('userscomments', $this->id); $messages_developement = $forum->countTopics('developement', $this->id); $messages_help = $forum->countTopics('help', $this->id); $messages_total = ($messages_global + $messages_userscomments + $messages_developement + $messages_help); // Page menu $file = 'public/upload/projects/'.$this->dbname.'/'.$this->logo; if ($this->logo == '!none!') $url = 'public/images/icons/project-logo_128.png'; elseif (file_exists(CT_BASEDIR.'/'.$file)) $url = 'project/'.$this->dbname.'/upload/'.$this->logo; else $url = $this->logo; $this->pagemenu = ''; $additional = ''; if (isset($this->page[3])) { if (in_array($this->page[3], array('news', 'doc', 'statistics'))) $additional = ' '; elseif ($this->page[3] == 'timeline') $additional = ' '; elseif (in_array($this->page[3], array('bugs', 'roadmap', 'board'))) $additional = ' '; /* TODO: move this. elseif ($this->page[3] == 'doc') { if (empty($this->page[4])) $pagename = 'HomePage'; elseif (in_array($this->page[4], array('edit', 'log', 'diff'))) $pagename = $this->page[5]; else $pagename = $this->page[4]; $additional = ' '; } */ elseif ($this->page[3] == 'forum') $additional = ' '; /* TODO: move this. elseif ($this->page[3] == 'statistics') $additional = ' '; */ else $additional = '
 
'; } else $additional = ' '; return array(// Module menu $this->pagemenu, // Page title and URL array('project/'.$this->dbname, $this->name), // Additional menu $additional, // Page logo $url ); } } ?>