当前位置: 首页>>代码示例>>PHP>>正文


PHP OutputPage::getUser方法代码示例

本文整理汇总了PHP中OutputPage::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP OutputPage::getUser方法的具体用法?PHP OutputPage::getUser怎么用?PHP OutputPage::getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OutputPage的用法示例。


在下文中一共展示了OutputPage::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onBeforePageDisplay

 public static function onBeforePageDisplay(OutputPage &$output, Skin &$skin)
 {
     $title = $output->getTitle();
     // Disallow commenting on pages without article id
     if ($title->getArticleID() == 0) {
         return true;
     }
     if ($title->isSpecialPage()) {
         return true;
     }
     // These could be explicitly allowed in later version
     if (!$title->canTalk()) {
         return true;
     }
     if ($title->isTalkPage()) {
         return true;
     }
     // No commenting on main page
     if ($title->isMainPage()) {
         return true;
     }
     // Do not display when printing
     if ($output->isPrintable()) {
         return true;
     }
     // Disable if not viewing
     if ($skin->getRequest()->getVal('action', 'view') != 'view') {
         return true;
     }
     // Blacklist several namespace
     if (in_array($title->getNamespace(), self::getFilteredNamespace())) {
         return true;
     }
     if ($output->getUser()->isAllowed('commentadmin-restricted')) {
         $output->addJsConfigVars(array('commentadmin' => ''));
     }
     global $wgFlowThreadConfig;
     $config = array('Avatar' => $wgFlowThreadConfig['Avatar'], 'AnonymousAvatar' => $wgFlowThreadConfig['AnonymousAvatar']);
     if (\FlowThread\Post::canPost($output->getUser())) {
         $output->addJsConfigVars(array('canpost' => ''));
     } else {
         $config['CantPostNotice'] = wfMessage('flowthread-ui-cantpost')->toString();
     }
     global $wgFlowThreadConfig;
     $output->addJsConfigVars(array('wgFlowThreadConfig' => $config));
     $output->addModules('ext.flowthread');
     return true;
 }
开发者ID:nbdd0121,项目名称:MW-FlowThread,代码行数:48,代码来源:FlowThread_body.php

示例2: onShowEditForm

 /**
  * @param \EditPage   $editPage
  * @param \OutputPage $output
  *
  * @return bool
  */
 public function onShowEditForm($editPage, $output)
 {
     if (!$output->getUser()->isEmailConfirmed()) {
         $editPage->editFormTextBeforeContent .= $this->installHtml();
     }
     return true;
 }
开发者ID:addshore,项目名称:reCaptcha,代码行数:13,代码来源:reCaptcha.hooks.php

示例3: onBeforePageDisplay

 /**
  * Adds module
  * @param OutputPage $out
  * @param SkinTemplate $skin
  * @return boolean
  */
 public static function onBeforePageDisplay(&$out, &$skin)
 {
     if (!$out->getTitle()->equals($out->getUser()->getUserPage())) {
         return true;
     }
     $out->addModules("ext.bluespice.avatars.js");
     return true;
 }
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:14,代码来源:Avatars.class.php

示例4: getUserPageContent

 /**
  * Generate user page content for non-existent user pages
  *
  * @param OutputPage $output
  * @param User $pageUser owner of the user page
  * @return string
  */
 public static function getUserPageContent($output, $pageUser)
 {
     $context = MobileContext::singleton();
     $pageUsername = $pageUser->getName();
     // Is the current user viewing their own page?
     $isCurrentUser = $output->getUser()->getName() === $pageUsername;
     $data['ctaHeading'] = $isCurrentUser ? $context->msg('mobile-frontend-user-page-no-owner-page-yet')->text() : $context->msg('mobile-frontend-user-page-no-page-yet', $pageUsername)->parse();
     $data['ctaDescription'] = $isCurrentUser ? $context->msg('mobile-frontend-user-page-describe-yourself', $context->msg('mobile-frontend-user-page-describe-yourself-editors')->text())->text() : $context->msg('mobile-frontend-user-page-desired-action', $pageUsername)->parse();
     $data['createPageLinkLabel'] = $isCurrentUser ? $context->msg('mobile-frontend-user-page-create-owner-page-link-label')->text() : $context->msg('mobile-frontend-user-page-create-user-page-link-label', $pageUser->getUserPage()->getBaseTitle())->parse();
     $data['createPageLinkAdditionalClasses'] = $isCurrentUser ? 'mw-ui-button' : '';
     $templateParser = new TemplateParser(__DIR__);
     return $templateParser->processTemplate('user_page_cta', $data);
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:20,代码来源:MobileFrontend.body.php

示例5: makeCustomURL

 /**
  * Build a load.php URL using OutputPage instance to get  most of the required information
  *
  * @param OutputPage $out
  * @param string|array $modules Module names
  * @param string $only
  * @param bool|string $user User name (true to get it from OutputPage)
  * @param string $version
  * @param array $extraQuery
  * @return string
  */
 public static function makeCustomURL(OutputPage $out, $modules, $only = ResourceLoaderModule::TYPE_COMBINED, $user = null, $version = null, $extraQuery = array())
 {
     if ($user === true) {
         $user = $out->getUser()->getName();
     } else {
         if ($user === false || $user === null) {
             $user = null;
         } else {
             $user = (string) $user;
         }
     }
     $url = ResourceLoader::makeLoaderURL($modules, $out->getLanguage()->getCode(), $out->getSkin()->getSkinName(), $user, $version, ResourceLoader::inDebugMode(), $only === ResourceLoaderModule::TYPE_COMBINED ? null : $only, $out->isPrintable(), $out->getRequest()->getBool('handheld'), $extraQuery);
     return $url;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:ResourceLoader.php

示例6: newArticleCampaign

 /**
  * Hook: EditPage::showEditForm:initial
  */
 public static function newArticleCampaign(EditPage $newPage, OutputPage $out)
 {
     global $wgContentTranslationCampaigns, $wgContentTranslationEventLogging;
     $user = $out->getUser();
     if (!$wgContentTranslationCampaigns['newarticle'] || $out->getRequest()->getCookie('cx_campaign_newarticle_hide', '') || $newPage->mTitle->exists() || !$newPage->mTitle->inNamespace(NS_MAIN) || $user->isAnon() || BetaFeatures::isFeatureEnabled($user, 'cx')) {
         return true;
     }
     // If EventLogging integration is enabled, load the event logging functions module
     // to measure and analyse the usage of this entry point.
     if ($wgContentTranslationEventLogging) {
         $out->addModules('ext.cx.eventlogging');
     }
     $out->addModules('ext.cx.campaigns.newarticle');
 }
开发者ID:Wikia,项目名称:mediawiki-extensions-ContentTranslation,代码行数:17,代码来源:ContentTranslation.hooks.php

示例7: 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 $wgGatherEnableBetaFeature;
     $desktopBetaFeatureEnabled = class_exists('BetaFeatures') && BetaFeatures::isFeatureEnabled($out->getUser(), 'betafeatures-gather') && $wgGatherEnableBetaFeature;
     if ($desktopBetaFeatureEnabled) {
         $out->addModules('ext.gather.desktop');
         $out->addModuleStyles(array('mediawiki.ui.input', 'mediawiki.ui.icon'));
     }
 }
开发者ID:joakin,项目名称:mediawiki-extensions-Gather,代码行数:17,代码来源:Gather.hooks.php

示例8: addGoogleAnalytics

 public static function addGoogleAnalytics(OutputPage &$out)
 {
     global $wgGoogleUniversalAnalyticsAccount, $wgGoogleUniversalAnalyticsAnonymizeIP, $wgGoogleUniversalAnalyticsTrackExtLinks, $wgGoogleUniversalAnalyticsSegmentByGroup, $wgGoogleUniversalAnalyticsSegmentByGroupDimension, $wgGoogleUniversalAnalyticsCookiePath, $wgGoogleUniversalAnalyticsDomainName, $wgGoogleUniversalAnalyticsPageGrouping, $wgGoogleUniversalAnalyticsEnahncedLinkAttribution, $wgGoogleUniversalAnalyticsRemarketing;
     if (is_null($wgGoogleUniversalAnalyticsAccount)) {
         $msg = self::messageToComment('googleuniversalanalytics-error-not-configured');
         return $msg;
     }
     if ($out->getUser()->isAllowed('noanalytics')) {
         return self::messageToComment('googleuniversalanalytics-disabled-for-user');
     }
     if (self::isIgnoredPage($out->getTitle())) {
         return self::messageToComment('googleuniversalanalytics-disabled-for-page');
     }
     /* Else: we load the script */
     $script = '<!-- Begin Google Analytics -->' . PHP_EOL;
     $script .= '<script>' . PHP_EOL . self::getBasicSnippet();
     $extraCreateParams = '';
     if (!empty($wgGoogleUniversalAnalyticsCookiePath)) {
         $extraCreateParams = ", {'cookiePath': '{$wgGoogleUniversalAnalyticsCookiePath}'}";
     }
     $cookieDomain = $wgGoogleUniversalAnalyticsDomainName ?: 'auto';
     $script .= "ga('create', '{$wgGoogleUniversalAnalyticsAccount}', '{$cookieDomain}'" . $extraCreateParams . ");" . PHP_EOL;
     if ($wgGoogleUniversalAnalyticsSegmentByGroup === true && is_int($wgGoogleUniversalAnalyticsSegmentByGroupDimension)) {
         // The following should be fine with caching, and simply always get "*" for anon users
         $userGroups = implode(',', $out->getUser()->getEffectiveGroups());
         $dimension = 'dimension' . $wgGoogleUniversalAnalyticsSegmentByGroupDimension;
         $script .= "ga('set', '{$dimension}', '{$userGroups}');" . PHP_EOL;
     }
     if (isset($wgGoogleUniversalAnalyticsPageGrouping) && $wgGoogleUniversalAnalyticsPageGrouping === true) {
         $title = $out->getTitle();
         $ns = $title->getNamespace();
         if (isset($ns) && in_array($ns, self::$ignoredPageGroupingNamespaces)) {
             $script .= PHP_EOL . "/* Namespace excluded from page grouping */" . PHP_EOL;
         } else {
             $normalCats = self::$normalCats;
             if (count($normalCats) > 1) {
                 $normalCats[0] = Title::makeTitleSafe(NS_CATEGORY, $normalCats[0])->getText();
                 $normalCats[1] = Title::makeTitleSafe(NS_CATEGORY, $normalCats[1])->getText();
                 $script .= "ga('set', 'contentGroup2', '{$normalCats[1]}');" . PHP_EOL . "ga('set', 'contentGroup3', '{$normalCats[0]}');" . PHP_EOL;
             }
         }
     }
     if (isset($wgGoogleUniversalAnalyticsRemarketing) && $wgGoogleUniversalAnalyticsRemarketing === true) {
         $script .= "ga('require', 'displayfeatures');" . PHP_EOL;
     }
     if (isset($wgGoogleUniversalAnalyticsEnahncedLinkAttribution) && $wgGoogleUniversalAnalyticsEnahncedLinkAttribution == true) {
         $script .= "ga('require', 'linkid', 'linkid.js');" . PHP_EOL;
     }
     if ($wgGoogleUniversalAnalyticsAnonymizeIP === true) {
         $script .= "ga('set', 'anonymizeIp', true);" . PHP_EOL;
     }
     // And finally... send the pageview
     $script .= "ga('send', 'pageview');" . PHP_EOL;
     // And end the script
     $script .= "</script>" . PHP_EOL;
     $script .= '<!-- End Google Analytics -->' . PHP_EOL;
     // Add module for tracking external links using events
     if (isset($wgGoogleUniversalAnalyticsTrackExtLinks) && $wgGoogleUniversalAnalyticsTrackExtLinks === true) {
         $out->addModules('ext.googleUniversalAnalytics.externalLinks');
     }
     return $script;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-GoogleUniversalAnalytics,代码行数:62,代码来源:GoogleUniversalAnalytics.hooks.php

示例9: onBeforePageDisplay

 /** Load the RL module */
 static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
 {
     global $wgWRGoogleSearchOnly;
     $user = $out->getUser();
     if ($wgWRGoogleSearchOnly && !WRGoogleSearch::isUserExempt($user)) {
         $out->addModules('ext.wrGoogleSearch.general');
     }
     return true;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-WRGoogleSearch,代码行数:10,代码来源:WRGoogleSearch.php

示例10: makeGlobalVariablesScript

 /**
  * Export variables which depend on the current user
  * @param $vars
  * @param OutputPage $out
  */
 public static function makeGlobalVariablesScript(&$vars, OutputPage $out)
 {
     global $wgDefaultUserOptions;
     $user = $out->getUser();
     $vars['wgMediaViewerOnClick'] = self::shouldHandleClicks($user);
     // needed because of bug 69942; could be different for anon and logged-in
     $vars['wgMediaViewerEnabledByDefault'] = !empty($wgDefaultUserOptions['multimediaviewer-enable']);
 }
开发者ID:tgr,项目名称:mediawiki-extensions-MultimediaViewer,代码行数:13,代码来源:MultimediaViewerHooks.php

示例11: makeGlobalVariablesScript

 /**
  * Handler for MakeGlobalVariablesScript hook.
  * @see http://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript
  * @param &$vars array Variables to be added into the output
  * @param $outputPage OutputPage instance calling the hook
  * @return bool true in all cases
  */
 public static function makeGlobalVariablesScript(&$vars, OutputPage $outputPage)
 {
     global $wgEchoHelpPage, $wgEchoMaxNotificationCount, $wgEchoConfig;
     $user = $outputPage->getUser();
     // Provide info for the Overlay
     $timestamp = new MWTimestamp(wfTimestampNow());
     //XXCHANGEDXX - allow anons [sc|rs]
     if (!$user->isAnon() || $user->hasCookies()) {
         $vars['wgEchoOverlayConfiguration'] = array('notification-count' => MWEchoNotifUser::newFromUser($user)->getFormattedNotificationCount(), 'max-notification-count' => $wgEchoMaxNotificationCount);
         $vars['wgEchoHelpPage'] = $wgEchoHelpPage;
         $vars['wgEchoConfig'] = $wgEchoConfig;
     }
     return true;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:21,代码来源:Hooks.php

示例12: onMakeGlobalVariablesScript

 /**
  * Adds extra variables to the page config.
  */
 public static function onMakeGlobalVariablesScript(array &$vars, OutputPage $out)
 {
     global $wgSVGMaxSize, $wgNamespacesWithSubpages;
     $pageLanguage = $out->getTitle()->getPageLanguage();
     $vars['wgVisualEditor'] = array('isPageWatched' => $out->getUser()->isWatched($out->getTitle()), 'pageLanguageCode' => $pageLanguage->getHtmlCode(), 'pageLanguageDir' => $pageLanguage->getDir(), 'svgMaxSize' => $wgSVGMaxSize, 'namespacesWithSubpages' => $wgNamespacesWithSubpages);
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:10,代码来源:VisualEditor.hooks.php

示例13: makeGlobalVariablesScript

 /**
  * Export variables which depend on the current user
  * @param $vars
  * @param OutputPage $out
  */
 public static function makeGlobalVariablesScript(&$vars, OutputPage $out)
 {
     $user = $out->getUser();
     $vars['wgMediaViewerOnClick'] = self::shouldHandleClicks($user);
 }
开发者ID:kevinmichaelchen,项目名称:mediawiki-mmv,代码行数:10,代码来源:MultimediaViewerHooks.php

示例14: addGoogleAnalytics

    static function addGoogleAnalytics(OutputPage &$out)
    {
        global $wgGoogleAnalyticsAccount, $wgGoogleAnalyticsSegmentByGroup, $wgGoogleAnalyticsTrackExtLinks, $wgGoogleAnalyticsDomainName, $wgGoogleAnalyticsCookiePath, $wgGoogleAnalyticsEnahncedLinkAttribution, $wgGoogleAnalyticsPageGrouping, $wgGoogleAnalyticsDemographics;
        if (is_null($wgGoogleAnalyticsAccount)) {
            $msg = self::messageToComment('googleanalytics-error-not-configured');
            return $msg;
        }
        if ($out->getUser()->isAllowed('noanalytics')) {
            return self::messageToComment('googleanalytics-disabled-for-user');
        }
        if (self::isIgnoredPage($out->getTitle())) {
            return self::messageToComment('googleanalytics-disabled-for-page');
        }
        /* Else: we load the script */
        /* Starts with regular GA.js queue initializing, but adds
         * custom code to make sure '_setAccount' is always first (using 'unshift').
         * This allows other extensions to shove things in the queue
         * without knowing anything about it, by doing something like (don't forget ResourceLoader encapsulation!):
         * var _gaq = _gaq || []; _gaq.push(cmd);
         */
        $script = <<<JS
<script>
\tvar _gaq = _gaq || [];
\tvar cmd = ['_setAccount', '{$wgGoogleAnalyticsAccount}'];
\tif (!_gaq.unshift){
\t\t_gaq.push(cmd);
\t} else {
\t _gaq.unshift(cmd);
\t}
JS;
        if (!empty($wgGoogleAnalyticsDomainName)) {
            $script .= "\n\t_gaq.push(['_setDomainName', '{$wgGoogleAnalyticsDomainName}']);";
        }
        if (!empty($wgGoogleAnalyticsCookiePath)) {
            $script .= "\n\t_gaq.push(['_setCookiePath', '{$wgGoogleAnalyticsCookiePath}']);";
        }
        if (isset($wgGoogleAnalyticsSegmentByGroup) && $wgGoogleAnalyticsSegmentByGroup === true) {
            $script .= "\n\twindow.RLQ.push( function () {\n\t\t_gaq.push(['_setCustomVar',\n\t\t\t1,\t\t\t\t\t\t\t\t// first slot\n\t\t\t'User Groups',\t\t\t\t\t// custom variable name\n\t\t\tmw.config.get( 'wgUserGroups' ).toString(),\t// custom variable filtered in GA\n\t\t\t2\t\t\t\t\t\t// custom variable scope - session-level\n\t\t]);\n\t});";
        }
        if (isset($wgGoogleAnalyticsPageGrouping) && $wgGoogleAnalyticsPageGrouping === true) {
            $title = $out->getTitle();
            $ns = $title->getNamespace();
            if (isset($ns) && in_array($ns, array(NS_CATEGORY, NS_FILE, NS_SPECIAL, NS_MEDIAWIKI))) {
                $script .= PHP_EOL . "/* Namespace excluded from page grouping */" . PHP_EOL;
            } else {
                $normalCats = self::$normalCats;
                if (count($normalCats) > 1) {
                    $normalCats[0] = Title::makeTitleSafe(NS_CATEGORY, $normalCats[0])->getText();
                    $normalCats[1] = Title::makeTitleSafe(NS_CATEGORY, $normalCats[1])->getText();
                    $grouping = $normalCats[1] . '/' . $normalCats[0];
                    $script .= "\n\t  _gaq.push(['_setPageGroup', '1', '{$grouping}']);\n\t  _gaq.push(['_setPageGroup', '2', '{$normalCats[1]}']);\n\t  _gaq.push(['_setPageGroup', '3', '{$normalCats[0]}']);\n\t";
                }
            }
        }
        $script .= "\n\t_gaq.push(['_trackPageview']);";
        if (isset($wgGoogleAnalyticsDemographics) && $wgGoogleAnalyticsDemographics === true) {
            $gaSource = "('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'";
        } else {
            $gaSource = "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'";
        }
        $script .= "\n\t(function() {\n\tvar ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n\tga.src = {$gaSource};\n\tvar s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n\t})();";
        if (isset($wgGoogleAnalyticsEnahncedLinkAttribution) && $wgGoogleAnalyticsEnahncedLinkAttribution === true) {
            $script .= "\n\tvar pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';\n\t_gaq.push(['_require', 'inpage_linkid', pluginUrl]);";
        }
        if (isset($wgGoogleAnalyticsTrackExtLinks) && $wgGoogleAnalyticsTrackExtLinks === true) {
            $script .= <<<JS
\tfunction trackEvent(category, action, label, value, noninteraction) {
\t\ttry {
\t\t  _gaq.push(['_trackEvent', category , action, label, value, noninteraction ]);
\t\t} catch(err) { }
\t}

\twindow.RLQ.push( function () {
\t\t\$( 'body' ).on( 'click', 'a.external, a.extiw, .interlanguage-link > a', function( e ) {
\t\t\tvar url = \$( this ).attr( 'href' );
\t\t\tvar host = e.currentTarget.host.replace( ':80', '' );
\t\t\tvar category = '';
\t\t\tif( \$(this).hasClass( 'external' ) ) { category = 'Outbound Links'; }
\t\t\telse if( \$(this).hasClass( 'extiw' ) ) { category = 'Outbound Interwiki'; }
\t\t\telse { category = 'Language Links'; }

\t\t\ttrackEvent( category, host, url, undefined, true );
\t\t});
\t});
JS;
        }
        // And finally...
        $script .= PHP_EOL . "</script>" . PHP_EOL;
        return $script;
    }
开发者ID:kolzchut,项目名称:mediawiki-extensions-GoogleAnalytics,代码行数:90,代码来源:googleAnalytics.hooks.php

示例15: addConfig

 /**
  * Hook: MakeGlobalVariablesScript
  *
  * Adds $wgTranslateDocumentationLanguageCode to ResourceLoader configuration
  * when Special:Translate is shown.
  */
 public static function addConfig(&$vars, OutputPage $out)
 {
     $request = $out->getRequest();
     $title = $out->getTitle();
     list($alias, ) = SpecialPageFactory::resolveAlias($title->getText());
     if (SpecialTranslate::isBeta($request) && $title->isSpecialPage() && ($alias === 'Translate' || $alias === 'TranslationStash' || $alias === 'SearchTranslations')) {
         global $wgTranslateDocumentationLanguageCode, $wgTranslatePermissionUrl, $wgTranslateUseSandbox;
         $vars['TranslateRight'] = $out->getUser()->isAllowed('translate');
         $vars['TranslateMessageReviewRight'] = $out->getUser()->isAllowed('translate-messagereview');
         $vars['DeleteRight'] = $out->getUser()->isAllowed('delete');
         $vars['wgTranslateDocumentationLanguageCode'] = $wgTranslateDocumentationLanguageCode;
         $vars['wgTranslatePermissionUrl'] = $wgTranslatePermissionUrl;
         $vars['wgTranslateUseSandbox'] = $wgTranslateUseSandbox;
     }
     return true;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:22,代码来源:TranslateHooks.php


注:本文中的OutputPage::getUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。