From 749633fb578ebba1a5d6c5b6f48a63ae11d93a9d Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 18 Dec 2006 08:24:28 +0000 Subject: [PATCH] Okay this finally looks good --- PrinterBaseElement.php | 32 +------------- PrinterElement.php | 15 ------- PrinterLabelElement.php | 83 +++++++++++++++++++++++++++++++++++++ PrinterRootElement.php | 11 ----- PrinterRootElementPage.php | 41 +++++------------- PrinterRootElementTable.php | 28 ++----------- PrinterTableElement.php | 66 ++++++++++++++++++----------- 7 files changed, 139 insertions(+), 137 deletions(-) create mode 100644 PrinterLabelElement.php diff --git a/PrinterBaseElement.php b/PrinterBaseElement.php index 61ace8a..16c2284 100644 --- a/PrinterBaseElement.php +++ b/PrinterBaseElement.php @@ -42,12 +42,6 @@ require_once('ISSO/PrinterElement.php'); */ class BSPrinterBaseElement extends BSPrinterElement { - /** - * The parent containing element - * @var BSPrinterElement - */ - private $parent; - /** * The name of the element * @var string @@ -75,37 +69,13 @@ class BSPrinterBaseElement extends BSPrinterElement /** * Constructor */ - function __construct(BSPrinterElement $parent, $type, $name, $value = '') + function __construct($type, $name, $value = '') { - $this->setParent($parent); $this->type = $type; $this->name = $name; $this->value = $value; } - // ################################################################### - /** - * Sets the parent element - * - * @param BSPrinterElement The parent - */ - public function setParent(BSPrinterElement $parent) - { - $this->parent = $parent; - $this->parent->addChild($this); - } - - // ################################################################### - /** - * Returns the parent element - * - * @return BSPrinterElement The parent element - */ - public function getParent() - { - return $this->parent; - } - // ################################################################### /** * If the type is either checkbox, radio, or option then this will diff --git a/PrinterElement.php b/PrinterElement.php index ad1a5e1..73df3d0 100644 --- a/PrinterElement.php +++ b/PrinterElement.php @@ -39,27 +39,12 @@ */ abstract class BSPrinterElement { - /** - * The printer writer - */ - protected $printer; - /** * Style information * @var array */ protected $style = array(); - /** - * Sets the parent element - */ - public abstract function setParent(BSPrinterElement $parent); - - /** - * Gets the parent element - */ - public abstract function getParent(); - /** * Tells the element to paint itself (and any children) */ diff --git a/PrinterLabelElement.php b/PrinterLabelElement.php new file mode 100644 index 0000000..ca0026c --- /dev/null +++ b/PrinterLabelElement.php @@ -0,0 +1,83 @@ +string = $string; + } + + // ################################################################### + /** + * Prints the string + * + * @return string The string; wrapped in a if it has styling + */ + public function paint() + { + if ($this->_prepareStyle()) + { + return '' . $this->string . ''; + } + return $this->string; + } +} + +/*=====================================================================* +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file diff --git a/PrinterRootElement.php b/PrinterRootElement.php index f143f68..669cbe9 100644 --- a/PrinterRootElement.php +++ b/PrinterRootElement.php @@ -48,17 +48,6 @@ abstract class BSPrinterRootElement extends BSPrinterElement */ protected $children = array(); - // ################################################################### - /** - * Constructor - * - * @param BSPrinter Print stream wrapper - */ - public function __construct($printer) - { - $this->printer = $printer; - } - /** * Returns all of the children painted in the right order */ diff --git a/PrinterRootElementPage.php b/PrinterRootElementPage.php index ef89541..de4e413 100644 --- a/PrinterRootElementPage.php +++ b/PrinterRootElementPage.php @@ -59,16 +59,15 @@ class BSPrinterRootElementPage extends BSPrinterRootElement */ private $stylesheet; + // ################################################################### /** * Constructor * - * @param BSPrinter Printer object * @param string Page title */ - function __construct($printer, $title) + function __construct($title) { $this->title = $title; - parent::__construct($printer); } // ################################################################### @@ -93,24 +92,6 @@ class BSPrinterRootElementPage extends BSPrinterRootElement $this->stylesheet = $stylesheet; } - // ################################################################### - /** - * Sets the parent element - */ - public function setParent(BSPrinterElement $parent) - { - trigger_error('Cannot set the parent element on a BSPrinterRootElement'); - } - - // ################################################################### - /** - * Gets the parent element (none exist as this is the root element) - */ - public function getParent() - { - return null; - } - // ################################################################### /** * Returns the HTML for all printed children elements @@ -135,20 +116,20 @@ class BSPrinterRootElementPage extends BSPrinterRootElement */ public function paint() { - $this->printer->paint("\n"); - $this->printer->paint("language['langcode'] . "\" lang=\"" . $this->language['langcode'] . "\" dir=\"" . $this->language['direction'] . "\">\n"); - $this->printer->paint("\n\t" . sprintf(_('%1$s - %2$s'), BSRegister::GetApplication(), $this->title) . ""); - $this->printer->paint("\n\t"); - $this->printer->paint("\n\tstylesheet . "\" />"); + echo("\n"); + echo("language['langcode'] . "\" lang=\"" . $this->language['langcode'] . "\" dir=\"" . $this->language['direction'] . "\">\n"); + echo("\n\t" . sprintf(_('%1$s - %2$s'), BSRegister::GetApplication(), $this->title) . ""); + echo("\n\t"); + echo("\n\tstylesheet . "\" />"); // echo $this->code; - $this->printer->paint("\n\n\n"); + echo("\n\n\n"); if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR (defined('ISSO_PRINTER_NO_NAVIGATION') AND constant('ISSO_PRINTER_NO_NAVIGATION') != true))) { echo BSRegister::GetType('PrinterNavigation')->generate_header_html(); } - $this->printer->paint($this->_paintChildren()); + echo($this->_paintChildren()); if (BSRegister::GetDebug() AND isset($_GET['query'])) { @@ -174,11 +155,11 @@ class BSPrinterRootElementPage extends BSPrinterRootElement if (!defined('ISSO_PRINTER_HIDE_SETUP')) { - $this->printer->paint("\n$copyright"); + echo("\n$copyright"); //echo $this->registry->construct_debug_block(false); } - $this->printer->paint("\n\n\n"); + echo("\n\n\n"); exit; } diff --git a/PrinterRootElementTable.php b/PrinterRootElementTable.php index 270fe1c..539288b 100644 --- a/PrinterRootElementTable.php +++ b/PrinterRootElementTable.php @@ -88,32 +88,10 @@ class BSPrinterRootElementTable extends BSPrinterRootElement foreach ($this->children AS $child) { - $this->builder .= "\n" . $child->paint() . "\n"; + $builder .= "\n" . $child->paint() . "\n"; } - return $this->builder; - } - - // ################################################################### - /** - * Sets the parent element - * - * @param BSPrinterElement Parent - */ - public function setParent(BSPrinterElement $parent) - { - $this->parent = $parent; - } - - // ################################################################### - /** - * Gets the parent element - * - * @return BSPrinterElement Parent - */ - public function getParent() - { - return $this->parent; + return $builder; } // ################################################################### @@ -124,7 +102,7 @@ class BSPrinterRootElementTable extends BSPrinterRootElement */ public function paint() { - $this->printer->paint("" . $this->_paintChildren() . "
"); + return "" . $this->_paintChildren() . "
"; } } diff --git a/PrinterTableElement.php b/PrinterTableElement.php index 9c230e8..18fc225 100644 --- a/PrinterTableElement.php +++ b/PrinterTableElement.php @@ -40,13 +40,7 @@ require_once('ISSO/PrinterBaseElement.php'); * */ class BSPrinterTableElement extends BSPrinterElement -{ - /** - * The parent table - * @var BSPrinterRootElementTable - */ - private $parent; - +{ /** * CSS class to use * @var string @@ -58,53 +52,75 @@ class BSPrinterTableElement extends BSPrinterElement * @var array */ private $children = array(); - + + // ################################################################### /** - * Constructor + * Returns a new instance of this class */ - function __construct(BSPrinterRootElementTable $table) + public static function Init() { - $this->parent = $table; + return new BSPrinterTableElement(); } // ################################################################### /** - * Sets the CSS class to use. Use ":swap:" to alternate + * Factory method that creates a checkbox row * - * @param string CSS class + * @param string Label + * @param string Element name + * @param mixed Value + * @param boolean Checked? + * + * @return BSPrinterTableElement A proper table element */ - public function setCssClass($class) + public static function RowCheckbox($label, $name, $value, $checked = false) { - $this->cssClass = $class; + $tr = new BSPrinterTableElement(); + + $tr->addChild(new BSPrinterLabelElement($label)); + + $elm = new BSPrinterBaseElement('checkbox', $name, $value); + $elm->setActive($checked); + + $tr->addChild($elm); + + return $tr; } // ################################################################### /** - * Sets the parent element + * Sets the CSS class to use. Use ":swap:" to alternate + * + * @param string CSS class */ - public function setParent(BSPrinterElement $parent) + public function setCssClass($class) { - trigger_error('Cannot set the parent element on a BSPrinterRootElement'); + $this->cssClass = $class; } // ################################################################### /** - * Gets the parent element (none exist as this is the root element) + * Returns the number of columns in this element + * + * @return integer Column count */ - public function getParent() + public function numberOfColumns() { - return null; + return sizeof($this->children); } // ################################################################### /** - * Returns the number of columns in this element + * Adds a child node to the element * - * @return integer Column count + * @param BSPrinterElement A child element + * + * @return BSPrinterTableElement Returns the current object */ - public function numberOfColumns() + public function addChild(BSPrinterElement $child) { - return sizeof($this->children); + $this->children[] = $child; + return $this; } // ################################################################### -- 2.22.5