2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2002-2007 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 2 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 - 2007, Blue Static
41 class BSPrinterRootElementPage
extends BSPrinterRootElement
49 // ###################################################################
53 * @param string Page title
55 function __construct($title)
57 $this->title
= $title;
60 // ###################################################################
62 * Creates a redirect to another page; constructs the header and footer
63 * (therefore execution stops)
65 * @param string Controller
66 * @param string Action
67 * @param string Redirect message to be shown
68 * @param array An aray of POST variables to send through on the redirect
70 public static function Redirect($controller, $action, $message = null, $postvars = array())
72 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
74 define('ISSO_PRINTER_NO_NAVIGATION', 1);
77 $page = new BSPrinterRootElementPage(_('Redirect'));
79 $page->addChild(new BSPrinterLabelElement('
80 <script type="text/javascript">
86 setTimeout("redirect()", timeout);
95 ' . ($postvars ? 'document.forms.postvars.submit();' : 'window.location = "' . "$controller.php?action=$action" . '";') . '
103 $vars = new BSPrinterRootElementForm($controller, $action, 'postvars
');
105 foreach ($postvars AS $key => $value)
107 $vars->addChild(new BSPrinterBaseElement('hidden
', $key, $value));
110 $page->addChild($vars);
113 $redir = _('Please wait to be redirected
. This page will load in a few seconds
.');
115 if ($message == null)
117 $showmessage = $redir;
121 $showmessage = '<blockquote
>' . $message . '</blockquote
>';
122 $showmessage .= "\n<p>" . $redir . "</p>";
126 $page->addChild(BSPrinterRootElementPage::Message(_('Redirect
'), $showmessage));
132 // ###################################################################
134 * Prints a complete table message
136 * @param string Message title
137 * @param string Message text
139 * @return BSPrinterRootElementTable A table
141 public static function Message($title, $message)
143 $table = new BSPrinterRootElementTable();
145 $head = new BSPrinterTableElement();
146 $head->setCssClass('tcat
');
147 $head->addChild(new BSPrinterLabelElement($title));
148 $table->addHeadingChild($head);
150 $msg = new BSPrinterTableElement();
151 $msg->addChild(new BSPrinterLabelElement((strpos($message, '<blockquote
') === false ? "<blockquote>$message</blockquote>" : $message)));
152 $table->addChild($msg);
157 // ###################################################################
159 * Produces an entire page layout that asks the user whether or not
160 * they want to perform X action and provides a link to the YES and NO
163 * @param string Message that asks if they want to do X
164 * @param string Controller to go for YES
165 * @param string Action to pass
166 * @param array Hidden parameters to pass to the next page
168 public static function Confirm($message, $controller, $action, $params)
170 if (!defined('ISSO_PRINTER_NO_NAVIGATION
'))
172 define('ISSO_PRINTER_NO_NAVIGATION
', 1);
175 $page = new BSPrinterRootElementPage(_('Confirm
'));
177 $form = new BSPrinterRootElementForm($controller, $action);
178 foreach ($params AS $key => $value)
180 $form->addChild(new BSPrinterBaseElement('hidden
', $key, $value));
182 $page->addChild($form);
184 $table = new BSPrinterRootElementTable();
185 $table->setWidth('75%
');
187 $head = new BSPrinterTableElement();
188 $head->addChild(new BSPrinterLabelElement(_('Confirm
')));
189 $head->setCssClass('tcat
');
190 $table->addChild($head);
192 $table->addChild(new BSPrinterTableElement(new BSPrinterLabelElement("<blockquote>$message</blockquote>")));
193 $no = new BSPrinterBaseElement('button
', '__no__
', _('No
'));
194 $no->setOnClick('history
.back(1); return false;');
195 $table->addChild(BSPrinterTableElement::RowSubmit(array($no), _('Yes
'), null));
197 $form->addChild($table);
203 // ###################################################################
205 * Throws a fatal error message
207 * @param string Error string
209 public static function Error($message)
211 if (!defined('ISSO_PRINTER_NO_NAVIGATION
'))
213 define('ISSO_PRINTER_NO_NAVIGATION
', 1);
216 $page = new BSPrinterRootElementPage(_('Error
'));
217 $page->addChild(BSPrinterRootElementPage::Message(_('Error
'), $message));
223 // ###################################################################
225 * Returns the HTML for all printed children elements
227 * @return string Printed HTML
229 protected function _paintChildren()
233 foreach ($this->children AS $child)
235 $this->builder .= "\n" . $child->paint() . "\n";
238 return $this->builder;
241 // ###################################################################
243 * Tells the element to paint itself (and any children)
245 public function paint()
247 $language = BSPrinter::GetLanguageInformation();
249 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
250 echo "<html xml:lang=\"" . $language['langcode
'] . "\" lang=\"" . $language['langcode
'] . "\" dir=\"" . $language['direction
'] . "\">\n<head>";
251 echo "\n\t<title>" . sprintf(_('%
1$s - %
2$s - %
3$s'), BSApp
::GetApplication(), BSPrinter
::GetRealm(), $this->title
) . "</title>";
252 echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . $language['charset'] . "\" />";
253 echo "\n\t<link rel=\"stylesheet\" href=\"" . BSPrinter
::GetStylesheet() . "\" />";
254 echo "\n</head>\n<body>\n";
256 if (BSApp
::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
258 echo BSApp
::GetType('PrinterNavigation')->constructHeaderHtml();
261 echo $this->_paintChildren();
263 if (BSApp
::GetType('PrinterNavigation') AND (!defined('ISSO_PRINTER_NO_NAVIGATION') OR !constant('ISSO_PRINTER_NO_NAVIGATION')))
265 echo BSApp
::GetType('PrinterNavigation')->constructFooterHtml();
268 $copyright = "\n<br />\n<p align=\"center\" class=\"copyright\">\n\t<a href=\"http://www.bluestatic.org\" target=\"_blank\">" . BSApp
::GetApplication() . ' ' . BSApp
::GetAppVersion() . ", ©2002 - " . gmdate('Y') . " Blue Static</a>\n</p>";
270 if (!defined('ISSO_PRINTER_HIDE_SETUP'))
276 if (BSApp::GetDebug())
278 if (defined('SVN') AND preg_match('#^\$Id:?#', constant('SVN')))
280 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'));
283 if (defined('ISSO_MT_START'))
285 echo "\n
<div align
=\"center\"
>Executed in
" . round(BSFunctions::FetchMicrotimeDiff(ISSO_MT_START), 10) . ' seconds</div>';
288 echo "\n
<br
/><div align
=\"center\"
>" . BSApp::GetDebugList() . "</div
>\n";
290 if (BSApp::GetType('Db'))
292 $queries = BSApp::GetType('Db')->getHistory();
294 $table = new BSPrinterRootElementTable();
295 $head = new BSPrinterTableElement();
296 $head->addChild(new BSPrinterLabelElement('Query Debug'));
297 $head->setCssClass('thead');
298 $table->addHeadingChild($head);
300 foreach ($queries AS $query)
302 $tr = new BSPrinterTableElement();
303 $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"));
304 $table->addChild($tr);
307 $table->setWidth('30%');
309 echo $table->paint();
314 echo "\n\n
</body
>\n</html
>";