| [ PHPXref.com ] | [ Generated: Sun Jul 20 18:08:07 2008 ] | [ html2ps 1.9.4 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 class PaddingSideValue { 4 var $value; 5 var $auto; 6 var $percentage; 7 8 function copy() { 9 $value = new MarginSideValue; 10 $value->value = $this->value; 11 $value->auto = $this->auto; 12 $value->percentage = $this->percentage; 13 return $value; 14 } 15 16 function is_default() { 17 return 18 $this->value == 0 && 19 !$this->auto && 20 !$this->percentage; 21 } 22 23 function init($data) { 24 $value = new PaddingSideValue; 25 $value->value = $data; 26 $value->percentage = $data{strlen($data)-1} === '%' ? (int)($data) : null; 27 $value->auto = $data === 'auto'; 28 return $value; 29 } 30 31 function units2pt($base) { 32 $this->value = units2pt($this->value, $base); 33 } 34 } 35 36 class PaddingValue { 37 var $top; 38 var $bottom; 39 var $left; 40 var $right; 41 42 function copy() { 43 $value = new PaddingValue; 44 $value->top = $this->top->copy(); 45 $value->bottom = $this->bottom->copy(); 46 $value->left = $this->left->copy(); 47 $value->right = $this->right->copy(); 48 return $value; 49 } 50 51 function is_default() { 52 return 53 $this->left->is_default() && 54 $this->right->is_default() && 55 $this->top->is_default() && 56 $this->bottom->is_default(); 57 } 58 59 function init($data) { 60 $value = new PaddingValue; 61 $value->top = PaddingSideValue::init($data[0]); 62 $value->right = PaddingSideValue::init($data[1]); 63 $value->bottom = PaddingSideValue::init($data[2]); 64 $value->left = PaddingSideValue::init($data[3]); 65 return $value; 66 } 67 68 function units2pt($base) { 69 $this->top->units2pt($base); 70 $this->bottom->units2pt($base); 71 $this->left->units2pt($base); 72 $this->right->units2pt($base); 73 } 74 } 75 76 class CSSPadding extends CSSProperty { 77 var $default_value; 78 79 function CSSPadding() { 80 $this->default_value = $this->parse("0"); 81 $this->CSSProperty(false, false); 82 } 83 84 function default_value() { return $this->default_value->copy(); } 85 86 function parse_in($value) { 87 $values = explode(" ",trim($value)); 88 switch (count($values)) { 89 case 1: 90 $v1 = $values[0]; 91 return array($v1, $v1, $v1, $v1); 92 case 2: 93 $v1 = $values[0]; 94 $v2 = $values[1]; 95 return array($v1, $v2, $v1, $v2); 96 case 3: 97 $v1 = $values[0]; 98 $v2 = $values[1]; 99 $v3 = $values[2]; 100 return array($v1, $v2, $v3, $v2); 101 case 4: 102 $v1 = $values[0]; 103 $v2 = $values[1]; 104 $v3 = $values[2]; 105 $v4 = $values[3]; 106 return array($v1, $v2, $v3, $v4); 107 default: 108 // We newer should get there, because 'padding' value can contain from 1 to 4 widths 109 return ""; 110 }; 111 } 112 113 function parse($string) { 114 return PaddingValue::init($this->parse_in($string)); 115 } 116 } 117 118 class CSSPaddingTop extends CSSSubProperty { 119 function parse($value) { return PaddingSideValue::init($value); } 120 } 121 122 class CSSPaddingRight extends CSSSubProperty { 123 function parse($value) { return PaddingSideValue::init($value); } 124 } 125 126 class CSSPaddingLeft extends CSSSubProperty { 127 function parse($value) { return PaddingSideValue::init($value); } 128 } 129 130 class CSSPaddingBottom extends CSSSubProperty { 131 function parse($value) { return PaddingSideValue::init($value); } 132 } 133 134 $ph = new CSSPadding; 135 register_css_property('padding' ,$ph); 136 register_css_property('padding-left' ,new CSSPaddingLeft($ph, 'left')); 137 register_css_property('padding-right' ,new CSSPaddingRight($ph, 'right')); 138 register_css_property('padding-top' ,new CSSPaddingTop($ph, 'top')); 139 register_css_property('padding-bottom',new CSSPaddingBottom($ph, 'bottom')); 140 141 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |