static function getCurrentTitleMetaDescription() { global $wgTitle; static $titleTest = null; $return = ''; if ($wgTitle->getNamespace() == NS_MAIN && $wgTitle->getFullText() == wfMsg('mainpage')) { $return = wfMsg('mainpage_meta_description'); } elseif ($wgTitle->getNamespace() == NS_MAIN) { $desc = ''; if (!$titleTest) { $titleTest = TitleTests::newFromTitle($wgTitle); if ($titleTest) { $desc = $titleTest->getMetaDescription(); } } if (!$desc) { if (!self::$wgTitleAMIcache) { self::$wgTitleAMIcache = new ArticleMetaInfo($wgTitle); } $ami = self::$wgTitleAMIcache; $desc = $ami->getDescription(); } if (!$desc) { $return = wfMsg('article_meta_description', $wgTitle->getText()); } else { $return = $desc; } } elseif ($wgTitle->getNamespace() == NS_CATEGORY) { // get keywords $subcats = self::getMetaSubcategories($wgTitle, 3); $keywords = implode(", ", $subcats); if ($keywords) { $return = wfMsg('category_meta_description', $wgTitle->getText(), $keywords); } else { $return = wfMsg('subcategory_meta_description', $wgTitle->getText(), $keywords); } } elseif ($wgTitle->getNamespace() == NS_USER) { $desc = ProfileBox::getMetaDesc(); $return = $desc; } elseif ($wgTitle->getNamespace() == NS_IMAGE) { $articles = ImageHelper::getLinkedArticles($wgTitle); if (count($articles) && $articles[0]) { $articleTitle = wfMsg('howto', $articles[0]); if (preg_match('@Step (\\d+)@', $wgTitle->getText(), $m)) { $imageNum = '#' . $m[1]; } else { $imageNum = ''; } $return = wfMsg('image_meta_description', $articleTitle, $imageNum); } else { $return = wfMsg('image_meta_description_no_article', $wgTitle->getText()); } } elseif ($wgTitle->getNamespace() == NS_SPECIAL && $wgTitle->getText() == "Popularpages") { $return = wfMsg('popularpages_meta_description'); } return $return; }