Breadcrumb::addLink()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php namespace Xoopsmodules\randomquote\common;
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
*/
12
/**
13
 * Module: randomquote
14
 *
15
 * @category        Module
16
 * @package         randomquote
17
 * @author          XOOPS Development Team <[email protected]> - <https://xoops.org>
18
 * @copyright       {@link https://xoops.org/ XOOPS Project}
19
 * @license         GPL 2.0 or later
20
 * @link            https://xoops.org/
21
 * @since           1.0.0
22
 */
23
/*
24
 * Example:
25
 * $breadcrumb = new PedigreeBreadcrumb();
26
 * $breadcrumb->addLink( 'bread 1', 'index1.php' );
27
 * $breadcrumb->addLink( 'bread 2', '' );
28
 * $breadcrumb->addLink( 'bread 3', 'index3.php' );
29
 * echo $breadcrumb->render();
30
 */
31
32
defined('XOOPS_ROOT_PATH') || exit('XOOPS Root Path not defined');
33
34
/**
35
 * Class Breadcrumb
36
 */
37
class Breadcrumb
38
{
39
    public  $dirname;
40
    private $bread = [];
41
42
    /**
43
     *
44
     */
45
    public function __construct()
46
    {
47
        $this->dirname = basename(dirname(__DIR__));
48
    }
49
50
    /**
51
     * Add link to breadcrumb
52
     *
53
     * @param string $title
54
     * @param string $link
55
     */
56
    public function addLink($title = '', $link = '')
57
    {
58
        $this->bread[] = [
59
            'link'  => $link,
60
            'title' => $title
61
        ];
62
    }
63
64
    /**
65
     * Render Pedigree BreadCrumb
66
     *
67
     */
68
    public function render()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
69
    {
70
        if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) {
71
            require_once $GLOBALS['xoops']->path('class/theme.php');
72
            $GLOBALS['xoTheme'] = new \xos_opal_Theme();
73
        }
74
75
        require_once $GLOBALS['xoops']->path('class/template.php');
76
        $breadcrumbTpl = new \XoopsTpl();
77
        $breadcrumbTpl->assign('breadcrumb', $this->bread);
78
        $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl');
79
        unset($breadcrumbTpl);
80
81
        return $html;
82
    }
83
}
84