Removing the pconnect option from BSDb and it's children.
[isso.git] / PrinterRootElementPage.php
1 <?php
2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
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 /**
52 * Constructor
53 *
54 * @param string Page title
55 */
56 function __construct($title)
57 {
58 $this->title = $title;
59 }
60
61 // ###################################################################
62 /**
63 * Creates a redirect to another page; constructs the header and footer
64 * (therefore execution stops)
65 *
66 * @param string Controller
67 * @param string Action
68 * @param string Redirect message to be shown
69 * @param array An aray of POST variables to send through on the redirect
70 */
71 public static function Redirect($controller, $action, $message = null, $postvars = array())
72 {
73 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
74 {
75 define('ISSO_PRINTER_NO_NAVIGATION', 1);
76 }
77
78 $page = new BSPrinterRootElementPage(_('Redirect'));
79
80 $page->addChild(new BSPrinterLabelElement('
81 <script type="text/javascript">
82 <!--
83 var timeout = 2000;
84
85 if (timeout > 0)
86 {
87 setTimeout("redirect()", timeout);
88 }
89 else
90 {
91 redirect();
92 }
93
94 function redirect()
95 {
96 ' . ($postvars ? 'document.forms.postvars.submit();' : 'window.location = "' . "$controller.php?action=$action" . '";') . '
97 }
98
99 //-->
100 </script>'));
101
102 if ($postvars)
103 {
104 $vars = new BSPrinterRootElementForm($controller, $action, 'postvars');
105
106 foreach ($postvars AS $key => $value)
107 {
108 $vars->addChild(new BSPrinterBaseElement('hidden', $key, $value));
109 }
110
111 $page->addChild($vars);
112 }
113
114 $redir = _('Please wait to be redirected. This page will load in a few seconds.');
115 $override = false;
116 if ($message == null)
117 {
118 $showmessage = $redir;
119 }
120 else
121 {
122 $showmessage = '<blockquote>' . $message . '</blockquote>';
123 $showmessage .= "\n<p>" . $redir . "</p>";
124 $override = true;
125 }
126
127 $page->addChild(BSPrinterRootElementPage::Message(_('Redirect'), $showmessage));
128
129 $page->paint();
130 exit;
131 }
132
133 // ###################################################################
134 /**
135 * Prints a complete table message
136 *
137 * @param string Message title
138 * @param string Message text
139 *
140 * @return BSPrinterRootElementTable A table
141 */
142 public static function Message($title, $message)
143 {
144 $table = new BSPrinterRootElementTable();
145
146 $head = new BSPrinterTableElement();
147 $head->setCssClass('tcat');
148 $head->addChild(new BSPrinterLabelElement($title));
149 $table->addHeadingChild($head);
150
151 $msg = new BSPrinterTableElement();
152 $msg->addChild(new BSPrinterLabelElement((strpos($message, '<blockquote') === false ? "<blockquote>$message</blockquote>" : $message)));
153 $table->addChild($msg);
154
155 return $table;
156 }
157
158 // ###################################################################
159 /**
160 * Produces an entire page layout that asks the user whether or not
161 * they want to perform X action and provides a link to the YES and NO
162 * action
163 *
164 * @param string Message that asks if they want to do X
165 * @param string Controller to go for YES
166 * @param string Action to pass
167 * @param array Hidden parameters to pass to the next page
168 */
169 public static function Confirm($message, $controller, $action, $params)
170 {
171 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
172 {
173 define('ISSO_PRINTER_NO_NAVIGATION', 1);
174 }
175
176 $page = new BSPrinterRootElementPage(_('Confirm'));
177
178 $form = new BSPrinterRootElementForm($controller, $action);
179 foreach ($params AS $key => $value)
180 {
181 $form->addChild(new BSPrinterBaseElement('hidden', $key, $value));
182 }
183 $page->addChild($form);
184
185 $table = new BSPrinterRootElementTable();
186 $table->setWidth('75%');
187
188 $head = new BSPrinterTableElement();
189 $head->addChild(new BSPrinterLabelElement(_('Confirm')));
190 $head->setCssClass('tcat');
191 $table->addChild($head);
192
193 $table->addChild(new BSPrinterTableElement(new BSPrinterLabelElement("<blockquote>$message</blockquote>")));
194 $no = new BSPrinterBaseElement('button', '__no__', _('No'));
195 $no->setOnClick('history.back(1); return false;');
196 $table->addChild(BSPrinterTableElement::RowSubmit(array($no), _('Yes'), null));
197
198 $form->addChild($table);
199
200 $page->paint();
201 exit;
202 }
203
204 // ###################################################################
205 /**
206 * Throws a fatal error message
207 *
208 * @param string Error string
209 */
210 public static function Error($message)
211 {
212 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
213 {
214 define('ISSO_PRINTER_NO_NAVIGATION', 1);
215 }
216
217 $page = new BSPrinterRootElementPage(_('Error'));
218 $page->addChild(BSPrinterRootElementPage::Message(_('Error'), $message));
219 $page->paint();
220
221 exit;
222 }
223
224 // ###################################################################
225 /**
226 * Returns the HTML for all printed children elements
227 *
228 * @return string Printed HTML
229 */
230 protected function _paintChildren()
231 {
232 $builder = '';
233
234 foreach ($this->children AS $child)
235 {
236 $this->builder .= "\n" . $child->paint() . "\n";
237 }
238
239 return $this->builder;
240 }
241
242 // ###################################################################
243 /**
244 * Tells the element to paint itself (and any children)
245 */
246 public function paint()
247 {
248 $language = BSPrinter::GetLanguageInformation();
249
250 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
251 echo "<html xml:lang=\"" . $language['langcode'] . "\" lang=\"" . $language['langcode'] . "\" dir=\"" . $language['direction'] . "\">\n<head>";
252 echo "\n\t<title>" . sprintf(_('%1$s - %2$s - %3$s'), BSRegister::GetApplication(), BSPrinter::GetRealm(), $this->title) . "</title>";
253 echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . $language['charset'] . "\" />";
254 echo "\n\t<link rel=\"stylesheet\" href=\"" . BSPrinter::GetStylesheet() . "\" />";
255 echo "\n</head>\n<body>\n";
256
257 if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
258 {
259 echo BSRegister::GetType('PrinterNavigation')->constructHeaderHtml();
260 }
261
262 echo $this->_paintChildren();
263
264 if (BSRegister::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
265 {
266 echo BSRegister::GetType('PrinterNavigation')->constructFooterHtml();
267 }
268
269 $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>";
270
271 if (!defined('ISSO_PRINTER_HIDE_SETUP'))
272 {
273 echo "\n$copyright";
274
275 echo "\n\n\n";
276
277 if (BSRegister::GetDebug())
278 {
279 if (defined('SVN') AND preg_match('#^\$Id:?#', constant('SVN')))
280 {
281 echo preg_replace('#\$' . 'Id: (.+?) ([0-9].+?) [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.+?) (.+?) \$#', "\n<br />\n" . '<div align="center"><strong>\1</strong> &mdash; r\2</div>', constant('SVN'));
282 }
283
284 if (defined('ISSO_MT_START'))
285 {
286 echo "\n<div align=\"center\">Executed in " . round(BSFunctions::FetchMicrotimeDiff(ISSO_MT_START), 10) . ' seconds</div>';
287 }
288
289 echo "\n<br /><div align=\"center\">" . BSRegister::GetDebugList() . "</div>\n";
290
291 if (BSRegister::GetType('Db'))
292 {
293 $queries = BSRegister::GetType('Db')->getHistory();
294
295 $table = new BSPrinterRootElementTable();
296 $head = new BSPrinterTableElement();
297 $head->addChild(new BSPrinterLabelElement('Query Debug'));
298 $head->setCssClass('thead');
299 $table->addHeadingChild($head);
300
301 foreach ($queries AS $query)
302 {
303 $tr = new BSPrinterTableElement();
304 $tr->addChild(new BSPrinterLabelElement("\n\t\t\t" . $query['query'] . "\n\n\t\t\t<div class=\"smallfont\">(" . $query['time'] . ")</div>\n<!--\n" . $query['trace'] . "\n-->\n\t\t"));
305 $table->addChild($tr);
306 }
307
308 $table->setWidth('30%');
309
310 echo $table->paint();
311 }
312 }
313 }
314
315 echo "\n\n</body>\n</html>";
316 }
317 }
318
319 /*=====================================================================*
320 || ###################################################################
321 || # $HeadURL$
322 || # $Id$
323 || ###################################################################
324 \*=====================================================================*/
325 ?>