@@ -277,7 +277,9 @@ discard block |
||
| 277 | 277 | $this->_connect(); |
| 278 | 278 | |
| 279 | 279 | if ($data) { |
| 280 | - if (!is_array($data)) $data = Util::getParams(func_get_args()); |
|
| 280 | + if (!is_array($data)) { |
|
| 281 | + $data = Util::getParams(func_get_args()); |
|
| 282 | + } |
|
| 281 | 283 | foreach($this->fields as $field) { |
| 282 | 284 | if (isset($data[$field])) { |
| 283 | 285 | $this->$field = $data[$field]; |
@@ -394,7 +396,7 @@ discard block |
||
| 394 | 396 | } else { |
| 395 | 397 | $relation->through = "{$relation_source}_{$this->source}"; |
| 396 | 398 | } |
| 397 | - }else{ |
|
| 399 | + } else{ |
|
| 398 | 400 | $through = explode('/', $relation->through); |
| 399 | 401 | $relation->through = end($through); |
| 400 | 402 | } |
@@ -593,8 +595,9 @@ discard block |
||
| 593 | 595 | if ($field['Key'] == 'PRI') { |
| 594 | 596 | $this->primary_key[] = $field['Field']; |
| 595 | 597 | $this->alias[$field['Field']] = 'Código'; |
| 596 | - } else |
|
| 597 | - $this->non_primary[] = $field['Field']; |
|
| 598 | + } else { |
|
| 599 | + $this->non_primary[] = $field['Field']; |
|
| 600 | + } |
|
| 598 | 601 | /** |
| 599 | 602 | * Si se indica que no puede ser nulo, pero se indica un |
| 600 | 603 | * valor por defecto, entonces no se incluye en la lista, ya que |
@@ -1282,8 +1285,9 @@ discard block |
||
| 1282 | 1285 | public function save($values=null) |
| 1283 | 1286 | { |
| 1284 | 1287 | if ($values) { |
| 1285 | - if (!is_array($values)) |
|
| 1286 | - $values = Util::getParams(func_get_args()); |
|
| 1288 | + if (!is_array($values)) { |
|
| 1289 | + $values = Util::getParams(func_get_args()); |
|
| 1290 | + } |
|
| 1287 | 1291 | foreach ($this->fields as $field) { |
| 1288 | 1292 | if (isset($values[$field])) { |
| 1289 | 1293 | $this->$field = $values[$field]; |
@@ -1345,8 +1349,9 @@ discard block |
||
| 1345 | 1349 | if (isset($this->_validates['presence_of'])) { |
| 1346 | 1350 | foreach ($this->_validates['presence_of'] as $f => $opt) { |
| 1347 | 1351 | if (isset($this->$f) && (is_null($this->$f) || $this->$f == '')) { |
| 1348 | - if (!$ex && $f == $this->primary_key[0]) |
|
| 1349 | - continue; |
|
| 1352 | + if (!$ex && $f == $this->primary_key[0]) { |
|
| 1353 | + continue; |
|
| 1354 | + } |
|
| 1350 | 1355 | if (isset($opt['message'])) { |
| 1351 | 1356 | Flash::error($opt['message']); |
| 1352 | 1357 | return false; |
@@ -1396,18 +1401,20 @@ discard block |
||
| 1396 | 1401 | $field = isset($opt['field']) ? $opt['field'] : $f; |
| 1397 | 1402 | |
| 1398 | 1403 | if (strlen($this->$f) < $opt['min']) { |
| 1399 | - if (isset($opt['too_short'])) |
|
| 1400 | - Flash::error($opt['too_short']); |
|
| 1401 | - else |
|
| 1402 | - Flash::error("Error: El campo $field debe tener como mínimo $opt[min] caracteres"); |
|
| 1404 | + if (isset($opt['too_short'])) { |
|
| 1405 | + Flash::error($opt['too_short']); |
|
| 1406 | + } else { |
|
| 1407 | + Flash::error("Error: El campo $field debe tener como mínimo $opt[min] caracteres"); |
|
| 1408 | + } |
|
| 1403 | 1409 | return false; |
| 1404 | 1410 | } |
| 1405 | 1411 | |
| 1406 | 1412 | if (strlen($this->$f) > $opt['max']) { |
| 1407 | - if (isset($opt['too_long'])) |
|
| 1408 | - Flash::error($opt['too_long']); |
|
| 1409 | - else |
|
| 1410 | - Flash::error("Error: El campo $field debe tener como máximo $opt[max] caracteres"); |
|
| 1413 | + if (isset($opt['too_long'])) { |
|
| 1414 | + Flash::error($opt['too_long']); |
|
| 1415 | + } else { |
|
| 1416 | + Flash::error("Error: El campo $field debe tener como máximo $opt[max] caracteres"); |
|
| 1417 | + } |
|
| 1411 | 1418 | return false; |
| 1412 | 1419 | } |
| 1413 | 1420 | } |
@@ -1569,8 +1576,9 @@ discard block |
||
| 1569 | 1576 | } else { |
| 1570 | 1577 | if (isset($this->after_validation_on_update)) { |
| 1571 | 1578 | $method = $this->after_validation_on_update; |
| 1572 | - if ($this->$method() == 'cancel') |
|
| 1573 | - return false; |
|
| 1579 | + if ($this->$method() == 'cancel') { |
|
| 1580 | + return false; |
|
| 1581 | + } |
|
| 1574 | 1582 | } |
| 1575 | 1583 | } |
| 1576 | 1584 | } |
@@ -2008,8 +2016,9 @@ discard block |
||
| 2008 | 2016 | */ |
| 2009 | 2017 | protected function validates_presence_of($field, $params=array()) |
| 2010 | 2018 | { |
| 2011 | - if (is_string($params)) |
|
| 2012 | - $params = Util::getParams(func_get_args()); |
|
| 2019 | + if (is_string($params)) { |
|
| 2020 | + $params = Util::getParams(func_get_args()); |
|
| 2021 | + } |
|
| 2013 | 2022 | |
| 2014 | 2023 | $this->_validates['presence_of'][$field] = $params; |
| 2015 | 2024 | } |
@@ -2029,8 +2038,9 @@ discard block |
||
| 2029 | 2038 | */ |
| 2030 | 2039 | protected function validates_length_of($field, $max, $min=0, $params=array()) |
| 2031 | 2040 | { |
| 2032 | - if (is_string($params)) |
|
| 2033 | - $params = Util::getParams(func_get_args()); |
|
| 2041 | + if (is_string($params)) { |
|
| 2042 | + $params = Util::getParams(func_get_args()); |
|
| 2043 | + } |
|
| 2034 | 2044 | |
| 2035 | 2045 | $this->_validates['length_of'][$field] = $params; |
| 2036 | 2046 | $this->_validates['length_of'][$field]['min'] = $min; |
@@ -2049,8 +2059,9 @@ discard block |
||
| 2049 | 2059 | */ |
| 2050 | 2060 | protected function validates_inclusion_in($field, $list, $params=array()) |
| 2051 | 2061 | { |
| 2052 | - if (is_string($params)) |
|
| 2053 | - $params = Util::getParams(func_get_args()); |
|
| 2062 | + if (is_string($params)) { |
|
| 2063 | + $params = Util::getParams(func_get_args()); |
|
| 2064 | + } |
|
| 2054 | 2065 | |
| 2055 | 2066 | $this->_validates['inclusion_in'][$field] = $params; |
| 2056 | 2067 | $this->_validates['inclusion_in'][$field]['list'] = $list; |
@@ -2068,8 +2079,9 @@ discard block |
||
| 2068 | 2079 | */ |
| 2069 | 2080 | protected function validates_exclusion_of($field, $list, $params=array()) |
| 2070 | 2081 | { |
| 2071 | - if (is_string($params)) |
|
| 2072 | - $params = Util::getParams(func_get_args()); |
|
| 2082 | + if (is_string($params)) { |
|
| 2083 | + $params = Util::getParams(func_get_args()); |
|
| 2084 | + } |
|
| 2073 | 2085 | |
| 2074 | 2086 | $this->_validates['exclusion_of'][$field] = $params; |
| 2075 | 2087 | $this->_validates['exclusion_of'][$field]['list'] = $list; |
@@ -2087,8 +2099,9 @@ discard block |
||
| 2087 | 2099 | */ |
| 2088 | 2100 | protected function validates_format_of($field, $pattern, $params=array()) |
| 2089 | 2101 | { |
| 2090 | - if (is_string($params)) |
|
| 2091 | - $params = Util::getParams(func_get_args()); |
|
| 2102 | + if (is_string($params)) { |
|
| 2103 | + $params = Util::getParams(func_get_args()); |
|
| 2104 | + } |
|
| 2092 | 2105 | |
| 2093 | 2106 | $this->_validates['format_of'][$field] = $params; |
| 2094 | 2107 | $this->_validates['format_of'][$field]['pattern'] = $pattern; |
@@ -2105,8 +2118,9 @@ discard block |
||
| 2105 | 2118 | */ |
| 2106 | 2119 | protected function validates_numericality_of($field, $params=array()) |
| 2107 | 2120 | { |
| 2108 | - if (is_string($params)) |
|
| 2109 | - $params = Util::getParams(func_get_args()); |
|
| 2121 | + if (is_string($params)) { |
|
| 2122 | + $params = Util::getParams(func_get_args()); |
|
| 2123 | + } |
|
| 2110 | 2124 | |
| 2111 | 2125 | $this->_validates['numericality_of'][$field] = $params; |
| 2112 | 2126 | } |
@@ -2122,8 +2136,9 @@ discard block |
||
| 2122 | 2136 | */ |
| 2123 | 2137 | protected function validates_email_in($field, $params=array()) |
| 2124 | 2138 | { |
| 2125 | - if (is_string($params)) |
|
| 2126 | - $params = Util::getParams(func_get_args()); |
|
| 2139 | + if (is_string($params)) { |
|
| 2140 | + $params = Util::getParams(func_get_args()); |
|
| 2141 | + } |
|
| 2127 | 2142 | |
| 2128 | 2143 | $this->_validates['email_in'][$field] = $params; |
| 2129 | 2144 | } |
@@ -2139,8 +2154,9 @@ discard block |
||
| 2139 | 2154 | */ |
| 2140 | 2155 | protected function validates_uniqueness_of($field, $params=array()) |
| 2141 | 2156 | { |
| 2142 | - if (is_string($params)) |
|
| 2143 | - $params = Util::getParams(func_get_args()); |
|
| 2157 | + if (is_string($params)) { |
|
| 2158 | + $params = Util::getParams(func_get_args()); |
|
| 2159 | + } |
|
| 2144 | 2160 | |
| 2145 | 2161 | $this->_validates['uniqueness_of'][$field] = $params; |
| 2146 | 2162 | } |
@@ -2156,8 +2172,9 @@ discard block |
||
| 2156 | 2172 | */ |
| 2157 | 2173 | protected function validates_date_in($field, $params=array()) |
| 2158 | 2174 | { |
| 2159 | - if (is_string($params)) |
|
| 2160 | - $params = Util::getParams(func_get_args()); |
|
| 2175 | + if (is_string($params)) { |
|
| 2176 | + $params = Util::getParams(func_get_args()); |
|
| 2177 | + } |
|
| 2161 | 2178 | |
| 2162 | 2179 | $this->_validates['date_in'][$field] = $params; |
| 2163 | 2180 | } |
@@ -85,7 +85,9 @@ |
||
| 85 | 85 | $dbclass = "DbPdo{$config['type']}"; |
| 86 | 86 | $db_file = "$path/adapters/pdo/{$config['type']}.php"; |
| 87 | 87 | } else { |
| 88 | - if($config['type'] == 'mysql') $config['type'] = 'mysqli'; |
|
| 88 | + if($config['type'] == 'mysql') { |
|
| 89 | + $config['type'] = 'mysqli'; |
|
| 90 | + } |
|
| 89 | 91 | $dbclass = "Db{$config['type']}"; |
| 90 | 92 | $db_file = "$path/adapters/{$config['type']}.php"; |
| 91 | 93 | } |
@@ -117,13 +117,19 @@ |
||
| 117 | 117 | */ |
| 118 | 118 | public function connect($config) |
| 119 | 119 | { |
| 120 | - if (!extension_loaded('mysqli')) throw new KumbiaException('Debe cargar la extensión de PHP llamada php_mysqli'); |
|
| 120 | + if (!extension_loaded('mysqli')) { |
|
| 121 | + throw new KumbiaException('Debe cargar la extensión de PHP llamada php_mysqli'); |
|
| 122 | + } |
|
| 121 | 123 | |
| 122 | 124 | $this->id_connection = new mysqli($config['host'], $config['username'], $config['password'], $config['name'], $config['port']); |
| 123 | 125 | //no se usa $object->error() ya que solo funciona a partir de 5.2.9 y 5.3 |
| 124 | - if (mysqli_connect_error ()) throw new KumbiaException(mysqli_connect_error()); |
|
| 126 | + if (mysqli_connect_error ()) { |
|
| 127 | + throw new KumbiaException(mysqli_connect_error()); |
|
| 128 | + } |
|
| 125 | 129 | //Selecciona charset |
| 126 | - if (isset($config['charset'])) $this->id_connection->set_charset($config['charset']); |
|
| 130 | + if (isset($config['charset'])) { |
|
| 131 | + $this->id_connection->set_charset($config['charset']); |
|
| 132 | + } |
|
| 127 | 133 | return TRUE; |
| 128 | 134 | } |
| 129 | 135 | |
@@ -151,7 +151,7 @@ |
||
| 151 | 151 | if($result_query = mssql_query($sql_query, $this->id_connection)){ |
| 152 | 152 | $this->last_result_query = $result_query; |
| 153 | 153 | return $result_query; |
| 154 | - }else{ |
|
| 154 | + } else{ |
|
| 155 | 155 | throw new KumbiaException($this->error(" al ejecutar <em>\"$sql_query\"</em>")); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -120,7 +120,9 @@ discard block |
||
| 120 | 120 | if (!extension_loaded('mysql')) { |
| 121 | 121 | throw new KumbiaException('Debe cargar la extensión de PHP llamada php_mysql'); |
| 122 | 122 | } |
| 123 | - if (!isset($config['port']) || !$config['port']) $config['port'] = 3306; |
|
| 123 | + if (!isset($config['port']) || !$config['port']) { |
|
| 124 | + $config['port'] = 3306; |
|
| 125 | + } |
|
| 124 | 126 | |
| 125 | 127 | if ($this->id_connection = mysql_connect("{$config['host']}:{$config['port']}", $config['username'], $config['password'], true)) { |
| 126 | 128 | if ($config['name'] !== '') { |
@@ -129,7 +131,9 @@ discard block |
||
| 129 | 131 | } |
| 130 | 132 | } |
| 131 | 133 | //Selecciona charset |
| 132 | - if (isset($config['charset'])) mysql_query("SET NAMES {$config['charset']}"); |
|
| 134 | + if (isset($config['charset'])) { |
|
| 135 | + mysql_query("SET NAMES {$config['charset']}"); |
|
| 136 | + } |
|
| 133 | 137 | //mysql_set_charset($config['charset'],$this->id_connection); //Necesita mysql > 5.0.7 |
| 134 | 138 | return true; |
| 135 | 139 | } else { |
@@ -187,10 +187,14 @@ |
||
| 187 | 187 | protected function _validatesTypes() |
| 188 | 188 | { |
| 189 | 189 | // Verifica que sea un archivo de imagen |
| 190 | - if (!$this->_imgInfo) return FALSE; |
|
| 190 | + if (!$this->_imgInfo) { |
|
| 191 | + return FALSE; |
|
| 192 | + } |
|
| 191 | 193 | |
| 192 | 194 | foreach ($this->_types as $type) { |
| 193 | - if ($this->_imgInfo['mime'] == "image/$type") return TRUE; |
|
| 195 | + if ($this->_imgInfo['mime'] == "image/$type") { |
|
| 196 | + return TRUE; |
|
| 197 | + } |
|
| 194 | 198 | } |
| 195 | 199 | |
| 196 | 200 | return FALSE; |
@@ -86,8 +86,9 @@ |
||
| 86 | 86 | $vars = $url; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if (++$cyclic > 1000) |
|
| 90 | - throw new KumbiaException('Se ha detectado un enrutamiento cíclico. Esto puede causar problemas de estabilidad'); |
|
| 89 | + if (++$cyclic > 1000) { |
|
| 90 | + throw new KumbiaException('Se ha detectado un enrutamiento cíclico. Esto puede causar problemas de estabilidad'); |
|
| 91 | + } |
|
| 91 | 92 | |
| 92 | 93 | Router::to($vars, TRUE); |
| 93 | 94 | } |
@@ -82,11 +82,13 @@ discard block |
||
| 82 | 82 | $ruleName = self::getRuleName($ruleName, $param); |
| 83 | 83 | $param = self::getParams($param); |
| 84 | 84 | /*Ignore the rule is starts with "#"*/ |
| 85 | - if($ruleName[0] == '#') continue; |
|
| 85 | + if($ruleName[0] == '#') { |
|
| 86 | + continue; |
|
| 87 | + } |
|
| 86 | 88 | /*Es una validación de modelo*/ |
| 87 | 89 | if($ruleName[0] == '@'){ |
| 88 | 90 | $this->modelRule($ruleName, $param, $field); |
| 89 | - }elseif(!Validations::$ruleName($value, $param, $this->obj)){ |
|
| 91 | + } elseif(!Validations::$ruleName($value, $param, $this->obj)){ |
|
| 90 | 92 | $this->addError($param, $field, $ruleName); |
| 91 | 93 | } |
| 92 | 94 | } |
@@ -185,7 +187,8 @@ discard block |
||
| 185 | 187 | * @param Array $error |
| 186 | 188 | */ |
| 187 | 189 | public static function errorToFlash(Array $error){ |
| 188 | - foreach ($error as $value) |
|
| 189 | - Flash::error($value); |
|
| 190 | + foreach ($error as $value) { |
|
| 191 | + Flash::error($value); |
|
| 192 | + } |
|
| 190 | 193 | } |
| 191 | 194 | } |
@@ -168,7 +168,9 @@ |
||
| 168 | 168 | self::$_events[$event][] = $handler2; |
| 169 | 169 | return; |
| 170 | 170 | } |
| 171 | - if ($after) ++$i; |
|
| 171 | + if ($after) { |
|
| 172 | + ++$i; |
|
| 173 | + } |
|
| 172 | 174 | |
| 173 | 175 | array_splice(self::$_events[$event], $i, 0, $handler2); |
| 174 | 176 | } |