3 * Resource loader 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
21 * @author Trevor Parscal
22 * @author Roan Kattouw
26 * Module for user customizations
28 class ResourceLoaderUserModule
extends ResourceLoaderWikiModule
{
30 /* Protected Members */
32 protected $origin = self
::ORIGIN_USER_INDIVIDUAL
;
34 /* Protected Methods */
37 * @param ResourceLoaderContext $context
40 protected function getPages( ResourceLoaderContext
$context ) {
41 $allowUserJs = $this->getConfig()->get( 'AllowUserJs' );
42 $allowUserCss = $this->getConfig()->get( 'AllowUserCss' );
43 if ( !$allowUserJs && !$allowUserCss ) {
47 $user = $context->getUserObj();
48 if ( !$user ||
$user->isAnon() ) {
52 // Needed so $excludepages works
53 $userPage = $user->getUserPage()->getPrefixedDBkey();
57 $pages["$userPage/common.js"] = array( 'type' => 'script' );
58 $pages["$userPage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' );
60 if ( $allowUserCss ) {
61 $pages["$userPage/common.css"] = array( 'type' => 'style' );
62 $pages["$userPage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' );
65 // Hack for bug 26283: if we're on a preview page for a CSS/JS page,
66 // we need to exclude that page from this module. In that case, the excludepage
67 // parameter will be set to the name of the page we need to exclude.
68 $excludepage = $context->getRequest()->getVal( 'excludepage' );
69 if ( isset( $pages[$excludepage] ) ) {
70 // This works because $excludepage is generated with getPrefixedDBkey(),
71 // just like the keys in $pages[] above
72 unset( $pages[$excludepage] );
82 public function getGroup() {