aboutsummaryrefslogtreecommitdiff
path: root/lib/navigation/SearchNavigation.php
blob: 66ca672a5fadbed741d2763fb7f6e63876ce5ff4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
# Lifter010: TODO
/*
 * SearchNavigation.php - navigation for search page
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * @author      Elmar Ludwig
 * @author      Michael Riehemann <michael.riehemann@uni-oldenburg.de>
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category    Stud.IP
 * @since       2.0
 */

/**
 * This navigation includes all search pages depending on the
 * activated modules.
 */
class SearchNavigation extends Navigation
{
    /**
     * Initialize a new Navigation instance.
     */
    public function __construct()
    {
        parent::__construct(_('Suche'));

        $this->setImage(Icon::create('search', 'navigation', ['title' => _('Suche')]));
    }

    /**
     * Initialize the subnavigation of this item. This method
     * is called once before the first item is added or removed.
     */
    public function initSubNavigation()
    {
        parent::initSubNavigation();
        if($GLOBALS['user']->id != 'nobody'){ 
            // global search 
            $navigation = new Navigation(_('Globale Suche'), 'dispatch.php/search/globalsearch'); 
            $this->addSubNavigation('globalsearch', $navigation); 
        } 

        // browse courses
        // get first search option
        if (($GLOBALS['user']->id == 'nobody' && Config::get()->COURSE_SEARCH_IS_VISIBLE_NOBODY) || $GLOBALS['user']->id != 'nobody') { 
            $navigation_option = SemBrowse::getSearchOptionNavigation('sidebar'); 

            if ($navigation_option) { 
                $navigation = new Navigation( 
                    _('Veranstaltungsverzeichnis'), 
                    $navigation_option->getURL() 
                ); 
                foreach (array_keys(Config::get()->COURSE_SEARCH_NAVIGATION_OPTIONS) as $name) { 
                    $navigation_option = SemBrowse::getSearchOptionNavigation('sidebar', $name); 
                    if ($navigation_option) { 
                        $navigation->addSubNavigation($name, $navigation_option); 
                    } 
                }
                    $this->addSubNavigation('courses', $navigation); 
            }
        }


        if ($GLOBALS['user']->id != 'nobody') {
            // search archive
            if (Config::get()->ENABLE_ARCHIVE_SEARCH) {
                $navigation = new Navigation(_('Archiv'), 'dispatch.php/search/archive');
                $this->addSubNavigation('archive', $navigation);
            }

            // browse resources
            if (Config::get()->RESOURCES_ENABLE) {
                $navigation = new Navigation(
                    _('Räume'),
                    'dispatch.php/resources/search/rooms'
                );
                $this->addSubNavigation('rooms', $navigation);
            }
        }
    }
}