/** * Method description * * More detailed method description * @param array $params * @return void */ function parseParams(SimpleXMLElement $elem) { if (isset($elem['text'])) { $this->setText((string) $elem['text']); } else { $this->setText(requestURI()); } $this->addToMemento(array("text")); parent::parseParams($elem); }
function restoreSteps() { $storage = Storage::createWithSession('pagehandler_steps'); $steps = $storage->get('steps'); if (isset($steps[requestURI()])) { Controller::getInstance()->getNavigator()->injectSteps($steps[requestURI()]); } }
/** * Adding step to the list. Usually it happens in * {@link Controller::init} method and only during the GET request and * provided that Controller's register_step variable is setted to non false value. * There is no need to add step if current request method is POST. * * Optionally title and description properties might be specified * to describe the current page. * * If for the current user controller name has been changed, * all history will be cleaned up. * * If the user has been already visited page, already situated in the list, * all steps, which were added after it will be deleted. * (if we jumping to the 3 page back, there is no need to keep * later 3 pages. Newer step will be added after it). * * If we trying to add new step to the list with the length grater than * MAX_PATH, least recently used step will be removed with the next on the list. * * @see setTitle * @see setDescription */ function addStep($page_name, $title = null, $description = null) { if (!isset($page_name)) { return; } if (!isset($title)) { $title = requestURI(); } if ($this->controller_name == "index" && $page_name == "index" || !isset($this->user_path[0]) || empty($this->user_path)) { $this->user_path = array(); $this->user_path[0]['url'] = requestURI(1); $this->user_path[0]['title'] = $title; $this->user_path[0]['desription'] = $description; $this->user_path[0]['page'] = $page_name; $this->user_path[0]['controller'] = $this->controller_name; } else { $to_add = 1; for ($i = 0, $c = count($this->user_path); $i < $c; $i++) { if (isset($this->user_path[$i]) && isset($this->user_path[$i]['page']) && $this->user_path[$i]['page'] == $page_name && $this->user_path[$i]['controller'] == $this->controller_name) { $this->user_path = array_slice($this->user_path, $i); $this->user_path[0]['url'] = requestURI(1); $this->user_path[0]['page'] = $page_name; $to_add = false; break; } } if ($to_add) { if (count($this->user_path) == self::MAX_PATH) { $this->user_path = array_slice($this->user_path, 0, -1); } array_unshift($this->user_path, array("url" => requestURI(1), "title" => $title, "desription" => $description, "page" => $page_name, "controller" => $this->controller_name)); } } $this->storage->set("user_path", $this->user_path); }
/** * Handles POST data while AJAX request. * It works like {Controller::handlePOST} and signaatures will be checked unless * form is on the current page and <code>no_check</code> attribute is not specified. * * Typical use-case of this function is posting form with javascript with * <code>$(form).serialize()</code> method or <code>ajaxSubmit</code> from * jquert.form plugin. * * Instead of redirects, like in <code>Controller::handlePOST()</code> * method, <code>exit()</code> calls will be used. * * Another difference is that no "save form values and show error boxes" sequence * is used. If some checker of validator error are present, <code>exit()</code> * will terminate futher form processing. * * Additionally, unlike <code>Controller::handlePOST</code>, handler methods could specify * <code>responce_string</code> to return status of form processing. It will be echo'ed at once. * * @param null * @return null */ protected function handlePOST() { $this->trigger("BeforeHandlePOST", $this); if ($this->post->isEmpty()) { Header::redirect(requestURI(true), Header::SEE_OTHER); } $formid = null; WidgetLoader::load("WForm"); list($formid) = explode(":", $this->post->{WForm::signature_name}); if (!empty($formid) && !in_array($formid, $this->no_check_forms)) { $this->trigger("BeforeCheckSignature", $this); if (!$this->checkSignature($this->post->{WForm::signature_name})) { exit("Error while checking POST data 1"); } POSTErrors::flushErrors(); $this->trigger("BeforeCheckByRules", array(&$this->post, $this->post->{WForm::signature_name})); POSTChecker::checkByRules($this->post->{WForm::signature_name}, $this->checker_rules, $this->checker_messages); POSTChecker::checkFiles($this->post->{WForm::signature_name}, $this->file_rules, $this->checker_messages); if (POSTErrors::hasErrors()) { //Header::redirect(requestURI(true), Header::SEE_OTHER); exit("Error while checking POST data 2"); } $this->trigger("BeforeCallHandlers", array($this, &$formid)); try { DataUpdaterPool::callCheckers($formid); } catch (CheckerException $e) { exit("Error " . $e->getMessage() . " in widget " . $e->getWidgetName); } DataUpdaterPool::callHandlers($formid); DataUpdaterPool::callFinalize($formid); } else { try { DataUpdaterPool::callCheckers($formid); } catch (CheckerException $e) { exit("Error " . $e->getMessage() . " in widget " . $e->getWidgetName); } DataUpdaterPool::callHandlers($formid); DataUpdaterPool::callFinalize($formid); } $this->trigger("AfterHandlePOST", $this); if (isset($this->response_string)) { $this->trigger("AfterHeadBodyTailResponce", array($this, &$this->response_string)); echo $this->response_string; } }