MediaWiki  1.23.2
ResourceLoaderUserCSSPrefsModule.php
Go to the documentation of this file.
1 <?php
29 
30  /* Protected Members */
31 
32  protected $modifiedTime = array();
33 
35 
36  /* Methods */
37 
42  public function getModifiedTime( ResourceLoaderContext $context ) {
43  $hash = $context->getHash();
44  if ( !isset( $this->modifiedTime[$hash] ) ) {
46  $this->modifiedTime[$hash] = wfTimestamp( TS_UNIX, $wgUser->getTouched() );
47  }
48 
49  return $this->modifiedTime[$hash];
50  }
51 
56  public function getStyles( ResourceLoaderContext $context ) {
57  global $wgAllowUserCssPrefs, $wgUser;
58 
59  if ( !$wgAllowUserCssPrefs ) {
60  return array();
61  }
62 
63  $options = $wgUser->getOptions();
64 
65  // Build CSS rules
66  $rules = array();
67 
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(kk-arab), a:lang(mzn), ' .
75  'a:lang(ps), a:lang(ur) { text-decoration: none; }';
76  }
77  if ( $options['editfont'] !== 'default' ) {
78  // Double-check that $options['editfont'] consists of safe characters only
79  if ( preg_match( '/^[a-zA-Z0-9_, -]+$/', $options['editfont'] ) ) {
80  $rules[] = "textarea { font-family: {$options['editfont']}; }\n";
81  }
82  }
83  $style = implode( "\n", $rules );
84  if ( $this->getFlip( $context ) ) {
85  $style = CSSJanus::transform( $style, true, false );
86  }
87  return array( 'all' => $style );
88  }
89 
93  public function getGroup() {
94  return 'private';
95  }
96 
100  public function getDependencies() {
101  return array( 'mediawiki.user' );
102  }
103 }
ResourceLoaderContext
Object passed around to modules which contains information about the state of a specific loader reque...
Definition: ResourceLoaderContext.php:29
$wgUser
$wgUser
Definition: Setup.php:552
ResourceLoaderModule\getFlip
getFlip( $context)
Definition: ResourceLoaderModule.php:115
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ResourceLoaderUserCSSPrefsModule\getDependencies
getDependencies()
Definition: ResourceLoaderUserCSSPrefsModule.php:100
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2483
ResourceLoaderUserCSSPrefsModule\getModifiedTime
getModifiedTime(ResourceLoaderContext $context)
Definition: ResourceLoaderUserCSSPrefsModule.php:42
ResourceLoaderUserCSSPrefsModule\$modifiedTime
$modifiedTime
Definition: ResourceLoaderUserCSSPrefsModule.php:32
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
ResourceLoaderUserCSSPrefsModule\getGroup
getGroup()
Definition: ResourceLoaderUserCSSPrefsModule.php:93
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1530
ResourceLoaderUserCSSPrefsModule
Module for user preference customizations.
Definition: ResourceLoaderUserCSSPrefsModule.php:28
ResourceLoaderModule\ORIGIN_CORE_INDIVIDUAL
const ORIGIN_CORE_INDIVIDUAL
Definition: ResourceLoaderModule.php:40
ResourceLoaderUserCSSPrefsModule\getStyles
getStyles(ResourceLoaderContext $context)
Definition: ResourceLoaderUserCSSPrefsModule.php:56
$hash
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
Definition: hooks.txt:2697
ResourceLoaderModule
Abstraction for resource loader modules, with name registration and maxage functionality.
Definition: ResourceLoaderModule.php:28
TS_UNIX
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
Definition: GlobalFunctions.php:2426
CSSJanus\transform
static transform( $css, $swapLtrRtlInURL=false, $swapLeftRightInURL=false)
Transform an LTR stylesheet to RTL.
Definition: CSSJanus.php:139
ResourceLoaderContext\getHash
getHash()
Definition: ResourceLoaderContext.php:231
ResourceLoaderUserCSSPrefsModule\$origin
$origin
Definition: ResourceLoaderUserCSSPrefsModule.php:34