Class HTMLPurifier_UnitConverter

Description

Class for converting between different unit-lengths as specified by CSS.

Located in /lib/core/Parsers/htmlpurifier/HTMLPurifier.standalone.php (line 7273)


	
			
Class Constant Summary
 DIGITAL = 3
 ENGLISH = 1
 METRIC = 2
Variable Summary
static mixed $units
Method Summary
HTMLPurifier_UnitConverter __construct ([ $output_precision = 4], [ $internal_precision = 10], [ $force_no_bcmath = false])
void convert (HTMLPurifier_Length $length, string $to_unit)
int getSigFigs (string $n)
Variables
static mixed $units = array(
self::ENGLISH => array(
'px' => 3, // This is as per CSS 2.1 and Firefox. Your mileage may vary
'pt' => 4,
'pc' => 48,
'in' => 288,
self::METRIC => array('pt', '0.352777778', 'mm'),),self::METRIC=>array('mm'=>1,'cm'=>10,self::ENGLISH=>array('mm','2.83464567','pt'),),)
(line 7289)

Units information array. Units are grouped into measuring systems

(English, Metric), and are assigned an integer representing the conversion factor between that unit and the smallest unit in the system. Numeric indexes are actually magical constants that encode conversion data from one system to the next, with a O(n^2) constraint on memory (this is generally not a problem, since the number of measuring systems is small.)

  • access: protected
mixed $internalPrecision (line 7312)

Bcmath precision for internal calculations.

  • access: protected
mixed $outputPrecision (line 7307)

Minimum bcmath precision for output.

  • access: protected
Methods
Constructor __construct (line 7319)
  • access: public
HTMLPurifier_UnitConverter __construct ([ $output_precision = 4], [ $internal_precision = 10], [ $force_no_bcmath = false])
  • $output_precision
  • $internal_precision
  • $force_no_bcmath
convert (line 7343)

Converts a length object of one unit into another unit.

  • access: public
void convert (HTMLPurifier_Length $length, string $to_unit)
  • HTMLPurifier_Length $length: Instance of HTMLPurifier_Length to convert. You must validate() it before passing it here!
  • string $to_unit: Unit to convert to.
getSigFigs (line 7439)

Returns the number of significant figures in a string number.

  • return: number of sigfigs
  • access: public
int getSigFigs (string $n)
  • string $n: Decimal number
Class Constants
DIGITAL = 3 (line 7278)
ENGLISH = 1 (line 7276)
METRIC = 2 (line 7277)

Documentation generated on Sun, 06 Mar 2011 00:24:13 -0500 by phpDocumentor 1.4.3