コード例 #1
0
 /**
  * Redirect to a specific page.
  *
  * @param   string  $target   Page to redirect to.
  * @param   array   $data     Optional data to save in a users session.
  */
 protected function redirect($target, $data = null)
 {
     // Write optional session data
     if ($data instanceof Messages) {
         Session::flash('errors', $data->toArray());
     } else {
         if (is_array($data)) {
             Session::flash($data);
         } else {
             if (!is_null($data)) {
                 Session::flash('data', $data);
             }
         }
     }
     // Allow to specify the redirect uri as parameter
     $url = r::get('redirect_to');
     if (!empty($url)) {
         redirect::to($url);
     }
     // Perform redirect
     switch ($target) {
         case 'home':
             redirect::home();
             break;
         case 'back':
             redirect::back();
             break;
         case '404':
             $page = site()->errorPage();
             redirect::to($page->uri());
             break;
         case 'referer':
             $referer = server::get('HTTP_REFERER');
             redirect::to($referer);
             break;
         default:
             redirect::to($target);
             break;
     }
 }
コード例 #2
0
ファイル: form.php プロジェクト: buditanrim/kirby-comments
 /**
  * Collect all field values from the $_GET/$_POST global.
  *
  * @return  array
  */
 public function input()
 {
     $fields = array_keys($this->fields);
     $values = array();
     // Expect form input to be returned within the Session global if the form
     // is sent to an external script.
     if ($this->attr('action')) {
         $input = Session::get('input', array());
         $input = array_intersect_key($input, array_flip($fields));
         $values = array_merge($values, $input);
     } else {
         foreach ($fields as $field) {
             $values[$field] = get($field);
         }
     }
     return $values;
 }