Completed
Branch master (49228f)
by Henry Stivens
02:50
created
core/kumbia/kumbia_view.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      *
162 162
      * @return boolean  En producción y cache de view
163 163
      */
164
-    public static function cache($time, $type='view', $group='kumbia.view')
164
+    public static function cache($time, $type = 'view', $group = 'kumbia.view')
165 165
     {
166 166
         if ($time === FALSE) { //TODO borrar cache
167 167
             self::$_cache['type'] = FALSE;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         $file = APP_PATH . 'views/' . self::getPath();
200 200
         //Si no existe el view y es scaffold
201 201
         if (!is_file($file) && ($scaffold = self::$_controller->scaffold)) {
202
-            $file = APP_PATH . "views/_shared/scaffolds/$scaffold/".self::$_view.'.phtml';
202
+            $file = APP_PATH . "views/_shared/scaffolds/$scaffold/" . self::$_view . '.phtml';
203 203
         }
204 204
         return $file;
205 205
     }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
      * @return string
310 310
      * @throw KumbiaException
311 311
      */
312
-    public static function partial($partial, $__time='', $params=NULL, $group ='kumbia.partials')
312
+    public static function partial($partial, $__time = '', $params = NULL, $group = 'kumbia.partials')
313 313
     {
314 314
         if (PRODUCTION && $__time && !Cache::driver()->start($__time, $partial, $group)) {
315 315
             return;
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
             $__file = CORE_PATH . "views/partials/$partial.phtml";
324 324
         }
325 325
 
326
-        if($params){
326
+        if ($params) {
327 327
             if (is_string($params)) {
328 328
                     $params = Util::getParams(explode(',', $params));
329 329
             }
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
      */
352 352
     public static function getVar($var = '')
353 353
     {
354
-        if(!$var) return get_object_vars(self::$_controller);
354
+        if (!$var) return get_object_vars(self::$_controller);
355 355
 
356 356
         return isset(self::$_controller->$var) ? self::$_controller->$var : NULL;
357 357
     }
Please login to merge, or discard this patch.
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -136,8 +136,9 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public static function getPath()
138 138
     {
139
-        if (self::$_response)
140
-            return self::$_path . self::$_view . '.' . self::$_response . '.phtml';
139
+        if (self::$_response) {
140
+                    return self::$_path . self::$_view . '.' . self::$_response . '.phtml';
141
+        }
141 142
 
142 143
         return self::$_path . self::$_view . '.phtml';
143 144
     }
@@ -224,8 +225,9 @@  discard block
 block discarded – undo
224 225
      */
225 226
     public static function render(Controller $controller)
226 227
     {
227
-        if (!self::$_view && !self::$_template)
228
-            return ob_end_flush();
228
+        if (!self::$_view && !self::$_template) {
229
+                    return ob_end_flush();
230
+        }
229 231
 
230 232
         // Guarda el controlador
231 233
         self::$_controller = $controller;
@@ -253,8 +255,9 @@  discard block
 block discarded – undo
253 255
             ob_start();
254 256
 
255 257
             // carga la vista
256
-            if (!include self::getView())
257
-                throw new KumbiaException('Vista "' . self::getPath() . '" no encontrada', 'no_view');
258
+            if (!include self::getView()) {
259
+                            throw new KumbiaException('Vista "' . self::getPath() . '" no encontrada', 'no_view');
260
+            }
258 261
 
259 262
             // si esta en produccion y se cachea la vista
260 263
             self::saveCache('view');
@@ -274,8 +277,9 @@  discard block
 block discarded – undo
274 277
             ob_start();
275 278
 
276 279
             // carga el template
277
-            if (!include APP_PATH . "views/_shared/templates/$__template.phtml")
278
-                throw new KumbiaException("Template $__template no encontrado");
280
+            if (!include APP_PATH . "views/_shared/templates/$__template.phtml") {
281
+                            throw new KumbiaException("Template $__template no encontrado");
282
+            }
279 283
 
280 284
             // si esta en produccion y se cachea template
281 285
             self::saveCache('template');
@@ -351,7 +355,9 @@  discard block
 block discarded – undo
351 355
      */
352 356
     public static function getVar($var = '')
353 357
     {
354
-        if(!$var) return get_object_vars(self::$_controller);
358
+        if(!$var) {
359
+            return get_object_vars(self::$_controller);
360
+        }
355 361
 
356 362
         return isset(self::$_controller->$var) ? self::$_controller->$var : NULL;
357 363
     }
Please login to merge, or discard this patch.
core/kumbia/load.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         if (!class_exists($Model, FALSE)) {
77 77
             //Carga la clase
78 78
             if (!include APP_PATH . "models/$model.php") {
79
-                throw new KumbiaException($model,'no_model');
79
+                throw new KumbiaException($model, 'no_model');
80 80
             }
81 81
         }
82 82
         return new $Model($params);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             //Si esta cargada continua con la siguiente clase
97 97
             if (class_exists($Model, FALSE)) continue;
98 98
             if (!include APP_PATH . "models/$model.php") {
99
-                throw new KumbiaException($model,'no_model');
99
+                throw new KumbiaException($model, 'no_model');
100 100
             }
101 101
         }
102 102
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,9 @@
 block discarded – undo
94 94
         foreach ($args as $model) {
95 95
             $Model = Util::camelcase(basename($model));
96 96
             //Si esta cargada continua con la siguiente clase
97
-            if (class_exists($Model, FALSE)) continue;
97
+            if (class_exists($Model, FALSE)) {
98
+                continue;
99
+            }
98 100
             if (!include APP_PATH . "models/$model.php") {
99 101
                 throw new KumbiaException($model,'no_model');
100 102
             }
Please login to merge, or discard this patch.
core/kumbia/autoload.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  */
20 20
 
21 21
 // @see Util
22
-require CORE_PATH.'kumbia/util.php';
22
+require CORE_PATH . 'kumbia/util.php';
23 23
 
24 24
 // Autocarga de clases
25 25
 function kumbia_autoload($class)
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
     // Optimizando carga
28 28
     static $classes;
29 29
     if (!isset($classes)) {
30
-        $classes = array (
31
-            'ActiveRecord'    => APP_PATH.'libs/active_record.php',
32
-            'Load'            => CORE_PATH.'kumbia/load.php',
33
-            'KumbiaException' => CORE_PATH.'kumbia/kumbia_exception.php',
34
-            'KumbiaRouter'    => CORE_PATH.'kumbia/kumbia_router.php',
35
-            'KumbiaFacade'    => CORE_PATH.'kumbia/kumbia_facade.php'
30
+        $classes = array(
31
+            'ActiveRecord'    => APP_PATH . 'libs/active_record.php',
32
+            'Load'            => CORE_PATH . 'kumbia/load.php',
33
+            'KumbiaException' => CORE_PATH . 'kumbia/kumbia_exception.php',
34
+            'KumbiaRouter'    => CORE_PATH . 'kumbia/kumbia_router.php',
35
+            'KumbiaFacade'    => CORE_PATH . 'kumbia/kumbia_facade.php'
36 36
         );
37 37
     }
38 38
     if (isset($classes[$class])) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 function kumbia_autoload_vendor($class)
66 66
 {
67 67
     //Autoload PSR0
68
-    $psr0 = dirname(CORE_PATH).'/vendor/'.str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $class).'.php';
68
+    $psr0 = dirname(CORE_PATH) . '/vendor/' . str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $class) . '.php';
69 69
     if (is_file($psr0)) {
70 70
         include $psr0;
71 71
     }
Please login to merge, or discard this patch.
core/kumbia/kumbia_router.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         $urlItems = explode('/', trim($url, '/'));
41 41
 
42 42
         // El primer parametro de la url es un módulo?
43
-        if (is_dir(APP_PATH."controllers/$urlItems[0]")) {
43
+        if (is_dir(APP_PATH . "controllers/$urlItems[0]")) {
44 44
             $router['module'] = $urlItems[0];
45 45
 
46 46
             // Si no hay mas parametros sale
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         // Si existe una ruta con el comodin * crea la nueva ruta
92 92
         foreach ($routes as $key => $val) {
93 93
             if ($key == '/*') {
94
-                return rtrim($val, '*').$url;
94
+                return rtrim($val, '*') . $url;
95 95
             }
96 96
 
97 97
             if (strripos($key, '*', -1)) {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             throw new KumbiaException(null, 'no_controller');
116 116
         }
117 117
         //Asigna el controlador activo
118
-        $app_controller = Util::camelcase($controller).'Controller';
118
+        $app_controller = Util::camelcase($controller) . 'Controller';
119 119
         return new $app_controller($param);
120 120
     }
121 121
 }
Please login to merge, or discard this patch.
core/kumbia/kumbia_exception.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
             $tpl = 'views/templates/exception.phtml';
88 88
         }
89 89
         //Fix problem with action name in REST
90
-        $action =  $e->getMessage() ? $e->getMessage() : $action;
90
+        $action = $e->getMessage() ? $e->getMessage() : $action;
91 91
 
92 92
         include CORE_PATH . "views/errors/{$view}.phtml";
93 93
  
94 94
         $content = ob_get_clean();
95 95
 
96 96
         // termina los buffers abiertos
97
-        while (ob_get_level ()) {
97
+        while (ob_get_level()) {
98 98
             ob_end_clean();
99 99
         }
100 100
         include CORE_PATH . $tpl;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      * */
106 106
     private static function setHeader($e)
107 107
     {
108
-        if (isset($e->view) && in_array($e->view, self::$view404)){
108
+        if (isset($e->view) && in_array($e->view, self::$view404)) {
109 109
             header('HTTP/1.1 404 Not Found');
110 110
             return;
111 111
         }
Please login to merge, or discard this patch.
core/kumbia/kumbia_facade.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
  * @license    http://wiki.kumbiaphp.com/Licencia     New BSD License
19 19
  */
20 20
 
21
- /**
22
-  * Clase principal para el manejo de excepciones
23
-  *
24
-  * @category   Kumbia
25
-  * @package    Core
26
-  */
27
- abstract class KumbiaFacade
28
- {
21
+    /**
22
+     * Clase principal para el manejo de excepciones
23
+     *
24
+     * @category   Kumbia
25
+     * @package    Core
26
+     */
27
+    abstract class KumbiaFacade
28
+    {
29 29
     protected static $providers = [];
30 30
 
31 31
 
@@ -79,4 +79,4 @@  discard block
 block discarded – undo
79 79
         }
80 80
     }
81 81
 
82
- }
82
+    }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@  discard block
 block discarded – undo
34 34
      * @param  Array  $p key/value array with providers
35 35
      * @return void
36 36
      */
37
-    public static function providers(Array $p){
37
+    public static function providers(Array $p) {
38 38
         self::$providers = $p;
39 39
     }
40 40
 
41 41
     /**
42 42
      * Getter for the alias of the component
43 43
      */
44
-    protected static function getAlias(){
44
+    protected static function getAlias() {
45 45
         throw new RuntimeException('Not implement');
46 46
     }
47 47
 
48 48
 
49 49
     protected static function getInstance($name)
50 50
     {
51
-        return  isset(self::$providers[$name])?self::$providers[$name]:null;
51
+        return  isset(self::$providers[$name]) ? self::$providers[$name] : null;
52 52
     }
53 53
 
54 54
     /**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public static function __callStatic($method, $args)
64 64
     {
65 65
         $instance = self::getInstance(static::getAlias());
66
-        if (! $instance) {
66
+        if (!$instance) {
67 67
             throw new RuntimeException('A facade root has not been set.');
68 68
         }
69 69
 
Please login to merge, or discard this patch.
core/kumbia/config.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     public static function get($var)
53 53
     {
54 54
         $namespaces = explode('.', $var);
55
-        if (! isset(self::$vars[$namespaces[0]])) {
55
+        if (!isset(self::$vars[$namespaces[0]])) {
56 56
             self::load($namespaces[0]);
57 57
         }
58 58
         switch (count($namespaces)) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
                 return isset(self::$vars[$namespaces[0]]) ? self::$vars[$namespaces[0]] : null;
67 67
             
68 68
             default:
69
-                trigger_error('Máximo 3 niveles en Config::get(fichero.sección.variable), pedido: '. $var);
69
+                trigger_error('Máximo 3 niveles en Config::get(fichero.sección.variable), pedido: ' . $var);
70 70
         }
71 71
     }
72 72
     /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                 self::$vars[$namespaces[0]] = $value;
104 104
                 break;
105 105
             default:
106
-                trigger_error('Máximo 3 niveles en Config::set(fichero.sección.variable), pedido: '. $var);
106
+                trigger_error('Máximo 3 niveles en Config::set(fichero.sección.variable), pedido: ' . $var);
107 107
         }
108 108
     }
109 109
 
Please login to merge, or discard this patch.
core/extensions/helpers/js.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@
 block discarded – undo
117 117
      * @param string $file nombre del archivo a añadir
118 118
      * @param array $dependencies archivos que son requisito del archivo a añadir
119 119
      */
120
-    public static function add( $file, $dependencies=array() )
120
+    public static function add($file, $dependencies = array())
121 121
     {
122 122
         self::$_js[$file] = $file;
123 123
         foreach ($dependencies as $file) self::$_dependencies[$file] = $file;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -120,7 +120,9 @@
 block discarded – undo
120 120
     public static function add( $file, $dependencies=array() )
121 121
     {
122 122
         self::$_js[$file] = $file;
123
-        foreach ($dependencies as $file) self::$_dependencies[$file] = $file;
123
+        foreach ($dependencies as $file) {
124
+            self::$_dependencies[$file] = $file;
125
+        }
124 126
     }
125 127
     
126 128
     /**
Please login to merge, or discard this patch.
core/extensions/helpers/form.php 1 patch
Spacing   +17 added lines, -20 removed lines patch added patch discarded remove patch
@@ -97,8 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     protected static function fieldName(Array $field) {
99 99
         return isset($field[1]) ?
100
-        array("{$field[0]}_{$field[1]}", "{$field[0]}[{$field[1]}]") :
101
-        array($field[0], $field[0]);
100
+        array("{$field[0]}_{$field[1]}", "{$field[0]}[{$field[1]}]") : array($field[0], $field[0]);
102 101
     }
103 102
 
104 103
     /**
@@ -139,7 +138,7 @@  discard block
 block discarded – undo
139 138
      */
140 139
     protected static function tag($tag, $field, $attrs = '', $value = NULL, $extra = '', $close = TRUE) {
141 140
         $attrs = Tag::getAttrs($attrs);
142
-        $end   = $close?">{{value}}</$tag>":'/>';
141
+        $end   = $close ? ">{{value}}</$tag>" : '/>';
143 142
         // Obtiene name, id y value (solo para autoload) para el campo y los carga en el scope
144 143
         list($id, $name, $value) = self::getFieldData($field, $value);
145 144
         return str_replace('{{value}}', $value, "<$tag id=\"$id\" name=\"$name\" $extra $attrs $end");
@@ -169,9 +168,9 @@  discard block
 block discarded – undo
169 168
     public static function open($action = '', $method = 'post', $attrs = '') {
170 169
         $attrs = Tag::getAttrs($attrs);
171 170
         if ($action) {
172
-            $action = PUBLIC_PATH.$action;
171
+            $action = PUBLIC_PATH . $action;
173 172
         } else {
174
-            $action = PUBLIC_PATH.ltrim(Router::get('route'), '/');
173
+            $action = PUBLIC_PATH . ltrim(Router::get('route'), '/');
175 174
         }
176 175
         return "<form action=\"$action\" method=\"$method\" $attrs>";
177 176
     }
@@ -238,7 +237,7 @@  discard block
 block discarded – undo
238 237
      */
239 238
     public static function button($text, $attrs = '', $type = 'button', $value = NULL) {
240 239
         $attrs = Tag::getAttrs($attrs);
241
-        $value = is_null($value)?'':"value=\"$value\"";
240
+        $value = is_null($value) ? '' : "value=\"$value\"";
242 241
         return "<button type=\"$type\" $value $attrs>$text</button>";
243 242
     }
244 243
 
@@ -284,8 +283,7 @@  discard block
 block discarded – undo
284 283
         // Obtiene name, id y value (solo para autoload) para el campo y los carga en el scope
285 284
         list($id, $name, $value) = self::getFieldData($field, $value);
286 285
         //Si se quiere agregar blank
287
-        $options = empty($blank)?'':
288
-        '<option value="">'.htmlspecialchars($blank, ENT_COMPAT, APP_CHARSET).'</option>';
286
+        $options = empty($blank) ? '' : '<option value="">' . htmlspecialchars($blank, ENT_COMPAT, APP_CHARSET) . '</option>';
289 287
         foreach ($data as $k => $v) {
290 288
             $val      = self::selectValue($v, $k, $itemId);
291 289
             $text     = self::selectShow($v, $show);
@@ -303,8 +301,8 @@  discard block
 block discarded – undo
303 301
      * @return string
304 302
      */
305 303
     public static function selectValue($item, $key, $id) {
306
-        return htmlspecialchars(is_object($item)?
307
-            $item->$id:$key, ENT_COMPAT, APP_CHARSET);
304
+        return htmlspecialchars(is_object($item) ?
305
+            $item->$id : $key, ENT_COMPAT, APP_CHARSET);
308 306
     }
309 307
 
310 308
     /**
@@ -315,8 +313,8 @@  discard block
 block discarded – undo
315 313
      * @return string
316 314
      */
317 315
     public static function selectedValue($value, $key) {
318
-        return ((is_array($value) && in_array($key, $value)) || ($key == $value))?
319
-        'selected="selected"':'';
316
+        return ((is_array($value) && in_array($key, $value)) || ($key == $value)) ?
317
+        'selected="selected"' : '';
320 318
     }
321 319
 
322 320
     /**
@@ -389,7 +387,7 @@  discard block
 block discarded – undo
389 387
      */
390 388
     public static function submitImage($img, $attrs = '') {
391 389
         $attrs = Tag::getAttrs($attrs);
392
-        return "<input type=\"image\" src=\"".PUBLIC_PATH."img/$img\" $attrs/>";
390
+        return "<input type=\"image\" src=\"" . PUBLIC_PATH . "img/$img\" $attrs/>";
393 391
     }
394 392
 
395 393
     /**
@@ -439,18 +437,17 @@  discard block
 block discarded – undo
439 437
 
440 438
     public static function dbSelect($field, $show = NULL, $data = NULL, $blank = 'Seleccione', $attrs = '', $value = NULL) {
441 439
 
442
-        $model = ($data === NULL) ? substr($field, strpos($field, '.')+1, -3) : $data[0];
440
+        $model = ($data === NULL) ? substr($field, strpos($field, '.') + 1, -3) : $data[0];
443 441
         $model = Util::camelcase($model);
444 442
         $model_asoc = new $model;
445 443
         //por defecto el primer campo no pk
446
-        $show = $show ? : $model_asoc->non_primary[0];
444
+        $show = $show ?: $model_asoc->non_primary[0];
447 445
         $pk   = $model_asoc->primary_key[0];
448 446
         if ($data === NULL) {
449
-            $data = $model_asoc->find("columns: $pk,$show", "order: $show asc");//mejor usar array
447
+            $data = $model_asoc->find("columns: $pk,$show", "order: $show asc"); //mejor usar array
450 448
         } else {
451
-            $data = (isset($data[2]))?
452
-            $model_asoc->{$data[1]}($data[2]):
453
-            $model_asoc->{$data[1]}();
449
+            $data = (isset($data[2])) ?
450
+            $model_asoc->{$data[1]}($data[2]) : $model_asoc->{$data[1]}();
454 451
         }
455 452
         return self::select($field, $data, $attrs, $value, $blank, $pk, $show);
456 453
     }
@@ -471,7 +468,7 @@  discard block
 block discarded – undo
471 468
         $attrs = Tag::getAttrs($attrs);
472 469
 
473 470
         // Obtiene name y id, y los carga en el scope
474
-        list($id, $name, ) = self::getFieldData($field, FALSE);
471
+        list($id, $name,) = self::getFieldData($field, FALSE);
475 472
         return "<input id=\"$id\" name=\"$name\" type=\"file\" $attrs/>";
476 473
     }
477 474
 
Please login to merge, or discard this patch.