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


PHP ResourceLoaderContext::getUser方法代码示例

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


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

示例1: getPages

 protected function getPages(ResourceLoaderContext $context)
 {
     if ($context->getUser()) {
         $username = $context->getUser();
         return array("User:{$username}/common.js" => array('type' => 'script'), "User:{$username}/" . $context->getSkin() . '.js' => array('type' => 'script'), "User:{$username}/common.css" => array('type' => 'style'), "User:{$username}/" . $context->getSkin() . '.css' => array('type' => 'style'));
     }
     return array();
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:8,代码来源:ResourceLoaderUserModule.php

示例2: getPages

 /**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getPages(ResourceLoaderContext $context)
 {
     global $wgUser, $wgUseSiteJs, $wgUseSiteCss;
     $userName = $context->getUser();
     if ($userName === null) {
         return array();
     }
     if (!$wgUseSiteJs && !$wgUseSiteCss) {
         return array();
     }
     // Use $wgUser is possible; allows to skip a lot of code
     if (is_object($wgUser) && $wgUser->getName() == $userName) {
         $user = $wgUser;
     } else {
         $user = User::newFromName($userName);
         if (!$user instanceof User) {
             return array();
         }
     }
     $pages = array();
     foreach ($user->getEffectiveGroups() as $group) {
         if (in_array($group, array('*', 'user'))) {
             continue;
         }
         if ($wgUseSiteJs) {
             $pages["MediaWiki:Group-{$group}.js"] = array('type' => 'script');
         }
         if ($wgUseSiteCss) {
             $pages["MediaWiki:Group-{$group}.css"] = array('type' => 'style');
         }
     }
     return $pages;
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:37,代码来源:ResourceLoaderUserGroupsModule.php

示例3: getUser

 public function getUser()
 {
     if ($this->user === self::INHERIT_VALUE) {
         return $this->context->getUser();
     }
     return $this->user;
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:7,代码来源:DerivativeResourceLoaderContext.php

示例4: getPages

 /**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getPages(ResourceLoaderContext $context)
 {
     $username = $context->getUser();
     if ($username === null) {
         return array();
     }
     // Get the normalized title of the user's user page
     $userpageTitle = Title::makeTitleSafe(NS_USER, $username);
     if (!$userpageTitle instanceof Title) {
         return array();
     }
     $userpage = $userpageTitle->getPrefixedDBkey();
     // Needed so $excludepages works
     $pages = array("{$userpage}/common.js" => array('type' => 'script'), "{$userpage}/" . $context->getSkin() . '.js' => array('type' => 'script'), "{$userpage}/common.css" => array('type' => 'style'), "{$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:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:29,代码来源:ResourceLoaderUserModule.php

示例5: getUser

 public function getUser()
 {
     if (!is_null($this->user)) {
         return $this->user;
     } else {
         return $this->context->getUser();
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:8,代码来源:DerivativeResourceLoaderContext.php

示例6: getPages

 /**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getPages(ResourceLoaderContext $context)
 {
     if ($context->getUser()) {
         $user = User::newFromName($context->getUser());
         if ($user instanceof User) {
             $pages = array();
             foreach ($user->getEffectiveGroups() as $group) {
                 if (in_array($group, array('*', 'user'))) {
                     continue;
                 }
                 $pages["MediaWiki:Group-{$group}.js"] = array('type' => 'script');
                 $pages["MediaWiki:Group-{$group}.css"] = array('type' => 'style');
             }
             return $pages;
         }
     }
     return array();
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:22,代码来源:ResourceLoaderUserGroupsModule.php

示例7: 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

示例8: contextUserOptions

 /**
  * Fetch the context's user options, or if it doesn't match current user,
  * the default options.
  * 
  * @param $context ResourceLoaderContext: Context object
  * @return Array: List of user options keyed by option name
  */
 protected function contextUserOptions(ResourceLoaderContext $context)
 {
     global $wgUser;
     // Verify identity -- this is a private module
     if ($context->getUser() === $wgUser->getName()) {
         return $wgUser->getOptions();
     } else {
         return User::getDefaultOptions();
     }
 }
开发者ID:natalieschauser,项目名称:csp_media_wiki,代码行数:17,代码来源:ResourceLoaderUserOptionsModule.php

示例9: createLoaderQuery

 /**
  * Helper for createLoaderURL()
  *
  * @since 1.24
  * @see makeLoaderQuery
  * @param ResourceLoaderContext $context
  * @param array $extraQuery
  * @return array
  */
 public static function createLoaderQuery(ResourceLoaderContext $context, $extraQuery = array())
 {
     return self::makeLoaderQuery($context->getModules(), $context->getLanguage(), $context->getSkin(), $context->getUser(), $context->getVersion(), $context->getDebug(), $context->getOnly(), $context->getRequest()->getBool('printable'), $context->getRequest()->getBool('handheld'), $extraQuery);
 }
开发者ID:ErdemA,项目名称:mediawiki,代码行数:13,代码来源:ResourceLoader.php

示例10: getStyleURLsForDebug

 /**
  * Get the URL or URLs to load for this module's CSS in debug mode.
  * The default behavior is to return a load.php?only=styles URL for
  * the module, but file-based modules will want to override this to
  * load the files directly. See also getScriptURLsForDebug()
  *
  * @param $context ResourceLoaderContext: Context object
  * @return Array: array( mediaType => array( URL1, URL2, ... ), ... )
  */
 public function getStyleURLsForDebug(ResourceLoaderContext $context)
 {
     $url = ResourceLoader::makeLoaderURL(array($this->getName()), $context->getLanguage(), $context->getSkin(), $context->getUser(), $context->getVersion(), true, 'styles', $context->getRequest()->getBool('printable'), $context->getRequest()->getBool('handheld'));
     return array('all' => array($url));
 }
开发者ID:tempbottle,项目名称:Work,代码行数:14,代码来源:ResourceLoaderModule.php

示例11: getStyleURLsForDebug

 /**
  * Get the URL or URLs to load for this module's CSS in debug mode.
  * The default behavior is to return a load.php?only=styles URL for
  * the module, but file-based modules will want to override this to
  * load the files directly. See also getScriptURLsForDebug()
  * 
  * @param $context ResourceLoaderContext: Context object
  * @return Array: array( mediaType => array( URL1, URL2, ... ), ... )
  */
 public function getStyleURLsForDebug(ResourceLoaderContext $context)
 {
     global $wgLoadScript;
     // TODO factor out to ResourceLoader static method and deduplicate from makeResourceLoaderLink()
     $query = array('modules' => $this->getName(), 'only' => 'styles', 'skin' => $context->getSkin(), 'user' => $context->getUser(), 'debug' => 'true', 'version' => $context->getVersion());
     ksort($query);
     return array('all' => array(wfAppendQuery($wgLoadScript, $query) . '&*'));
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:17,代码来源:ResourceLoaderModule.php


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