static function render($viewName) { $viewName = str_replace('\\', DIRECTORY_SEPARATOR, $viewName); if (!self::exists($viewName)) { throw new ViewNotFoundException('View not found: ' . $viewName); } // Add some useful vars to the response $config = \ManiaLib\Application\Config::getInstance(); $session = \ManiaLib\Application\Session::getInstance(); $response = \ManiaLib\Application\Response::getInstance(); $tracking = \ManiaLib\Application\Tracking\Config::getInstance(); $response->login = $session->login; $response->mediaURL = $config->getMediaURL(); $response->appURL = $config->getLinkCreationURL(); $response->baseURL = $config->URL; $response->trackingAccount = $tracking->account; $vars = \ManiaLib\Application\Response::getInstance()->getAll(); extract($vars); error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); if (file_exists(MANIALIB_APP_PATH . 'resources/' . $viewName . '.php')) { require MANIALIB_APP_PATH . 'resources/' . $viewName . '.php'; } else { require MANIALIB_APP_PATH . 'ressources/' . $viewName . '.php'; } error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED); }
function __destruct() { if ($this->registerRefererAtDestruct) { if (!Response::getInstance()->dialog) { $session = Session::getInstance(); $session->set('referer', rawurlencode($this->registerRefererAtDestruct)); } } }
/** * Display box, or boxes, automatically depending in session vars * Usage: * <?php echo NadeoLib\WebUI\Helpers\Box\Box::detect() ?> * @param bool $delete Delete session var after usage * @return string */ public static function detect($delete = true) { $session = \ManiaLib\Application\Session::getInstance(); $result = ''; foreach (self::$boxTypes as $type => $class) { $values = $session->get($type); if ($values) { if (!is_array($values)) { $values = array($values); } foreach ($values as $key => $value) { /* @var $error Box */ $object = new $class(); $object->setMessage($value); $result .= $object->save(); } } if ($delete) { $session->delete($type); } } return $result; }
/** * Call the parent constructor when you override it in your filters! */ function __construct() { $this->request = \ManiaLib\Application\Request::getInstance(); $this->response = \ManiaLib\Application\Response::getInstance(); $this->session = \ManiaLib\Application\Session::getInstance(); }
/** * If you want to do stuff at instanciation, override self::onConstruct() */ protected function __construct($controllerName) { $this->controllerName = $controllerName; if (!$this->defaultAction) { $this->defaultAction = Config::getInstance()->defaultAction; } $this->request = \ManiaLib\Application\Request::getInstance(); $this->response = \ManiaLib\Application\Response::getInstance(); $this->session = \ManiaLib\Application\Session::getInstance(); $this->onConstruct(); }