2010-10-19 18:25:42 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @author Trevor Parscal
|
|
|
|
|
* @author Roan Kattouw
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Module for user customizations
|
|
|
|
|
*/
|
|
|
|
|
class ResourceLoaderUserModule extends ResourceLoaderWikiModule {
|
|
|
|
|
|
|
|
|
|
/* Protected Methods */
|
2011-02-04 16:39:17 +00:00
|
|
|
protected $origin = self::ORIGIN_USER_INDIVIDUAL;
|
2010-10-19 18:25:42 +00:00
|
|
|
|
2011-05-21 17:45:20 +00:00
|
|
|
/**
|
|
|
|
|
* @param $context ResourceLoaderContext
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2010-10-19 18:25:42 +00:00
|
|
|
protected function getPages( ResourceLoaderContext $context ) {
|
2010-12-08 20:10:11 +00:00
|
|
|
if ( $context->getUser() ) {
|
2011-08-17 14:55:06 +00:00
|
|
|
// Get the normalized title of the user's user page
|
2010-10-19 18:25:42 +00:00
|
|
|
$username = $context->getUser();
|
2011-08-17 14:55:06 +00:00
|
|
|
$userpageTitle = Title::makeTitleSafe( NS_USER, $username );
|
|
|
|
|
$userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works
|
|
|
|
|
|
2011-08-13 17:27:35 +00:00
|
|
|
$pages = array(
|
2011-08-17 14:55:06 +00:00
|
|
|
"$userpage/common.js" => array( 'type' => 'script' ),
|
|
|
|
|
"$userpage/" . $context->getSkin() . '.js' =>
|
2011-02-08 06:34:38 +00:00
|
|
|
array( 'type' => 'script' ),
|
2011-08-17 14:55:06 +00:00
|
|
|
"$userpage/common.css" => array( 'type' => 'style' ),
|
|
|
|
|
"$userpage/" . $context->getSkin() . '.css' =>
|
2011-02-08 06:34:38 +00:00
|
|
|
array( 'type' => 'style' ),
|
2010-10-19 18:25:42 +00:00
|
|
|
);
|
2011-08-13 17:27:35 +00:00
|
|
|
|
|
|
|
|
// 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] ) ) {
|
2011-08-17 14:55:06 +00:00
|
|
|
// This works because $excludepage is generated with getPrefixedDBkey(),
|
|
|
|
|
// just like the keys in $pages[] above
|
2011-08-13 17:27:35 +00:00
|
|
|
unset( $pages[$excludepage] );
|
|
|
|
|
}
|
|
|
|
|
return $pages;
|
2010-10-19 18:25:42 +00:00
|
|
|
}
|
|
|
|
|
return array();
|
|
|
|
|
}
|
2011-05-21 17:45:20 +00:00
|
|
|
|
2010-10-19 18:25:42 +00:00
|
|
|
/* Methods */
|
2011-05-21 17:45:20 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-10-19 18:25:42 +00:00
|
|
|
public function getGroup() {
|
|
|
|
|
return 'user';
|
|
|
|
|
}
|
|
|
|
|
}
|