/** * This method inits lots of inner components of the system. * It designed to be called directly by user. * * It also calls handler for POST data if current request method is post. * Otherwise application continues to initialize data for GET request, * adds essential javascript and css files, parse current page * and sets flag inited to "true". * * Triggers "BeforeInit", "BeforeHandlePOST", "BeforeAddScript", "AfterInit" events. * $this passed as 1st argument in all of this events. * @param null * @return null * @throws ControllerException if system can't load page file */ function init() { $this->trigger("BeforeInit", $this); Boot::setupAll(); $this->header = Header::get(); $this->dispatcher = new WidgetEventDispatcher(); $this->display_mode_params = new DisplayModeParams(); $this->adjacency_list = new WidgetsAdjacencyList(); $this->navigator = new Navigator(); $full_path = $this->findPage(); $dom = new DomDocument(); if ($dom->load($full_path) === false) { throw new ControllerException("Can not load XML " . $full_path); } $this->restoreSignatures(); POSTErrors::restoreErrorList(); $this->trigger("BeforeHandlePOST", $this); if ($_SERVER['REQUEST_METHOD'] == "POST") { $this->restoreCheckers(); $this->parsePageOnPOST($this->processPage($dom)); $this->handlePOST(); exit; } $this->trigger("BeforeAddScript", $this); $this->addScript("jquery.js", null, 5); $this->addScript("jquery.cookie.js", null, 5); $this->addScript("jquery.bgiframe.js", null, 5); $this->addScript("jquery.tooltip.js", null, 5); $this->addCSS("jquery.tooltip.css", null, 5); $this->addCSS("default.css", null, 5); $this->addScript("default.js", null, 5); if ($this->register_step) { $this->navigator->addStep($this->page); } $this->parsePageOnGET($this->processPage($dom)); $this->inited = true; $this->trigger("AfterInit", $this); }