function smartsection_createMetaTags($title, $categoryPath = '', $description = '', $minChar = 4) { global $xoopsTpl, $xoopsModule, $xoopsModuleConfig; $myts =& MyTextSanitizer::getInstance(); $ret = ''; $title = $myts->displayTarea($title); $title = $myts->undoHtmlSpecialChars($title); if (isset($categoryPath)) { $categoryPath = $myts->displayTarea($categoryPath); $categoryPath = $myts->undoHtmlSpecialChars($categoryPath); } // Creating Meta Keywords if (isset($title) && $title != '') { $keywords = smartsection_findMetaKeywords($title, $minChar); if (isset($xoopsModuleConfig) && isset($xoopsModuleConfig['moduleMetaKeywords']) && $xoopsModuleConfig['moduleMetaKeywords'] != '') { $moduleKeywords = explode(",", $xoopsModuleConfig['moduleMetaKeywords']); foreach ($moduleKeywords as $moduleKeyword) { if (!in_array($moduleKeyword, $keywords)) { $keywords[] = trim($moduleKeyword); } } } $keywordsCount = count($keywords); for ($i = 0; $i < $keywordsCount; $i++) { $ret .= $keywords[$i]; if ($i < $keywordsCount - 1) { $ret .= ', '; } } $xoopsTpl->assign('xoops_meta_keywords', $ret); } // Creating Meta Description if ($description != '') { $xoopsTpl->assign('xoops_meta_description', smartsection_createMetaDescription($description)); } // Creating Page Title $moduleName = ''; $titleTag = array(); if (isset($xoopsModule)) { $moduleName = $myts->displayTarea($xoopsModule->name()); $titleTag['module'] = $moduleName; } if (isset($title) && $title != '' && strtoupper($title) != strtoupper($moduleName)) { $titleTag['title'] = $title; } if (isset($categoryPath) && $categoryPath != '') { $titleTag['category'] = $categoryPath; } $ret = ''; if (isset($titleTag['title']) && $titleTag['title'] != '') { $ret .= smartsection_metagen_html2text($titleTag['title']); } if (isset($titleTag['category']) && $titleTag['category'] != '') { if ($ret != '') { $ret .= ' - '; } $ret .= $titleTag['category']; } if (isset($titleTag['module']) && $titleTag['module'] != '') { if ($ret != '') { $ret .= ' - '; } $ret .= $titleTag['module']; } $xoopsTpl->assign('xoops_pagetitle', $ret); }
// If the selected ITEM was not found, exit if ($itemObj->notLoaded()) { redirect_header("javascript:history.go(-1)", 1, _MD_SS_NOITEMSELECTED); exit; } // Creating the category object that holds the selected ITEM $categoryObj =& $itemObj->category(); // Check user permissions to access that category of the selected ITEM if (!ss_itemAccessGranted($itemObj->getVar('itemid'), $itemObj->getVar('categoryid'))) { redirect_header("javascript:history.go(-1)", 1, _NOPERM); exit; } $xoopsTpl = new XoopsTpl(); global $xoopsConfig, $xoopsDB, $xoopsModule, $myts; $item = $itemObj->toArray(null, $categoryObj, false); $printtitle = $xoopsConfig['sitename'] . " - " . smartsection_metagen_html2text($categoryObj->getCategoryPath()) . " > " . $myts->displayTarea($item['title']); $printheader = $myts->displayTarea(ss_getConfig('headerprint')); $who_where = sprintf(_MD_SS_WHO_WHEN, $itemObj->posterName(), $itemObj->datesub()); $item['categoryname'] = $myts->displayTarea($categoryObj->name()); $xoopsTpl->assign('printtitle', $printtitle); $xoopsTpl->assign('printlogourl', ss_getConfig('printlogourl')); $xoopsTpl->assign('printheader', $printheader); $xoopsTpl->assign('lang_category', _MD_SS_CATEGORY); $xoopsTpl->assign('lang_author_date', $who_where); $xoopsTpl->assign('item', $item); if (ss_getConfig('footerprint') == 'item footer' || ss_getConfig('footerprint') == 'both') { $xoopsTpl->assign('itemfooter', $myts->displayTarea(ss_getConfig('itemfooter'))); } if (ss_getConfig('footerprint') == 'index footer' || ss_getConfig('footerprint') == 'both') { $xoopsTpl->assign('indexfooter', $myts->displayTarea(ss_getConfig('indexfooter'))); }
function findMetaKeywords($text, $minChar) { $keywords = array(); $text = $this->purifyText($text); $text = smartsection_metagen_html2text($text); $originalKeywords = explode(" ", $text); foreach ($originalKeywords as $originalKeyword) { $secondRoundKeywords = explode("'", $originalKeyword); foreach ($secondRoundKeywords as $secondRoundKeyword) { if (strlen($secondRoundKeyword) >= $minChar) { if (!in_array($secondRoundKeyword, $keywords)) { $keywords[] = trim($secondRoundKeyword); } } } } return $keywords; }