Completed
Push — master ( 3b33a7...03df00 )
by Anu
02:48
created
helpers/Model.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 		);
20 20
 
21 21
 	public function __construct() {
22
-		if(property_exists($this, 'fields')) {
22
+		if (property_exists($this, 'fields')) {
23 23
 			$this->fieldConf = array_merge($this->fields, $this->fieldConf);
24 24
 		}
25 25
 
Please login to merge, or discard this patch.
app.php 3 patches
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -1,145 +1,145 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class App extends Prefab{
4
-    public $db;
4
+	public $db;
5 5
 	public $app;
6
-    public $session;
7
-    public $authenticatedUser;
6
+	public $session;
7
+	public $authenticatedUser;
8 8
 
9 9
 	public function __construct() {
10
-	    $this->app = $this->app ?: Base::instance();
10
+		$this->app = $this->app ?: Base::instance();
11 11
 	}
12 12
 
13
-    static public function singleton() {
14
-        if (Registry::exists('APP'))
15
-            $app = Registry::get('APP');
16
-        else {
17
-            $app = new self;
18
-            Registry::set('APP',$app);
19
-        }
20
-        return $app;
21
-    }
13
+	static public function singleton() {
14
+		if (Registry::exists('APP'))
15
+			$app = Registry::get('APP');
16
+		else {
17
+			$app = new self;
18
+			Registry::set('APP',$app);
19
+		}
20
+		return $app;
21
+	}
22 22
 
23
-    public function db() {
24
-        return $this->db ?: $this->app->DB;
25
-    }
23
+	public function db() {
24
+		return $this->db ?: $this->app->DB;
25
+	}
26 26
 
27
-    public function session() {
28
-        return $this->session ?: $this->app->SESSION;
29
-    }
27
+	public function session() {
28
+		return $this->session ?: $this->app->SESSION;
29
+	}
30 30
 
31 31
 	public function user() {
32 32
 		return $this->authenticatedUser = $this->app->get('SESSION.USER')?:false;
33 33
 	}
34 34
 
35
-    public function initialized($def = null) {
36
-        return null !== $def ? $this->app->set('INITIALIZED', $def) : $this->app->get('INITIALIZED');
37
-    }
35
+	public function initialized($def = null) {
36
+		return null !== $def ? $this->app->set('INITIALIZED', $def) : $this->app->get('INITIALIZED');
37
+	}
38 38
 
39
-    public function config($key = null) {
40
-        return $this->app->get($key?:'CONFIG') ;
41
-    }
39
+	public function config($key = null) {
40
+		return $this->app->get($key?:'CONFIG') ;
41
+	}
42 42
 
43
-    public function status() {
44
-        return $this->app->IS_LIVE;
45
-    }
43
+	public function status() {
44
+		return $this->app->IS_LIVE;
45
+	}
46 46
 
47
-    public function run() {
48
-        $this->loadConfig();
49
-        $this->loadRoutes();
50
-        $this->checkForMaintenance();
51
-        $this->configureDebug();
52
-	    $this->configureDB();
53
-	    $this->configureSession();
54
-        $this->configureAssets();
47
+	public function run() {
48
+		$this->loadConfig();
49
+		$this->loadRoutes();
50
+		$this->checkForMaintenance();
51
+		$this->configureDebug();
52
+		$this->configureDB();
53
+		$this->configureSession();
54
+		$this->configureAssets();
55 55
 		$this->registerErrorHandler();
56
-	    $this->initialized(true);
56
+		$this->initialized(true);
57 57
 		$this->app->run();
58
-    }
59
-
60
-    public function loadRoutes($file = null){
61
-        $this->_load('routes', $file);
62
-    }
63
-
64
-    public function loadConfig($file = null){
65
-        $this->_load('config', $file);
66
-    }
67
-
68
-    private function _load($path, $file = null) {
69
-        if($file) {
70
-            $this->app->config(base_path("{path}/{$file}"));
71
-        }else{
72
-            foreach(glob(base_path("{$path}/*.ini")) as $file) {
73
-                $this->app->config($file);
74
-            }
75
-        }
76
-    }
58
+	}
59
+
60
+	public function loadRoutes($file = null){
61
+		$this->_load('routes', $file);
62
+	}
63
+
64
+	public function loadConfig($file = null){
65
+		$this->_load('config', $file);
66
+	}
67
+
68
+	private function _load($path, $file = null) {
69
+		if($file) {
70
+			$this->app->config(base_path("{path}/{$file}"));
71
+		}else{
72
+			foreach(glob(base_path("{$path}/*.ini")) as $file) {
73
+				$this->app->config($file);
74
+			}
75
+		}
76
+	}
77 77
 
78 78
 	public function checkForMaintenance() {
79 79
 		if(!$this->status()) {
80
-	       	template('maintenance');
81
-		    exit();
82
-        }
83
-	}
84
-
85
-    public function configureDebug() {
86
-	    if(!$this->app->DEV) {
87
-	        $this->app->set('DEBUG', 0);
88
-        }
89
-    }
90
-
91
-    public function configureDB() {
92
-        $type = strtolower($this->app->DB_TYPE);
93
-
94
-        if($type == 'jig'){
95
-            $this->db = new DB\Jig($this->app->DB_PATH, DB\Jig::FORMAT_JSON);
96
-        }else if($type == 'sql'){
97
-            $this->db = new DB\SQL($this->app->DB, $this->app->DB_USER, $this->app->DB_PSWD);
98
-        }else if($type == 'mongo'){
99
-            $this->db = new DB\Mongo($this->app->DB, $this->app->DB_USER);
100
-        }
101
-        $this->app->set('DB', $this->db);
102
-    }
103
-
104
-    public function configureSession() {
105
-        $type = strtolower($this->app->SESSION);
106
-
107
-        if($type) {
108
-            if($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
109
-                $this->configureCSRF($type);
110
-            }else if($this->app->CSRF){
111
-                $this->session = new Session(null, 'CSRF');
112
-            }else{
113
-                if($type == 'jig' || $type == 'mongo' || $type == 'sql'){
114
-                    $session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
115
-                    $this->session = new $session($this->app->DB);
116
-                }else{
117
-                    $this->session = new Session();
118
-                }
119
-            }
120
-            $this->app->set('SESSION', $this->session);
121
-        }
122
-    }
123
-
124
-    public function configureCSRF($type) {
125
-        $session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
126
-        $this->session = new $session($this->app->DB, 'sessions', null, 'CSRF');
127
-    }
128
-
129
-    private function _getDBType($type) {
130
-        if($type == 'jig' || $type == 'mongo'){
131
-            return ucfirst($type);
132
-        }else if($type == 'sql') {
133
-            return strtoupper($type);
134
-        }
135
-    }
136
-
137
-    public function configureAssets() {
138
-        $assets = Assets::instance();
139
-        $this->app->set('ASSETS.onFileNotFound',function($file) {
140
-            echo 'file not found: '.$file;
141
-        });
142
-    }
80
+		   	template('maintenance');
81
+			exit();
82
+		}
83
+	}
84
+
85
+	public function configureDebug() {
86
+		if(!$this->app->DEV) {
87
+			$this->app->set('DEBUG', 0);
88
+		}
89
+	}
90
+
91
+	public function configureDB() {
92
+		$type = strtolower($this->app->DB_TYPE);
93
+
94
+		if($type == 'jig'){
95
+			$this->db = new DB\Jig($this->app->DB_PATH, DB\Jig::FORMAT_JSON);
96
+		}else if($type == 'sql'){
97
+			$this->db = new DB\SQL($this->app->DB, $this->app->DB_USER, $this->app->DB_PSWD);
98
+		}else if($type == 'mongo'){
99
+			$this->db = new DB\Mongo($this->app->DB, $this->app->DB_USER);
100
+		}
101
+		$this->app->set('DB', $this->db);
102
+	}
103
+
104
+	public function configureSession() {
105
+		$type = strtolower($this->app->SESSION);
106
+
107
+		if($type) {
108
+			if($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
109
+				$this->configureCSRF($type);
110
+			}else if($this->app->CSRF){
111
+				$this->session = new Session(null, 'CSRF');
112
+			}else{
113
+				if($type == 'jig' || $type == 'mongo' || $type == 'sql'){
114
+					$session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
115
+					$this->session = new $session($this->app->DB);
116
+				}else{
117
+					$this->session = new Session();
118
+				}
119
+			}
120
+			$this->app->set('SESSION', $this->session);
121
+		}
122
+	}
123
+
124
+	public function configureCSRF($type) {
125
+		$session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
126
+		$this->session = new $session($this->app->DB, 'sessions', null, 'CSRF');
127
+	}
128
+
129
+	private function _getDBType($type) {
130
+		if($type == 'jig' || $type == 'mongo'){
131
+			return ucfirst($type);
132
+		}else if($type == 'sql') {
133
+			return strtoupper($type);
134
+		}
135
+	}
136
+
137
+	public function configureAssets() {
138
+		$assets = Assets::instance();
139
+		$this->app->set('ASSETS.onFileNotFound',function($file) {
140
+			echo 'file not found: '.$file;
141
+		});
142
+	}
143 143
 
144 144
 	public function registerErrorHandler() {
145 145
 		if($this->app->DEV) {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class App extends Prefab{
3
+class App extends Prefab {
4 4
     public $db;
5 5
 	public $app;
6 6
     public $session;
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
             $app = Registry::get('APP');
16 16
         else {
17 17
             $app = new self;
18
-            Registry::set('APP',$app);
18
+            Registry::set('APP', $app);
19 19
         }
20 20
         return $app;
21 21
     }
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     }
30 30
 
31 31
 	public function user() {
32
-		return $this->authenticatedUser = $this->app->get('SESSION.USER')?:false;
32
+		return $this->authenticatedUser = $this->app->get('SESSION.USER') ?: false;
33 33
 	}
34 34
 
35 35
     public function initialized($def = null) {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     }
38 38
 
39 39
     public function config($key = null) {
40
-        return $this->app->get($key?:'CONFIG') ;
40
+        return $this->app->get($key ?: 'CONFIG');
41 41
     }
42 42
 
43 43
     public function status() {
@@ -57,33 +57,33 @@  discard block
 block discarded – undo
57 57
 		$this->app->run();
58 58
     }
59 59
 
60
-    public function loadRoutes($file = null){
60
+    public function loadRoutes($file = null) {
61 61
         $this->_load('routes', $file);
62 62
     }
63 63
 
64
-    public function loadConfig($file = null){
64
+    public function loadConfig($file = null) {
65 65
         $this->_load('config', $file);
66 66
     }
67 67
 
68 68
     private function _load($path, $file = null) {
69
-        if($file) {
69
+        if ($file) {
70 70
             $this->app->config(base_path("{path}/{$file}"));
71
-        }else{
72
-            foreach(glob(base_path("{$path}/*.ini")) as $file) {
71
+        }else {
72
+            foreach (glob(base_path("{$path}/*.ini")) as $file) {
73 73
                 $this->app->config($file);
74 74
             }
75 75
         }
76 76
     }
77 77
 
78 78
 	public function checkForMaintenance() {
79
-		if(!$this->status()) {
79
+		if (!$this->status()) {
80 80
 	       	template('maintenance');
81 81
 		    exit();
82 82
         }
83 83
 	}
84 84
 
85 85
     public function configureDebug() {
86
-	    if(!$this->app->DEV) {
86
+	    if (!$this->app->DEV) {
87 87
 	        $this->app->set('DEBUG', 0);
88 88
         }
89 89
     }
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
     public function configureDB() {
92 92
         $type = strtolower($this->app->DB_TYPE);
93 93
 
94
-        if($type == 'jig'){
94
+        if ($type == 'jig') {
95 95
             $this->db = new DB\Jig($this->app->DB_PATH, DB\Jig::FORMAT_JSON);
96
-        }else if($type == 'sql'){
96
+        }else if ($type == 'sql') {
97 97
             $this->db = new DB\SQL($this->app->DB, $this->app->DB_USER, $this->app->DB_PSWD);
98
-        }else if($type == 'mongo'){
98
+        }else if ($type == 'mongo') {
99 99
             $this->db = new DB\Mongo($this->app->DB, $this->app->DB_USER);
100 100
         }
101 101
         $this->app->set('DB', $this->db);
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
     public function configureSession() {
105 105
         $type = strtolower($this->app->SESSION);
106 106
 
107
-        if($type) {
108
-            if($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
107
+        if ($type) {
108
+            if ($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
109 109
                 $this->configureCSRF($type);
110
-            }else if($this->app->CSRF){
110
+            }else if ($this->app->CSRF) {
111 111
                 $this->session = new Session(null, 'CSRF');
112
-            }else{
113
-                if($type == 'jig' || $type == 'mongo' || $type == 'sql'){
112
+            }else {
113
+                if ($type == 'jig' || $type == 'mongo' || $type == 'sql') {
114 114
                     $session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
115 115
                     $this->session = new $session($this->app->DB);
116
-                }else{
116
+                }else {
117 117
                     $this->session = new Session();
118 118
                 }
119 119
             }
@@ -127,24 +127,24 @@  discard block
 block discarded – undo
127 127
     }
128 128
 
129 129
     private function _getDBType($type) {
130
-        if($type == 'jig' || $type == 'mongo'){
130
+        if ($type == 'jig' || $type == 'mongo') {
131 131
             return ucfirst($type);
132
-        }else if($type == 'sql') {
132
+        }else if ($type == 'sql') {
133 133
             return strtoupper($type);
134 134
         }
135 135
     }
136 136
 
137 137
     public function configureAssets() {
138 138
         $assets = Assets::instance();
139
-        $this->app->set('ASSETS.onFileNotFound',function($file) {
139
+        $this->app->set('ASSETS.onFileNotFound', function($file) {
140 140
             echo 'file not found: '.$file;
141 141
         });
142 142
     }
143 143
 
144 144
 	public function registerErrorHandler() {
145
-		if($this->app->DEV) {
145
+		if ($this->app->DEV) {
146 146
 			Falsum\Run::handler($this->app->DEBUG != 3);
147
-		}else{
147
+		}else {
148 148
 			$this->app->set('ONERROR', 'App\Core\Controllers\ErrorController->init');
149 149
 		}
150 150
 	}
Please login to merge, or discard this patch.
Braces   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
     static public function singleton() {
14
-        if (Registry::exists('APP'))
15
-            $app = Registry::get('APP');
16
-        else {
14
+        if (Registry::exists('APP')) {
15
+                    $app = Registry::get('APP');
16
+        } else {
17 17
             $app = new self;
18 18
             Registry::set('APP',$app);
19 19
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     private function _load($path, $file = null) {
69 69
         if($file) {
70 70
             $this->app->config(base_path("{path}/{$file}"));
71
-        }else{
71
+        } else{
72 72
             foreach(glob(base_path("{$path}/*.ini")) as $file) {
73 73
                 $this->app->config($file);
74 74
             }
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 
94 94
         if($type == 'jig'){
95 95
             $this->db = new DB\Jig($this->app->DB_PATH, DB\Jig::FORMAT_JSON);
96
-        }else if($type == 'sql'){
96
+        } else if($type == 'sql'){
97 97
             $this->db = new DB\SQL($this->app->DB, $this->app->DB_USER, $this->app->DB_PSWD);
98
-        }else if($type == 'mongo'){
98
+        } else if($type == 'mongo'){
99 99
             $this->db = new DB\Mongo($this->app->DB, $this->app->DB_USER);
100 100
         }
101 101
         $this->app->set('DB', $this->db);
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
         if($type) {
108 108
             if($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
109 109
                 $this->configureCSRF($type);
110
-            }else if($this->app->CSRF){
110
+            } else if($this->app->CSRF){
111 111
                 $this->session = new Session(null, 'CSRF');
112
-            }else{
112
+            } else{
113 113
                 if($type == 'jig' || $type == 'mongo' || $type == 'sql'){
114 114
                     $session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
115 115
                     $this->session = new $session($this->app->DB);
116
-                }else{
116
+                } else{
117 117
                     $this->session = new Session();
118 118
                 }
119 119
             }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     private function _getDBType($type) {
130 130
         if($type == 'jig' || $type == 'mongo'){
131 131
             return ucfirst($type);
132
-        }else if($type == 'sql') {
132
+        } else if($type == 'sql') {
133 133
             return strtoupper($type);
134 134
         }
135 135
     }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	public function registerErrorHandler() {
145 145
 		if($this->app->DEV) {
146 146
 			Falsum\Run::handler($this->app->DEBUG != 3);
147
-		}else{
147
+		} else{
148 148
 			$this->app->set('ONERROR', 'App\Core\Controllers\ErrorController->init');
149 149
 		}
150 150
 	}
Please login to merge, or discard this patch.
bootstrap/helpers.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function f3($get=null){$f3=Base::instance();return $get?$f3->get($get):$f3;}
3
+function f3($get = null) {$f3 = Base::instance(); return $get ? $f3->get($get) : $f3; }
4 4
 
5
-function base_path($inner = ''){return realpath(__DIR__.'/../').'/'.$inner;}
6
-function storage_path($inner = ''){return base_path('storage/').'/'.$inner;}
7
-function db_path($db = ''){return storage_path('db/').$db;}
8
-function lang_path($lang = ''){return base_path('resources/lang/').'/'.$lang;}
9
-function views_path(){return base_path('resources/views/');}
10
-function config_path($config = ''){return base_path('config/').'/'.$config;}
5
+function base_path($inner = '') {return realpath(__DIR__.'/../').'/'.$inner; }
6
+function storage_path($inner = '') {return base_path('storage/').'/'.$inner; }
7
+function db_path($db = '') {return storage_path('db/').$db; }
8
+function lang_path($lang = '') {return base_path('resources/lang/').'/'.$lang; }
9
+function views_path() {return base_path('resources/views/'); }
10
+function config_path($config = '') {return base_path('config/').'/'.$config; }
11 11
 
12
-function abort(){f3()->abort();}
13
-function status($code=404){f3()->error($code);}
14
-function reroute($where){f3()->reroute($where);}
15
-function is_api($path){if(is_string($path)) {return explode('/', $path)[1] === 'api';}return false;}
12
+function abort() {f3()->abort(); }
13
+function status($code = 404) {f3()->error($code); }
14
+function reroute($where) {f3()->reroute($where); }
15
+function is_api($path) {if (is_string($path)) {return explode('/', $path)[1] === 'api'; }return false; }
16 16
 
17 17
 function template($template, array $params = [], $mime = 'text/html') {
18 18
 	$f3 = f3();
19
-	if(!empty($params)) {
19
+	if (!empty($params)) {
20 20
 		$f3->mset($params);
21 21
 	}
22
-	if(is_array($template)){
22
+	if (is_array($template)) {
23 23
 		$layout = $template[0];
24 24
 		$view = $template[1];
25
-	}else{
25
+	}else {
26 26
 		$layout = 'layouts/app.htm';
27 27
 		$view = $template;
28 28
 	}
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
31 31
 	echo Template::instance()->render($layout, $mime);
32 32
 }
33 33
 
34
-function str_contains($haystack,$needles){foreach((array)$needles as $needle){if($needle!=''&&mb_strpos($haystack,$needle)!==false){return true;}}return false;}
35
-function extension($file,$default='json'){return $file.'.'.(pathinfo($file,PATHINFO_EXTENSION)?:$default);}
36
-function flash($message, $type = 'success') {Flash::instance()->addMessage($message, $type);}
37
-function trans($key,$params=null){return f3()->format(f3()->get($key),($params?:''));}
34
+function str_contains($haystack, $needles) {foreach ((array) $needles as $needle) {if ($needle != '' && mb_strpos($haystack, $needle) !== false) {return true; }}return false; }
35
+function extension($file, $default = 'json') {return $file.'.'.(pathinfo($file, PATHINFO_EXTENSION) ?: $default); }
36
+function flash($message, $type = 'success') {Flash::instance()->addMessage($message, $type); }
37
+function trans($key, $params = null) {return f3()->format(f3()->get($key), ($params ?: '')); }
38 38
 function error($error) {
39
-	if(null === $error) {return;}
40
-	if(is_array($error)) {
41
-		foreach($error as $err) {
42
-			if(is_array($err)) {
43
-				foreach($err as $e) {
39
+	if (null === $error) {return; }
40
+	if (is_array($error)) {
41
+		foreach ($error as $err) {
42
+			if (is_array($err)) {
43
+				foreach ($err as $e) {
44 44
 					flash($e, 'danger');
45 45
 				}
46
-			}else{
46
+			}else {
47 47
 				flash($err, 'danger');
48 48
 			}
49 49
 		}
50
-	}else{
50
+	}else {
51 51
 		flash($error, 'danger');
52 52
 	}
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	if(is_array($template)){
23 23
 		$layout = $template[0];
24 24
 		$view = $template[1];
25
-	}else{
25
+	} else{
26 26
 		$layout = 'layouts/app.htm';
27 27
 		$view = $template;
28 28
 	}
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 				foreach($err as $e) {
44 44
 					flash($e, 'danger');
45 45
 				}
46
-			}else{
46
+			} else{
47 47
 				flash($err, 'danger');
48 48
 			}
49 49
 		}
50
-	}else{
50
+	} else{
51 51
 		flash($error, 'danger');
52 52
 	}
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.