From 9e23cd3163d1a768309877bc9cee8c6965a172a3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 18 Mar 2006 20:22:37 +0000 Subject: [PATCH] We can now export the query information --- printer_css.php | 101 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 96 insertions(+), 5 deletions(-) diff --git a/printer_css.php b/printer_css.php index ef26af4..a987126 100644 --- a/printer_css.php +++ b/printer_css.php @@ -166,7 +166,10 @@ class Printer_CSS 'font_size' => $this->registry->modules['localize']->string('Font Size'), 'font_family' => $this->registry->modules['localize']->string('Font Family'), - 'text_decoration' => $this->registry->modules['localize']->string('Text Decoration') + 'text_decoration' => $this->registry->modules['localize']->string('Text Decoration'), + + 'css_selector' => $this->registry->modules['localize']->string('CSS Selector'), + 'save_css' => $this->registry->modules['localize']->string('Save CSS') ); foreach ($this->descriptors AS $descriptor) @@ -174,7 +177,7 @@ class Printer_CSS $value = array(); $print->table_start(); - $print->table_head($descriptor['title'] . ' (' . $descriptor['descriptor'] . ')'); + $print->table_head($descriptor['title']); $value['background'] = $this->fetch_value($descriptor['descriptor'], 'background'); $value['color'] = $this->fetch_value($descriptor['descriptor'], 'color'); @@ -252,7 +255,7 @@ HTML; $lang[text_decoration] - + @@ -273,7 +276,7 @@ HTML; $lang[text_decoration] - + @@ -294,7 +297,7 @@ HTML; $lang[text_decoration] - + @@ -306,6 +309,10 @@ HTML; $print->row_span($html, 'alt2', 'left', 1); + $print->row_span(' +
' . $lang['css_selector'] . ': ' . $descriptor['descriptor'] . '
+ ', 'tfoot', 'right', 1); + $print->table_end(); } } @@ -333,6 +340,90 @@ HTML; return $this->customdata["$desciptor"]["$property"]; } } + + // ################################################################### + /** + * Generates an array of queries that should be run on your database to + * update CSS changes. All of the queries have sprintf() markers that + * need to be evaluated: + * + * %1$s - Database table + * %2$s - styleid field + * %3$s - descriptor field + * %4$s - property field + * %5$s - value field + * %6%d - Styleid value + * + * @access public + * + * @param array Array of user-inputted information to be transformed into queries + * + * @return array Queries that need to be evaluated then ran + */ + function generate_change_query($data) + { + $queries[0] = '--- RESERVED FOR LATER USE ---'; + + print_r($data); + + $deletes = array(); + + foreach ($this->descriptors AS $descriptor => $opts) + { + $dolink = $opts['dolink']; + + if ($dolink) + { + $loops = array('', ' a:link', ' a:visited', ' a:hover'); + } + else + { + $loops = array(''); + } + + foreach ($loops AS $sel) + { + foreach ($data["$descriptor$sel"] AS $prop => $value) + { + // the given value matches the master -- no change + if ($this->masterdata["$descriptor$sel"]["$prop"] == $value) + { + continue; + } + // the given matches the custom -- no change + else if ($this->customdata["$descriptor$sel"]["$prop"] == $value) + { + continue; + } + // no matching, it's new + else + { + $deletes[] = "%3\$s = '" . $this->escape($descriptor . $sel) . "' AND %4\$s = '" . $this->escape($prop) . "'"; + $queries[] = "INSERT INTO %1\$s (%2\$s, %3\$s, %4\$s, %5\$s) VALUES (%6\$d, '" . $this->escape($descriptor . $sel) . "', '" . $this->escape($prop) . "', '" . $this->escape($value) . "')"; + } + } + } + } + + $queries[0] = "DELETE FROM %1\$s WHERE styleid = %6\$d AND ((" . implode(') OR (', $deletes) . "))"; + + return $queries; + } + + // ################################################################### + /** + * Wrapper for $this->registry->modules[ISSO_DB_LAYER]->escape_string() + * + * @access private + * + * @param string Unprotected string + * + * @return string Sanitized string + */ + function escape($string) + { + return $this->registry->modules[ISSO_DB_LAYER]->escape_string($string); + } } /*=====================================================================*\ -- 2.22.5