[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Resource loader module for user customizations. 4 * 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. 9 * 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. 14 * 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 19 * 20 * @file 21 * @author Trevor Parscal 22 * @author Roan Kattouw 23 */ 24 25 /** 26 * Module for user customizations 27 */ 28 class ResourceLoaderUserModule extends ResourceLoaderWikiModule { 29 30 /* Protected Members */ 31 32 protected $origin = self::ORIGIN_USER_INDIVIDUAL; 33 34 /* Protected Methods */ 35 36 /** 37 * @param ResourceLoaderContext $context 38 * @return array 39 */ 40 protected function getPages( ResourceLoaderContext $context ) { 41 $username = $context->getUser(); 42 43 if ( $username === null ) { 44 return array(); 45 } 46 47 $allowUserJs = $this->getConfig()->get( 'AllowUserJs' ); 48 $allowUserCss = $this->getConfig()->get( 'AllowUserCss' ); 49 50 if ( !$allowUserJs && !$allowUserCss ) { 51 return array(); 52 } 53 54 // Get the normalized title of the user's user page 55 $userpageTitle = Title::makeTitleSafe( NS_USER, $username ); 56 57 if ( !$userpageTitle instanceof Title ) { 58 return array(); 59 } 60 61 $userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works 62 63 $pages = array(); 64 if ( $allowUserJs ) { 65 $pages["$userpage/common.js"] = array( 'type' => 'script' ); 66 $pages["$userpage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' ); 67 } 68 if ( $allowUserCss ) { 69 $pages["$userpage/common.css"] = array( 'type' => 'style' ); 70 $pages["$userpage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' ); 71 } 72 73 // Hack for bug 26283: if we're on a preview page for a CSS/JS page, 74 // we need to exclude that page from this module. In that case, the excludepage 75 // parameter will be set to the name of the page we need to exclude. 76 $excludepage = $context->getRequest()->getVal( 'excludepage' ); 77 if ( isset( $pages[$excludepage] ) ) { 78 // This works because $excludepage is generated with getPrefixedDBkey(), 79 // just like the keys in $pages[] above 80 unset( $pages[$excludepage] ); 81 } 82 return $pages; 83 } 84 85 /* Methods */ 86 87 /** 88 * @return string 89 */ 90 public function getGroup() { 91 return 'user'; 92 } 93 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |