From 7bdb67e4a70bbd9713c5bfa80187900d9ef23494 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 18 Mar 2006 19:04:16 +0000 Subject: [PATCH] Adding base printer_css.php file --- printer_css.php | 346 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 346 insertions(+) create mode 100644 printer_css.php diff --git a/printer_css.php b/printer_css.php new file mode 100644 index 0000000..f3043fe --- /dev/null +++ b/printer_css.php @@ -0,0 +1,346 @@ +registry =& $registry; + } + + // ################################################################### + /** + * (PHP 4) Constructor + */ + function Printer_CSS(&$registry) + { + $this->__construct($registry); + } + + // ################################################################### + /** + * Adds a CSS information block to the array for later use + * + * @access public + * + * @param string Block title to display in thead + * @param string CSS class/descriptor/element name + * @param bool Show the link CSS information + */ + function add_block($title, $descriptor, $dolink) + { + if (isset($this->descriptors["$descriptor"])) + { + trigger_error('The descriptor `' . $descriptor . '` already exists', E_USER_WARNING); + return; + } + + $this->descriptors["$descriptor"] = array( + 'title' => $title, + 'descriptor' => $descriptor, + 'dolink' => $dolink + ); + } + + // ################################################################### + /** + * Sets a master data key for a given descriptor and property + * + * @access public + * + * @param string Descriptor + * @param string Property + * @param string Value + */ + function set_master_data($descriptor, $property, $value) + { + $this->masterdata["$descriptor"]["$property"] = $value; + } + + // ################################################################### + /** + * Sets a custom data key for a given descriptor and property + * + * @access public + * + * @param string Descriptor + * @param string Property + * @param string Value + */ + function set_custom_data($descriptor, $property, $value) + { + $this->customdata["$descriptor"]["$property"] = $value; + } + + // ################################################################### + /** + * Generates the HTML needed to output the CSS editing blocks; this is + * done in the form of using ISSO.Printer + * + * @access public + */ + function generate_blocks() + { + $print =& $this->registry->modules['printer']; + + $lang = array( + 'standard_css_attributes' => $this->registry->modules['localize']->string('Standard CSS Attributes'), + 'extra_css_attributes' => $this->registry->modules['localize']->string('Extra CSS Attributes'), + + 'links_normal' => $this->registry->modules['localize']->string('Normal CSS Links'), + 'links_visited' => $this->registry->modules['localize']->string('Visited CSS Links'), + 'links_hover' => $this->registry->modules['localize']->string('Hover CSS Links'), + + 'background' => $this->registry->modules['localize']->string('Background'), + 'font_color' => $this->registry->modules['localize']->string('Font Color'), + 'font_style' => $this->registry->modules['localize']->string('Font Style'), + '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') + ); + + foreach ($this->descriptors AS $descriptor) + { + $value = array(); + + $print->table_start(); + $print->table_head($descriptor['title'] . ' (' . $descriptor['descriptor'] . ')'); + + $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'); + $value['extra'] = $this->fetch_value($descriptor['descriptor'], 'extra'); + + $html = << + + +
+ $lang[standard_css_attributes] + + + + + + + + + + + + + + + + + + + + + + +
$lang[background]
$lang[font_color]
$lang[font_style]
$lang[font_size]
$lang[font_family]
+
+ + + +
+ $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'); + } + + print_r($value); + + $html .= << + + +
+ $lang[links_normal] + + + + + + + + + + + + + + +
$lang[background]
$lang[font_color]
$lang[text_decoration]
+
+ + + +
+ $lang[links_visited] + + + + + + + + + + + + + + +
$lang[background]
$lang[font_color]
$lang[text_decoration]
+
+ + + +
+ $lang[links_hover] + + + + + + + + + + + + + + +
$lang[background]
$lang[font_color]
$lang[text_decoration]
+
+ + + +HTML; + } + + $print->row_span($html, 'alt2', 'left', 1); + + $print->table_end(); + } + } + + // ################################################################### + /** + * Returns the value of a given descriptor and property by comparing + * the mater set and custom set then returning the right one + * + * @access private + * + * @param string Descriptor + * @param string Property + * + * @return string Value of the given property + */ + function fetch_value($descriptor, $property) + { + if ($this->customdata["$descriptor"]["$property"] == '') + { + return $this->masterdata["$descriptor"]["$property"]; + } + else + { + return $this->customdata["$desciptor"]["$property"]; + } + } +} + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file -- 2.22.5