public function merge_bg($input_css) {
		$background_prop_default = & $this->parser->data['csstidy']['background_prop_default'];
		// Max number of background images. CSS3 not yet fully implemented
		$number_of_values = @max(count($this->explode_ws(',', $input_css['background-image'])), count($this->explode_ws(',', $input_css['background-color'])), 1);
		// Array with background images to check if BG image exists
		$bg_img_array = @$this->explode_ws(',', $this->parser->gvw_important($input_css['background-image']));
		$new_bg_value = '';
		$important = '';

		// if background properties is here and not empty, don't try anything
		if (isset($input_css['background']) && $input_css['background'])
			return $input_css;

		for ($i = 0; $i < $number_of_values; $i++) {
			foreach ($background_prop_default as $bg_property => $default_value) {
				// Skip if property does not exist
				if (!isset($input_css[$bg_property])) {
					continue;
				}

				$cur_value = $input_css[$bg_property];
				// skip all optimisation if gradient() somewhere
				if (stripos($cur_value, 'gradient(') !== false)
					return $input_css;

				// Skip some properties if there is no background image
				if ((!isset($bg_img_array[$i]) || $bg_img_array[$i] === 'none')
								&& ($bg_property === 'background-size' || $bg_property === 'background-position'
								|| $bg_property === 'background-attachment' || $bg_property === 'background-repeat')) {
					continue;
				}

				// Remove !important
				if ($this->parser->is_important($cur_value)) {
					$important = ' !important';
					$cur_value = $this->parser->gvw_important($cur_value);
				}

				// Do not add default values
				if ($cur_value === $default_value) {
					continue;
				}

				$temp = $this->explode_ws(',', $cur_value);

				if (isset($temp[$i])) {
					if ($bg_property === 'background-size') {
						$new_bg_value .= '(' . $temp[$i] . ') ';
					} else {
						$new_bg_value .= $temp[$i] . ' ';
					}
				}
			}

			$new_bg_value = trim($new_bg_value);
			if ($i != $number_of_values - 1)
				$new_bg_value .= ',';
		}

		// Delete all background-properties
		foreach ($background_prop_default as $bg_property => $default_value) {
			unset($input_css[$bg_property]);
		}

		// Add new background property
		if ($new_bg_value !== '')
			$input_css['background'] = $new_bg_value . $important;
		elseif(isset ($input_css['background']))
			$input_css['background'] = 'none';

		return $input_css;
	}
public function merge_bg($input_css) {
		$background_prop_default = & $this->parser->data['csstidy']['background_prop_default'];
		// Max number of background images. CSS3 not yet fully implemented
		$number_of_values = @max(count($this->explode_ws(',', $input_css['background-image'])), count($this->explode_ws(',', $input_css['background-color'])), 1);
		// Array with background images to check if BG image exists
		$bg_img_array = @$this->explode_ws(',', $this->parser->gvw_important($input_css['background-image']));
		$new_bg_value = '';
		$important = '';

		// if background properties is here and not empty, don't try anything
		if (isset($input_css['background']) && $input_css['background'])
			return $input_css;

		for ($i = 0; $i < $number_of_values; $i++) {
			foreach ($background_prop_default as $bg_property => $default_value) {
				// Skip if property does not exist
				if (!isset($input_css[$bg_property])) {
					continue;
				}

				$cur_value = $input_css[$bg_property];
				// skip all optimisation if gradient() somewhere
				if (stripos($cur_value, 'gradient(') !== false)
					return $input_css;

				// Skip some properties if there is no background image
				if ((!isset($bg_img_array[$i]) || $bg_img_array[$i] === 'none')
								&& ($bg_property === 'background-size' || $bg_property === 'background-position'
								|| $bg_property === 'background-attachment' || $bg_property === 'background-repeat')) {
					continue;
				}

				// Remove !important
				if ($this->parser->is_important($cur_value)) {
					$important = ' !important';
					$cur_value = $this->parser->gvw_important($cur_value);
				}

				// Do not add default values
				if ($cur_value === $default_value) {
					continue;
				}

				$temp = $this->explode_ws(',', $cur_value);

				if (isset($temp[$i])) {
					if ($bg_property === 'background-size') {
						$new_bg_value .= '(' . $temp[$i] . ') ';
					} else {
						$new_bg_value .= $temp[$i] . ' ';
					}
				}
			}

			$new_bg_value = trim($new_bg_value);
			if ($i != $number_of_values - 1)
				$new_bg_value .= ',';
		}

		// Delete all background-properties
		foreach ($background_prop_default as $bg_property => $default_value) {
			unset($input_css[$bg_property]);
		}

		// Add new background property
		if ($new_bg_value !== '')
			$input_css['background'] = $new_bg_value . $important;
		elseif(isset ($input_css['background']))
			$input_css['background'] = 'none';

		return $input_css;
	}
public function merge_bg ( $ input_css ) { $ background_prop_default = & $ this -> parser -> data [ 'csstidy' ] [ 'background_prop_default' ] ; // Max number of background images. CSS3 not yet fully implemented $ number_of_values = @ max ( count ( $ this -> explode_ws ( ',' , $ input_css [ 'background-image' ] ) ) , count ( $ this -> explode_ws ( ',' , $ input_css [ 'background-color' ] ) ) , 1 ) ; // Array with background images to check if BG image exists $ bg_img_array = @ $ this -> explode_ws ( ',' , $ this -> parser -> gvw_important ( $ input_css [ 'background-image' ] ) ) ; $ new_bg_value = '' ; $ important = '' ; // if background properties is here and not empty, don't try anything if ( isset ( $ input_css [ 'background' ] ) && $ input_css [ 'background' ] ) return $ input_css ; for ( $ i = 0 ; $ i < $ number_of_values ; $ i ++ ) { foreach ( $ background_prop_default as $ bg_property => $ default_value ) { // Skip if property does not exist if ( ! isset ( $ input_css [ $ bg_property ] ) ) { continue ; } $ cur_value = $ input_css [ $ bg_property ] ; // skip all optimisation if gradient() somewhere if ( stripos ( $ cur_value , 'gradient(' ) !== false ) return $ input_css ; // Skip some properties if there is no background image if ( ( ! isset ( $ bg_img_array [ $ i ] ) || $ bg_img_array [ $ i ] === 'none' ) && ( $ bg_property === 'background-size' || $ bg_property === 'background-position' || $ bg_property === 'background-attachment' || $ bg_property === 'background-repeat' ) ) { continue ; } // Remove !important if ( $ this -> parser -> is_important ( $ cur_value ) ) { $ important = ' !important' ; $ cur_value = $ this -> parser -> gvw_important ( $ cur_value ) ; } // Do not add default values if ( $ cur_value === $ default_value ) { continue ; } $ temp = $ this -> explode_ws ( ',' , $ cur_value ) ; if ( isset ( $ temp [ $ i ] ) ) { if ( $ bg_property === 'background-size' ) { $ new_bg_value .= '(' . $ temp [ $ i ] . ') ' ; } else { $ new_bg_value .= $ temp [ $ i ] . ' ' ; } } } $ new_bg_value = trim ( $ new_bg_value ) ; if ( $ i != $ number_of_values - 1 ) $ new_bg_value .= ',' ; } // Delete all background-properties foreach ( $ background_prop_default as $ bg_property => $ default_value ) { unset ( $ input_css [ $ bg_property ] ) ; } // Add new background property if ( $ new_bg_value !== '' ) $ input_css [ 'background' ] = $ new_bg_value . $ important ; elseif ( isset ( $ input_css [ 'background' ] ) ) $ input_css [ 'background' ] = 'none' ; return $ input_css ; }
Merges all background properties
@param array $input_css
@return array
@version 1.0
@see dissolve_short_bg()
@todo full CSS 3 compliance
Merges all background properties