Breadcrumb::addLink()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Cssholmes\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     cssholmes
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
    public  $dirname;
35
    private $bread = [];
36
37
    public function __construct()
38
    {
39
        $this->dirname = \basename(\dirname(\dirname(__DIR__)));
40
    }
41
42
    /**
43
     * Add link to breadcrumb
44
     *
45
     * @param string $title
46
     * @param string $link
47
     */
48
    public function addLink($title = '', $link = '')
49
    {
50
        $this->bread[] = [
51
            'link'  => $link,
52
            'title' => $title,
53
        ];
54
    }
55
56
    /**
57
     * Render BreadCrumb
58
     */
59
    public function render()
60
    {
61
        /*
62
        TODO if you want to use the render code below,
63
        1) create ./templates/chess_common_breadcrumb.tpl)
64
        2) add declaration to  xoops_version.php
65
        */
66
67
        /*
68
        if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) {
69
            require $GLOBALS['xoops']->path('class/theme.php');
70
71
            $GLOBALS['xoTheme'] = new \xos_opal_Theme();
72
        }
73
74
        require $GLOBALS['xoops']->path('class/template.php');
75
76
        $breadcrumbTpl = new \XoopsTpl();
77
78
        $breadcrumbTpl->assign('breadcrumb', $this->bread);
79
80
        $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl');
81
82
        unset($breadcrumbTpl);
83
84
        return $html;
85
        */
86
    }
87
}
88