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


PHP ResourceLoaderContext::getUserObj方法代码示例

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


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

示例1: getStyles

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 public function getStyles(ResourceLoaderContext $context)
 {
     if (!$this->getConfig()->get('AllowUserCssPrefs')) {
         return array();
     }
     $options = $context->getUserObj()->getOptions();
     // Build CSS rules
     $rules = array();
     // Underline: 2 = browser default, 1 = always, 0 = never
     if ($options['underline'] < 2) {
         $rules[] = "a { text-decoration: " . ($options['underline'] ? 'underline' : 'none') . "; }";
     } else {
         # The scripts of these languages are very hard to read with underlines
         $rules[] = 'a:lang(ar), a:lang(kk-arab), a:lang(mzn), ' . 'a:lang(ps), a:lang(ur) { text-decoration: none; }';
     }
     if ($options['editfont'] !== 'default') {
         // Double-check that $options['editfont'] consists of safe characters only
         if (preg_match('/^[a-zA-Z0-9_, -]+$/', $options['editfont'])) {
             $rules[] = "textarea { font-family: {$options['editfont']}; }\n";
         }
     }
     $style = implode("\n", $rules);
     if ($this->getFlip($context)) {
         $style = CSSJanus::transform($style, true, false);
     }
     return array('all' => $style);
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:31,代码来源:ResourceLoaderUserCSSPrefsModule.php

示例2: getPages

 /**
  * Get list of pages used by this module
  *
  * @param ResourceLoaderContext $context
  * @return array List of pages
  */
 protected function getPages(ResourceLoaderContext $context)
 {
     $allowUserJs = $this->getConfig()->get('AllowUserJs');
     $allowUserCss = $this->getConfig()->get('AllowUserCss');
     if (!$allowUserJs && !$allowUserCss) {
         return array();
     }
     $user = $context->getUserObj();
     if (!$user || $user->isAnon()) {
         return array();
     }
     // Needed so $excludepages works
     $userPage = $user->getUserPage()->getPrefixedDBkey();
     $pages = array();
     if ($allowUserJs) {
         $pages["{$userPage}/common.js"] = array('type' => 'script');
         $pages["{$userPage}/" . $context->getSkin() . '.js'] = array('type' => 'script');
     }
     if ($allowUserCss) {
         $pages["{$userPage}/common.css"] = array('type' => 'style');
         $pages["{$userPage}/" . $context->getSkin() . '.css'] = array('type' => 'style');
     }
     // Hack for bug 26283: if we're on a preview page for a CSS/JS page,
     // we need to exclude that page from this module. In that case, the excludepage
     // parameter will be set to the name of the page we need to exclude.
     $excludepage = $context->getRequest()->getVal('excludepage');
     if (isset($pages[$excludepage])) {
         // This works because $excludepage is generated with getPrefixedDBkey(),
         // just like the keys in $pages[] above
         unset($pages[$excludepage]);
     }
     return $pages;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:39,代码来源:ResourceLoaderUserModule.php

示例3: getPages

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getPages(ResourceLoaderContext $context)
 {
     $useSiteJs = $this->getConfig()->get('UseSiteJs');
     $useSiteCss = $this->getConfig()->get('UseSiteCss');
     if (!$useSiteJs && !$useSiteCss) {
         return array();
     }
     $user = $context->getUserObj();
     if (!$user || $user->isAnon()) {
         return array();
     }
     $pages = array();
     foreach ($user->getEffectiveGroups() as $group) {
         if ($group == '*') {
             continue;
         }
         if ($useSiteJs) {
             $pages["MediaWiki:Group-{$group}.js"] = array('type' => 'script');
         }
         if ($useSiteCss) {
             $pages["MediaWiki:Group-{$group}.css"] = array('type' => 'style');
         }
     }
     return $pages;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:29,代码来源:ResourceLoaderUserGroupsModule.php

示例4: getPages

 /**
  * @param ResourceLoaderContext $context
  * @return array List of pages
  */
 protected function getPages(ResourceLoaderContext $context)
 {
     $config = $this->getConfig();
     $user = $context->getUserObj();
     if ($user->isAnon()) {
         return [];
     }
     // Use localised/normalised variant to ensure $excludepage matches
     $userPage = $user->getUserPage()->getPrefixedDBkey();
     $pages = [];
     if ($config->get('AllowUserCss')) {
         $pages["{$userPage}/common.css"] = ['type' => 'style'];
         $pages["{$userPage}/" . $context->getSkin() . '.css'] = ['type' => 'style'];
     }
     // User group pages are maintained site-wide and enabled with site JS/CSS.
     if ($config->get('UseSiteCss')) {
         foreach ($user->getEffectiveGroups() as $group) {
             if ($group == '*') {
                 continue;
             }
             $pages["MediaWiki:Group-{$group}.css"] = ['type' => 'style'];
         }
     }
     // Hack for T28283: Allow excluding pages for preview on a CSS/JS page.
     // The excludepage parameter is set by OutputPage.
     $excludepage = $context->getRequest()->getVal('excludepage');
     if (isset($pages[$excludepage])) {
         unset($pages[$excludepage]);
     }
     return $pages;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:35,代码来源:ResourceLoaderUserStylesModule.php

示例5: testGetUser

 public function testGetUser()
 {
     $ctx = new ResourceLoaderContext($this->getResourceLoader(), new FauxRequest([]));
     $this->assertSame(null, $ctx->getUser());
     $this->assertTrue($ctx->getUserObj()->isAnon());
     $ctx = new ResourceLoaderContext($this->getResourceLoader(), new FauxRequest(['user' => 'Example']));
     $this->assertSame('Example', $ctx->getUser());
     $this->assertEquals('Example', $ctx->getUserObj()->getName());
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:9,代码来源:ResourceLoaderContextTest.php

示例6: getPages

 /**
  * Get list of pages used by this module
  *
  * @param ResourceLoaderContext $context
  * @return array List of pages
  */
 protected function getPages(ResourceLoaderContext $context)
 {
     $config = $this->getConfig();
     $user = $context->getUserObj();
     if ($user->isAnon()) {
         return [];
     }
     // Use localised/normalised variant to ensure $excludepage matches
     $userPage = $user->getUserPage()->getPrefixedDBkey();
     $pages = [];
     if ($config->get('AllowUserJs')) {
         $pages["{$userPage}/common.js"] = ['type' => 'script'];
         $pages["{$userPage}/" . $context->getSkin() . '.js'] = ['type' => 'script'];
     }
     if ($config->get('AllowUserCss')) {
         $pages["{$userPage}/common.css"] = ['type' => 'style'];
         $pages["{$userPage}/" . $context->getSkin() . '.css'] = ['type' => 'style'];
     }
     $useSiteJs = $config->get('UseSiteJs');
     $useSiteCss = $config->get('UseSiteCss');
     // User group pages are maintained site-wide and enabled with site JS/CSS.
     if ($useSiteJs || $useSiteCss) {
         foreach ($user->getEffectiveGroups() as $group) {
             if ($group == '*') {
                 continue;
             }
             if ($useSiteJs) {
                 $pages["MediaWiki:Group-{$group}.js"] = ['type' => 'script'];
             }
             if ($useSiteCss) {
                 $pages["MediaWiki:Group-{$group}.css"] = ['type' => 'style'];
             }
         }
     }
     // Hack for bug 26283: if we're on a preview page for a CSS/JS page,
     // we need to exclude that page from this module. In that case, the excludepage
     // parameter will be set to the name of the page we need to exclude.
     $excludepage = $context->getRequest()->getVal('excludepage');
     if (isset($pages[$excludepage])) {
         // This works because $excludepage is generated with getPrefixedDBkey(),
         // just like the keys in $pages[] above
         unset($pages[$excludepage]);
     }
     return $pages;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:51,代码来源:ResourceLoaderUserModule.php

示例7: getStyles

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 public function getStyles(ResourceLoaderContext $context)
 {
     if (!$this->getConfig()->get('AllowUserCssPrefs')) {
         return [];
     }
     $options = $context->getUserObj()->getOptions();
     // Build CSS rules
     $rules = [];
     // Underline: 2 = skin default, 1 = always, 0 = never
     if ($options['underline'] < 2) {
         $rules[] = "a { text-decoration: " . ($options['underline'] ? 'underline' : 'none') . "; }";
     }
     $style = implode("\n", $rules);
     if ($this->getFlip($context)) {
         $style = CSSJanus::transform($style, true, false);
     }
     return ['all' => $style];
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:22,代码来源:ResourceLoaderUserCSSPrefsModule.php

示例8: getStyles

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 public function getStyles(ResourceLoaderContext $context)
 {
     if (!$this->getConfig()->get('AllowUserCssPrefs')) {
         return [];
     }
     $options = $context->getUserObj()->getOptions();
     // Build CSS rules
     $rules = [];
     // Underline: 2 = skin default, 1 = always, 0 = never
     if ($options['underline'] < 2) {
         $rules[] = "a { text-decoration: " . ($options['underline'] ? 'underline' : 'none') . "; }";
     }
     if ($options['editfont'] !== 'default') {
         // Double-check that $options['editfont'] consists of safe characters only
         if (preg_match('/^[a-zA-Z0-9_, -]+$/', $options['editfont'])) {
             $rules[] = "textarea { font-family: {$options['editfont']}; }\n";
         }
     }
     $style = implode("\n", $rules);
     if ($this->getFlip($context)) {
         $style = CSSJanus::transform($style, true, false);
     }
     return ['all' => $style];
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:28,代码来源:ResourceLoaderUserCSSPrefsModule.php

示例9: contextUserTokens

 /**
  * Fetch the tokens for the current user.
  *
  * @param ResourceLoaderContext $context
  * @return array List of tokens keyed by token type
  */
 protected function contextUserTokens(ResourceLoaderContext $context)
 {
     $user = $context->getUserObj();
     return array('editToken' => $user->getEditToken(), 'patrolToken' => $user->getEditToken('patrol'), 'watchToken' => $user->getEditToken('watch'));
 }
开发者ID:pirater,项目名称:mediawiki,代码行数:11,代码来源:ResourceLoaderUserTokensModule.php

示例10: getScript

 /**
  * @param ResourceLoaderContext $context
  * @return string
  */
 public function getScript(ResourceLoaderContext $context)
 {
     return Xml::encodeJsCall('mw.user.options.set', [$context->getUserObj()->getOptions(User::GETOPTIONS_EXCLUDE_DEFAULTS)], ResourceLoader::inDebugMode());
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:8,代码来源:ResourceLoaderUserOptionsModule.php


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