當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。