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
50 // ###################################################################
54 * @param string Page title
56 function __construct($title)
58 $this->title
= $title;
61 // ###################################################################
63 * Creates a redirect to another page; constructs the header and footer
64 * (therefore execution stops)
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
71 public static function Redirect($controller, $action, $message = null, $postvars = array())
73 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
75 define('ISSO_PRINTER_NO_NAVIGATION', 1);
78 $page = new BSPrinterRootElementPage(_('Redirect'));
80 $page->addChild(new BSPrinterLabelElement('
81 <script type="text/javascript">
87 setTimeout("redirect()", timeout);
96 ' . ($postvars ? 'document.forms.postvars.submit();' : 'window.location = "' . "$controller.php?action=$action" . '";') . '
104 $vars = new BSPrinterRootElementForm($controller, $action, 'postvars
');
106 foreach ($postvars AS $key => $value)
108 $vars->addChild(new BSPrinterBaseElement('hidden
', $key, $value));
111 $page->addChild($vars);
114 $redir = _('Please wait to be redirected
. This page will load in a few seconds
.');
116 if ($message == null)
118 $showmessage = $redir;
122 $showmessage = '<blockquote
>' . $message . '</blockquote
>';
123 $showmessage .= "\n<p>" . $redir . "</p>";
127 $page->addChild(BSPrinterRootElementPage::Message(_('Redirect
'), $showmessage));
133 // ###################################################################
135 * Prints a complete table message
137 * @param string Message title
138 * @param string Message text
140 * @return BSPrinterRootElementTable A table
142 public static function Message($title, $message)
144 $table = new BSPrinterRootElementTable();
146 $head = new BSPrinterTableElement();
147 $head->setCssClass('tcat
');
148 $head->addChild(new BSPrinterLabelElement($title));
149 $table->addHeadingChild($head);
151 $msg = new BSPrinterTableElement();
152 $msg->addChild(new BSPrinterLabelElement((strpos($message, '<blockquote
') === false ? "<blockquote>$message</blockquote>" : $message)));
153 $table->addChild($msg);
158 // ###################################################################
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
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
169 public static function Confirm($message, $controller, $action, $params)
171 if (!defined('ISSO_PRINTER_NO_NAVIGATION
'))
173 define('ISSO_PRINTER_NO_NAVIGATION
', 1);
176 $page = new BSPrinterRootElementPage(_('Confirm
'));
178 $form = new BSPrinterRootElementForm($controller, $action);
179 foreach ($params AS $key => $value)
181 $form->addChild(new BSPrinterBaseElement('hidden
', $key, $value));
183 $page->addChild($form);
185 $table = new BSPrinterRootElementTable();
186 $table->setWidth('75%
');
188 $head = new BSPrinterTableElement();
189 $head->addChild(new BSPrinterLabelElement(_('Confirm
')));
190 $head->setCssClass('tcat
');
191 $table->addChild($head);
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));
198 $form->addChild($table);
204 // ###################################################################
206 * Throws a fatal error message
208 * @param string Error string
210 public static function Error($message)
212 if (!defined('ISSO_PRINTER_NO_NAVIGATION
'))
214 define('ISSO_PRINTER_NO_NAVIGATION
', 1);
217 $page = new BSPrinterRootElementPage(_('Error
'));
218 $page->addChild(BSPrinterRootElementPage::Message(_('Error
'), $message));
224 // ###################################################################
226 * Returns the HTML for all printed children elements
228 * @return string Printed HTML
230 protected function _paintChildren()
234 foreach ($this->children AS $child)
236 $this->builder .= "\n" . $child->paint() . "\n";
239 return $this->builder;
242 // ###################################################################
244 * Tells the element to paint itself (and any children)
246 public function paint()
248 $language = BSPrinter::GetLanguageInformation();
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";
257 if (BSRegister
::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
259 echo BSRegister
::GetType('PrinterNavigation')->constructHeaderHtml();
262 echo $this->_paintChildren();
264 if (BSRegister
::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
266 echo BSRegister
::GetType('PrinterNavigation')->constructFooterHtml();
269 $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>";
271 if (!defined('ISSO_PRINTER_HIDE_SETUP'))
277 if (BSRegister::GetDebug())
279 if (defined('SVN') AND preg_match('#^\$Id:?#', constant('SVN')))
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> — r\2</div>', constant('SVN'));
284 if (defined('ISSO_MT_START'))
286 echo "\n
<div align
=\"center\"
>Executed in
" . round(BSFunctions::FetchMicrotimeDiff(ISSO_MT_START), 10) . ' seconds</div>';
289 echo "\n
<br
/><div align
=\"center\"
>" . BSRegister::GetDebugList() . "</div
>\n";
291 if (BSRegister::GetType('Db'))
293 $queries = BSRegister::GetType('Db')->getHistory();
295 $table = new BSPrinterRootElementTable();
296 $head = new BSPrinterTableElement();
297 $head->addChild(new BSPrinterLabelElement('Query Debug'));
298 $head->setCssClass('thead');
299 $table->addHeadingChild($head);
301 foreach ($queries AS $query)
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);
308 $table->setWidth('30%');
310 echo $table->paint();
315 echo "\n\n
</body
>\n</html
>";
319 /*=====================================================================*
320 || ###################################################################
323 || ###################################################################
324 \*=====================================================================*/