|
1
|
|
|
<?php namespace XoopsModules\Mymenus\Plugins\Smarty; |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
You may not change or alter any portion of this comment or credits |
|
5
|
|
|
of supporting developers from this source code or any supporting source code |
|
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
|
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
15
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
|
16
|
|
|
* @package Mymenus |
|
17
|
|
|
* @since 1.0 |
|
18
|
|
|
* @author trabis <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
use XoopsModules\Mymenus; |
|
22
|
|
|
|
|
23
|
|
|
defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class PluginItem |
|
27
|
|
|
*/ |
|
28
|
|
|
class PluginItem extends Mymenus\PluginItem |
|
29
|
|
|
{ |
|
30
|
|
|
public static function eventLinkDecoration() |
|
31
|
|
|
{ |
|
32
|
|
|
$registry = Mymenus\Registry::getInstance(); |
|
33
|
|
|
$linkArray = $registry->getEntry('link_array'); |
|
|
|
|
|
|
34
|
|
|
$linkArray['link'] = self::doDecoration($linkArray['link']); |
|
35
|
|
|
$registry->setEntry('link_array', $linkArray); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public static function eventImageDecoration() |
|
39
|
|
|
{ |
|
40
|
|
|
$registry = Mymenus\Registry::getInstance(); |
|
41
|
|
|
$linkArray = $registry->getEntry('link_array'); |
|
|
|
|
|
|
42
|
|
|
$linkArray['image'] = self::doDecoration($linkArray['image']); |
|
43
|
|
|
$registry->setEntry('link_array', $linkArray); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public static function eventTitleDecoration() |
|
47
|
|
|
{ |
|
48
|
|
|
$registry = Mymenus\Registry::getInstance(); |
|
49
|
|
|
$linkArray = $registry->getEntry('link_array'); |
|
|
|
|
|
|
50
|
|
|
$linkArray['title'] = self::doDecoration($linkArray['title']); |
|
51
|
|
|
$registry->setEntry('link_array', $linkArray); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public static function eventAltTitleDecoration() |
|
55
|
|
|
{ |
|
56
|
|
|
$registry = Mymenus\Registry::getInstance(); |
|
57
|
|
|
$linkArray = $registry->getEntry('link_array'); |
|
|
|
|
|
|
58
|
|
|
$linkArray['alt_title'] = self::doDecoration($linkArray['alt_title']); |
|
59
|
|
|
$registry->setEntry('link_array', $linkArray); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param $string |
|
64
|
|
|
* |
|
65
|
|
|
* @return mixed |
|
66
|
|
|
*/ |
|
67
|
|
|
protected static function doDecoration($string) |
|
68
|
|
|
{ |
|
69
|
|
|
$registry = Mymenus\Registry::getInstance(); |
|
|
|
|
|
|
70
|
|
|
if (!preg_match('/{(.*\|.*)}/i', $string, $reg)) { |
|
71
|
|
|
return $string; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
$expression = $reg[0]; |
|
75
|
|
|
list($validator, $value) = array_map('mb_strtolower', explode('|', $reg[1])); |
|
76
|
|
|
|
|
77
|
|
|
if ('smarty' === $validator) { |
|
78
|
|
|
if (isset($GLOBALS['xoopsTpl']->_tpl_vars[$value])) { |
|
79
|
|
|
$string = str_replace($expression, $GLOBALS['xoopsTpl']->_tpl_vars[$value], $string); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return $string; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.