Expose $wgMaxArticleSize in siteinfo query api
[mediawiki.git] / includes / resourceloader / ResourceLoaderUserModule.php
blob8d4f263493a5ec3ec2b3aa1a597fa30f235a81b0
1 <?php
2 /**
3 * ResourceLoader module for user customizations.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @author Trevor Parscal
22 * @author Roan Kattouw
25 /**
26 * Module for user customizations
28 class ResourceLoaderUserModule extends ResourceLoaderWikiModule {
30 protected $origin = self::ORIGIN_USER_INDIVIDUAL;
31 protected $targets = [ 'desktop', 'mobile' ];
33 /**
34 * Get list of pages used by this module
36 * @param ResourceLoaderContext $context
37 * @return array List of pages
39 protected function getPages( ResourceLoaderContext $context ) {
40 $config = $this->getConfig();
41 $user = $context->getUserObj();
42 if ( $user->isAnon() ) {
43 return [];
46 // Use localised/normalised variant to ensure $excludepage matches
47 $userPage = $user->getUserPage()->getPrefixedDBkey();
48 $pages = [];
50 if ( $config->get( 'AllowUserJs' ) ) {
51 $pages["$userPage/common.js"] = [ 'type' => 'script' ];
52 $pages["$userPage/" . $context->getSkin() . '.js'] = [ 'type' => 'script' ];
55 if ( $config->get( 'AllowUserCss' ) ) {
56 $pages["$userPage/common.css"] = [ 'type' => 'style' ];
57 $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
60 $useSiteJs = $config->get( 'UseSiteJs' );
61 $useSiteCss = $config->get( 'UseSiteCss' );
62 // User group pages are maintained site-wide and enabled with site JS/CSS.
63 if ( $useSiteJs || $useSiteCss ) {
64 foreach ( $user->getEffectiveGroups() as $group ) {
65 if ( $group == '*' ) {
66 continue;
68 if ( $useSiteJs ) {
69 $pages["MediaWiki:Group-$group.js"] = [ 'type' => 'script' ];
71 if ( $useSiteCss ) {
72 $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
77 // Hack for bug 26283: if we're on a preview page for a CSS/JS page,
78 // we need to exclude that page from this module. In that case, the excludepage
79 // parameter will be set to the name of the page we need to exclude.
80 $excludepage = $context->getRequest()->getVal( 'excludepage' );
81 if ( isset( $pages[$excludepage] ) ) {
82 // This works because $excludepage is generated with getPrefixedDBkey(),
83 // just like the keys in $pages[] above
84 unset( $pages[$excludepage] );
87 return $pages;
90 /**
91 * Get group name
93 * @return string
95 public function getGroup() {
96 return 'user';