Ejemplo n.º 1
0
 /**
  * Implements getValues.
  *
  * @return array
  */
 public function getValues()
 {
     if (isset($this->post->values) && isset($this->post->values->form_id)) {
         $form = $this->form_query->getForm($this->post->values->form_id);
         $errors = array();
         foreach ($form['required_fields'] as $key => $required) {
             if (!isset($this->post->values->{$key})) {
                 $errors[] = $required;
             }
         }
         if (count($errors) > 0) {
             foreach ($errors as $error) {
                 Messages::set($error . ' is required.', 'Error');
             }
             return array();
         }
         $controller = Factory::build($form['controller']);
         $validate = $controller->validate();
         if ($validate !== TRUE) {
             return $validate;
         }
         return $controller->submit();
     } else {
         Messages::set('Your form has expired or is invalid.', 'Warn');
     }
 }
Ejemplo n.º 2
0
 /**
  * Implements getValues.
  *
  * @return array
  */
 public function getValues()
 {
     $wildcard = FALSE;
     $full_path = Headers::get('CurrentPath');
     $path = explode('/', $full_path);
     if ($path_cache = Cache::get(self::PATH_CACHE . $full_path)) {
         $path_values = $this->path_query->getPathDataById($path_cache['id']);
         return $this->setupPathValues($path_values, $path_cache['query_parameters']);
     }
     $host = Headers::get('Host');
     if ($path[0] == "") {
         array_shift($path);
     }
     $query_parameters = array();
     while (count($path)) {
         $path_query = implode('/', $path);
         $path_values = $this->path_query->getPathDataFromPath($path_query, $host, $wildcard, true);
         if ($path_values) {
             $cache = array('id' => $path_values['_id']->{'$id'}, 'query_parameters' => $query_parameters);
             Cache::set(self::PATH_CACHE . $full_path, $cache);
             return $this->setupPathValues($path_values, $query_parameters);
         }
         if ($wildcard == TRUE) {
             $query_parameters[] = array_pop($path);
         }
         $wildcard = TRUE;
     }
     // We did not find a match send to the 404, if available.
     if (isset($this->config->FourOFour)) {
         if ($this->config->FourOFour === Headers::get('CurrentPath')) {
             Messages::set('Page Error', 'Error');
         } else {
             Redirect::set($this->config->FourOFour);
         }
     }
     return;
 }