예제 #1
0
 /**
  * Performs a redirection to the specified URL with storage of state
  * information in the session.
  *
  * @see  Redirector::redirect()
  *
  * @param  string  $url         Where to redirect to.
  * @param  mixed   $extra_data  Extra data to preserve across redirect.
  *
  * @throws  RedirectorException
  */
 public static function redirectWithState($url = null, $extra_data = null)
 {
     $url = URL::ize($url);
     # Store redirect information in the session
     $item_key = self::generateKey();
     $_SESSION[self::DATA_KEY][$item_key] = array('source' => isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null, 'target' => $url->absolute(), 'time' => microtime(true), 'post_data' => $_POST, 'extra_data' => $extra_data);
     # Append item key to query string
     $url = new URL($url);
     $url->appendToQueryString(self::ITEM_KEY, $item_key);
     # Perform redirect
     self::redirect($url);
 }
예제 #2
0
 /**
  * Render the form.
  *
  * @param  string  $action  URL to submit to, defaults to self.
  * @param  string  $method  HTTP method to use: POST or GET.
  *
  * @return  string
  */
 public function render($action = null, $method = null)
 {
     $out = '';
     if ($this->generateFormTags) {
         $props = $this->formProperties;
         if (!is_null($action)) {
             $props['action'] = $action;
         } elseif (!isset($props['action'])) {
             $props['action'] = URL::getCurrent();
         }
         if (!is_null($method)) {
             $props['method'] = strtolower($method);
         } elseif (!isset($props['method'])) {
             $props['method'] = 'post';
         }
         $out .= '<form';
         foreach ($props as $k => $v) {
             $out .= ' ' . $k . '="' . String::escape($v, true) . '"';
         }
         $out .= ">\n";
     }
     // render elements
     $out .= $this->renderElementList($this->fields);
     if ($this->generateFormTags) {
         $out .= "</form>\n";
     }
     return $out;
 }