thumb_handler.php doesn't seem to extract path_info correctly
[mediawiki.git] / includes / resourceloader / ResourceLoaderUserCSSPrefsModule.php
blob7b4b668de367e0a109792d10be32dd430f8a4866
1 <?php
2 /**
3 * Resource loader module for user preference 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 preference customizations
28 class ResourceLoaderUserCSSPrefsModule extends ResourceLoaderModule {
30 /* Protected Members */
32 protected $modifiedTime = array();
34 protected $origin = self::ORIGIN_CORE_INDIVIDUAL;
36 /* Methods */
38 /**
39 * @param $context ResourceLoaderContext
40 * @return array|int|Mixed
42 public function getModifiedTime( ResourceLoaderContext $context ) {
43 $hash = $context->getHash();
44 if ( isset( $this->modifiedTime[$hash] ) ) {
45 return $this->modifiedTime[$hash];
48 global $wgUser;
49 return $this->modifiedTime[$hash] = wfTimestamp( TS_UNIX, $wgUser->getTouched() );
52 /**
53 * @param $context ResourceLoaderContext
54 * @return array
56 public function getStyles( ResourceLoaderContext $context ) {
57 global $wgAllowUserCssPrefs, $wgUser;
59 if ( !$wgAllowUserCssPrefs ) {
60 return array();
63 $options = $wgUser->getOptions();
65 // Build CSS rules
66 $rules = array();
68 // Underline: 2 = browser default, 1 = always, 0 = never
69 if ( $options['underline'] < 2 ) {
70 $rules[] = "a { text-decoration: " .
71 ( $options['underline'] ? 'underline' : 'none' ) . "; }";
72 } else {
73 # The scripts of these languages are very hard to read with underlines
74 $rules[] = 'a:lang(ar), a:lang(ckb), a:lang(fa),a:lang(kk-arab), ' .
75 'a:lang(mzn), a:lang(ps), a:lang(ur) { text-decoration: none; }';
77 if ( $options['justify'] ) {
78 $rules[] = "#article, #bodyContent, #mw_content { text-align: justify; }\n";
80 if ( !$options['showtoc'] ) {
81 $rules[] = "#toc { display: none; }\n";
83 if ( !$options['editsection'] ) {
84 $rules[] = ".mw-editsection { display: none; }\n";
86 if ( $options['editfont'] !== 'default' ) {
87 // Double-check that $options['editfont'] consists of safe characters only
88 if ( preg_match( '/^[a-zA-Z0-9_, -]+$/', $options['editfont'] ) ) {
89 $rules[] = "textarea { font-family: {$options['editfont']}; }\n";
92 $style = implode( "\n", $rules );
93 if ( $this->getFlip( $context ) ) {
94 $style = CSSJanus::transform( $style, true, false );
96 return array( 'all' => $style );
99 /**
100 * @return string
102 public function getGroup() {
103 return 'private';
107 * @return array
109 public function getDependencies() {
110 return array( 'mediawiki.user' );