title = $title; } /** * Makes a new instance of the object in a static fashion * * @return object */ public static function make() { $obj = new ReflectionClass(__CLASS__); $args = func_get_args(); return $obj->newInstanceArgs($args); } /** * Sets the navigation object * * @param BSPrinterNavigation Navigator * * @return fluent interface */ public function setNavigator(BSPrinterNavigation $nav) { $this->navigator = $nav; return $this; } /** * Returns the printer navigation object * * @return BSPrinterNavigation Navigation object */ public function getNavigatior() { return $this->navigatior; } // ################################################################### /** * Creates a redirect to another page; constructs the header and footer * (therefore execution stops) * * @param string Controller * @param string Action * @param string Redirect message to be shown * @param array An aray of POST variables to send through on the redirect */ public static function redirect($controller, $action, $message = null, $postvars = array()) { if (!defined('ISSO_PRINTER_NO_NAVIGATION')) { define('ISSO_PRINTER_NO_NAVIGATION', 1); } $page = new BSPrinterRootElementPage(_('Redirect')); $page->addChild(new BSPrinterLabelElement(' ')); if ($postvars) { $vars = new BSPrinterRootElementForm($controller, $action, 'postvars'); foreach ($postvars as $key => $value) { $vars->addChild(new BSPrinterBaseElement('hidden', $key, $value)); } $page->addChild($vars); } $redir = _('Please wait to be redirected. This page will load in a few seconds.'); $override = false; if ($message == null) { $showmessage = $redir; } else { $showmessage = '
' . $message . '
'; $showmessage .= "\n

" . $redir . "

"; $override = true; } $page->addChild(BSPrinterRootElementPage::message(_('Redirect'), $showmessage)); $page->paint(); exit; } // ################################################################### /** * Prints a complete table message * * @param string Message title * @param string Message text * * @return BSPrinterRootElementTable A table */ public static function message($title, $message) { $table = new BSPrinterRootElementTable(); $head = new BSPrinterTableElement(); $head->setCssClass('tcat'); $head->addChild(new BSPrinterLabelElement($title)); $table->addHeadingChild($head); $msg = new BSPrinterTableElement(); $msg->addChild(new BSPrinterLabelElement((strpos($message, '$message" : $message))); $table->addChild($msg); return $table; } // ################################################################### /** * Produces an entire page layout that asks the user whether or not * they want to perform X action and provides a link to the YES and NO * action * * @param string Message that asks if they want to do X * @param string Controller to go for YES * @param string Action to pass * @param array Hidden parameters to pass to the next page */ public static function confirm($message, $controller, $action, $params) { if (!defined('ISSO_PRINTER_NO_NAVIGATION')) { define('ISSO_PRINTER_NO_NAVIGATION', 1); } $page = new BSPrinterRootElementPage(_('Confirm')); $form = new BSPrinterRootElementForm($controller, $action); foreach ($params as $key => $value) { $form->addChild(new BSPrinterBaseElement('hidden', $key, $value)); } $page->addChild($form); $table = new BSPrinterRootElementTable(); $table->setWidth('75%'); $head = new BSPrinterTableElement(); $head->addChild(new BSPrinterLabelElement(_('Confirm'))); $head->setCssClass('tcat'); $table->addChild($head); $table->addChild(new BSPrinterTableElement(new BSPrinterLabelElement("
$message
"))); $no = new BSPrinterBaseElement('button', '__no__', _('No')); $no->setOnClick('history.back(1); return false;'); $table->addChild(BSPrinterTableElement::row_submit(array($no), _('Yes'), null)); $form->addChild($table); $page->paint(); exit; } // ################################################################### /** * Throws a fatal error message * * @param string Error string */ public static function error($message) { if (!defined('ISSO_PRINTER_NO_NAVIGATION')) { define('ISSO_PRINTER_NO_NAVIGATION', 1); } $page = new BSPrinterRootElementPage(_('Error')); $page->addChild(BSPrinterRootElementPage::message(_('Error'), $message)); $page->paint(); exit; } // ################################################################### /** * Returns the HTML for all printed children elements * * @return string Printed HTML */ protected function _paintChildren() { $builder = ''; foreach ($this->children as $child) { $builder .= "\n" . $child->paint() . "\n"; } return $builder; } // ################################################################### /** * Tells the element to paint itself (and any children) */ public function paint() { $language = BSPrinter::get_language_information(); echo "\n"; echo "\n"; echo "\n\t" . BSPrinter::get_realm() . " - " . $this->title . ""; echo "\n\t"; echo "\n\t"; echo "\n\n\n"; if ($this->navigator && (!defined('ISSO_PRINTER_NO_NAVIGATION') || !constant('ISSO_PRINTER_NO_NAVIGATION'))) { echo $this->navigator->constructHeaderHtml(); } echo $this->_paintChildren(); if ($this->navigator && (!defined('ISSO_PRINTER_NO_NAVIGATION') || !constant('ISSO_PRINTER_NO_NAVIGATION'))) { echo $this->navigator->constructFooterHtml(); } $copyright = "\n
\n

\n\t" . BSPrinter::get_copyright() . "\n

"; if (!defined('ISSO_PRINTER_HIDE_SETUP')) { echo "\n$copyright"; echo "\n\n\n"; if (BSApp::get_debug()) { if (defined('SVN') && preg_match('#^\$Id:?#', constant('SVN'))) { 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
\n" . '
\1 — r\2
', constant('SVN')); } if (defined('ISSO_MT_START')) { echo "\n
Executed in " . round(BSFunctions::fetch_microtime_diff(ISSO_MT_START), 10) . ' seconds
'; } echo "\n
" . BSApp::get_debug_list() . "
\n"; if (BSApp::$db) { $queries = BSApp::$db->getHistory(); $table = new BSPrinterRootElementTable(); $head = new BSPrinterTableElement(); $head->addChild(new BSPrinterLabelElement('Query Debug')); $head->setCssClass('thead'); $table->addHeadingChild($head); foreach ($queries as $query) { $tr = new BSPrinterTableElement(); $tr->addChild(new BSPrinterLabelElement("\n\t\t\t" . $query['query'] . "\n\n\t\t\t
(" . $query['time'] . ")
\n\n\t\t")); $table->addChild($tr); } $table->setWidth('30%'); echo $table->paint(); } } } echo "\n\n\n"; } } ?>