当前位置: 首页>>代码示例>>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;未经允许,请勿转载。