|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Xooghost; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Created by PhpStorm. |
|
7
|
|
|
* User: mamba |
|
8
|
|
|
* Date: 2015-10-11 |
|
9
|
|
|
* Time: 00:08 |
|
10
|
|
|
*/ |
|
11
|
|
|
class Utility |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @param $string |
|
15
|
|
|
* |
|
16
|
|
|
* @return mixed|string |
|
17
|
|
|
*/ |
|
18
|
|
|
public function getMetaDescription($string) |
|
19
|
|
|
{ |
|
20
|
|
|
$xoops = \Xoops::getInstance(); |
|
21
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
22
|
|
|
|
|
23
|
|
|
if (is_array($string)) { |
|
24
|
|
|
$string = implode(', ', $string); |
|
25
|
|
|
} |
|
26
|
|
|
$string = $xoops->module->name() . ' : ' . $string; |
|
|
|
|
|
|
27
|
|
|
$string .= '. ' . $xoops->getConfig('meta_description', 3); |
|
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
$string = $myts->undoHtmlSpecialChars($string); |
|
30
|
|
|
$string = str_replace('[breakpage]', '', $string); |
|
31
|
|
|
// remove html tags |
|
32
|
|
|
$string = strip_tags($string); |
|
33
|
|
|
|
|
34
|
|
|
return $string; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param $string |
|
39
|
|
|
* @param int $limit |
|
40
|
|
|
* |
|
41
|
|
|
* @return string |
|
42
|
|
|
*/ |
|
43
|
|
|
public function getMetaKeywords($string, $limit = 5) |
|
44
|
|
|
{ |
|
45
|
|
|
$xoops = \Xoops::getInstance(); |
|
46
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
47
|
|
|
$keywords = []; |
|
48
|
|
|
if (is_array($string)) { |
|
49
|
|
|
$string = implode(', ', $string); |
|
50
|
|
|
} |
|
51
|
|
|
$string = mb_strtolower($string) . ', ' . mb_strtolower($xoops->getConfig('meta_keywords', 3)); |
|
|
|
|
|
|
52
|
|
|
$string = $myts->undoHtmlSpecialChars($string); |
|
53
|
|
|
$string = str_replace('[breakpage]', '', $string); |
|
54
|
|
|
$string = strip_tags($string); |
|
55
|
|
|
$string = html_entity_decode($string, ENT_QUOTES); |
|
56
|
|
|
|
|
57
|
|
|
$search_pattern = ["\t", "\r\n", "\r", "\n", ',', '.', "'", ';', ':', ')', '(', '"', '?', '!', '{', '}', '[', ']', '<', '>', '/', '+', '_', '\\', '*', 'pagebreak', 'page']; |
|
58
|
|
|
$replace_pattern = [' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']; |
|
59
|
|
|
$string = str_replace($search_pattern, $replace_pattern, $string); |
|
60
|
|
|
|
|
61
|
|
|
$tmpkeywords = explode(' ', $string); |
|
62
|
|
|
|
|
63
|
|
|
$tmpkeywords = array_unique($tmpkeywords); |
|
64
|
|
|
foreach ($tmpkeywords as $keyword) { |
|
65
|
|
|
if (mb_strlen(trim($keyword)) >= $limit && !is_numeric($keyword)) { |
|
66
|
|
|
$keywords[] = htmlentities(trim($keyword)); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
return implode(', ', $keywords); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.