protected function getContent() { $man_ctr = \OWeb\manage\Controller::getInstance(); //On va voir quel page on doit charger $get = \OWeb\OWeb::getInstance()->get_get(); if (isset($get['page'])) { $ctr = $get['page']; } else { $ctr = OWEB_DEFAULT_PAGE; } try { $ctr = str_replace("\\\\", "\\", $ctr); $ctr = str_replace(".", "\\", $ctr); $ctr = $man_ctr->loadController('Page\\' . $ctr); $ctr->loadParams(); $man_ctr->initController(); } catch (\Exception $ex) { $ctr = $man_ctr->loadController('Page\\OWeb\\errors\\http\\NotFound'); } ob_start(); try { $ctr->display(); } catch (\Exception $e) { ob_end_clean(); ob_start(); $ctr = $man_ctr->loadException($e); $ctr->addParams("exception", $e); $man_ctr->display(); } $this->content = ob_get_contents(); ob_end_clean(); Events::getInstance()->sendEvent('Didplay_Prepare@OWeb\\manage\\Headers'); $header = \OWeb\manage\Headers::getInstance()->getAllHeaders(); return array('headers' => $header, "content" => $this->content); }
/** * Will return a new instance of the Controller required as a subview. After * having initialized it. * * !! A controller can also be initiated throught manually with new <name> but * it might then need manual initialisation * * @param type $name Name of the controller you want to use as a sub view. * @return \Controller The controller that was asked. * @throws \OWeb\manage\exceptions\Controller */ public function getNewSubView($name) { try { $controller = new $name(); if (!$controller instanceof \OWeb\types\Controller) { throw new \OWeb\manage\exceptions\Controller("The class \"" . $name . "\" isn't an instance of \\OWeb\\Types\\Controller"); } if (!isset($this->subViews[$name])) { $this->subViews[$name] = $controller; } \OWeb\manage\Events::getInstance()->sendEvent('loaded@OWeb\\manage\\SubViews', $controller); $controller->init(); return $controller; } catch (\Exception $ex) { throw new \OWeb\manage\exceptions\Controller("The SubView : \"" . $name . "\"couldn't be loaded due to Errors", 0, $ex); } }
public function add_Event($Nomevent, $fonction) { \OWeb\manage\Events::getInstance()->registerEvent($Nomevent, $this, $fonction); }
/** * Will display the main controller/page */ public function display() { \OWeb\manage\Events::getInstance()->sendEvent('DisplayContent_Start@OWeb\\manage\\Template'); echo $this->content; \OWeb\manage\Events::getInstance()->sendEvent('DisplayContent_End@OWeb\\manage\\Template'); }
function __construct() { $event = Events::getInstance(); $event->registerEvent('Didplay_Prepare@OWeb\\manage\\Headers', $this, 'makeAdd'); }
public function __construct(&$get, &$post, &$files, &$cookies, &$server, $adr) { $this->get_runTime(); //Checking if There is an older instance. If yes Exception. if (self::$instance != null) { throw new Exception("Only 1 instance of OWeb can run."); } else { self::$instance = $this; } error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT); //Variables d'environement $this->_get = $get; $this->_post = $post; $this->_files = $files; $this->_cookies = $cookies; $this->_server = $server; $this->_adresse = $adr; //Initializing AutoLoader. $this->autoLoader = new autoLoader(); //Initialize Events manager $this->manage_events = \OWeb\manage\Events::getInstance(); //Initialize headers manager $this->manage_headers = \OWeb\manage\Headers::getInstance(); //Initialize Extension manager $this->manage_extensions = \OWeb\manage\Extensions::getInstance(); //Initialize Controller manager $this->manage_controllers = \OWeb\manage\Controller::getInstance(); //Initialize SubView manager $this->manage_subViews = \OWeb\manage\SubViews::getInstance(); //Initialize Setting Manager $this->manage_settings = \OWeb\manage\Settings::getInstance(); }
/** * Will initialize all extensions when Oweb has finished Initializing itself */ public function init_extensions() { \OWeb\manage\Events::getInstance()->sendEvent('InitPrep@OWeb\\manage\\Etensions'); foreach ($this->obj_extension as $extension) { $extension->OWeb_Init(); } $this->notInit = false; \OWeb\manage\Events::getInstance()->sendEvent('Init@OWeb\\manage\\Etensions'); }
/** * Will load the Controller as main controller. * Will automaticlly set up the initialisation sequence for the Controller. * The Controller will be initialized once OWeb has finished initialisation. * * @param \String $name of the Controller to load. * * @return \OWeb\types\Controller Loaded Controller * @throws \OWeb\manage\exceptions\Controller If there is a error to the loading of the COntroller */ public function loadController($name) { if ($this->controller != null) { throw new \OWeb\manage\exceptions\Controller("A Controller was already loaded"); } else { try { $controller = new $name(true); $this->controller = $controller; if (!$controller instanceof \OWeb\types\Controller) { throw new \OWeb\manage\exceptions\Controller("A Controller needs to be an instance of \\OWeb\\Types\\Controller"); } \OWeb\manage\Events::getInstance()->sendEvent('loaded@OWeb\\manage\\Controller', $this->controller); } catch (\Exception $ex) { throw new \OWeb\manage\exceptions\Controller("The Controller couldn't be loaded due to Errors", 0, $ex); } } return $this->controller; }
function __construct() { $this->eventM = Events::getInstance(); self::forceInstance($this); }