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\Wfdownloads\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
 * Breadcrumb Class
17
 *
18
 * @copyright   XOOPS Project (https://xoops.org)
19
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
20
 * @author      lucio <[email protected]>
21
 * @package     Wfdownloads
22
 *
23
 * Example:
24
 * $breadcrumb = new Common\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
use XoopsModules\Wfdownloads\{
32
    Common,
33
    Helper,
34
    Utility
35
};
36
/** @var Helper $helper */
37
/** @var Utility $utility */
38
39
require_once dirname(__DIR__, 2) . '/include/common.php';
40
41
/**
42
 * Class Breadcrumb
43
 */
44
class Breadcrumb
45
{
46
    public $helper;
47
    private $dirname;
48
    private $bread = [];
49
50
    public function __construct()
51
    {
52
        $this->helper  = Helper::getInstance();
53
        $this->dirname = \basename(dirname(__DIR__, 2));
54
    }
55
56
    /**
57
     * Add link to breadcrumb
58
     *
59
     * @param string $title
60
     * @param string $link
61
     */
62
    public function addLink($title = '', $link = '')
63
    {
64
        $this->bread[] = [
65
            'link'  => $link,
66
            'title' => $title,
67
        ];
68
    }
69
70
    /**
71
     * Render BreadCrumb
72
     */
73
    public function render()
74
    {
75
        $ret = '';
76
77
        if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) {
78
            require_once $GLOBALS['xoops']->path('/class/theme.php');
79
            $GLOBALS['xoTheme'] = new \xos_opal_Theme();
80
        }
81
        require_once $GLOBALS['xoops']->path('/class/template.php');
82
        $breadcrumbTpl = new \XoopsTpl();
83
        $breadcrumbTpl->assign('breadcrumb', $this->bread);
84
        // IN PROGRESS
85
        // IN PROGRESS
86
        // IN PROGRESS
87
        $ret .= $breadcrumbTpl->fetch("db:{$this->helper->getDirname()}_co_breadcrumb.tpl");
88
        unset($breadcrumbTpl);
89
90
        return $ret;
91
    }
92
}
93