Exemplo n.º 1
0
 public static function prepare()
 {
     if (FajrConfig::get('URL.Path')) {
         $_get = array_merge(FajrRouter::pathToParams(FajrUtils::pathInfo()), $_GET);
     } else {
         $_get = $_GET;
     }
     $_post = $_POST;
     // podla pola definujeceho vstupne parametre overim ich platnost
     foreach (self::$allowedParamters as $input => $params) {
         foreach ($params as $name => $type) {
             if (isset(${$input}[$name])) {
                 $checker = self::$conditions[$type]['cond'];
                 if (!Validator::$checker(${$input}[$name], self::$conditions[$type]['options'])) {
                     throw new Exception(str_replace('%%NAME%%', $name, self::$conditions[$type]['message']));
                 }
                 self::$inputParameters[$name] = ${$input}[$name];
                 self::${$input}[$name] = ${$input}[$name];
             }
         }
     }
     // budeme pouzivat uz len Input
     unset($_GET);
     unset($_POST);
 }
Exemplo n.º 2
0
 public static function buildUrl($params, $file = null)
 {
     if ($file === null) {
         if (!empty($params['_file'])) {
             $file = $params['_file'];
             unset($params['_file']);
         } else {
             $file = 'fajr.php';
         }
     }
     $path = '';
     if (FajrConfig::get('URL.Path')) {
         $path = FajrRouter::paramsToPath($params);
     }
     $query = http_build_query($params);
     if (strlen($query) > 0) {
         $query = '?' . $query;
     }
     $base = '';
     if (!FajrConfig::get('URL.Rewrite') || $file != 'fajr.php' || $path == '' || $path == '/') {
         $base = $file;
         if (strlen($path) > 0) {
             $base .= '/';
         }
     }
     return self::basePath() . $base . $path . $query;
 }
Exemplo n.º 3
0
 public function prepare()
 {
     if (self::$prepared) {
         throw new IllegalStateException("Input::prepare should be called only once per request.");
     }
     self::$prepared = true;
     if (FajrConfig::get('URL.Path')) {
         $_get = array_merge(FajrRouter::pathToParams(FajrUtils::pathInfo()), $_GET);
     } else {
         $_get = $_GET;
     }
     $_post = $_POST;
     // budeme pouzivat uz len Input
     unset($_GET);
     unset($_POST);
     $this->_get = $this->_prepare_array($_get, $this->allowed_get);
     $this->_post = $this->_prepare_array($_post, $this->allowed_post);
     $this->inputParameters = array_merge($this->_get, $this->_post);
 }