MediaWiki  REL1_19
CSSJanus Class Reference

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. More...

List of all members.

Static Public Member Functions

static transform ($css, $swapLtrRtlInURL=false, $swapLeftRightInURL=false)
 Transform an LTR stylesheet to RTL.

Static Private Member Functions

static buildPatterns ()
 Build patterns we can't define above because they depend on other patterns.
static calculateNewBackgroundPosition ($matches)
 Callback for calculateNewBackgroundPosition()
static fixBackgroundPosition ($css)
 Flip horizontal background percentages.
static fixCursorProperties ($css)
 Flip East and West in rules like cursor: nw-resize;.
static fixDirection ($css)
 Replace direction: ltr; with direction: rtl; and vice versa.
static fixFourPartNotation ($css)
 Swap the second and fourth parts in four-part notation rules like padding: 1px 2px 3px 4px;.
static fixLeftAndRight ($css)
 Flip rules like left: , padding-right: , etc.
static fixLeftRightInURL ($css)
 Replace 'left' with 'right' and vice versa in background URLs.
static fixLtrRtlInURL ($css)
 Replace 'ltr' with 'rtl' and vice versa in background URLs.

Static Private Attributes

static $patterns

Detailed Description

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 This is a PHP port of CSSJanus, a utility that transforms CSS style sheets written for LTR to RTL.

The original Python version of CSSJanus is Copyright 2008 by Google Inc. and is distributed under the Apache license. This PHP port is Copyright 2010 by Roan Kattouw and is dual-licensed under the GPL (as in the comment above) and the Apache (as in the original code) licenses.

Original code: http://code.google.com/p/cssjanus/source/browse/trunk/cssjanus.py License of original code: http://code.google.com/p/cssjanus/source/browse/trunk/LICENSE

Author:
Roan Kattouw

Definition at line 34 of file CSSJanus.php.


Member Function Documentation

static CSSJanus::buildPatterns ( ) [static, private]

Build patterns we can't define above because they depend on other patterns.

Definition at line 82 of file CSSJanus.php.

References $patterns.

Referenced by transform().

Here is the caller graph for this function:

static CSSJanus::calculateNewBackgroundPosition ( matches) [static, private]

Callback for calculateNewBackgroundPosition()

Parameters:
$matchesarray
Returns:
string

Definition at line 281 of file CSSJanus.php.

References $matches.

static CSSJanus::fixBackgroundPosition ( css) [static, private]

Flip horizontal background percentages.

Parameters:
$cssstring
Returns:
string

Definition at line 267 of file CSSJanus.php.

Referenced by transform().

Here is the caller graph for this function:

static CSSJanus::fixCursorProperties ( css) [static, private]

Flip East and West in rules like cursor: nw-resize;.

Parameters:
$cssstring
Returns:
string

Definition at line 234 of file CSSJanus.php.

Referenced by transform().

Here is the caller graph for this function:

static CSSJanus::fixDirection ( css) [static, private]

Replace direction: ltr; with direction: rtl; and vice versa.

The original implementation only does this inside body selectors and misses "body\n{\ndirection:ltr;\n}". This function does not have these problems.

See http://code.google.com/p/cssjanus/issues/detail?id=15 and TODO: URL

Parameters:
$cssstring
Returns:
string

Definition at line 181 of file CSSJanus.php.

Referenced by transform().

Here is the caller graph for this function:

static CSSJanus::fixFourPartNotation ( css) [static, private]

Swap the second and fourth parts in four-part notation rules like padding: 1px 2px 3px 4px;.

Unlike the original implementation, this function doesn't suffer from the bug where whitespace is not preserved when flipping four-part rules and four-part color rules with multiple whitespace characters between colors are not recognized. See http://code.google.com/p/cssjanus/issues/detail?id=16

Parameters:
$cssstring
Returns:
string

Definition at line 255 of file CSSJanus.php.

Referenced by transform().

Here is the caller graph for this function:

static CSSJanus::fixLeftAndRight ( css) [static, private]

Flip rules like left: , padding-right: , etc.

Parameters:
$cssstring
Returns:
string

Definition at line 221 of file CSSJanus.php.

Referenced by transform().

Here is the caller graph for this function:

static CSSJanus::fixLeftRightInURL ( css) [static, private]

Replace 'left' with 'right' and vice versa in background URLs.

Parameters:
$cssstring
Returns:
string

Definition at line 208 of file CSSJanus.php.

Referenced by transform().

Here is the caller graph for this function:

static CSSJanus::fixLtrRtlInURL ( css) [static, private]

Replace 'ltr' with 'rtl' and vice versa in background URLs.

Parameters:
$cssstring
Returns:
string

Definition at line 195 of file CSSJanus.php.

Referenced by transform().

Here is the caller graph for this function:

static CSSJanus::transform ( css,
swapLtrRtlInURL = false,
swapLeftRightInURL = false 
) [static]

Transform an LTR stylesheet to RTL.

Parameters:
$cssString: stylesheet to transform
$swapLtrRtlInURLBoolean: If true, swap 'ltr' and 'rtl' in URLs
$swapLeftRightInURLBoolean: If true, swap 'left' and 'right' in URLs
Returns:
Transformed stylesheet

Definition at line 127 of file CSSJanus.php.

References buildPatterns(), fixBackgroundPosition(), fixCursorProperties(), fixDirection(), fixFourPartNotation(), fixLeftAndRight(), fixLeftRightInURL(), and fixLtrRtlInURL().

Referenced by OutputPage\addInlineStyle(), OutputPage\buildCssLinks(), WebInstallerOutput\getCSS(), ResourceLoaderUserCSSPrefsModule\getStyles(), ResourceLoaderWikiModule\getStyles(), and ResourceLoaderFileModule\readStyleFile().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

CSSJanus::$patterns [static, private]

Definition at line 36 of file CSSJanus.php.

Referenced by buildPatterns().


The documentation for this class was generated from the following file: