示例#1
0
global $sh_LANG;
$mainframe = JFactory::getApplication();
$shPageInfo =& Sh404sefFactory::getPageInfo();
// get page details gathered by system plugin
$sefConfig =& Sh404sefFactory::getConfig();
$database = ShlDbHelper::getDb();
$view = JREQUEST::getCmd('view', null);
$catid = JREQUEST::getInt('catid', null);
$id = JREQUEST::getInt('id', null);
$limit = JREQUEST::getInt('limit', null);
$limitstart = JREQUEST::getInt('limitstart', null);
$layout = JREQUEST::getCmd('layout', null);
$showall = JREQUEST::getInt('showall', null);
$format = JREQUEST::getCmd('format', null);
$print = JREQUEST::getInt('print', null);
$tmpl = JREQUEST::getCmd('tmpl', null);
$lang = JREQUEST::getString('lang', null);
$shLangName = empty($lang) ? $shPageInfo->currentLanguageTag : shGetNameFromIsoCode($lang);
$shLangIso = isset($lang) ? $lang : shGetIsoCodeFromName($shPageInfo->currentLanguageTag);
$shLangIso = shLoadPluginLanguage('com_content', $shLangIso, 'COM_SH404SEF_CREATE_NEW');
//-------------------------------------------------------------
global $shCustomTitleTag, $shCustomDescriptionTag, $shCustomKeywordsTag, $shCustomLangTag, $shCustomRobotsTag, $shCanonicalTag;
// special case for 404
if (!empty($shPageInfo->httpStatus) && $shPageInfo->httpStatus == 404) {
    $shCustomTitleTag = '404';
    $shCustomRobotsTag = 'noindex, follow';
    return;
}
// add no follow to print pages
$shCustomRobotsTag = $tmpl == 'component' && !empty($print) ? 'noindex, nofollow' : $shCustomRobotsTag;
// calculate page title
示例#2
0
 static function addTitleAndMetaTags()
 {
     global $database, $doc, $mainframe, $Itemid;
     $view = JREQUEST::getCmd('view', null);
     $catid = JREQUEST::getInt('catid', null);
     $id = JREQUEST::getInt('id', null);
     $lang = JREQUEST::getString('lang', null);
     $title = array();
     $sitename = htmlspecialchars($mainframe->getCfg('sitename'));
     if (isset($view)) {
         $view = str_replace("_", " ", $view);
         $view = ucfirst($view);
         $title[] = $view;
     }
     $s = blLittleThings::getWhereUsergroupsCondition();
     if (!isset($catid)) {
         // Parameters
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $menu = new JTableMenu($database);
             $menu->load($Itemid);
             $params = new JRegistry();
             $params->loadString($menu->params);
         } else {
             $menu = new mosMenu($database);
             $menu->load($Itemid);
             $params = new mosParameters($menu->params);
         }
         if (version_compare(JVERSION, "1.6.0", "lt")) {
             $catid = $params->get('catid');
         } else {
             if (version_compare(JVERSION, "1.6.0", "ge") && version_compare(JVERSION, "3.5.100", "lt")) {
                 $single_category_id = '';
                 // for 1.6
                 $single_category_id = $params->get('single_category');
                 if ($single_category_id > 0) {
                     $catid = $single_category_id;
                 }
             }
         }
     }
     //To get name of category
     if (isset($catid)) {
         $query = "SELECT  c.name, c.id AS catid, c.parent_id\n                    FROM #__booklibrary_main_categories AS c\n                    WHERE ({$s}) AND c.id = " . intval($catid);
         $database->setQuery($query);
         $row = null;
         $row = $database->loadObject();
         if (isset($row)) {
             $cattitle = array();
             $cattitle[] = $row->name;
             while (isset($row) && $row->parent_id > 0) {
                 $query = "SELECT  name, c.id AS catid, parent_id \n                        FROM #__booklibrary_main_categories AS c\n                        WHERE ({$s}) AND c.id = " . intval($row->parent_id);
                 $database->setQuery($query);
                 $row = $database->loadObject();
                 if (isset($row) && $row->name != '') {
                     $cattitle[] = $row->name;
                 }
             }
             $title = array_merge($title, array_reverse($cattitle));
         }
     }
     //To get Name of the book
     if (isset($id)) {
         $row = $database->loadObject();
         if (isset($row)) {
             $idtitle = array();
             $title = array_merge($title, $idtitle);
         }
     }
     $tagtitle = "";
     for ($i = 0; $i < count($title); $i++) {
         $tagtitle = trim($tagtitle) . " | " . trim($title[$i]);
     }
     $blm = "BookLibrary Manager ";
     //To set Title
     $title_tag = PHP_booklibrary::mylenStr($blm . $tagtitle, 75);
     //To set meta Description
     $metadata_description_tag = PHP_booklibrary::mylenStr($blm . $tagtitle, 200);
     //To set meta KeywordsTag
     $metadata_keywords_tag = PHP_booklibrary::mylenStr($blm . $tagtitle, 250);
     $doc->setTitle($title_tag);
     $doc->setMetaData('description', $metadata_description_tag);
     $doc->setMetaData('keywords', $metadata_keywords_tag);
 }