/**
 * @param OutputPage $out
 * @param string $text
 * @return bool
 */
function wfArticleMetaDescription(&$out, &$text)
{
    global $wgTitle;
    wfProfileIn(__METHOD__);
    $sMessage = null;
    $sMainPage = wfMsgForContent('Mainpage');
    if (strpos($sMainPage, ':') !== false) {
        $sTitle = $wgTitle->getFullText();
    } else {
        $sTitle = $wgTitle->getText();
    }
    if (strcmp($sTitle, $sMainPage) == 0) {
        // we're on Main Page, check MediaWiki:Description message
        $sMessage = wfMsg("Description");
    }
    if ($sMessage == null || wfEmptyMsg("Description", $sMessage)) {
        $DESC_LENGTH = 100;
        $articleId = $wgTitle->getArticleID();
        $articleService = new ArticleService($articleId);
        $description = $articleService->getTextSnippet($DESC_LENGTH);
    } else {
        // MediaWiki:Description message found, use it
        $description = $sMessage;
    }
    if (!empty($description)) {
        $out->addMeta('description', htmlspecialchars($description));
    }
    wfProfileOut(__METHOD__);
    return true;
}
 /**
  * @author mech
  * @param OutputPage $out
  * @return bool true
  */
 function onBeforePageDisplay($out)
 {
     if (!empty(F::app()->wg->SEOGoogleSiteVerification)) {
         $out->addMeta('google-site-verification', F::app()->wg->SEOGoogleSiteVerification);
     }
     if (!empty(F::app()->wg->SEOGooglePlusLink)) {
         $out->addLink(array('href' => F::app()->wg->SEOGooglePlusLink, 'rel' => 'publisher'));
     }
     return true;
 }
 /**
  * @author mech
  * @param OutputPage $out
  * @return bool true
  */
 static function onBeforePageDisplay($out)
 {
     global $wgSEOGoogleSiteVerification, $wgSEOGooglePlusLink;
     if (!empty($wgSEOGoogleSiteVerification)) {
         $out->addMeta('google-site-verification', $wgSEOGoogleSiteVerification);
     }
     if (!empty($wgSEOGooglePlusLink)) {
         $out->addLink(array('href' => $wgSEOGooglePlusLink, 'rel' => 'publisher'));
     }
     return true;
 }
Example #4
0
 /**
  * Initializes output page and sets up skin-specific parameters
  * @param $out OutputPage object to initialize
  */
 public function initPage(OutputPage $out)
 {
     global $wgLocalStylePath;
     $out->addMeta('viewport', 'width=device-width');
     parent::initPage($out);
     // Append CSS which includes IE only behavior fixes for hover support -
     // this is better than including this in a CSS file since it doesn't
     // wait for the CSS file to load before fetching the HTC file.
     $min = $this->getRequest()->getFuzzyBool('debug') ? '' : '.min';
     /*              $out->addHeadItem( 'csshover',
                             '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
                                     htmlspecialchars( $wgLocalStylePath ) .
                                     "/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
                     );*/
     //$out->addHeadItem( 'csshover', '<link rel="stylesheet" href="//enhawiki.kr../skins/moniwiki/theme/enha/css/default.css?v=1541703"/>'  );
     $out->addModules(array('skins.paper.js', 'skins.paper.collapsibleNav'));
 }
Example #5
0
 public static function onBeforePageDisplay(OutputPage $out, Skin $sk)
 {
     wfProfileIn(__METHOD__);
     $title = $out->getTitle();
     if ($title instanceof Title && $title->isContentPage()) {
         $storage = PlaceStorage::newFromTitle($out->getTitle());
         $model = $storage->getModel();
         /* @var $model PlaceModel */
         if ($model instanceof PlaceModel && !$model->isEmpty()) {
             $out->addMeta('geo.position', implode(',', $model->getLatLon()));
         }
     }
     if ($title instanceof Title && $title->getNamespace() == NS_CATEGORY) {
         $out->addScript('<script src="' . F::app()->wg->extensionsPath . '/wikia/Places/js/GeoEnableButton.js"></script>');
         $out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/Places/css/GeoEnableButton.scss'));
     }
     wfProfileOut(__METHOD__);
     return true;
 }
Example #6
0
 public function initPage(OutputPage $out)
 {
     $baseURL = $GLOBALS['egBootyBaseURL'];
     //add the css modules separately to prevent a FOUC
     $out->addModuleStyles('bootstrap.css');
     $out->addModuleStyles('skin.booty.css');
     $out->addModuleStyles('font-awesome');
     //since we're using theb mediawiki generated head element, we have to add the viewport meta tag
     //so the layout scaled properly to mobile devices
     $out->addMeta('viewport', 'width=device-width');
     //,initial-width=1,maximum-width=1' );
     /* Until ResourceLoader can correctly parse multiple urls in a single font-family
     		webfont files have to be defined in the head to prevent it screwing things up */
     $out->addInlineStyle("@font-face {\n\t\t  font-family: 'Glyphicons Halflings';\n\t\t  src: url('{$baseURL}/bootstrap-3.0.3/fonts/glyphicons-halflings-regular.eot');\n\t\t  src: url('{$baseURL}/bootstrap-3.0.3/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('{$baseURL}/bootstrap-3.0.3/fonts/glyphicons-halflings-regular.woff') format('woff'), url('{$baseURL}/bootstrap-3.0.3/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('{$baseURL}/bootstrap-3.0.3/fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');\n\t\t}");
     $out->addInlineStyle("@font-face {\n\t\t  font-family: 'FontAwesome';\n\t\t  src: url('{$baseURL}/font-awesome-4.0.3/fonts/fontawesome-webfont.eot?v=4.0.3');\n\t\t  src: url('{$baseURL}/font-awesome-4.0.3/fonts/fontawesome-webfont.eot?#iefix&v=4.0.3') format('embedded-opentype'), url('{$baseURL}/font-awesome-4.0.3/fonts/fontawesome-webfont.woff?v=4.0.3') format('woff'), url('{$baseURL}/font-awesome-4.0.3/fonts/fontawesome-webfont.ttf?v=4.0.3') format('truetype'), url('{$baseURL}/font-awesome-4.0.3/fonts/fontawesome-webfont.svg?v=4.0.3#fontawesomeregular') format('svg');\n\t\t  font-weight: normal;\n\t\t  font-style: normal;\n\t\t}");
     //js items will be appended after page load
     $out->addModules('bootstrap.js');
     $out->addModules('skin.booty.js');
     $out->addHeadItem('meta-viewport', '<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">');
     parent::initPage($out);
 }
/**
 * @param OutputPage $out
 * @param string $text
 * @return bool
 */
function wfArticleMetaDescription(&$out, &$text)
{
    wfProfileIn(__METHOD__);
    $wg = F::app()->wg;
    // Whether the description has already been added
    static $addedToPage = false;
    // The OutputPage::addParserOutput method calls the OutputPageBeforeHTML hook which can happen
    // more than once in a request.  Make sure we don't add two <meta> tags
    // https://wikia-inc.atlassian.net/browse/VID-2102
    if ($addedToPage) {
        wfProfileOut(__METHOD__);
        return true;
    }
    $sMessage = null;
    $sMainPage = wfMessage('Mainpage')->inContentLanguage()->text();
    if (strpos($sMainPage, ':') !== false) {
        $sTitle = $wg->Title->getFullText();
    } else {
        $sTitle = $wg->Title->getText();
    }
    if (strcmp($sTitle, $sMainPage) == 0) {
        // we're on Main Page, check MediaWiki:Description message
        $sMessage = wfMessage('Description')->text();
    }
    if ($sMessage == null || wfEmptyMsg('Description', $sMessage)) {
        $DESC_LENGTH = 100;
        $article = new Article($wg->Title);
        $articleService = new ArticleService($article);
        $description = $articleService->getTextSnippet($DESC_LENGTH);
    } else {
        // MediaWiki:Description message found, use it
        $description = $sMessage;
    }
    if (!empty($description)) {
        $out->addMeta('description', htmlspecialchars($description));
        $addedToPage = true;
    }
    wfProfileOut(__METHOD__);
    return true;
}
Example #8
0
 function wfModifyMetaTags(OutputPage $out)
 {
     $out->addMeta('description', 'Miraheze is an open source project that offers free MediaWiki hosting, for everyone. Request your free wiki today!');
     $out->addMeta('revisit-after', '2 days');
     $out->addMeta('keywords', 'miraheze, free, wiki hosting, mediawiki, mediawiki hosting, open source, hosting');
 }
Example #9
0
function efOpenGraphMetaPageHook(OutputPage &$out, &$sk)
{
    global $wgLogo, $wgSitename, $wgXhtmlNamespaces, $egFacebookAppId, $egFacebookAdmins;
    $wgXhtmlNamespaces["og"] = "http://opengraphprotocol.org/schema/";
    $title = $out->getTitle();
    $isMainpage = $title->isMainPage();
    $meta = array();
    if ($isMainpage) {
        $meta["og:type"] = "website";
        $meta["og:title"] = $wgSitename;
    } else {
        $meta["og:type"] = "article";
        $meta["og:site_name"] = $wgSitename;
        // Try to chose the most appropriate title for showing in news feeds.
        if (defined('NS_BLOG_ARTICLE') && $title->getNamespace() == NS_BLOG_ARTICLE || defined('NS_BLOG_ARTICLE_TALK') && $title->getNamespace() == NS_BLOG_ARTICLE_TALK) {
            $meta["og:title"] = $title->getSubpageText();
        } else {
            $meta["og:title"] = $title->getText();
        }
    }
    if (isset($out->mMainImage) && $out->mMainImage !== false) {
        if (is_object($out->mMainImage)) {
            $meta["og:image"] = wfExpandUrl($out->mMainImage->createThumb(100 * 3, 100));
        } else {
            // In some edge-cases we won't have defined an object but rather a full URL.
            $meta["og:image"] = $out->mMainImage;
        }
    } elseif ($isMainpage) {
        $meta["og:image"] = wfExpandUrl($wgLogo);
    }
    if (isset($out->mDescription)) {
        // set by Description2 extension, install it if you want proper og:description support
        $meta["og:description"] = $out->mDescription;
    }
    $meta["og:url"] = $title->getFullURL();
    if ($egFacebookAppId) {
        /* begin wikia change */
        // $meta["fb:app_id"] = $egFacebookAppId;
        // fb:app_id needs a prefix property declaring the namespace, so just add it directly
        $out->addHeadItem("meta:property:fb:app_id", "\t" . Html::element('meta', array('property' => 'fb:app_id', 'content' => $egFacebookAppId, 'prefix' => "fb: http://www.facebook.com/2008/fbml")) . "\n");
        /* end wikia change */
    }
    if ($egFacebookAdmins) {
        $meta["fb:admins"] = $egFacebookAdmins;
    }
    /* begin wikia change */
    wfRunHooks('OpenGraphMetaHeaders', array("meta" => &$meta, "title" => $title));
    /* end wikia change */
    foreach ($meta as $property => $value) {
        if ($value) {
            if (isset(OutputPage::$metaAttrPrefixes) && isset(OutputPage::$metaAttrPrefixes['property'])) {
                $out->addMeta("property:{$property}", $value);
            } else {
                $out->addHeadItem("meta:property:{$property}", "\t" . Html::element('meta', array('property' => $property, 'content' => $value)) . "\n");
            }
        }
    }
    return true;
}
Example #10
0
 /**
  * Modify the HTML to set the relevant tags to the specified values
  *
  * This method is called by the BeforePageDisplay hook
  *
  * @param OutputPage $out
  */
 public static function modifyHTML($out)
 {
     //set title
     if (!empty(self::$title)) {
         switch (self::$title_mode) {
             case 'append':
                 $title = $out->getPageTitle() . self::$title_separator . self::$title;
                 break;
             case 'prepend':
                 $title = self::$title . self::$title_separator . $out->getPageTitle();
                 break;
             case 'replace':
             default:
                 $title = self::$title;
         }
         $out->setHTMLTitle($title);
         $out->addMeta("twitter:title", $title);
         $out->addHeadItem("og:title", "<meta property=\"og:title\" content=\"{$title}\" />" . "\n");
     }
     //set meta tags
     if (!empty(self::$meta)) {
         foreach (self::$meta as $name => $content) {
             if ($name == 'description') {
                 $out->addMeta($name, $content);
                 $out->addMeta("twitter:description", $content);
                 $out->addHeadItem("og:description", Html::element('meta', array('property' => 'og:description', 'content' => $content)) . "\n");
             } else {
                 $out->addMeta($name, $content);
             }
         }
     }
     //set property tags
     if (!empty(self::$property)) {
         foreach (self::$property as $property => $content) {
             $out->addHeadItem("{$property}", Html::element('meta', array('property' => $property, 'content' => $content)) . "\n");
         }
     }
     return true;
 }
Example #11
0
 /**
  * Adds the <meta> keywords to document head.
  * Usage: $wgHooks['OutputPageBeforeHTML'][] = 'insertMetaKeywords';
  * @param OutputPage $out Handle to an OutputPage object - presumably $wgOut (passed by reference).
  * @param String $text Output text.
  * @return Boolean Always true to allow other extensions to continue processing.
  */
 function insertMetaKeywords($out, $text)
 {
     # Extract meta keywords
     if (preg_match_all('/<!-- META_KEYWORDS ([0-9a-zA-Z\\+\\/]+=*) -->/m', $text, $matches) === false) {
         return true;
     }
     $data = $matches[1];
     # Merge keyword data into OutputPage as meta tags
     foreach ($data as $item) {
         $content = @base64_decode($item);
         if ($content) {
             $out->addMeta('keywords', $content);
         }
     }
     return true;
 }
 /**
  * @brief Adds fragment metatag in <head> section on single maps' pages
  * 
  * @param OutputPage $out
  * 
  * @return bool true
  */
 public static function onBeforePageDisplay($out)
 {
     if (self::isSpecialMapsPage() && self::isSingleMapPage()) {
         $out->addMeta('fragment', '!');
     }
     return true;
 }