1
|
|
|
<?php namespace XoopsModules\Mymenus\Plugins\Constant; |
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
|
|
|
// $string = ''; |
71
|
|
|
|
72
|
|
|
if (!preg_match('/{(.*\|.*)}/i', $string, $reg)) { |
73
|
|
|
return $string; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$expression = $reg[0]; |
77
|
|
|
list($validator, $value) = array_map('strtoupper', explode('|', $reg[1])); |
78
|
|
|
|
79
|
|
|
if ('CONSTANT' === $validator) { |
80
|
|
|
if (defined($value)) { |
81
|
|
|
$string = str_replace($expression, constant($value), $string); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
return isset($string) ? $string : null; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
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.