1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Xoopspoll\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 GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
19
|
|
|
* @author lucio <[email protected]> |
20
|
|
|
* |
21
|
|
|
* Example: |
22
|
|
|
* $breadcrumb = new Breadcrumb(); |
23
|
|
|
* $breadcrumb->addLink( 'bread 1', 'index1.php' ); |
24
|
|
|
* $breadcrumb->addLink( 'bread 2', '' ); |
25
|
|
|
* $breadcrumb->addLink( 'bread 3', 'index3.php' ); |
26
|
|
|
* echo $breadcrumb->render(); |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class Breadcrumb |
31
|
|
|
*/ |
32
|
|
|
class Breadcrumb |
33
|
|
|
{ |
34
|
|
|
public string $dirname; |
35
|
|
|
public array $bread = []; |
36
|
|
|
|
37
|
|
|
public function __construct() |
38
|
|
|
{ |
39
|
|
|
$this->dirname = \basename(\dirname(__DIR__, 2)); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Add link to breadcrumb |
44
|
|
|
* |
45
|
|
|
* @param string $title |
46
|
|
|
* @param string $link |
47
|
|
|
*/ |
48
|
|
|
public function addLink(string $title = '', string $link = ''): void |
49
|
|
|
{ |
50
|
|
|
$this->bread[] = [ |
51
|
|
|
'link' => $link, |
52
|
|
|
'title' => $title, |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Render BreadCrumb |
58
|
|
|
*/ |
59
|
|
|
public function render(): void |
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
|
|
|
if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) { |
68
|
|
|
require $GLOBALS['xoops']->path('class/theme.php'); |
69
|
|
|
|
70
|
|
|
$GLOBALS['xoTheme'] = new \xos_opal_Theme(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
require $GLOBALS['xoops']->path('class/template.php'); |
74
|
|
|
|
75
|
|
|
$breadcrumbTpl = new \XoopsTpl(); |
76
|
|
|
|
77
|
|
|
$breadcrumbTpl->assign('breadcrumb', $this->bread); |
78
|
|
|
|
79
|
|
|
$html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
80
|
|
|
|
81
|
|
|
unset($breadcrumbTpl); |
82
|
|
|
|
83
|
|
|
return $html; |
84
|
|
|
*/ |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|