當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ResourceLoaderContext類代碼示例

本文整理匯總了PHP中ResourceLoaderContext的典型用法代碼示例。如果您正苦於以下問題:PHP ResourceLoaderContext類的具體用法?PHP ResourceLoaderContext怎麽用?PHP ResourceLoaderContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ResourceLoaderContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPages

 public function getPages(ResourceLoaderContext $context)
 {
     $pages = array();
     $missingCallback = $context->getRequest()->getVal('missingCallback');
     if ($this->type) {
         foreach ($this->articles as $article) {
             $pageKey = $article['title'];
             $type = isset($article['type']) ? $article['type'] : $this->type;
             $pageInfo = array('type' => $type);
             if (isset($article['originalName'])) {
                 $pageInfo['originalName'] = $article['originalName'];
             }
             if ($missingCallback) {
                 $pageInfo['missingCallback'] = $missingCallback;
             }
             if (!empty($article['cityId'])) {
                 $pageIndex = 'fakename' . $this->id++;
                 $pageInfo['city_id'] = intval($article['cityId']);
                 $pageInfo['title'] = $article['title'];
                 // Unable to resolve wiki to cityId
             } else {
                 if (isset($article['cityId'])) {
                     $pageInfo['missing'] = true;
                 }
             }
             $pages[$pageKey] = $pageInfo;
         }
     }
     return $pages;
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:30,代碼來源:ResourceLoaderCustomWikiModule.class.php

示例2: useFileCache

 /**
  * Check if an RL request can be cached.
  * Caller is responsible for checking if any modules are private.
  * @param $context ResourceLoaderContext
  * @return bool
  */
 public static function useFileCache(ResourceLoaderContext $context)
 {
     global $wgUseFileCache, $wgDefaultSkin, $wgLanguageCode;
     if (!$wgUseFileCache) {
         return false;
     }
     // Get all query values
     $queryVals = $context->getRequest()->getValues();
     foreach ($queryVals as $query => $val) {
         if ($query === 'modules' || $query === 'version' || $query === '*') {
             continue;
             // note: &* added as IE fix
         } elseif ($query === 'skin' && $val === $wgDefaultSkin) {
             continue;
         } elseif ($query === 'lang' && $val === $wgLanguageCode) {
             continue;
         } elseif ($query === 'only' && in_array($val, array('styles', 'scripts'))) {
             continue;
         } elseif ($query === 'debug' && $val === 'false') {
             continue;
         }
         return false;
     }
     return true;
     // cacheable
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:32,代碼來源:ResourceFileCache.php

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

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

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

示例6: useFileCache

 /**
  * Check if an RL request can be cached.
  * Caller is responsible for checking if any modules are private.
  * @param ResourceLoaderContext $context
  * @return bool
  */
 public static function useFileCache(ResourceLoaderContext $context)
 {
     global $wgUseFileCache, $wgDefaultSkin, $wgLanguageCode;
     if (!$wgUseFileCache) {
         return false;
     }
     // Get all query values
     $queryVals = $context->getRequest()->getValues();
     foreach ($queryVals as $query => $val) {
         if (in_array($query, array('modules', 'image', 'variant', 'version', '*'))) {
             // Use file cache regardless of the value of this parameter
             continue;
             // note: &* added as IE fix
         } elseif ($query === 'skin' && $val === $wgDefaultSkin) {
             continue;
         } elseif ($query === 'lang' && $val === $wgLanguageCode) {
             continue;
         } elseif ($query === 'only' && in_array($val, array('styles', 'scripts'))) {
             continue;
         } elseif ($query === 'debug' && $val === 'false') {
             continue;
         } elseif ($query === 'format' && $val === 'rasterized') {
             continue;
         }
         return false;
     }
     return true;
     // cacheable
 }
開發者ID:eliagbayani,項目名稱:LiteratureEditor,代碼行數:35,代碼來源:ResourceFileCache.php

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

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

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

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

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

示例12: getPages

 /**
  * Get list of pages used by this module
  *
  * @param ResourceLoaderContext $context
  * @return array List of pages
  */
 protected function getPages(ResourceLoaderContext $context)
 {
     $pages = [];
     if ($this->getConfig()->get('UseSiteJs')) {
         $pages['MediaWiki:Common.js'] = ['type' => 'script'];
         $pages['MediaWiki:' . ucfirst($context->getSkin()) . '.js'] = ['type' => 'script'];
     }
     return $pages;
 }
開發者ID:paladox,項目名稱:mediawiki,代碼行數:15,代碼來源:ResourceLoaderSiteModule.php

示例13: getModifiedTime

 /**
  * @param $context ResourceLoaderContext
  * @return array|int|Mixed
  */
 public function getModifiedTime(ResourceLoaderContext $context)
 {
     $hash = $context->getHash();
     if (isset($this->modifiedTime[$hash])) {
         return $this->modifiedTime[$hash];
     }
     global $wgUser;
     return $this->modifiedTime[$hash] = wfTimestamp(TS_UNIX, $wgUser->getTouched());
 }
開發者ID:laiello,項目名稱:media-wiki-law,代碼行數:13,代碼來源:ResourceLoaderUserCSSPrefsModule.php

示例14: getPages

 /**
  * Gets list of pages used by this module
  *
  * @param $context ResourceLoaderContext
  *
  * @return Array: List of pages
  */
 protected function getPages(ResourceLoaderContext $context)
 {
     global $wgHandheldStyle;
     $pages = array('MediaWiki:Common.js' => array('type' => 'script'), 'MediaWiki:Common.css' => array('type' => 'style'), 'MediaWiki:' . ucfirst($context->getSkin()) . '.js' => array('type' => 'script'), 'MediaWiki:' . ucfirst($context->getSkin()) . '.css' => array('type' => 'style'), 'MediaWiki:Print.css' => array('type' => 'style', 'media' => 'print'));
     if ($wgHandheldStyle) {
         $pages['MediaWiki:Handheld.css'] = array('type' => 'style', 'media' => 'handheld');
     }
     return $pages;
 }
開發者ID:eFFemeer,項目名稱:seizamcore,代碼行數:16,代碼來源:ResourceLoaderSiteModule.php

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


注:本文中的ResourceLoaderContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。