Breadcrumb::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Xlanguage\Common;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
16
17
/**
18
 * Breadcrumb Class
19
 *
20
 * @copyright   XOOPS Project (https://xoops.org)
21
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
22
 * @author      lucio <[email protected]>
23
 * @package     xlanguage
24
 *
25
 * Example:
26
 * $breadcrumb = new PedigreeBreadcrumb();
27
 * $breadcrumb->addLink( 'bread 1', 'index1.php' );
28
 * $breadcrumb->addLink( 'bread 2', '' );
29
 * $breadcrumb->addLink( 'bread 3', 'index3.php' );
30
 * echo $breadcrumb->render();
31
 */
32
33
/**
34
 * Class Breadcrumb
35
 */
36
class Breadcrumb
37
{
38
    public  $dirname;
39
    private $bread = [];
40
41
    public function __construct()
42
    {
43
        $this->dirname = \basename(\dirname(__DIR__, 2));
44
    }
45
46
    /**
47
     * Add link to breadcrumb
48
     *
49
     * @param string $title
50
     * @param string $link
51
     */
52
    public function addLink($title = '', $link = '')
53
    {
54
        $this->bread[] = [
55
            'link'  => $link,
56
            'title' => $title,
57
        ];
58
    }
59
60
    /**
61
     * Render BreadCrumb
62
     */
63
    public function render()
64
    {
65
        /*
66
        TODO if you want to use the render code below,
67
        1) create ./templates/chess_common_breadcrumb.tpl)
68
        2) add declaration to  xoops_version.php
69
        */
70
        /*
71
        if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) {
72
            require $GLOBALS['xoops']->path('class/theme.php');
73
74
            $GLOBALS['xoTheme'] = new \xos_opal_Theme();
75
        }
76
77
        require $GLOBALS['xoops']->path('class/template.php');
78
79
        $breadcrumbTpl = new \XoopsTpl();
80
81
        $breadcrumbTpl->assign('breadcrumb', $this->bread);
82
83
        $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl');
84
85
        unset($breadcrumbTpl);
86
87
        return $html;
88
        */
89
    }
90
}
91