1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Xoopsfaq\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 xoopsfaq |
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
|
|
|
defined('XOOPS_ROOT_PATH') || die('XOOPS Root Path not defined'); |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Class Breadcrumb |
33
|
|
|
*/ |
34
|
|
|
class Breadcrumb |
35
|
|
|
{ |
36
|
|
|
public $dirname; |
37
|
|
|
private $bread = []; |
38
|
|
|
|
39
|
|
|
public function __construct() |
40
|
|
|
{ |
41
|
|
|
$this->dirname = basename(dirname(dirname(__DIR__))); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Add link to breadcrumb |
46
|
|
|
* |
47
|
|
|
* @param string $title |
48
|
|
|
* @param string $link |
49
|
|
|
*/ |
50
|
|
|
public function addLink($title = '', $link = '') |
51
|
|
|
{ |
52
|
|
|
$this->bread[] = [ |
53
|
|
|
'link' => $link, |
54
|
|
|
'title' => $title, |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Render Pedigree BreadCrumb |
60
|
|
|
*/ |
61
|
|
|
public function render() |
62
|
|
|
{ |
63
|
|
|
if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
64
|
|
|
require_once $GLOBALS['xoops']->path('class/theme.php'); |
65
|
|
|
$GLOBALS['xoTheme'] = new \xos_opal_Theme(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
require_once $GLOBALS['xoops']->path('class/template.php'); |
69
|
|
|
$breadcrumbTpl = new \XoopsTpl(); |
70
|
|
|
$breadcrumbTpl->assign('breadcrumb', $this->bread); |
71
|
|
|
$html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
72
|
|
|
unset($breadcrumbTpl); |
73
|
|
|
|
74
|
|
|
return $html; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|