[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/libs/ -> CSSJanus.php (summary)

PHP port of CSSJanus. 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.

File Size: 458 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

CSSJanus:: (12 methods):
  buildPatterns()
  transform()
  fixDirection()
  fixLtrRtlInURL()
  fixLeftRightInURL()
  fixLeftAndRight()
  fixCursorProperties()
  fixFourPartNotation()
  fixBorderRadius()
  fixShadows()
  fixBackgroundPosition()
  calculateNewBackgroundPosition()

CSSJanusTokenizer:: (5 methods):
  __construct()
  tokenize()
  tokenizeCallback()
  detokenize()
  detokenizeCallback()


Class: CSSJanus  - X-Ref

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
buildPatterns()   X-Ref
Build patterns we can't define above because they depend on other patterns.


transform($css, $swapLtrRtlInURL = false, $swapLeftRightInURL = false)   X-Ref
Transform an LTR stylesheet to RTL

param: string $css stylesheet to transform
param: $swapLtrRtlInURL Boolean: If true, swap 'ltr' and 'rtl' in URLs
param: $swapLeftRightInURL Boolean: If true, swap 'left' and 'right' in URLs
return: string Transformed stylesheet

fixDirection($css)   X-Ref
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 https://code.google.com/p/cssjanus/issues/detail?id=15

param: $css string
return: string

fixLtrRtlInURL($css)   X-Ref
Replace 'ltr' with 'rtl' and vice versa in background URLs

param: $css string
return: string

fixLeftRightInURL($css)   X-Ref
Replace 'left' with 'right' and vice versa in background URLs

param: $css string
return: string

fixLeftAndRight($css)   X-Ref
Flip rules like left: , padding-right: , etc.

param: $css string
return: string

fixCursorProperties($css)   X-Ref
Flip East and West in rules like cursor: nw-resize;

param: $css string
return: string

fixFourPartNotation($css)   X-Ref
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 https://code.google.com/p/cssjanus/issues/detail?id=16
param: $css string
return: string

fixBorderRadius($css)   X-Ref
Swaps appropriate corners in border-radius values.

param: $css string
return: string

fixShadows($css)   X-Ref
Negates horizontal offset in box-shadow and text-shadow rules.

param: $css string
return: string

fixBackgroundPosition($css)   X-Ref
Flip horizontal background percentages.

param: $css string
return: string

calculateNewBackgroundPosition($matches)   X-Ref
Callback for fixBackgroundPosition()

param: $matches array
return: string

Class: CSSJanusTokenizer  - X-Ref

Utility class used by CSSJanus that tokenizes and untokenizes things we want
to protect from being janused.

__construct($regex, $token)   X-Ref
Constructor

param: string $regex Regular expression whose matches to replace by a token.
param: string $token Token

tokenize($str)   X-Ref
Replace all occurrences of $regex in $str with a token and remember
the original strings.

param: string $str to tokenize
return: string Tokenized string

tokenizeCallback($matches)   X-Ref

param: $matches array
return: string

detokenize($str)   X-Ref
Replace tokens with their originals. If multiple strings were tokenized, it's important they be
detokenized in exactly the SAME ORDER.

param: string $str previously run through tokenize()
return: string Original string

detokenizeCallback($matches)   X-Ref

param: $matches
return: mixed



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1