MediaWiki
REL1_19
|
00001 <?php 00026 class ResourceLoaderUserCSSPrefsModule extends ResourceLoaderModule { 00027 00028 /* Protected Members */ 00029 00030 protected $modifiedTime = array(); 00031 00032 protected $origin = self::ORIGIN_CORE_INDIVIDUAL; 00033 00034 /* Methods */ 00035 00040 public function getModifiedTime( ResourceLoaderContext $context ) { 00041 $hash = $context->getHash(); 00042 if ( isset( $this->modifiedTime[$hash] ) ) { 00043 return $this->modifiedTime[$hash]; 00044 } 00045 00046 global $wgUser; 00047 return $this->modifiedTime[$hash] = wfTimestamp( TS_UNIX, $wgUser->getTouched() ); 00048 } 00049 00054 public function getStyles( ResourceLoaderContext $context ) { 00055 global $wgAllowUserCssPrefs, $wgUser; 00056 00057 if ( $wgAllowUserCssPrefs ) { 00058 $options = $wgUser->getOptions(); 00059 00060 // Build CSS rules 00061 $rules = array(); 00062 00063 // Underline: 2 = browser default, 1 = always, 0 = never 00064 if ( $options['underline'] < 2 ) { 00065 $rules[] = "a { text-decoration: " . 00066 ( $options['underline'] ? 'underline' : 'none' ) . "; }"; 00067 } else { 00068 # The scripts of these languages are very hard to read with underlines 00069 $rules[] = 'a:lang(ar), a:lang(ckb), a:lang(fa),a:lang(kk-arab), ' . 00070 'a:lang(mzn), a:lang(ps), a:lang(ur) { text-decoration: none; }'; 00071 } 00072 if ( $options['highlightbroken'] ) { 00073 $rules[] = "a.new, #quickbar a.new { color: #ba0000; }\n"; 00074 } else { 00075 $rules[] = "a.new, #quickbar a.new, a.stub, #quickbar a.stub { color: inherit; }"; 00076 $rules[] = "a.new:after, #quickbar a.new:after { content: '?'; color: #ba0000; }"; 00077 $rules[] = "a.stub:after, #quickbar a.stub:after { content: '!'; color: #772233; }"; 00078 } 00079 if ( $options['justify'] ) { 00080 $rules[] = "#article, #bodyContent, #mw_content { text-align: justify; }\n"; 00081 } 00082 if ( !$options['showtoc'] ) { 00083 $rules[] = "#toc { display: none; }\n"; 00084 } 00085 if ( !$options['editsection'] ) { 00086 $rules[] = ".editsection { display: none; }\n"; 00087 } 00088 if ( $options['editfont'] !== 'default' ) { 00089 $rules[] = "textarea { font-family: {$options['editfont']}; }\n"; 00090 } 00091 $style = implode( "\n", $rules ); 00092 if ( $this->getFlip( $context ) ) { 00093 $style = CSSJanus::transform( $style, true, false ); 00094 } 00095 return array( 'all' => $style ); 00096 } 00097 return array(); 00098 } 00099 00103 public function getGroup() { 00104 return 'private'; 00105 } 00106 00110 public function getDependencies() { 00111 return array( 'mediawiki.user' ); 00112 } 00113 }