From 6fa6a8a98ae76a36666671206cd419a748b614ce Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 19 Dec 2006 03:39:09 +0000 Subject: [PATCH] Change BSRouter::route() to BSRouter::dispatch() --- Router.php | 2 +- printer.css.php | 8 +- printer.php | 342 +++++++++--------------------------------------- printer_css.php | 101 +++++--------- 4 files changed, 108 insertions(+), 345 deletions(-) diff --git a/Router.php b/Router.php index eee38fc..4ac045f 100644 --- a/Router.php +++ b/Router.php @@ -95,7 +95,7 @@ class BSRouter /** * Listens for routing requests and handles them appropriately */ - public function route() + public function dispatch() { $request = str_replace($this->basePath, '', $_SERVER['REQUEST_URI']); diff --git a/printer.css.php b/printer.css.php index f1640e0..3624f59 100755 --- a/printer.css.php +++ b/printer.css.php @@ -87,6 +87,8 @@ body .tcat { color: rgb(30, 35, 46); + font-weight: bold; + text-align: center; background-color: rgb(109, 187, 45); } @@ -98,7 +100,7 @@ body } /* Row under the TCAT row (often used for column headers) */ -td.thead, .thead td, .alt3 +.thead, .alt3 { color: rgb(45, 45, 45); @@ -140,6 +142,8 @@ td.thead, .thead td, .alt3 .tfoot { color: rgb(55, 55, 55); + text-align: center; + font-weight: bold; background-color: rgb(64, 64, 64); } @@ -149,7 +153,7 @@ td.thead, .thead td, .alt3 /* ################################################################### */ /* Font settings for all non-styled elements */ -body, p, td, tr, ol, ul +body { font-family: verdana, geneva, arial, helvetica, sans-serif; font-size: 11px; diff --git a/printer.php b/printer.php index 8b5dd07..f789822 100644 --- a/printer.php +++ b/printer.php @@ -26,6 +26,14 @@ * @package ISSO */ +require_once('ISSO/PrinterElement.php'); +require_once('ISSO/PrinterBaseElement.php'); +require_once('ISSO/PrinterLabelElement.php'); +require_once('ISSO/PrinterRootElement.php'); +require_once('ISSO/PrinterRootElementPage.php'); +require_once('ISSO/PrinterRootElementTable.php'); +require_once('ISSO/PrinterTableElement.php'); + /** * Printer * @@ -83,44 +91,15 @@ class Printer */ private $language = array('langcode' => 'en_US', 'direction' => 'ltr', 'charset' => 'utf-8'); - /** - * Fields array that is used in this module - * @var array - */ - private $fields = array( - 'realm' => array(REQ_YES, null, false) - ); - - // ################################################################### - /** - * Constructor - */ - public function __construct(&$registry) - { - $this->registry =& $registry; - } - // ################################################################### /** - * Sets an ISSO field + * Sets the realm (or title) of the printed output * - * @param string Field name - * @param mixed Value of the field + * @param string Title/realm */ - public function set($name, $value) + public function setRealm($realm) { - $this->registry->do_set($name, $value, 'printer'); - } - - // ################################################################### - /** - * Gets the language array information - * - * @return array Language array - */ - public function getLanguageInformation() - { - return $this->language; + $this->realm = $realm; } // ################################################################### @@ -134,19 +113,6 @@ class Printer $this->language = $lang; } - // ################################################################### - /** - * Gets an ISSO field - * - * @param string Field name - * - * @return mixed Value of the field - */ - public function get($fieldname) - { - return $this->registry->do_get($fieldname, 'printer'); - } - // ################################################################### /** * Creates a redirect to another page; constructs the header and footer @@ -158,18 +124,14 @@ class Printer */ public function redirect($location, $message = null, $postvars = array()) { - $timeout = 10 * 200; - - if ($postvars) - { - $js = << - -JS; - } - else - { - $js = << - - -JS; - } + '; if (!defined('ISSO_PRINTER_NO_NAVIGATION')) { define('ISSO_PRINTER_NO_NAVIGATION', 1); } - $this->page_start($this->registry->modules['localize']->string('Redirect')); + $this->page_start(_('Redirect')); if ($postvars) { @@ -229,7 +165,7 @@ JS; $this->form_end(); } - $redir = sprintf($this->registry->modules['localize']->string('Please wait to be redirected. If you are not redirected in a few seconds, click here.'), $location); + $redir = sprintf(_('Please wait to be redirected. If you are not redirected in a few seconds, click here.'), $location); $override = false; if ($message == null) { @@ -242,7 +178,7 @@ JS; $override = true; } - $this->page_message($this->registry->modules['localize']->string('Redirect'), $showmessage, $override); + $this->page_message(_('Redirect'), $showmessage, $override); $this->page_code($js); @@ -251,68 +187,59 @@ JS; // ################################################################### /** - * Throws a fatal error; constructs the header and footer + * Produces an entire page layout that asks the user whether or not + * they want to perform X action and provides a link to the YES and NO + * action * - * @param string Error messsage text + * @param string Message that asks if they want to do X + * @param string Location to go for YES + * @param string DO action to pass + * @param array Hidden parameters to pass to the next page */ - public function error($message) + public function confirm($message, $location, $action, $params) { if (!defined('ISSO_PRINTER_NO_NAVIGATION')) { define('ISSO_PRINTER_NO_NAVIGATION', 1); } - $this->page_start($this->registry->modules['localize']->string('Error')); - $this->page_message($this->registry->modules['localize']->string('Error'), $message); - $this->page_end(); + $this->page_start(_('Confirm')); - exit; + $this->form_start($location, $action); + foreach ($params AS $key => $value) + { + $this->form_hidden_field($key, $value); + } + + $this->table_start(true, '75%'); + $this->table_head(_('Confirm'), 1); + $this->row_span("
$message
", ':swap:', 'left', 1); + $this->row_submit('', _('Yes'), ''); + $this->table_end(); + + $this->form_end(); + + $this->page_end(); } // ################################################################### /** - * Outputs the header of the page: doctype, , , , - * <body> and imbeds the style information + * Throws a fatal error; constructs the header and footer * - * @param string Title of the page - * @param string Class of the page to be applied to the body - * @param string Extra HTML to imbed in the <head> tag - * @param string <body> onLoad action to imbed + * @param string Error messsage text */ - public function page_start($actiontitle, $pageclass = null, $extra = '', $onload = false) + public function error($message) { - $this->registry->check_isso_fields(get_class($this)); - - if ($this->registry->debug AND isset($_GET['query'])) - { - ob_start(); - } - - if (defined('ISSO_PRINTER_DONE_HEADER') AND constant('ISSO_PRINTER_DONE_HEADER')) + if (!defined('ISSO_PRINTER_NO_NAVIGATION')) { - return; + define('ISSO_PRINTER_NO_NAVIGATION', 1); } - $title = sprintf($this->registry->modules['localize']->string('%1$s - %2$s - %3$s'), $this->registry->application, $this->realm, $actiontitle); - - echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; - echo "<html xml:lang=\"" . $this->language['langcode'] . "\" lang=\"" . $this->language['langcode'] . "\" dir=\"" . $this->language['direction'] . "\">\n<head>"; - echo "\n\t<title>$title"; - echo "\n\t"; - echo $this->css; - echo $this->code; - echo ($extra ? "\n$extra" : ''); - echo "\n\n\n"; - - if ($this->registry->is_loaded('printer_navigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR (defined('ISSO_PRINTER_NO_NAVIGATION') AND constant('ISSO_PRINTER_NO_NAVIGATION') != true))) - { - echo $this->registry->modules['printer_navigation']->generate_header_html(); - } + $this->page_start(_('Error')); + $this->page_message(_('Error'), $message); + $this->page_end(); - if (!defined('ISSO_PRINTER_DONE_HEADER')) - { - define('ISSO_PRINTER_DONE_HEADER', 1); - } + exit; } // ################################################################### @@ -376,43 +303,6 @@ JS; $this->table_end(); } - // ################################################################### - /** - * Produces an entire page layout that asks the user whether or not - * they want to perform X action and provides a link to the YES and NO - * action - * - * @param string Message that asks if they want to do X - * @param string Location to go for YES - * @param string DO action to pass - * @param array Hidden parameters to pass to the next page - */ - public function page_confirm($message, $location, $action, $params) - { - if (!defined('ISSO_PRINTER_NO_NAVIGATION')) - { - define('ISSO_PRINTER_NO_NAVIGATION', 1); - } - - $this->page_start($this->registry->modules['localize']->string('Confirm')); - - $this->form_start($location, $action); - foreach ($params AS $key => $value) - { - $this->form_hidden_field($key, $value); - } - - $this->table_start(true, '75%'); - $this->table_head($this->registry->modules['localize']->string('Confirm'), 1); - $this->row_span("
$message
", ':swap:', 'left', 1); - $this->row_submit('', $this->registry->modules['localize']->string('Yes'), ''); - $this->table_end(); - - $this->form_end(); - - $this->page_end(); - } - // ################################################################### /** * Closes the HTML document structure an adds the copyright; this also @@ -420,7 +310,7 @@ JS; */ public function page_end() { - if ($this->registry->debug AND isset($_GET['query'])) + if (BSRegister::GetDebug() AND isset($_GET['query'])) { ob_clean(); ob_end_clean(); @@ -440,7 +330,7 @@ JS; echo $this->registry->modules['printer_navigation']->generate_footer_html(); } - $copyright = "\n
\n

\n\t" . $this->registry->get('application') . ' ' . $this->registry->get('appversion') . ", ©2002 - " . date('Y') . " Blue Static\n

"; + $copyright = "\n
\n

\n\t" . BSRegister::GetApplication() . ' ' . BSRegister::GetAppVersion() . ", ©2002 - " . date('Y') . " Blue Static\n

"; if (!defined('ISSO_PRINTER_HIDE_SETUP')) { @@ -478,11 +368,10 @@ JS; * * @param string Title string * @param integer Colspan attribute value - * @param bool Whether to bold the title */ - public function table_head($title, $colspan = 2, $strong = true) + public function table_head($title, $colspan = 2) { - echo "\n\t" . (($strong) ? "$title" : $title) . "\n\n"; + echo "\n\t$title\n\n"; } // ################################################################### @@ -533,7 +422,7 @@ JS; */ public function form_start($action, $do, $enctype = false, $name = 'inputform', $submitmethod = 'post') { - echo "\n\n
\n"; + echo "\n\n\n"; if ($do !== null) { @@ -564,41 +453,6 @@ JS; // ------------------------------------------------------------------- - // ################################################################### - /** - * Creates a table row that spans an entire row; this is used to divide - * sections, usually - * - * @param string Text to place in the row - * @param string Class name to style with; by default it alternates between alt1 and alt2 (use :swap: to do that) - * @param string Alignment of the text in the row - * @param integer Colspan attribute - */ - public function row_span($text, $class = ':swap:', $align = 'left', $colspan = 2) - { - if ($class === ':swap:') - { - $this->registry->modules['functions']->exec_swap_bg(); - $row_class = $this->registry->modules['functions']->bgcolour; - $is_style_element = false; - } - else - { - if (preg_match('#:style:(.*?)#i', $class)) - { - $is_style_element = true; - $style = str_replace(':style:', '', $class); - } - else - { - $row_class = $class; - $is_style_element = false; - } - } - - echo "\n\n\t$text\n"; - } - // ################################################################### /** * Creates a table row that has more than two columns; this is used in @@ -609,7 +463,7 @@ JS; */ public function row_multi_item($row_array) { - $this->registry->modules['functions']->exec_swap_bg(); + BSFunctions::SwapCssClasses(); foreach ($row_array AS $item => $align) { @@ -635,7 +489,7 @@ JS; foreach ($item_array AS $value) { - echo "\n\tregistry->modules['functions']->bgcolour}\" align=\"$align\">$value"; + echo "\n\t$value"; } } @@ -662,8 +516,8 @@ JS; { if (!$IS_SETTINGS) { - $this->registry->modules['functions']->exec_swap_bg(); - $row_class = $this->registry->modules['functions']->bgcolour; + BSFunctions::SwapCssClasses(); + $row_class = BSFunctions::$cssClass; } else { @@ -682,24 +536,6 @@ JS; echo "\n\n"; } - // ################################################################### - /** - * Creates a table row with an text field as the value column - * - * @param string Label text - * @param string Name of the field - * @param string Value of the field - * @param integer Colspan attribute - * @param integer Size of the field - * @param integer Length attribute; use FALSE for no length to be specified - * @param bool Whether to make this a password field - * @param string Vertical align (valign attribute) - */ - public function row_input($label, $name, $value = '', $colspan = 2, $size = 35, $length = false, $password = false, $lalign = 'top') - { - $this->row_text($label, "", $lalign, $colspan); - } - // ################################################################### /** * Creates a table row with a ", 'top', $colspan); - } - - // ################################################################### - /** - * Creates a table row with the tfoot class - * - * @param string Extra text or HTML to insert into the row - * @param integer Colspan attribute - */ - public function row_tfoot($data, $colspan = 2) - { - echo $this->row_span($data, 'tfoot', 'center', $colspan); - } - - // ################################################################### - /** - * Creates a tfoot table row with submit buttons - * - * @param string Extra HTML to imbed in the row after the buttons - * @param string Submit button text (by default it uses pre-translated "Submit" from :save:) - * @param string Reset button text (default it uses pre-translated "Reset" from :reset:) - * @param integer Colspan attribute - */ - public function row_submit($extra = false, $submit = ':save:', $reset = ':reset:', $colspan = 2) - { - if ($submit === ':save:') - { - $submit = " " . $this->registry->modules['localize']->string('Submit') . " "; - } - else - { - $submit = " $submit "; - } - - if ($reset === ':reset:') - { - $reset = " " . $this->registry->modules['localize']->string('Reset') . " "; - } - else - { - $reset = (($reset) ? " $reset " : ''); - } - - $output = "\n\t\t"; - $output .= ($reset ? "\n\t\t" : ''); - $output .= ($extra ? "\n\t\t$extra" : ''); - $output .= "\n\t"; - $this->row_tfoot($output, $colspan); + $this->row_text($label, "", 'top', $colspan); } // ################################################################### @@ -816,7 +604,7 @@ JS; $listitem = array(); - $this->row_text($label, "\n" . (($is_jump) ? "\nregistry->modules['localize']->string('Go') . " \" accesskey=\"g\" />" : '') . "\n", $colspan); + $this->row_text($label, "\n" . ($is_jump ? "\n" : '') . "\n", $colspan); } // ################################################################### @@ -852,7 +640,7 @@ JS; */ public function row_yesno($label, $name, $value, $colspan = 2) { - $this->row_text($label, " " . $this->registry->modules['localize']->string('Yes') . " " . $this->registry->modules['localize']->string('No'), $colspan); + $this->row_text($label, " " . _('Yes') . " " . _('No'), $colspan); } } diff --git a/printer_css.php b/printer_css.php index f571f5b..b629922 100644 --- a/printer_css.php +++ b/printer_css.php @@ -26,6 +26,8 @@ * @package ISSO */ +require_once('ISSO/Functions.php'); + /** * Printer - CSS Blocks * @@ -44,12 +46,6 @@ */ class Printer_CSS { - /** - * Framework registry object - * @var object - */ - private $registry = null; - /** * CSS block list * @var array @@ -85,48 +81,28 @@ class Printer_CSS * Hook ran in fetch_modified_link; takes three params: $descriptor, $property, $name * @var string */ - private $fetch_modified_link_hook = ':=NO METHOD=:'; - - /** - * Module fields - * @var array - */ - private $fields = array( - 'fetch_modified_link_hook' => array(REQ_YES, null, false) - ); + private $modifiedLinkHook = ':undefined:'; // ################################################################### /** * Constructor */ - public function __construct(&$registry) - { - $this->registry =& $registry; - } - - // ################################################################### - /** - * Sets an ISSO field - * - * @param string Field name - * @param mixed Value of the field - */ - public function set($name, $value) + public function __construct() { - $this->registry->do_set($name, $value, 'printer_css'); + BSRegister::RequiredModules(array('Db', 'Printer')); } // ################################################################### /** - * Gets an ISSO field - * - * @param string Field name + * Sets the function callback that creates a link for modified properties + * in the CSS blocks display. It should have the signature: + * public string _M(string $descriptor, string $property, string $name) * - * @return mixed Value of the field + * @param string Callback function */ - public function get($fieldname) + public function setModifiedLinkHook($callback) { - return $this->registry->do_get($fieldname, 'printer_css'); + $this->modifiedLinkHook = $callback; } // ################################################################### @@ -141,7 +117,7 @@ class Printer_CSS { if (isset($this->descriptors["$descriptor"])) { - trigger_error('The descriptor `' . $descriptor . '` already exists'); + trigger_error('The descriptor "' . $descriptor . '" already exists'); return; } @@ -185,26 +161,26 @@ class Printer_CSS */ public function generate_blocks() { - $print =& $this->registry->modules['printer']; + $print =& BSRegister::GetType('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'), + 'standard_css_attributes' => _('Standard CSS Attributes'), + 'extra_css_attributes' => _('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'), + 'links_normal' => _('Normal CSS Links'), + 'links_visited' => _('Visited CSS Links'), + 'links_hover' => _('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'), + 'background' => _('Background'), + 'font_color' => _('Font Color'), + 'font_style' => _('Font Style'), + 'font_size' => _('Font Size'), + 'font_family' => _('Font Family'), - 'text_decoration' => $this->registry->modules['localize']->string('Text Decoration'), + 'text_decoration' => _('Text Decoration'), - 'css_selector' => $this->registry->modules['localize']->string('CSS Selector'), - 'save_css' => $this->registry->modules['localize']->string('Save CSS') + 'css_selector' => _('CSS Selector'), + 'save_css' => _('Save CSS') ); foreach ($this->descriptors AS $descriptor) @@ -390,12 +366,7 @@ class Printer_CSS */ private 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; + return ($this->masterdata["$descriptor"]["$property"] != $this->customdata["$descriptor"]["$property"] AND isset($this->customdata["$descriptor"]["$property"])); } // ################################################################### @@ -415,13 +386,13 @@ class Printer_CSS if ($status) { - if (is_callable($this->fetch_modified_link_hook)) + if (is_callable($this->modifiedLinkHook)) { - return call_user_func($this->fetch_modified_link_hook, $descriptor, $property, $name); + return call_user_func($this->modifiedLinkHook, $descriptor, $property, $name); } else { - trigger_error('Printer_CSS::fetch_modified_link() needs to have the fetch_modified_link_hook( $descriptor , $property , $name ) defined'); + trigger_error('Printer_CSS::fetch_modified_link() needs to have the fetchModifiedLinkHook( $descriptor , $property , $name ) defined'); } } else @@ -484,8 +455,8 @@ class Printer_CSS else { $value = str_replace('%', '%%', $value); - $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) . "')"; + $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) . "')"; } } } @@ -505,15 +476,15 @@ class Printer_CSS // ################################################################### /** - * Wrapper for $this->registry->modules[ISSO_DB_LAYER]->escape_string() + * Wrapper for BSDb->escapeString() * * @param string Unprotected string * * @return string Sanitized string */ - private function escape($string) + private function _escape($string) { - return $this->registry->modules[ISSO_DB_LAYER]->escape_string($string); + return BSRegister::GetType('Db')->escapeString($string); } // ################################################################### @@ -571,7 +542,7 @@ class Printer_CSS if ($props['extra']) { - $extra = explode("\n", $this->registry->modules['functions']->convert_line_breaks($props['extra'])); + $extra = explode("\n", BSFunctions::ConvertLineBreaks($props['extra'])); foreach ($extra AS $prop) { -- 2.43.5