From aa267ec9d7cc3745ec15d180fbc5cb4c3b3f5399 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 25 Dec 2006 23:16:26 +0000 Subject: [PATCH] Create BSPrinter to handle CSS stylesheet linking and language information so individual pages don't keep track of it --- PrinterRootElementPage.php | 44 +++------------- printer.php | 104 +++++++++++++++++++++++++++++++------ 2 files changed, 95 insertions(+), 53 deletions(-) diff --git a/PrinterRootElementPage.php b/PrinterRootElementPage.php index c4e65e2..7158a4c 100644 --- a/PrinterRootElementPage.php +++ b/PrinterRootElementPage.php @@ -47,18 +47,6 @@ class BSPrinterRootElementPage extends BSPrinterRootElement */ private $title; - /** - * Language information array: ('langcode' =>, 'direction' =>, 'charset' =>) - * @var array - */ - private $language = array('langcode' => 'en_US', 'direction' => 'ltr', 'charset' => 'utf-8'); - - /** - * The CSS stylesheet - * @var string - */ - private $stylesheet; - // ################################################################### /** * Constructor @@ -233,28 +221,6 @@ class BSPrinterRootElementPage extends BSPrinterRootElement exit; } - // ################################################################### - /** - * Sets the language array information - * - * @param array Language array - */ - public function setLanguageInformation($lang) - { - $this->language = $lang; - } - - // ################################################################### - /** - * Sets the path to the CSS style sheet - * - * @param string Path - */ - public function setStylesheet($stylesheet) - { - $this->stylesheet = $stylesheet; - } - // ################################################################### /** * Returns the HTML for all printed children elements @@ -278,12 +244,14 @@ class BSPrinterRootElementPage extends BSPrinterRootElement * Tells the element to paint itself (and any children) */ public function paint() - { + { + $language = BSPrinter::GetLanguageInformation(); + echo "\n"; - echo "language['langcode'] . "\" lang=\"" . $this->language['langcode'] . "\" dir=\"" . $this->language['direction'] . "\">\n"; + echo "\n"; echo "\n\t" . sprintf(_('%1$s - %2$s'), BSRegister::GetApplication(), $this->title) . ""; - echo "\n\t"; - echo "\n\tstylesheet . "\" />"; + echo "\n\t"; + echo "\n\t"; echo "\n\n\n"; if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION'))) diff --git a/printer.php b/printer.php index e969329..ac2e403 100644 --- a/printer.php +++ b/printer.php @@ -20,8 +20,7 @@ \*=====================================================================*/ /** -* Printer -* printer.php +* Printer System (printer.php) * * @package ISSO */ @@ -36,27 +35,102 @@ require_once('ISSO/PrinterRootElementForm.php'); require_once('ISSO/PrinterTableElement.php'); /** -* Printer +* Printer System * -* This framework generates standard HTML through various functions. The purpose -* is generally so that things like the admin system can be created without templates. -* -* Constants: -* ISSO_PRINTER_DONE_HEADER - An internal constant that is used to check to see -* if the page header has already been printed -* ISSO_PRINTER_HIDE_SETUP - Will stop the page footer data (copyright and debug -* box) from being printed -* ISSO_PRINTER_NO_NAVIGATION - Do not show the navigation frame from ISSO.Printer.Navigation +* This is the root static framework module for the HTML printer system that +* works without templates. Here, you simply set the language and stylesheet +* information and use the other classes to generate the code. * * @author Blue Static -* @copyright Copyright ©2002 - [#]year[#], Blue Static +* @copyright Copyright (c)2002 - [#]year[#], Blue Static * @version $Revision$ * @package ISSO * */ -class Printer +class BSPrinter { - + /** + * Singleton instance + * @var BSPrinter + */ + private static $instance; + + /** + * Language information for all printer elements with format array(langcode: en_US, direction: ltr/rtl, charset: utf-8) + * @var string + */ + private $language = array('langcode' => 'en_US', 'direction' => 'ltr', 'charset' => 'utf-8'); + + /** + * CSS stylesheet to link to + * @var string + */ + private $stylesheet; + + // ################################################################### + /** + * Constructor (private) + */ + private function __construct() {} + + // ################################################################### + /** + * Returns the singleton instance + * + * @return BSPrinter Singleton instance + */ + public static function _Instance() + { + if (is_null(self::$instance)) + { + self::$instance = new BSPrinter(); + } + return self::$instance; + } + + // ################################################################### + /** + * Returns the language array + * + * @return array Language array + */ + public static function GetLanguageInformation() + { + return self::_Instance()->language; + } + + // ################################################################### + /** + * Sets the language array information + * + * @param array Language array + */ + public static function SetLanguageInformation($lang) + { + self::_Instance()->language = $lang; + } + + // ################################################################### + /** + * Returns the stylesheet URL + * + * @return string Stylesheet link + */ + public static function GetStylesheet() + { + return self::_Instance()->stylesheet; + } + + // ################################################################### + /** + * Sets the path to the CSS style sheet + * + * @param string Path + */ + public static function SetStylesheet($stylesheet) + { + self::_Instance()->stylesheet = $stylesheet; + } } /*=====================================================================*\ -- 2.43.5