47 $title = trim($title);
48 $title = self::asPlainText($title);
50 if (is_object($xoTheme)) {
51 $xoTheme->addMeta(
'meta',
'title', $title);
53 $xoopsTpl->assign(
'xoops_pagetitle', $title);
68 if (!empty($keywords) && is_array($keywords)) {
69 $keyword_tag = implode(
', ', $keywords);
71 if (!empty($keyword_tag)) {
72 if (is_object($xoTheme)) {
73 $xoTheme->addMeta(
'meta',
'keywords', $keyword_tag);
75 $xoopsTpl->assign(
'xoops_meta_keywords', $keyword_tag);
92 $description = trim($description);
93 if (!empty($description)) {
94 if (is_object($xoTheme)) {
95 $xoTheme->addMeta(
'meta',
'description', $description);
97 $xoopsTpl->assign(
'xoops_meta_description', $description);
120 if (!is_array($forceKeys)) {
121 $forceKeys = array();
124 $text = self::asPlainText($body);
127 $originalKeywords = preg_split(
134 foreach ($originalKeywords as $originalKeyword) {
135 if (self::checkStopWords($originalKeyword)) {
136 $secondRoundKeywords = explode(
"'", $originalKeyword);
137 foreach ($secondRoundKeywords as $secondRoundKeyword) {
138 if (self::checkStopWords($secondRoundKeyword)
139 && strlen($secondRoundKeyword) >= $minLength
141 $keycnt[$secondRoundKeyword] =
142 empty($keycnt[$secondRoundKeyword]) ? 1 : $keycnt[$secondRoundKeyword] + 1;
148 while (!empty($forceKeys)) {
149 $tempkey = strtolower(array_pop($forceKeys));
150 $keycnt[$tempkey] = 999999;
153 arsort($keycnt, SORT_NUMERIC);
154 $key = array_keys($keycnt);
155 $keywords = array_slice($key, 0,
$count);
170 static $stopwords = null;
173 if (!defined(
'_XMF_STOPWORDS')) {
176 if (defined(
'_XMF_STOPWORDS')) {
178 $stopwords = array_fill_keys($sw,
true);
180 $stopwords = array(
'_'=>
true);
184 return !isset($stopwords[mb_strtolower($key)]);
199 $text = self::asPlainText($body);
201 $words = explode(
" ",
$text);
206 while (
$i < $wordCount - 1 &&
$i < count($words)) {
207 $newWords[] = $words[
$i];
210 $ret = implode(
' ', $newWords);
211 $len = mb_strlen($ret);
212 $lastperiod = mb_strrpos($ret,
'.');
213 $ret .= ($lastperiod ===
false) ? self::ELLIPSIS :
'';
214 if ($len>100 && ($len-$lastperiod)<30) {
215 $ret = mb_substr($ret, 0, $lastperiod+1);
241 $title_keywords = self::generateKeywords($title,
$count, 3, $forceKeys);
242 $keywords = self::generateKeywords($body,
$count, $minLength, $title_keywords);
243 $description = self::generateDescription($body, $wordCount);
244 self::assignTitle($title);
245 self::assignKeywords($keywords);
246 self::assignDescription($description);
260 return (strlen(
$var) > 0);
275 $title = preg_replace(
"/[^a-zA-Z0-9]/",
"-", $title);
276 $title = \Normalizer::normalize($title, \Normalizer::FORM_C);
278 $tableau = explode(
"-", $title);
279 $tableau = array_filter($tableau,
'self::nonEmptyString');
280 $tableau = array_filter($tableau,
'self::checkStopWords');
281 $title = implode(
"-", $tableau);
283 $title = (empty($title)) ?
'' : $title . $extension;
306 $haystack = self::asPlainText($haystack);
307 $pos = self::getNeedlePositions($haystack, $needles);
309 $start = empty($pos) ? 0 : min($pos);
316 $temp = mb_strpos($haystack,
' ',
$start, $encoding);
318 $haystack = mb_substr($haystack,
$start, null, $encoding);
321 $post = !(mb_strlen($haystack, $encoding) < $length);
323 $haystack = mb_substr($haystack, 0, $length, $encoding);
324 $end = mb_strrpos($haystack,
' ', 0, $encoding);
326 $haystack = mb_substr($haystack, 0, $end, $encoding);
330 $haystack = ($pre ? self::ELLIPSIS :
'') . trim($haystack) . ($post ? self::ELLIPSIS :
'');
348 $text = str_replace(array(
"\n",
"\r"),
' ',
$text);
349 $text = preg_replace(
'/[ ]* [ ]*/',
' ',
$text);
368 $needles = empty($needles) ? array() : (array) $needles;
369 foreach ($needles as $needle) {
370 $i = mb_stripos($haystack, $needle, 0,
'UTF-8');
static load($name, $domain= '', $language=null)