1<?php 2// $Header: /cvsroot/html2ps/css.background.inc.php,v 1.23 2007/03/15 18:37:30 Konstantin Exp $ 3 4require_once(HTML2PS_DIR.'value.background.php'); 5 6class CSSBackground extends CSSPropertyHandler { 7 var $default_value; 8 9 function get_property_code() { 10 return CSS_BACKGROUND; 11 } 12 13 function get_property_name() { 14 return 'background'; 15 } 16 17 function CSSBackground() { 18 $this->default_value = new Background(CSSBackgroundColor::default_value(), 19 CSSBackgroundImage::default_value(), 20 CSSBackgroundRepeat::default_value(), 21 CSSBackgroundPosition::default_value(), 22 CSSBackgroundAttachment::default_value()); 23 24 $this->CSSPropertyHandler(true, false); 25 } 26 27 function inherit($state, &$new_state) { 28 // Determine parent 'display' value 29 $parent_display = $state[CSS_DISPLAY]; 30 31 // If parent is a table row, inherit the background settings 32 $this->replace_array(($parent_display == 'table-row') ? $state[CSS_BACKGROUND] : $this->default_value(), 33 $new_state); 34 } 35 36 function default_value() { 37 return $this->default_value->copy(); 38 } 39 40 function parse($value, &$pipeline) { 41 if ($value === 'inherit') { 42 return CSS_PROPERTY_INHERIT; 43 } 44 45 $background = new Background(CSSBackgroundColor::parse($value), 46 CSSBackgroundImage::parse($value, $pipeline), 47 CSSBackgroundRepeat::parse($value), 48 CSSBackgroundPosition::parse($value), 49 CSSBackgroundAttachment::parse($value)); 50 51 return $background; 52 } 53} 54 55$bg = new CSSBackground; 56 57CSS::register_css_property($bg); 58CSS::register_css_property(new CSSBackgroundColor($bg, '_color')); 59CSS::register_css_property(new CSSBackgroundImage($bg, '_image')); 60CSS::register_css_property(new CSSBackgroundRepeat($bg, '_repeat')); 61CSS::register_css_property(new CSSBackgroundPosition($bg, '_position')); 62CSS::register_css_property(new CSSBackgroundAttachment($bg, '_attachment')); 63 64?>