1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
/** |
12
|
|
|
* presenter module for xoops |
13
|
|
|
* |
14
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
15
|
|
|
* @license GPL 2.0 or later |
16
|
|
|
* @package presenter |
17
|
|
|
* @since 2.5.5 |
18
|
|
|
* @author XOOPS Development Team <[email protected]> - <https://xoops.org> |
19
|
|
|
*/ |
20
|
|
|
/***************Blocks************** |
21
|
|
|
* @param $cats |
22
|
|
|
* @return string |
23
|
|
|
*/ |
24
|
|
|
function presenter_block_addCatSelect($cats) |
25
|
|
|
{ |
26
|
|
|
if (is_array($cats)) { |
27
|
|
|
$cat_sql = '(' . current($cats); |
28
|
|
|
array_shift($cats); |
29
|
|
|
foreach ($cats as $cat) { |
30
|
|
|
$cat_sql .= ',' . $cat; |
31
|
|
|
} |
32
|
|
|
$cat_sql .= ')'; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
return $cat_sql; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param $global |
40
|
|
|
* @param $key |
41
|
|
|
* @param string $default |
42
|
|
|
* @param string $type |
43
|
|
|
* @return mixed|string |
44
|
|
|
*/ |
45
|
|
|
function presenter_CleanVars(&$global, $key, $default = '', $type = 'int') |
46
|
|
|
{ |
47
|
|
|
switch ($type) { |
48
|
|
|
case 'string': |
49
|
|
|
$ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default; |
50
|
|
|
break; |
51
|
|
|
case 'int': |
52
|
|
|
default: |
53
|
|
|
$ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default; |
54
|
|
|
break; |
55
|
|
|
} |
56
|
|
|
if (false === $ret) { |
57
|
|
|
return $default; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return $ret; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param $content |
65
|
|
|
*/ |
66
|
|
View Code Duplication |
function presenter_meta_keywords($content) |
|
|
|
|
67
|
|
|
{ |
68
|
|
|
global $xoopsTpl, $xoTheme; |
69
|
|
|
$myts = MyTextSanitizer::getInstance(); |
70
|
|
|
$content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
71
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
72
|
|
|
$xoTheme->addMeta('meta', 'keywords', strip_tags($content)); |
73
|
|
|
} else { // Compatibility for old Xoops versions |
74
|
|
|
$xoopsTpl->assign('xoops_meta_keywords', strip_tags($content)); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param $content |
80
|
|
|
*/ |
81
|
|
View Code Duplication |
function presenter_meta_description($content) |
|
|
|
|
82
|
|
|
{ |
83
|
|
|
global $xoopsTpl, $xoTheme; |
84
|
|
|
$myts = MyTextSanitizer::getInstance(); |
85
|
|
|
$content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
86
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
87
|
|
|
$xoTheme->addMeta('meta', 'description', strip_tags($content)); |
88
|
|
|
} else { // Compatibility for old Xoops versions |
89
|
|
|
$xoopsTpl->assign('xoops_meta_description', strip_tags($content)); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.