/** * Initialize alerts alerts. * * Initialize alerts alerts by copying redirected alerts from * session to the local <var>$alerts</var> array. */ public static function init() { // setup alerts self::$alerts[self::TYPE_ERROR] = array(); self::$alerts[self::TYPE_NOTICE] = array(); if (Pfw_Session::isStarted()) { // setup session alerts $session_alerts = Pfw_Session::get(self::SESSION_KEY); if (isset($session_alerts)) { if (isset($session_alerts[self::TYPE_ERROR])) { self::$alerts[self::TYPE_ERROR] = $session_alerts[self::TYPE_ERROR]; } if (isset($session_alerts[self::TYPE_NOTICE])) { self::$alerts[self::TYPE_NOTICE] = $session_alerts[self::TYPE_NOTICE]; } Pfw_Session::clear(self::SESSION_KEY); } } else { error_log("Pfw_Session is not initialized prior to Pfw_Alert, " . "alerts / notices which follow redirects " . "may exhibit unexpected behavior", E_USER_WARNING); } self::$initialized = true; }
/** * Add a project specific startup here */ global $_PATHS, $_ENVIRONMENT; Pfw_Loader::loadFile("pfw_routes.php", $_PATHS['conf']); Pfw_Loader::loadClass('Pfw_Controller_Front'); Pfw_Loader::loadClass('Pfw_PluginManager'); Pfw_Loader::loadClass('Pfw_Session'); Pfw_Loader::loadClass('Pfw_Alert'); // initialize the session Pfw_Session::start(); // initialize the plugin manager Pfw_PluginManager::init(); // initialize alerts Pfw_Alert::init(); // turn off error display for production if ($_ENVIRONMENT == "production") { ini_set('display_errors', 0); ini_set('log_errors', 1); } // setup front controller and routing $front = Pfw_Controller_Front::getInstance(); $front->getRouter()->setRoutes($_pfw_routes)->setModules($_pfw_modules); $four_oh_four = false; try { $front->dispatch(); } catch (Pfw_Exception_System $e) { $e->emitLog(); if ($_ENVIRONMENT == "development") { objp($e);
function smarty_function_display_errors($args, &$smarty) { $inc_fields = isset($args['inc_fields']) ? $args['inc_fields'] : false; if (Pfw_Alert::hasError()) { $errors = Pfw_Alert::getErrors($in); $list = "<ul class=\"pfw-alert pfw-error\">\n"; foreach ($errors as $error) { $list .= "<li>{$error}</li>\n"; } $list .= "</ul>"; return $list; } return ""; }