Breadcrumb   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 34
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A addLink() 0 5 1
A render() 0 2 1
1
<?php
2
3
namespace XoopsModules\Newbb\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
 * Breadcrumb Class
16
 *
17
 * @copyright   XOOPS Project (https://xoops.org)
18
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
19
 * @author      lucio <[email protected]>
20
 * @package     newbb
21
 *
22
 * Example:
23
 * $breadcrumb = new PedigreeBreadcrumb();
24
 * $breadcrumb->addLink( 'bread 1', 'index1.php' );
25
 * $breadcrumb->addLink( 'bread 2', '' );
26
 * $breadcrumb->addLink( 'bread 3', 'index3.php' );
27
 * echo $breadcrumb->render();
28
 */
29
/**
30
 * Class Breadcrumb
31
 */
32
class Breadcrumb
33
{
34
    /** @var string */
35
    private $dirname;
36
37
    /** @var array */
38
    private $bread = [];
39
40
    public function __construct()
41
    {
42
        $this->dirname = \basename(\dirname(\dirname(__DIR__)));
43
    }
44
45
    /**
46
     * Add link to breadcrumb
47
     *
48
     * @param string $title
49
     * @param string $link
50
     */
51
    public function addLink($title = '', $link = '')
52
    {
53
        $this->bread[] = [
54
            'link'  => $link,
55
            'title' => $title,
56
        ];
57
    }
58
59
    /**
60
     * Render BreadCrumb
61
     *
62
     * @return string
63
     */
64
    public function render()
65
    {
66
        /*
67
        TODO if you want to use the render code below,
68
        1) create ./templates/chess_common_breadcrumb.tpl)
69
        2) add declaration to  xoops_version.php
70
        */
71
72
        /*
73
        if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) {
74
            require $GLOBALS['xoops']->path('class/theme.php');
75
76
            $GLOBALS['xoTheme'] = new \xos_opal_Theme();
77
        }
78
79
        require $GLOBALS['xoops']->path('class/template.php');
80
81
        $breadcrumbTpl = new \XoopsTpl();
82
83
        $breadcrumbTpl->assign('breadcrumb', $this->bread);
84
85
        $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl');
86
87
        unset($breadcrumbTpl);
88
89
        return $html;
90
        */
91
    }
92
}
93