websiteWebsite
codingteam CodingTeam
A free forge, lightweight and extensible.

 

Browse the code

Revision log Information on the revision
Revision: 438 (differences)
Author: xbright
Log message: * Introduced developers roadmap
* Added statistics in the roadmap (milestone, distribution, progression)
* Added Inconsolata fonts (used by our piegraph.class.php edit)
Change revision:
<?php
//   This file is a part of CodingTeam. Take a look at <http://codingteam.org>.
//   Copyright © 2007-2011 Erwan Briand <erwan@codingteam.net>
//
//   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 <http://www.gnu.org/licenses/>.
 
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()
    {
        // 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->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.');
 
        // Page menu
        $file = 'public/upload/projects/'.$this->dbname.'/'.$this->logo;
 
        if ($this->logo == '!none!')
            $url = 'public/images/icons/mimetypes/application-x-executable_big.png';
        elseif (file_exists(CT_BASEDIR.'/'.$file))
            $url = 'project/'.$this->dbname.'/upload/'.$this->logo;
        else
            $url = $this->logo;
 
        if (!empty($this->website))
            $this->pagemenu = '<div style="float: right;margin-top: 5px;padding-right: 20px;display: block;text-align: right;padding-left: 50px;">
            <a href="'.$this->website.'" style="min-height: 16px;display: block;">
              <img src="public/images/icons/apps/web-browser.png" alt="website" style="float: right;padding-left: 5px;" />'.i18n('Website').'</a><br />';
        else
            $this->pagemenu = '<div style="float: right;margin-top: 5px;padding-right: 20px;display: block;text-align: right;padding-left: 50px;">';
 
        $this->pagemenu .= '</div>
        <a href="project/'.$this->dbname.'" class="pheader">
          <img src="'.$url.'" alt="'.$this->dbname.'" style="float: left;width: 34px;max-height: 34px;" />
          <strong style="padding-left: 5px;">'.$this->name.'</strong><br />
          <span class="text_normal" style="padding-left: 5px;"><em>'.$this->oneline.'</em></span><br />
        </a>';
 
        $this->pagemenu .= '<ul id="rootmenu">
                            <li '.( (!isset($this->page[3]) || in_array($this->page[3], array('screenshots', 'statistics'))) ?
                           'class="current"><a href="project/'.$this->dbname.'"><img src="public/images/icons/places/user-desktop.png" style="float: left;padding-right: 5px;" alt="menu" />' :
                           '><a href="project/'.$this->dbname.'">' ).i18n('Project').' <img src="public/images/dropdown.png" alt="dropdown" /></a>
                              <ul class="submenu">
                                '.( (!empty($this->website)) ? '<li><a href="'.$this->website.'">'.i18n('Website').'</a></li>' : '' ).'
                                '.( ($this->views['screenshots'] == 'TRUE') ? '<li><a href="project/'.$this->dbname.'/screenshots">'.i18n('Screenshots').'</a></li>' : '' ).'
                                '.( ($this->views['statistics'] == 'TRUE') ? '<li><a href="project/'.$this->dbname.'/statistics">'.i18n('Statistics').'</a></li>' : '' ).'
                              </ul>
                            </li>';
 
        if ($this->views['timeline'] == 'TRUE')
            $this->pagemenu .= '<li '.( (isset($this->page[3]) && $this->page[3] == 'timeline') ?
                               'class="current"><a href="project/'.$this->dbname.'/timeline"><img src="public/images/icons/stock/form/stock_form-time-field.png" alt="menu" style="float: left;padding-right: 5px;" />' :
                               '><a href="project/'.$this->dbname.'/timeline">' ).i18n('Timeline').'</a></li>';
 
        if ($this->views['download'] == 'TRUE')
            $this->pagemenu .= '<li '.( (isset($this->page[3]) && $this->page[3] == 'download') ?
                               'class="current"><a href="project/'.$this->dbname.'/download"><img src="public/images/icons/actions/go-bottom.png" alt="menu" style="float: left;padding-right: 5px;" />' :
                               '><a href="project/'.$this->dbname.'/download">' ).i18n('Download').'</a></li>';
 
        if ($this->views['browse'] == 'TRUE')
        {
            $this->pagemenu .= '<li '.( (isset($this->page[3]) && $this->page[3] == 'browse') ?
                               'class="current"><a href="project/'.$this->dbname.'/browse"><img src="public/images/icons/places/folder-remote.png" alt="menu" style="float: left;padding-right: 5px;" />' :
                               '><a href="project/'.$this->dbname.'/browse">' ).i18n('Code').' <img src="public/images/dropdown.png" alt="dropdown" /></a>
                                  <ul class="submenu">
                                    <li><a href="';
 
            if ($this->scm == 'mercurial')
                $this->pagemenu .= CT_HG_SUBDOMAIN.CT_HG_LOCATION;
            elseif ($this->scm == 'git')
                $this->pagemenu .= CT_GIT_SUBDOMAIN.CT_GIT_LOCATION;
            else
                $this->pagemenu .= CT_SVN_SUBDOMAIN.CT_SVN_LOCATION;
 
            $this->pagemenu .= $this->dbname.'">'.i18n('Repository').'</a></li>
                                    <li><a href="project/'.$this->dbname.'/browse"><strong>'.i18n('Browse the code').'</strong></a></li>
                                  </ul>
                                </li>';
        }
 
        if ($this->views['bugs'] == 'TRUE')
            $this->pagemenu .= '<li '.( (isset($this->page[3]) && in_array($this->page[3], array('bugs', 'roadmap', 'todo'))) ?
                               'class="current"><a href="project/'.$this->dbname.'/bugs"><img src="public/images/icons/categories/preferences-system.png" alt="menu" style="float: left;padding-right: 5px;" />' :
                               '><a href="project/'.$this->dbname.'/bugs">' ).i18n('Tracker').' <img src="public/images/dropdown.png" alt="dropdown" /></a>
                                   <ul class="submenu">
                                    '.( ($this->views['roadmap'] == 'TRUE') ? '<li><a href="project/'.$this->dbname.'/roadmap">'.i18n('Roadmap').'</a></li>' : '' ).'
                                    <li><a href="project/'.$this->dbname.'/bugs/add"><strong>'.i18n('Report a bug').'</strong></a></li>
                                  </ul>
                                </li>';
 
        if ($this->views['i18n'] == 'TRUE')
            $this->pagemenu .= '<li '.( (isset($this->page[3]) && $this->page[3] == 'i18n') ?
                               'class="current"><a href="project/'.$this->dbname.'/i18n"><img src="public/images/icons/apps/preferences-desktop-locale.png" alt="menu" style="float: left;padding-right: 5px;" />' :
                               '><a href="project/'.$this->dbname.'/i18n">' ).i18n('Internationalization').'</a></li>';
 
        if ($this->views['doc'] == 'TRUE')
            $this->pagemenu .= '<li '.( (isset($this->page[3]) && $this->page[3] == 'doc') ?
                               'class="current"><a href="project/'.$this->dbname.'/doc"><img src="public/images/icons/apps/accessories-dictionary.png" alt="menu" style="float: left;padding-right: 5px;" />' :
                               '><a href="project/'.$this->dbname.'/doc">' ).i18n('Documentation').'</a></li>';
 
        if ($this->views['news'] == 'TRUE')
            $this->pagemenu .= '<li '.( (isset($this->page[3]) && $this->page[3] == 'news') ?
                               'class="current"><a href="project/'.$this->dbname.'/news"><img src="public/images/icons/stock/generic/stock_news.png" alt="menu" style="float: left;padding-right: 5px;" />' :
                               '><a href="project/'.$this->dbname.'/news">' ).i18n('News').'</a></li>';
 
        if ($this->views['forum'] == 'TRUE')
            $this->pagemenu .= '<li '.( (isset($this->page[3]) && $this->page[3] == 'forum') ?
                               'class="current"><a href="project/'.$this->dbname.'/forum"><img src="public/images/icons/actions/mail-reply-all.png" alt="menu" style="float: left;padding-right: 5px;" />' :
                               '><a href="project/'.$this->dbname.'/forum">' ).i18n('Forum').' <img src="public/images/dropdown.png" alt="dropdown" /></a>
                                  <ul class="submenu">
                                    <li><a href="project/'.$this->dbname.'/forum/category/help">'.i18n('Help').'</a></li>
                                    <li><a href="project/'.$this->dbname.'/forum/category/developement">'.i18n('Developement').'</a></li>
                                    <li><a href="project/'.$this->dbname.'/forum/category/userscomments">'.i18n('Users comments').'</a></li>
                                    <li><a href="project/'.$this->dbname.'/forum/category/global">'.i18n('Global').'</a></li>
                                    <li><a href="project/'.$this->dbname.'/forum/add"><strong>'.i18n('Post a new topic').'</strong></a></li>
                                  </ul>
                                </li>';
 
        if ($this->views['jabber'] == 'TRUE')
            $this->pagemenu .= '<li '.( (isset($this->page[3]) && $this->page[3] == 'jabber') ?
                               'class="current"><a href="project/'.$this->dbname.'/jabber"><img src="public/images/icons/apps/im-jabber.png" alt="menu" style="float: left;padding-right: 5px;" />' :
                               '><a href="project/'.$this->dbname.'/jabber">' ).i18n('Chat rooms').'</a></li>';
 
        $this->pagemenu .= '</ul>';
 
        return $this->pagemenu;
    }
}
?>