|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Module: RandomQuote |
|
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
|
|
|
* PHP version 5 |
|
11
|
|
|
* |
|
12
|
|
|
* @category Module |
|
13
|
|
|
* @package Randomquote |
|
14
|
|
|
* @author XOOPS Development Team, Mamba |
|
15
|
|
|
* @copyright 2001-2016 XOOPS Project (http://xoops.org) |
|
16
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
|
17
|
|
|
* @link http://xoops.org/ |
|
18
|
|
|
* @since 2.0.0 |
|
19
|
|
|
*/ |
|
20
|
|
|
class RandomQuoteUtilities |
|
|
|
|
|
|
21
|
|
|
{ |
|
22
|
|
|
|
|
23
|
|
|
/***************Blocks************** |
|
24
|
|
|
* @param $cats |
|
25
|
|
|
* @return string |
|
26
|
|
|
*/ |
|
27
|
|
|
public static function randomquote_block_addCatSelect($cats) |
|
28
|
|
|
{ |
|
29
|
|
|
$cat_sql = ''; |
|
30
|
|
|
if (is_array($cats)) { |
|
31
|
|
|
$cat_sql = '(' . current($cats); |
|
32
|
|
|
array_shift($cats); |
|
33
|
|
|
foreach ($cats as $cat) { |
|
34
|
|
|
$cat_sql .= ',' . $cat; |
|
35
|
|
|
} |
|
36
|
|
|
$cat_sql .= ')'; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
return $cat_sql; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param $global |
|
44
|
|
|
* @param $key |
|
45
|
|
|
* @param string $default |
|
46
|
|
|
* @param string $type |
|
47
|
|
|
* @return mixed|string |
|
48
|
|
|
*/ |
|
49
|
|
|
public static function cleanVarsRandomquote(&$global, $key, $default = '', $type = 'int') |
|
50
|
|
|
{ |
|
51
|
|
|
switch ($type) { |
|
52
|
|
|
case 'string': |
|
53
|
|
|
$ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default; |
|
54
|
|
|
break; |
|
55
|
|
|
case 'int': |
|
56
|
|
|
default: |
|
57
|
|
|
$ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default; |
|
58
|
|
|
break; |
|
59
|
|
|
} |
|
60
|
|
|
if ($ret === false) { |
|
61
|
|
|
return $default; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return $ret; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param $content |
|
69
|
|
|
*/ |
|
70
|
|
View Code Duplication |
public static function setMetaKeywordsRandomquote($content) |
|
|
|
|
|
|
71
|
|
|
{ |
|
72
|
|
|
global $xoopsTpl, $xoTheme; |
|
|
|
|
|
|
73
|
|
|
$myts = MyTextSanitizer::getInstance(); |
|
74
|
|
|
$content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
|
75
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
|
76
|
|
|
$xoTheme->addMeta('meta', 'keywords', strip_tags($content)); |
|
77
|
|
|
} else { // Compatibility for old Xoops versions |
|
78
|
|
|
$xoopsTpl->assign('xoops_meta_keywords', strip_tags($content)); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param $content |
|
84
|
|
|
*/ |
|
85
|
|
View Code Duplication |
public static function setMetaDescriptionRandomquote($content) |
|
|
|
|
|
|
86
|
|
|
{ |
|
87
|
|
|
global $xoopsTpl, $xoTheme; |
|
|
|
|
|
|
88
|
|
|
$myts = MyTextSanitizer::getInstance(); |
|
89
|
|
|
$content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
|
90
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
|
91
|
|
|
$xoTheme->addMeta('meta', 'description', strip_tags($content)); |
|
92
|
|
|
} else { // Compatibility for old Xoops versions |
|
93
|
|
|
$xoopsTpl->assign('xoops_meta_description', strip_tags($content)); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.