Breadcrumb   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

3 Methods

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