1<?php 2// $Header: /cvsroot/html2ps/css.pseudo.align.inc.php,v 1.13 2006/09/07 18:38:14 Konstantin Exp $ 3 4define('PA_LEFT',0); 5define('PA_CENTER',1); 6define('PA_RIGHT',2); 7 8// This is a pseudo CSS property for 9 10class CSSPseudoAlign extends CSSPropertyHandler { 11 function CSSPseudoAlign() { $this->CSSPropertyHandler(true, true); } 12 13 function default_value() { 14 return PA_LEFT; 15 } 16 17 function inherit($old_state, &$new_state) { 18 // This pseudo-property is not inherited by tables 19 // As current box display value may not be know at the moment of inheriting, 20 // we'll use parent display value, stopping inheritance on the table-row/table-group level 21 22 // Determine parent 'display' value 23 $parent_display = $old_state[CSS_DISPLAY]; 24 25 $this->replace_array(($parent_display === 'table') ? $this->default_value() : $this->get($old_state), 26 $new_state); 27 } 28 29 function parse($value) { 30 // Convert value to lower case, as html allows values 31 // in both cases to be entered 32 // 33 $value = strtolower($value); 34 35 if ($value === 'left') { return PA_LEFT; } 36 if ($value === 'right') { return PA_RIGHT; } 37 if ($value === 'center') { return PA_CENTER; } 38 39 // For compatibility with non-valid HTML 40 // 41 if ($value === 'middle') { return PA_CENTER; } 42 43 return $this->default_value(); 44 } 45 46 function value2pdf($value) { 47 switch ($value) { 48 case PA_LEFT: 49 return "ta_left"; 50 case PA_RIGHT: 51 return "ta_right"; 52 case PA_CENTER: 53 return "ta_center"; 54 default: 55 return "ta_left"; 56 } 57 } 58 59 function get_property_code() { 60 return CSS_HTML2PS_ALIGN; 61 } 62 63 function get_property_name() { 64 return '-html2ps-align'; 65 } 66} 67 68CSS::register_css_property(new CSSPseudoAlign); 69 70?>