本文整理汇总了PHP中OutputPage::addHeadItem方法的典型用法代码示例。如果您正苦于以下问题:PHP OutputPage::addHeadItem方法的具体用法?PHP OutputPage::addHeadItem怎么用?PHP OutputPage::addHeadItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputPage
的用法示例。
在下文中一共展示了OutputPage::addHeadItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getForm
/**
* Get the captcha form.
* @return string
*/
function getForm(OutputPage $out)
{
global $wgReCaptchaSiteKey;
// Insert reCAPTCHA script.
// See https://developers.google.com/recaptcha/docs/faq
$out->addHeadItem('g-recaptchascript', '<script src="https://www.google.com/recaptcha/api.js" async defer></script>');
$output = Html::element('div', array('class' => array('g-recaptcha', 'mw-confirmedit-captcha-fail' => !!$this->error), 'data-sitekey' => $wgReCaptchaSiteKey));
$htmlUrlencoded = htmlspecialchars(urlencode($wgReCaptchaSiteKey));
$output .= <<<HTML
<noscript>
<div style="width: 302px; height: 422px;">
<div style="width: 302px; height: 422px; position: relative;">
<div style="width: 302px; height: 422px; position: absolute;">
<iframe src="https://www.google.com/recaptcha/api/fallback?k={$htmlUrlencoded}"
frameborder="0" scrolling="no"
style="width: 302px; height:422px; border-style: none;">
</iframe>
</div>
<div style="width: 300px; height: 60px; border-style: none;
bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px;
background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px;">
<textarea id="g-recaptcha-response" name="g-recaptcha-response"
class="g-recaptcha-response"
style="width: 250px; height: 40px; border: 1px solid #c1c1c1;
margin: 10px 25px; padding: 0px; resize: none;" >
</textarea>
</div>
</div>
</div>
</noscript>
HTML;
return $output;
}
示例2: onBeforePageDisplay
public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
{
// Run this only if it's a high priority
if (self::isHighPriority()) {
$out->addHeadItem('FacebookConversionPixel', self::getFbPixelScript($skin));
}
}
开发者ID:kolzchut,项目名称:mediawiki-extensions-FacebookConversionPixel,代码行数:7,代码来源:FacebookConversionPixel.hooks.php
示例3: onBeforePageDisplay
public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
{
global $wgGoogleUniversalAnalyticsRiveted, $wgGoogleUniversalAnalyticsScrollDepth;
$out->addHeadItem('GoogleUniversalAnalyticsIntegration', self::addGoogleAnalytics($out));
if ($wgGoogleUniversalAnalyticsScrollDepth === true) {
$out->addModules('ext.googleUniversalAnalytics.scrolldepth.init');
}
if ($wgGoogleUniversalAnalyticsRiveted === true) {
$out->addModules('ext.googleUniversalAnalytics.riveted');
}
return true;
}
开发者ID:kolzchut,项目名称:mediawiki-extensions-GoogleUniversalAnalytics,代码行数:12,代码来源:GoogleUniversalAnalytics.hooks.php
示例4: hookAnalyticsInsideHead
/**
* @param Skin $skin
* @param string $text
* @return bool
*/
public static function hookAnalyticsInsideHead(OutputPage &$out, Skin &$skin, &$text = '')
{
global $wgGoogleAnalyticsAccount, $wgGoogleAnalyticsAnonymizeIP, $wgGoogleAnalyticsOtherCode, $wgGoogleAnalyticsIgnoreNsIDs, $wgGoogleAnalyticsIgnorePages, $wgGoogleAnalyticsIgnoreSpecials;
if ($skin->getUser()->isAllowed('noanalytics')) {
$text .= "<!-- Web analytics code inclusion is disabled for this user. -->\r\n";
return true;
}
if (count(array_filter($wgGoogleAnalyticsIgnoreSpecials, function ($v) use($skin) {
return $skin->getTitle()->isSpecial($v);
})) > 0 || in_array($skin->getTitle()->getNamespace(), $wgGoogleAnalyticsIgnoreNsIDs, true) || in_array($skin->getTitle()->getPrefixedText(), $wgGoogleAnalyticsIgnorePages, true)) {
$text .= "<!-- Web analytics code inclusion is disabled for this page. -->\r\n";
return true;
}
$appended = false;
if ($wgGoogleAnalyticsAccount !== '') {
$text .= <<<EOD
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '
EOD
. $wgGoogleAnalyticsAccount . <<<EOD
', 'auto');
EOD
. ($wgGoogleAnalyticsAnonymizeIP ? " ga('set', 'anonymizeIp', true);\r\n" : "") . <<<EOD
ga('send', 'pageview');
</script>
EOD;
$appended = true;
}
if ($wgGoogleAnalyticsOtherCode !== '') {
$text .= $wgGoogleAnalyticsOtherCode . "\r\n";
$appended = true;
}
if (!$appended) {
$text .= "<!-- No web analytics configured. -->\r\n";
}
$out->addHeadItem("analytics script", $text);
return true;
}
示例5: onBeforePageDisplay
public static function onBeforePageDisplay(OutputPage $out, SkinTemplate $sk)
{
$config = $out->getConfig();
if (self::canOutputHreflang($config)) {
# Generate hreflang tags
$languageLinks = $out->getLanguageLinks();
if (empty($languageLinks)) {
// shortcut - if we don't have any language links, don't bother
return;
}
$addedLink = false;
$pages = $config->get("HreflangPages");
if (!$pages) {
$pages = array();
$foundPage = true;
} else {
$pages = array_flip($pages);
$pageName = $out->getLanguage()->getHtmlCode() . ":" . $out->getTitle()->getBaseText();
$foundPage = isset($pages[$pageName]);
}
foreach ($languageLinks as $languageLinkText) {
$languageLinkTitle = Title::newFromText($languageLinkText);
if (!$languageLinkTitle) {
continue;
}
$ilInterwikiCode = $languageLinkTitle->getInterwiki();
if (!Language::isKnownLanguageTag($ilInterwikiCode)) {
continue;
}
$foundPage = $foundPage || isset($pages[$languageLinkText]);
$tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => wfBCP47($ilInterwikiCode), 'href' => $languageLinkTitle->getFullURL()));
$addedLink = true;
}
// Only add current language link if we had any other links
if ($addedLink) {
$tags[] = Html::element('link', array('rel' => 'alternate', 'hreflang' => $out->getLanguage()->getHtmlCode(), 'href' => $out->getTitle()->getFullURL()));
}
}
if ($foundPage && $tags) {
$out->addHeadItem("hreflang:tags", join("\n", $tags));
}
}
示例6: initPage
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);
}
示例7: viewHook
/**
* Hook into Article::view() to provide syntax highlighting for
* custom CSS and JavaScript pages
*
* @param string $text
* @param Title $title
* @param OutputPage $output
* @return bool
*/
public static function viewHook($text, $title, $output)
{
// Determine the language
preg_match('!\\.(css|js)$!u', $title->getText(), $matches);
$lang = $matches[1] == 'css' ? 'css' : 'javascript';
// Attempt to format
$geshi = self::prepare($text, $lang);
if ($geshi instanceof GeSHi) {
$out = $geshi->parse_code();
if (!$geshi->error()) {
// Done
$output->addHeadItem("source-{$lang}", self::buildHeadItem($geshi));
$output->addHTML("<div dir=\"ltr\">{$out}</div>");
return false;
}
}
// Bottle out
return true;
}
示例8: efOpenGraphMetaPageHook
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;
}
示例9: viewHook
/**
* Hook into Article::view() to provide syntax highlighting for
* custom CSS and JavaScript pages.
*
* B/C for MW 1.20 and before. 1.21 and later use renderHook() instead.
*
* @param string $text
* @param Title $title
* @param OutputPage $output
* @return bool
*/
public static function viewHook( $text, $title, $output ) {
global $wgUseSiteCss;
// Determine the language
$matches = array();
preg_match( '!\.(css|js)$!u', $title->getText(), $matches );
$lang = isset( $matches[1] ) && $matches[1] == 'css' ? 'css' : 'javascript';
// Attempt to format
$geshi = self::prepare( $text, $lang );
if( $geshi instanceof GeSHi ) {
$out = $geshi->parse_code();
if( !$geshi->error() ) {
// Done
$output->addHeadItem( "source-$lang", self::buildHeadItem( $geshi ) );
$output->addHTML( "<div dir=\"ltr\">{$out}</div>" );
if( $wgUseSiteCss ) {
$output->addModuleStyles( 'ext.geshi.local' );
}
return false;
}
}
// Bottle out
return true;
}
示例10: commitToOutputPage
/**
* Acutally commit the collected requirements to a given OutputPage object that
* will later generate the HTML output. This makes sure that HTML output contains
* all required output items. Note that there is no parser caching at this level of
* processing. In particular, data should not be committed to $wgOut in methods
* that run during page parsing, since these would not run next time when the page
* is produced from parser cache.
*
* @param OutputPage $output
*/
public static function commitToOutputPage(OutputPage $output)
{
foreach (self::$scripts as $script) {
$output->addScript($script);
}
foreach (self::$headItems as $key => $item) {
$output->addHeadItem($key, "\t\t" . $item . "\n");
}
$output->addModules(array_values(self::$resourceModules));
self::$resourceModules = array();
self::$headItems = array();
}
示例11: modifyHTML
/**
* 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;
}
示例12: onBeforePageDisplay
/**
* BeforePageDisplay hook handler
* @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
*
* @param OutputPage $out
* @param Skin $sk
* @return bool
*/
public static function onBeforePageDisplay(&$out, &$sk)
{
global $wgMFEnableXAnalyticsLogging, $wgMFAppPackageId, $wgMFAppScheme;
$context = MobileContext::singleton();
$title = $sk->getTitle();
$request = $context->getRequest();
# Add deep link to a mobile app specified by $wgMFAppScheme
if ($wgMFAppPackageId !== false && $title->isContentPage() && $request->getRawQueryString() === '') {
$fullUrl = $title->getFullURL();
$mobileUrl = $context->getMobileUrl($fullUrl);
$path = preg_replace("/^([a-z]+:)?(\\/)*/", '', $mobileUrl, 1);
$scheme = 'http';
if ($wgMFAppScheme !== false) {
$scheme = $wgMFAppScheme;
} else {
$protocol = $request->getProtocol();
if ($protocol != '') {
$scheme = $protocol;
}
}
$hreflink = 'android-app://' . $wgMFAppPackageId . '/' . $scheme . '/' . $path;
$out->addLink(array('rel' => 'alternate', 'href' => $hreflink));
}
$config = $context->getMFConfig();
$mfNoIndexPages = $config->get('MFNoindexPages');
$mfMobileUrlTemplate = $config->get('MobileUrlTemplate');
$tabletSize = $config->get('MFDeviceWidthTablet');
// an alternate link is only useful, if the mobile and desktop URL are different
// and $wgMFNoindexPages needs to be true
// add alternate link to desktop sites - bug T91183
if ($mfMobileUrlTemplate && $mfNoIndexPages) {
$desktopUrl = $title->getFullUrl();
$out->addHeadItem('mobilelink', Html::element('link', array('rel' => 'alternate', 'media' => 'only screen and (max-width: ' . $tabletSize . 'px)', 'href' => $context->getMobileUrl($desktopUrl))));
}
if (!$context->shouldDisplayMobileView()) {
return true;
}
// an canonical link is only useful, if the mobile and desktop URL are different
// and $wgMFNoindexPages needs to be true
// add canonical link to mobile pages, instead of noindex - bug T91183
if ($mfMobileUrlTemplate && $mfNoIndexPages) {
$out->addHeadItem('desktoplink', Html::element('link', array('rel' => 'canonical', 'href' => $title->getFullUrl())));
}
// Set X-Analytics HTTP response header if necessary
if ($wgMFEnableXAnalyticsLogging) {
$analyticsHeader = $context->getXAnalyticsHeader();
if ($analyticsHeader) {
$resp = $out->getRequest()->response();
$resp->header($analyticsHeader);
}
}
$out->addVaryHeader('Cookie');
return true;
}
示例13: commitToOutputPage
/**
* Acutally commit the collected requirements to a given OutputPage object that
* will later generate the HTML output. This makes sure that HTML output contains
* all required output items. Note that there is no parser caching at this level of
* processing. In particular, data should not be committed to $wgOut in methods
* that run during page parsing, since these would not run next time when the page
* is produced from parser cache.
*
* @param OutputPage $output
*/
public static function commitToOutputPage(OutputPage $output)
{
foreach (self::$scripts as $script) {
$output->addScript($script);
}
foreach (self::$headItems as $key => $item) {
$output->addHeadItem($key, "\t\t" . $item . "\n");
}
// Check if the resource loader can be used or not.
if (method_exists($output, 'addModules')) {
$output->addModules(array_values(self::$resourceModules));
} else {
self::addModulesBC($output);
}
self::$resourceModules = array();
self::$headItems = array();
}
示例14: onBeforePageDisplay
static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
{
$out->addHeadItem('GoogleAnalyticsIntegration', self::addGoogleAnalytics($out));
return true;
}
示例15: addEditModule
public static function addEditModule(EditPage $editPage, OutputPage $output)
{
$output->addModules('ext.wikieditor.huijiextra.top');
$output->addModules('ext.wikieditor.huijiextra.bottom');
$output->addHeadItem('loader', '<script language="JavaScript">' . "\n" . '$(window).load(function() {' . "\n" . '// Animate loader off screen' . "\n" . '$(".se-pre-con").fadeOut("slow");' . "\n" . 'var editFormSisyphus = $( "#editform" ).sisyphus( {' . "\n" . 'locationBased: true, ' . "\n" . 'timeout: 0,' . "\n" . 'autoRelease: true,' . "\n" . 'onBeforeRestore:function(){' . "\n" . '$("#autoRestoreModal").modal({' . "\n" . 'keyboard: false,' . "\n" . 'backdrop: "static"' . "\n" . '}); ' . "\n" . 'return false;' . "\n" . '}' . "\n" . '} ); ' . "\n" . '});' . "\n" . '</script>');
$output->prependHTML('<div class="se-pre-con"></div>');
}