From da1fd9cb9aca40129a1b39012a9a62ead1694408 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 19 Mar 2006 03:27:45 +0000 Subject: [PATCH] - Properties are now stored in an ivar - Show some kind of marking for modified properties --- printer_css.php | 181 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 124 insertions(+), 57 deletions(-) diff --git a/printer_css.php b/printer_css.php index cea3f42..3d534e4 100644 --- a/printer_css.php +++ b/printer_css.php @@ -68,6 +68,20 @@ class Printer_CSS */ var $customdata = array(); + /** + * Valid properties that can be used in CSS + * @var array + * @access private + */ + var $properties = array( + 'background' => 'background', + 'color' => 'color', + 'font-style' => 'font_style', + 'font-size' => 'font_size', + 'font-family' => 'font_family', + 'text-decoration' => 'text_decoration' + ); + // ################################################################### /** * Constructor @@ -175,136 +189,139 @@ class Printer_CSS foreach ($this->descriptors AS $descriptor) { $value = array(); + $status = array(); + + $desc = $descriptor['descriptor']; $print->table_start(); $print->table_head($descriptor['title']); - $value['background'] = $this->fetch_value($descriptor['descriptor'], 'background'); - $value['color'] = $this->fetch_value($descriptor['descriptor'], 'color'); - $value['font_style'] = $this->fetch_value($descriptor['descriptor'], 'font-style'); - $value['font_size'] = $this->fetch_value($descriptor['descriptor'], 'font-size'); - $value['font_family'] = $this->fetch_value($descriptor['descriptor'], 'font-family'); + foreach ($this->properties AS $prop => $name) + { + $value["$name"] = $this->fetch_value($descriptor['descriptor'], $prop); + $status["$name"] = $this->fetch_modified_status($descriptor['descriptor'], $prop); + } + $value['extra'] = $this->fetch_value($descriptor['descriptor'], 'extra'); - $html = << - - + $html = " + + -
$lang[standard_css_attributes] - +
- - + + - - + + - - + + - - + + - - + +
$lang[background]" . $this->fetch_modified_link($desc, 'background', $lang['background']) . "
$lang[font_color]" . $this->fetch_modified_link($desc, 'color', $lang['font_color']) . "
$lang[font_style]" . $this->fetch_modified_link($desc, 'font-style', $lang['font_style']) . "
$lang[font_size]" . $this->fetch_modified_link($desc, 'font-size', $lang['font_size']) . "
$lang[font_family]" . $this->fetch_modified_link($desc, 'font-family', $lang['font_family']) . "
-
- $lang[extra_css_attributes] - +
+ " . $this->fetch_modified_link($desc, 'extra', $lang['extra_css_attributes']) . " +
-HTML; +"; if ($descriptor['dolink']) { foreach (array('a:link' => 'a_link', 'a:visited' => 'a_visited', 'a:hover' => 'a_hover') AS $sel => $selname) { - $value[$selname . '_background'] = $this->fetch_value($descriptor['descriptor'] . ' ' . $sel, 'background'); - $value[$selname . '_color'] = $this->fetch_value($descriptor['descriptor'] . ' ' . $sel, 'color'); - $value[$selname . '_text_decoration'] = $this->fetch_value($descriptor['descriptor'] . ' ' . $sel, 'text-decoration'); + foreach (array('background' => 'background', 'color' => 'color', 'text-decoration' => 'text_decoration') AS $prop => $name) + { + $value["{$selname}_{$name}"] = $this->fetch_value($descriptor['descriptor'] . ' ' . $sel, $prop); + $status["{$selname}_{$name}"] = $this->fetch_modified_status($descriptor['descriptor'] . ' ' . $sel, $prop); + } } - $html .= << - - + + + - - -
$lang[links_normal] - +
- - + + - - + + - - + +
$lang[background]" . $this->fetch_modified_link($desc . ' a:link', 'background', $lang['background']) . "
$lang[font_color]" . $this->fetch_modified_link($desc . ' a:link', 'color', $lang['font_color']) . "
$lang[text_decoration]" . $this->fetch_modified_link($desc . ' a:link', 'text-decoration', $lang['text_decoration']) . "
+
$lang[links_visited] - +
- - + + - - + + - - + +
$lang[background]" . $this->fetch_modified_link($desc . ' a:visited', 'background', $lang['background']) . "
$lang[font_color]" . $this->fetch_modified_link($desc . ' a:visited', 'color', $lang['font_color']) . "
$lang[text_decoration]" . $this->fetch_modified_link($desc . ' a:visited', 'text-decoration', $lang['text_decoration']) . "
+
$lang[links_hover] - +
- - + + - - + + - - + +
$lang[background]" . $this->fetch_modified_link($desc . ' a:hover', 'background', $lang['background']) . "
$lang[font_color]" . $this->fetch_modified_link($desc . ' a:hover', 'color', $lang['font_color']) . "
$lang[text_decoration]" . $this->fetch_modified_link($desc . ' a:hover', 'text-decoration', $lang['text_decoration']) . "
-HTML; +"; } $print->row_span($html, 'alt2', 'left', 1); @@ -341,6 +358,56 @@ HTML; } } + // ################################################################### + /** + * Returns the state modified state (false for untouched and true + * for modified) from the descriptor-property value between the master + * set and the custom set of data + * + * @access private + * + * @param string Descriptor + * @param string Property + * + * @return bool Modified from the master value? + */ + function fetch_modified_status($descriptor, $property) + { + if ($this->masterdata["$descriptor"]["$property"] != $this->customdata["$descriptor"]["$property"] AND isset($this->customdata["$descriptor"]["$property"])) + { + return true; + } + + return false; + } + + // ################################################################### + /** + * Fetches a link that shows a revert link for a given property + * that uses AJAX to revert when clicked + * + * @access private + * + * @param string Descriptor + * @param string Property + * @param string Nominalized text + * + * @return string Output HTML + */ + function fetch_modified_link($descriptor, $property, $name) + { + $status = $this->fetch_modified_status($descriptor, $property); + + if ($status) + { + return '' . $name . ''; + } + else + { + return $name; + } + } + // ################################################################### /** * Generates an array of queries that should be run on your database to -- 2.22.5