1
|
|
|
<?php declare(strict_types=1);
|
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Xoopsfaq;
|
4
|
|
|
|
5
|
|
|
/*
|
6
|
|
|
Xoopsfaq Utility Class Definition
|
7
|
|
|
|
8
|
|
|
You may not change or alter any portion of this comment or credits of
|
9
|
|
|
supporting developers from this source code or any supporting source code
|
10
|
|
|
which is considered copyrighted (c) material of the original comment or credit
|
11
|
|
|
authors.
|
12
|
|
|
|
13
|
|
|
This program is distributed in the hope that it will be useful, but
|
14
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
16
|
|
|
*/
|
17
|
|
|
|
18
|
|
|
/**
|
19
|
|
|
* Module: myQuiz
|
20
|
|
|
*
|
21
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License
|
22
|
|
|
* @copyright https://xoops.org 2001-2017 © XOOPS Project
|
23
|
|
|
* @author ZySpec <[email protected]>
|
24
|
|
|
* @author Mamba <[email protected]>
|
25
|
|
|
* @since :: File available since version 4.10
|
26
|
|
|
*/
|
27
|
|
|
|
28
|
|
|
use Xmf\Module\Admin;
|
29
|
|
|
use XoopsModules\Xoopsfaq\{
|
30
|
|
|
Common
|
31
|
|
|
};
|
32
|
|
|
|
33
|
|
|
/**
|
34
|
|
|
* Class Utility
|
35
|
|
|
*/
|
36
|
|
|
class Utility extends Common\SysUtility
|
37
|
|
|
{
|
38
|
|
|
//--------------- Custom module methods -----------------------------
|
39
|
|
|
/**
|
40
|
|
|
* Render the icon links
|
41
|
|
|
*
|
42
|
|
|
* @param array $icon_array contains operation=>icon_name as key=>value
|
43
|
|
|
* @param mixed $param HTML parameter
|
44
|
|
|
* @param mixed $value HTML parameter value to set
|
45
|
|
|
* @param mixed $extra are any additional HTML attributes desired for the <a> tag
|
46
|
|
|
* @return string
|
47
|
|
|
*/
|
48
|
|
|
public static function renderIconLinks(array $icon_array, $param, $value = null, $extra = null): string
|
49
|
|
|
{
|
50
|
|
|
$moduleDirName = \basename(\dirname(__DIR__));
|
51
|
|
|
\xoops_loadLanguage('admin', $moduleDirName);
|
52
|
|
|
$ret = '';
|
53
|
|
|
if (null !== $value) {
|
54
|
|
|
foreach ($icon_array as $_op => $icon) {
|
55
|
|
|
if (false !== \mb_strpos($icon, '.')) {
|
56
|
|
|
$iconName = \mb_substr($icon, 0, \mb_strlen($icon) - \mb_strrchr($icon, '.'));
|
57
|
|
|
$iconExt = \mb_substr(\mb_strrchr($icon, '.'), 1);
|
58
|
|
|
} else {
|
59
|
|
|
$iconName = $icon;
|
60
|
|
|
$iconExt = 'png';
|
61
|
|
|
}
|
62
|
|
|
$url = (!\is_numeric($_op)) ? $_op . '?' . $param . '=' . $value : \xoops_getenv('SCRIPT_NAME') . '?op=' . $iconName . '&' . $param . '=' . $value;
|
63
|
|
|
if (null !== $extra) {
|
64
|
|
|
$url .= ' ' . $extra;
|
65
|
|
|
}
|
66
|
|
|
$title = \constant(\htmlspecialchars(mb_strtoupper('_XO_LA_' . $iconName), \ENT_QUOTES | \ENT_HTML5));
|
67
|
|
|
$img = '<img src="' . Admin::iconUrl($iconName . '.' . $iconExt, '16') . '"' . ' title ="' . $title . '"' . ' alt = "' . $title . '"' . ' class="bnone middle">';
|
68
|
|
|
$ret .= '<a href="' . $url . '"' . $extra . '>' . $img . '</a>';
|
69
|
|
|
}
|
70
|
|
|
}
|
71
|
|
|
|
72
|
|
|
return $ret;
|
73
|
|
|
}
|
74
|
|
|
}
|
75
|
|
|
|