2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright ©2002-[#]year[#] Blue Static
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.
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
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 \*=====================================================================*/
23 * Printer Root Element: Page (PrinterRootElementPage.php)
28 require_once('ISSO/PrinterRootElement.php');
31 * Printer Root Element: Page
33 * This root element represents the entire page and is usually used for all
34 * printer applications
37 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
42 class BSPrinterRootElementPage
extends BSPrinterRootElement
51 * Language information array: ('langcode' =>, 'direction' =>, 'charset' =>)
54 private $language = array('langcode' => 'en_US', 'direction' => 'ltr', 'charset' => 'utf-8');
62 // ###################################################################
66 * @param string Page title
68 function __construct($title)
70 $this->title
= $title;
73 // ###################################################################
75 * Creates a redirect to another page; constructs the header and footer
76 * (therefore execution stops)
78 * @param string Controller
79 * @param string Action
80 * @param string Redirect message to be shown
81 * @param array An aray of POST variables to send through on the redirect
83 public static function Redirect($controller, $action, $message = null
, $postvars = array())
85 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
87 define('ISSO_PRINTER_NO_NAVIGATION', 1);
90 $page = new BSPrinterRootElementPage(_('Redirect'));
92 $page->addChild(new BSPrinterLabelElement('
93 <script type="text/javascript">
99 setTimeout("redirect()", timeout);
108 ' . ($postvars ?
'document.forms.postvars.submit();' : 'window.location = "' . (BSRegister
::GetType('Router') ?
(defined('ISSO_ROUTER_NO_REWRITE') ?
"index.php?controller=$controller&action=$action" : "$controller.$action") : "$controller.php?action=$action") . '";') . '
116 $vars = new BSPrinterRootElementForm($controller, $action, 'postvars');
118 foreach ($postvars AS $key => $value)
120 $vars->addChild(new BSPrinterBaseElement('hidden', $key, $value));
123 $page->addChild($vars);
126 $redir = _('Please wait to be redirected. This page will load in a few seconds.');
128 if ($message == null
)
130 $showmessage = $redir;
134 $showmessage = '<blockquote>' . $message . '</blockquote>';
135 $showmessage .= "\n<p>" . $redir . "</p>";
139 $page->addChild(BSPrinterRootElementPage
::Message(_('Redirect'), $showmessage));
145 // ###################################################################
147 * Prints a complete table message
149 * @param string Message title
150 * @param string Message text
152 * @return BSPrinterRootElementTable A table
154 public static function Message($title, $message)
156 $table = new BSPrinterRootElementTable();
158 $head = new BSPrinterTableElement();
159 $head->setCssClass('tcat');
160 $head->addChild(new BSPrinterLabelElement($title));
161 $table->addHeadingChild($head);
163 $msg = new BSPrinterTableElement();
164 $msg->addChild(new BSPrinterLabelElement((strpos($message, '<blockquote') === false ?
"<blockquote>$message</blockquote>" : $message)));
165 $table->addChild($msg);
170 // ###################################################################
172 * Produces an entire page layout that asks the user whether or not
173 * they want to perform X action and provides a link to the YES and NO
176 * @param string Message that asks if they want to do X
177 * @param string Controller to go for YES
178 * @param string Action to pass
179 * @param array Hidden parameters to pass to the next page
181 public static function Confirm($message, $controller, $action, $params)
183 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
185 define('ISSO_PRINTER_NO_NAVIGATION', 1);
188 $page = new BSPrinterRootElementPage(_('Confirm'));
190 $form = new BSPrinterRootElementForm($controller, $action);
191 foreach ($params AS $key => $value)
193 $form->addChild(new BSPrinterBaseElement('hidden', $key, $value));
195 $page->addChild($form);
197 $table = new BSPrinterRootElementTable();
198 $table->setWidth('75%');
200 $head = new BSPrinterTableElement();
201 $head->addChild(new BSPrinterLabelElement(_('Confirm')));
202 $head->setCssClass('tcat');
203 $table->addChild($head);
205 $table->addChild(new BSPrinterTableElement(new BSPrinterLabelElement("<blockquote>$message</blockquote>")));
206 $no = new BSPrinterBaseElement('button', '__no__', _('No'));
207 $no->setOnClick('history.back(1); return false;');
208 $table->addChild(BSPrinterTableElement
::RowSubmit(array($no), _('Yes'), null
));
210 $form->addChild($table);
216 // ###################################################################
218 * Throws a fatal error message
220 * @param string Error string
222 public static function Error($message)
224 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
226 define('ISSO_PRINTER_NO_NAVIGATION', 1);
229 $page = new BSPrinterRootElementPage(_('Error'));
230 $page->addChild(BSPrinterRootElementPage
::Message(_('Error'), $message));
236 // ###################################################################
238 * Sets the language array information
240 * @param array Language array
242 public function setLanguageInformation($lang)
244 $this->language
= $lang;
247 // ###################################################################
249 * Sets the path to the CSS style sheet
253 public function setStylesheet($stylesheet)
255 $this->stylesheet
= $stylesheet;
258 // ###################################################################
260 * Returns the HTML for all printed children elements
262 * @return string Printed HTML
264 protected function _paintChildren()
268 foreach ($this->children
AS $child)
270 $this->builder
.= "\n" . $child->paint() . "\n";
273 return $this->builder
;
276 // ###################################################################
278 * Tells the element to paint itself (and any children)
280 public function paint()
282 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
283 echo "<html xml:lang=\"" . $this->language
['langcode'] . "\" lang=\"" . $this->language
['langcode'] . "\" dir=\"" . $this->language
['direction'] . "\">\n<head>";
284 echo "\n\t<title>" . sprintf(_('%1$s - %2$s'), BSRegister
::GetApplication(), $this->title
) . "</title>";
285 echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . $this->language
['charset'] . "\" />";
286 echo "\n\t<link rel=\"stylesheet\" href=\"" . $this->stylesheet
. "\" />";
287 echo "\n</head>\n<body>\n";
289 if (BSRegister
::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
291 echo BSRegister
::GetType('PrinterNavigation')->generate_header_html();
294 echo $this->_paintChildren();
296 if (BSRegister
::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
298 echo BSRegister
::GetType('PrinterNavigation')->generate_footer_html();
301 $copyright = "\n<br />\n<p align=\"center\" class=\"copyright\">\n\t<a href=\"http://www.bluestatic.org\" target=\"_blank\">" . BSRegister
::GetApplication() . ' ' . BSRegister
::GetAppVersion() . ", ©2002 - " . gmdate('Y') . " Blue Static</a>\n</p>";
303 if (!defined('ISSO_PRINTER_HIDE_SETUP'))
309 if (BSRegister
::GetDebug())
311 if (defined('SVN') AND preg_match('#^\$Id:?#', constant('SVN')))
313 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> — r\2</div>', constant('SVN'));
316 if (defined('ISSO_MT_START'))
318 echo "\n<div align=\"center\">Executed in " . round(BSFunctions
::FetchMicrotimeDiff(ISSO_MT_START
), 10) . ' seconds</div>';
321 echo "\n<br /><div align=\"center\">" . BSRegister
::GetDebugList() . "</div>\n";
323 if (BSRegister
::GetType('Db'))
325 $queries = BSRegister
::GetType('Db')->getHistory();
327 $table = new BSPrinterRootElementTable();
328 $head = new BSPrinterTableElement();
329 $head->addChild(new BSPrinterLabelElement('Query Debug'));
330 $head->setCssClass('thead');
331 $table->addHeadingChild($head);
333 foreach ($queries AS $query)
335 $tr = new BSPrinterTableElement();
336 $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"));
337 $table->addChild($tr);
340 $table->setWidth('30%');
342 echo $table->paint();
347 echo "\n\n</body>\n</html>";
351 /*=====================================================================*
352 || ###################################################################
355 || ###################################################################
356 \*=====================================================================*/