コード例 #1
0
ファイル: api.php プロジェクト: vjroby/library
 public function matches($url)
 {
     $pattern = $this->_pattern;
     $httpRequestMethod = HttpRequest::getRequestMethod();
     if ($httpRequestMethod === $this->_httpMethod) {
         //\Framework\Smooth::$_cleanRequest = true;
         // check if the same method is in route added with api
         // get keys
         preg_match_all("#:([a-zA-Z0-9]+)#", $pattern, $keys);
         if (count($keys) && count($keys[0]) && count($keys[1])) {
             $keys = $keys[1];
         } else {
             // no keys in the pattern , return a simple match
             return preg_match("#^{$pattern}\$#", $url);
         }
         // normalize route pattern
         $pattern = preg_replace("#(:[a-zA-Z0-9]+)#", "([a-zA-Z0-9-_]+)", $pattern);
         // check values
         preg_match_all("#^{$pattern}\$#", $url, $values);
         if (sizeof($values) && sizeof($values[0]) && sizeof($values[1])) {
             // unset the matched url
             unset($values[0]);
             $new_val = array();
             foreach ($values as $key => $val) {
                 if (isset($val[0])) {
                     $new_val[] = $val[0];
                 }
             }
             // values found, modify parameters and return
             $derived = array_combine($keys, ArrayMethods::flatten($new_val));
             $this->_parameters = array_merge($this->_parameters, $derived);
             return true;
         }
     }
 }
コード例 #2
0
ファイル: ini.php プロジェクト: vjroby/library
 public function parse($path)
 {
     if (empty($path)) {
         throw new Exception\Argument("\$path argument is not valid");
     }
     if (!isset($this->_parsed[$path])) {
         $config = array();
         ob_start();
         include "{$path}.ini";
         $string = ob_get_contents();
         ob_end_clean();
         $pairs = @parse_ini_string($string);
         if ($pairs == false) {
             throw new Exception\Syntax("Could not parse configuration file");
         }
         foreach ($pairs as $key => $value) {
             $config = $this->_pair($config, $key, $value);
         }
         $this->_parsed[$path] = ArrayMethods::toObject($config);
     }
     return $this->_parsed[$path];
 }
コード例 #3
0
ファイル: simple.php プロジェクト: vjroby/library
 public function matches($url)
 {
     $pattern = $this->_pattern;
     // get keys
     preg_match_all("#:([a-zA-Z0-9]+)#", $pattern, $keys);
     if (count($keys) && count($keys[0]) && count($keys[1])) {
         $keys = $keys[1];
     } else {
         // no keys in the pattern , return a simple match
         return preg_match("#^{$pattern}\$#", $url);
     }
     // normalize route pattern
     $pattern = preg_replace("#(:[a-zA-Z0-9]+)#", "([a-zA-Z0-9-_]+)", $pattern);
     // check values
     preg_match_all("#^{$pattern}\$#", $url, $values);
     if (sizeof($values) && sizeof($values[0]) && sizeof($values[1])) {
         // unset the matched url
         unset($values[0]);
         // values found, modify parameters and return
         $derived = array_combine($keys, ArrayMethods::flatten($values));
         $this->_parameters = array_merge($this->_parameters, $derived);
         return true;
     }
 }
コード例 #4
0
ファイル: html.php プロジェクト: vjroby/library
 public static function textarea(array $options)
 {
     $options = ArrayMethods::prepareForHtml($options);
     $disabled = isset($options['disabled']) && is_bool($options['disabled']) ? $options['disabled'] : false;
     $readonly = isset($options['readonly']) && is_bool($options['readonly']) ? $options['readonly'] : false;
     $return = self::createLabelForInput($options);
     $return .= '<textarea ';
     $return .= ' class="' . self::checkOption($options, 'class') . '" ';
     $return .= ' name="' . self::checkOption($options, 'name') . '" ';
     $return .= ' id="' . self::checkOption($options, 'id') . '" ';
     $return .= ' type="' . self::checkOption($options, 'type') . '" ';
     if ($disabled === true) {
         $return .= ' disabled ';
     }
     if ($readonly === true) {
         $return .= ' readonly ';
     }
     $return .= ' >';
     $return .= '' . self::checkOption($options, 'value') . '';
     $return .= '</textarea>';
     $return = self::apply_wrapper($options, $return);
     return $return;
 }
コード例 #5
0
ファイル: query.php プロジェクト: vjroby/library
 public function first()
 {
     $limit = $this->_limit;
     $offset = $this->_offset;
     $this->limit(1);
     $all = $this->all();
     $first = ArrayMethods::first($all);
     if ($limit) {
         $this->_limit = $limit;
     }
     if ($offset) {
         $this->_offset = $offset;
     }
     return $first;
 }