websiteWebsite
codingteam CodingTeam
A free forge, lightweight and extensible.

 

Browse the code

Revision log Information on the revision
Revision: 362 (differences)
Author: xbright
Log message: * Updated AGPL headers
Change revision:
<?php
//   This file is a part of CodingTeam. Take a look at <http://codingteam.org>.
//   Copyright © 2007-2010 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 head_search {
    private $ct_session, $ct_db, $page;
 
    function __construct($ct_session, $ct_db, $page)
    {
        $this->ct_session = $ct_session;
        $this->ct_db = $ct_db;
        $this->page = $page;
 
        if ($this->page[1] == 'project' && isset($this->page[2]))
            $this->in_array = array('projects-bugs' => i18n('Bugs'),
                                    'projects-doc' => i18n('Documentation'),
                                    'projects-forum' => i18n('Forum'),
                                    'projects-news' => i18n('News'));
        else
            $this->in_array = array('projects' => i18n('Projects'),
                                    'projects-bugs' => i18n('Bugs'),
                                    'projects-doc' => i18n('Documentation'),
                                    'projects-forum' => i18n('Forum'),
                                    'projects-news' => i18n('News'),
                                    'notepad' => i18n('Notepad'),
                                    'users' => i18n('Users'));
    }
 
    function treatForms()
    {
    }
 
    function getPageContent()
    {
        echo '
        <form action="search/" method="get">
          <p style="float: left;padding-right: 3px;">';
 
        if ($this->page[1] == 'project' && isset($this->page[2]))
        {
            echo '<input type="hidden" name="project" value="'.
                 htmlspecialchars($this->page[2]).'" />';
 
            $prj = getClass('projects.projects', $this->ct_db);
            $prj->load($this->page[2], 'dbname');
            $prjname = htmlspecialchars($prj->getName());
            $text = i18n('Search in %(project)s',
                         array('project' => map_str($prjname, 15)));
        }
        else
            $text = i18n('Search');
 
        echo '<input type="text" size="15" maxlength="255" name="keyword" '.
             'style="width: 200px;" />
             <select name="in" style="width: 140px;">';
 
        foreach ($this->in_array as $key => $value)
        {
            echo '<option value="'.$key.'">';
 
            $explode = explode('-', $key);
            if (isset($explode[1]) &&
                !($this->page[1] == 'project' && isset($this->page[2])))
                echo '&nbsp;&nbsp;';
 
            echo $value.'</option>';
        }
 
        echo '</select>
            <input class="submit" type="submit" value="'.$text.'" />
          </p>
        </form>';
    }
}
?>