Adding a bunch of new Printer stuff that I'm not sure works quite yet
[isso.git] / PrinterRootElementPage.php
1 <?php
2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 /**
23 * Printer Root Element: Page (PrinterRootElementPage.php)
24 *
25 * @package ISSO
26 */
27
28 require_once('ISSO/PrinterRootElement.php');
29
30 /**
31 * Printer Root Element: Page
32 *
33 * This root element represents the entire page and is usually used for all
34 * printer applications
35 *
36 * @author Blue Static
37 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
38 * @version $Revision$
39 * @package ISSO
40 *
41 */
42 class BSPrinterRootElementPage extends BSPrinterRootElement
43 {
44 /**
45 * The page title
46 * @var string
47 */
48 private $title;
49
50 /**
51 * Language information array: ('langcode' =>, 'direction' =>, 'charset' =>)
52 * @var array
53 */
54 private $language = array('langcode' => 'en_US', 'direction' => 'ltr', 'charset' => 'utf-8');
55
56 /**
57 * The CSS stylesheet
58 * @var string
59 */
60 private $stylesheet;
61
62 /**
63 * Constructor
64 *
65 * @param BSPrinter Printer object
66 * @param string Page title
67 */
68 function __construct($printer, $title)
69 {
70 $this->title = $title;
71 parent::__construct($printer);
72 }
73
74 // ###################################################################
75 /**
76 * Sets the language array information
77 *
78 * @param array Language array
79 */
80 public function setLanguageInformation($lang)
81 {
82 $this->language = $lang;
83 }
84
85 // ###################################################################
86 /**
87 * Sets the path to the CSS style sheet
88 *
89 * @param string Path
90 */
91 public function setStylesheet($stylesheet)
92 {
93 $this->stylesheet = $stylesheet;
94 }
95
96 // ###################################################################
97 /**
98 * Sets the parent element
99 */
100 public function setParent(BSPrinterElement $parent)
101 {
102 trigger_error('Cannot set the parent element on a BSPrinterRootElement');
103 }
104
105 // ###################################################################
106 /**
107 * Gets the parent element (none exist as this is the root element)
108 */
109 public function getParent()
110 {
111 return null;
112 }
113
114 // ###################################################################
115 /**
116 * Returns the HTML for all printed children elements
117 *
118 * @return string Printed HTML
119 */
120 protected function _paintChildren()
121 {
122 $builder = '';
123
124 foreach ($this->children AS $child)
125 {
126 $this->builder .= "\n" . $child->paint() . "\n";
127 }
128
129 return $this->builder;
130 }
131
132 // ###################################################################
133 /**
134 * Tells the element to paint itself (and any children)
135 */
136 public function paint()
137 {
138 $this->printer->paint("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
139 $this->printer->paint("<html xml:lang=\"" . $this->language['langcode'] . "\" lang=\"" . $this->language['langcode'] . "\" dir=\"" . $this->language['direction'] . "\">\n<head>");
140 $this->printer->paint("\n\t<title>" . sprintf(_('%1$s - %2$s'), BSRegister::GetApplication(), $this->title) . "</title>");
141 $this->printer->paint("\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . $this->language['charset'] . "\" />");
142 $this->printer->paint("\n\t<link rel=\"stylesheet\" href=\"" . $this->stylesheet . "\" />");
143 // echo $this->code;
144 $this->printer->paint("\n</head>\n<body>\n");
145
146 if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR (defined('ISSO_PRINTER_NO_NAVIGATION') AND constant('ISSO_PRINTER_NO_NAVIGATION') != true)))
147 {
148 echo BSRegister::GetType('PrinterNavigation')->generate_header_html();
149 }
150
151 $this->printer->paint($this->_paintChildren());
152
153 if (BSRegister::GetDebug() AND isset($_GET['query']))
154 {
155 ob_clean();
156 ob_end_clean();
157
158 if (is_array($this->registry->modules[ISSO_DB_LAYER]->history))
159 {
160 foreach ($this->registry->modules[ISSO_DB_LAYER]->history AS $query)
161 {
162 echo $this->registry->modules[ISSO_DB_LAYER]->construct_query_debug($query);
163 }
164 }
165 exit;
166 }
167
168 if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR (defined('ISSO_PRINTER_NO_NAVIGATION') AND constant('ISSO_PRINTER_NO_NAVIGATION') != true)))
169 {
170 echo BSRegister::GetType('PrinterNavigation')->generate_footer_html();
171 }
172
173 $copyright = "\n<br />\n<p align=\"center\" class=\"copyright\">\n\t<a href=\"http://www.bluestatic.org\" target=\"_blank\">" . BSRegister::GetApplication() . ' ' . BSRegister::GetAppVersion() . ", &copy;2002 - " . gmdate('Y') . " Blue Static</a>\n</p>";
174
175 if (!defined('ISSO_PRINTER_HIDE_SETUP'))
176 {
177 $this->printer->paint("\n$copyright");
178 //echo $this->registry->construct_debug_block(false);
179 }
180
181 $this->printer->paint("\n\n</body>\n</html>");
182
183 exit;
184 }
185 }
186
187 /*=====================================================================*
188 || ###################################################################
189 || # $HeadURL$
190 || # $Id$
191 || ###################################################################
192 \*=====================================================================*/
193 ?>