Issues (3083)

htdocs/modules/system/class/breadcrumb.php (1 issue)

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * BreadCrumb Class
14
 *
15
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
16
 * @license             GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
17
 * @author              Andricq Nicolas (AKA MusS)
18
 * @package             system
19
 */
20
class SystemBreadcrumb
21
{
22
    /* Variables */
23
    public $_directory;
24
    public $_bread = array();
25
    public $_help;
26
    public $_tips;
27
28
    /**
29
     * @param $directory
30
     */
31
    public function __construct($directory)
32
    {
33
        $this->_directory = $directory;
34
    }
35
36
    /**
37
     * Add link to breadcrumb
38
     * @param string $title
39
     * @param string $link
40
     * @param bool   $home
41
     */
42
    public function addLink($title = '', $link = '', $home = false)
43
    {
44
        $this->_bread[] = array(
45
            'link'  => $link,
46
            'title' => $title,
47
            'home'  => $home);
48
    }
49
50
    /**
51
     * Add Help link
52
     * @param string $link
53
     */
54
    public function addHelp($link = '')
55
    {
56
        $this->_help = $link;
57
    }
58
59
    /**
60
     * Add Tips
61
     * @param $value
62
     */
63
    public function addTips($value)
64
    {
65
        $this->_tips = $value;
66
    }
67
68
    /**
69
     * Render System BreadCrumb
70
     *
71
     */
72
    public function render()
73
    {
74
        if (isset($GLOBALS['xoopsTpl'])) {
75
            $GLOBALS['xoopsTpl']->assign('xo_sys_breadcrumb', $this->_bread);
76
            $GLOBALS['xoopsTpl']->assign('xo_sys_help', $this->_help);
77
            if ($this->_tips) {
78
                if (xoops_getModuleOption('usetips', 'system')) {
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

78
                if (/** @scrutinizer ignore-deprecated */ xoops_getModuleOption('usetips', 'system')) {
Loading history...
79
                    $GLOBALS['xoopsTpl']->assign('xo_sys_tips', $this->_tips);
80
                }
81
            }
82
            // Call template
83
            if (file_exists(XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/help/' . $this->_directory . '.html')) {
84
                $GLOBALS['xoopsTpl']->assign('help_content', XOOPS_ROOT_PATH . '/modules/system/language/' . $GLOBALS['xoopsConfig']['language'] . '/help/' . $this->_directory . '.html');
85
            } else {
86
                if (file_exists(XOOPS_ROOT_PATH . '/modules/system/language/english/help/' . $this->_directory . '.html')) {
87
                    $GLOBALS['xoopsTpl']->assign('help_content', XOOPS_ROOT_PATH . '/modules/system/language/english/help/' . $this->_directory . '.html');
88
                } else {
89
                    $GLOBALS['xoopsTpl']->assign('load_error', 1);
90
                }
91
            }
92
        } else {
93
            $out = $menu = '<style type="text/css" media="screen">@import ' . XOOPS_URL . '/modules/system/css/menu.css;</style>';
94
            $out .= '<ul id="xo-breadcrumb">';
95
            foreach ($this->_bread as $menu) {
96
                if ($menu['home']) {
97
                    $out .= '<li><a href="' . $menu['link'] . '" title="' . $menu['title'] . '"><img src="images/home.png" alt="' . $menu['title'] . '" class="home" /></a></li>';
98
                } else {
99
                    if ($menu['link'] != '') {
100
                        $out .= '<li><a href="' . $menu['link'] . '" title="' . $menu['title'] . '">' . $menu['title'] . '</a></li>';
101
                    } else {
102
                        $out .= '<li>' . $menu['title'] . '</li>';
103
                    }
104
                }
105
            }
106
            $out .= '</ul>';
107
            if ($this->_tips) {
108
                $out .= '<div class="tips">' . $this->_tips . '</div>';
109
            }
110
            echo $out;
111
        }
112
    }
113
}
114