예제 #1
0
 /**
  * Method description
  *
  * More detailed method description
  * @param    array $params
  * @return void
  */
 function parseParams(SimpleXMLElement $params)
 {
     if (isset($params['priority'])) {
         $this->setPriority(0 + $params['priority']);
     }
     if (isset($params['forms'])) {
         $this->setFormIds((string) $params['forms']);
     }
     if (isset($params['static'])) {
         $this->setStatic(0 + $params['static']);
     }
     $this->handler_object = new DataHandlerObject($this->getStatic());
     $this->handler_object->parseParams($params);
     DataUpdaterPool::set($this->handler_object, $this->getPriority(), $this->getId(), $this->getFormIds());
 }
예제 #2
0
 /**
  * Method description
  *
  * More detailed method description
  * @param    void
  * @return   array
  */
 function handle()
 {
     if (isset($this->goto_url)) {
         return $this->getGotoURL();
     } elseif (isset($this->object_from_id)) {
         if (($dh = DataUpdaterPool::getById($this->getObjectFrom())) !== null && ($o = $dh->getObject()) !== null && method_exists($o, $this->getMethod())) {
             return $o->{$this->getMethod()}();
         }
     } else {
         return $this->handler_object->handle(null);
     }
 }
예제 #3
0
파일: Controller.php 프로젝트: point/cassea
 /**
  * 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;
     }
 }