@@ -74,6 +74,9 @@ discard block |
||
74 | 74 | self::send($array); |
75 | 75 | } |
76 | 76 | |
77 | + /** |
|
78 | + * @param integer $timestamp |
|
79 | + */ |
|
77 | 80 | public static function sendCSS($timestamp) |
78 | 81 | { |
79 | 82 | $array = array( |
@@ -184,6 +187,9 @@ discard block |
||
184 | 187 | self::send($array); |
185 | 188 | } |
186 | 189 | |
190 | + /** |
|
191 | + * @param string[] $array |
|
192 | + */ |
|
187 | 193 | private static function send($array, $gzip = true) |
188 | 194 | { |
189 | 195 | if($gzip) |
@@ -205,7 +205,7 @@ |
||
205 | 205 | private static function start_gzipping() |
206 | 206 | { |
207 | 207 | if(!ob_start('ob_gzhandler')) |
208 | - ob_start(); |
|
208 | + ob_start(); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | } |
212 | 212 | \ No newline at end of file |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | |
187 | 187 | private static function send($array, $gzip = true) |
188 | 188 | { |
189 | - if($gzip) |
|
189 | + if ($gzip) |
|
190 | 190 | self::start_gzipping(); |
191 | 191 | |
192 | - foreach($array as $row) |
|
192 | + foreach ($array as $row) |
|
193 | 193 | { |
194 | 194 | header($row, TRUE); |
195 | 195 | } |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | |
198 | 198 | private static function get_date($timestamp = false) |
199 | 199 | { |
200 | - if($timestamp == 0) |
|
200 | + if ($timestamp == 0) |
|
201 | 201 | $timestamp = time(); |
202 | 202 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
203 | 203 | } |
204 | 204 | |
205 | 205 | private static function start_gzipping() |
206 | 206 | { |
207 | - if(!ob_start('ob_gzhandler')) |
|
207 | + if (!ob_start('ob_gzhandler')) |
|
208 | 208 | ob_start(); |
209 | 209 | } |
210 | 210 |
@@ -186,8 +186,9 @@ discard block |
||
186 | 186 | |
187 | 187 | private static function send($array, $gzip = true) |
188 | 188 | { |
189 | - if($gzip) |
|
190 | - self::start_gzipping(); |
|
189 | + if($gzip) { |
|
190 | + self::start_gzipping(); |
|
191 | + } |
|
191 | 192 | |
192 | 193 | foreach($array as $row) |
193 | 194 | { |
@@ -197,15 +198,17 @@ discard block |
||
197 | 198 | |
198 | 199 | private static function get_date($timestamp = false) |
199 | 200 | { |
200 | - if($timestamp == 0) |
|
201 | - $timestamp = time(); |
|
201 | + if($timestamp == 0) { |
|
202 | + $timestamp = time(); |
|
203 | + } |
|
202 | 204 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
203 | 205 | } |
204 | 206 | |
205 | 207 | private static function start_gzipping() |
206 | 208 | { |
207 | - if(!ob_start('ob_gzhandler')) |
|
208 | - ob_start(); |
|
209 | + if(!ob_start('ob_gzhandler')) { |
|
210 | + ob_start(); |
|
211 | + } |
|
209 | 212 | } |
210 | 213 | |
211 | 214 | } |
212 | 215 | \ No newline at end of file |
@@ -69,6 +69,9 @@ discard block |
||
69 | 69 | return $extension; |
70 | 70 | } |
71 | 71 | |
72 | + /** |
|
73 | + * @param string $type |
|
74 | + */ |
|
72 | 75 | public static function getImagePath($type, $file) |
73 | 76 | { |
74 | 77 | if($type == 'photo') |
@@ -142,6 +145,10 @@ discard block |
||
142 | 145 | return new ReflectionClass($class_name); |
143 | 146 | } |
144 | 147 | |
148 | + /** |
|
149 | + * @param string $type |
|
150 | + * @param string $file |
|
151 | + */ |
|
145 | 152 | public static function loadInstance($type, $file) |
146 | 153 | { |
147 | 154 | self::load($type, $file); |
@@ -157,6 +164,9 @@ discard block |
||
157 | 164 | trigger_error("Requested class cannot be instance'd: {$type}, {$file}"); |
158 | 165 | } |
159 | 166 | |
167 | + /** |
|
168 | + * @param string $type |
|
169 | + */ |
|
160 | 170 | public static function loadNew($type, $file, $data = array()) |
161 | 171 | { |
162 | 172 | self::load($type, $file); |
@@ -179,16 +179,16 @@ |
||
179 | 179 | return self::instance()->is_live; |
180 | 180 | } |
181 | 181 | |
182 | - public static function getRootURL($site = '') |
|
183 | - { |
|
184 | - if (strlen($site) > 0) { |
|
185 | - if ($site == 'waterfalls' && self::instance()->is_live) { |
|
186 | - return 'http://www.waterfallsofthekeweenaw.com/'; |
|
187 | - } else { |
|
188 | - return 'http://' . (self::instance()->is_live ? '' : 'dev.') . $site . '.jacobemerick.com/'; |
|
189 | - } |
|
190 | - } |
|
191 | - return '/'; |
|
192 | - } |
|
182 | + public static function getRootURL($site = '') |
|
183 | + { |
|
184 | + if (strlen($site) > 0) { |
|
185 | + if ($site == 'waterfalls' && self::instance()->is_live) { |
|
186 | + return 'http://www.waterfallsofthekeweenaw.com/'; |
|
187 | + } else { |
|
188 | + return 'http://' . (self::instance()->is_live ? '' : 'dev.') . $site . '.jacobemerick.com/'; |
|
189 | + } |
|
190 | + } |
|
191 | + return '/'; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | } |
195 | 195 | \ No newline at end of file |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | |
18 | 18 | public static function instance() |
19 | 19 | { |
20 | - if(!isset(self::$instance)) |
|
20 | + if (!isset(self::$instance)) |
|
21 | 21 | self::$instance = new Loader(); |
22 | 22 | return self::$instance; |
23 | 23 | } |
24 | 24 | |
25 | 25 | private function get_root() |
26 | 26 | { |
27 | - if(!isset($this->root)) |
|
27 | + if (!isset($this->root)) |
|
28 | 28 | { |
29 | 29 | $current_directory = dirname(__FILE__); |
30 | 30 | $current_directory = substr($current_directory, 0, -7); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | private static function get_extension($type) |
54 | 54 | { |
55 | - switch($type) |
|
55 | + switch ($type) |
|
56 | 56 | { |
57 | 57 | case 'collector' : |
58 | 58 | case 'controller' : |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | public static function getImagePath($type, $file) |
73 | 73 | { |
74 | - if($type == 'photo') |
|
74 | + if ($type == 'photo') |
|
75 | 75 | $type = 'photo/processed'; |
76 | 76 | |
77 | 77 | $path = self::instance()->get_root(); |
@@ -107,18 +107,18 @@ discard block |
||
107 | 107 | |
108 | 108 | public static function load($type, $files, $data = array()) |
109 | 109 | { |
110 | - foreach((array) $files as $file) |
|
110 | + foreach ((array) $files as $file) |
|
111 | 111 | { |
112 | 112 | $file_path = self::instance()->get_path($type, $file); |
113 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
113 | + if (in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
114 | 114 | continue; |
115 | 115 | |
116 | - if(!file_exists($file_path)) |
|
116 | + if (!file_exists($file_path)) |
|
117 | 117 | Debugger::logMessage("Requested file does not exist: {$type}, {$file}"); |
118 | 118 | |
119 | 119 | self::instance()->add_included_file($file_path); |
120 | 120 | |
121 | - switch($type) |
|
121 | + switch ($type) |
|
122 | 122 | { |
123 | 123 | case 'images' : |
124 | 124 | case 'scripts' : |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | $reflectionObject = self::create_reflection_class($file); |
150 | 150 | |
151 | - if( |
|
151 | + if ( |
|
152 | 152 | $reflectionObject->hasMethod('instance') && |
153 | 153 | $reflectionObject->getMethod('instance')->isStatic()) |
154 | 154 | { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | $reflectionObject = self::create_reflection_class($file); |
165 | 165 | |
166 | - if($reflectionObject->hasMethod('__construct')) |
|
166 | + if ($reflectionObject->hasMethod('__construct')) |
|
167 | 167 | return $reflectionObject->newInstanceArgs($data); |
168 | 168 | else |
169 | 169 | return $reflectionObject->newInstance(); |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | |
18 | 18 | public static function instance() |
19 | 19 | { |
20 | - if(!isset(self::$instance)) |
|
21 | - self::$instance = new Loader(); |
|
20 | + if(!isset(self::$instance)) { |
|
21 | + self::$instance = new Loader(); |
|
22 | + } |
|
22 | 23 | return self::$instance; |
23 | 24 | } |
24 | 25 | |
@@ -71,8 +72,9 @@ discard block |
||
71 | 72 | |
72 | 73 | public static function getImagePath($type, $file) |
73 | 74 | { |
74 | - if($type == 'photo') |
|
75 | - $type = 'photo/processed'; |
|
75 | + if($type == 'photo') { |
|
76 | + $type = 'photo/processed'; |
|
77 | + } |
|
76 | 78 | |
77 | 79 | $path = self::instance()->get_root(); |
78 | 80 | $path .= 'images'; |
@@ -110,11 +112,13 @@ discard block |
||
110 | 112 | foreach((array) $files as $file) |
111 | 113 | { |
112 | 114 | $file_path = self::instance()->get_path($type, $file); |
113 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
114 | - continue; |
|
115 | + if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') { |
|
116 | + continue; |
|
117 | + } |
|
115 | 118 | |
116 | - if(!file_exists($file_path)) |
|
117 | - Debugger::logMessage("Requested file does not exist: {$type}, {$file}"); |
|
119 | + if(!file_exists($file_path)) { |
|
120 | + Debugger::logMessage("Requested file does not exist: {$type}, {$file}"); |
|
121 | + } |
|
118 | 122 | |
119 | 123 | self::instance()->add_included_file($file_path); |
120 | 124 | |
@@ -163,10 +167,11 @@ discard block |
||
163 | 167 | |
164 | 168 | $reflectionObject = self::create_reflection_class($file); |
165 | 169 | |
166 | - if($reflectionObject->hasMethod('__construct')) |
|
167 | - return $reflectionObject->newInstanceArgs($data); |
|
168 | - else |
|
169 | - return $reflectionObject->newInstance(); |
|
170 | + if($reflectionObject->hasMethod('__construct')) { |
|
171 | + return $reflectionObject->newInstanceArgs($data); |
|
172 | + } else { |
|
173 | + return $reflectionObject->newInstance(); |
|
174 | + } |
|
170 | 175 | } |
171 | 176 | |
172 | 177 | public static function getRoot() |
@@ -18,6 +18,9 @@ discard block |
||
18 | 18 | $this->headers['Bcc'] = "Jacob <{$config->admin_email}>"; |
19 | 19 | } |
20 | 20 | |
21 | + /** |
|
22 | + * @param string $person |
|
23 | + */ |
|
21 | 24 | public function setToAddress($email, $person = null) |
22 | 25 | { |
23 | 26 | if($person) |
@@ -27,12 +30,18 @@ discard block |
||
27 | 30 | return $this; |
28 | 31 | } |
29 | 32 | |
33 | + /** |
|
34 | + * @param string $subject |
|
35 | + */ |
|
30 | 36 | public function setSubject($subject) |
31 | 37 | { |
32 | 38 | $this->subject = $subject; |
33 | 39 | return $this; |
34 | 40 | } |
35 | 41 | |
42 | + /** |
|
43 | + * @param string $message |
|
44 | + */ |
|
36 | 45 | public function setMessage($message) |
37 | 46 | { |
38 | 47 | $this->message = $message; |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function __construct() |
14 | 14 | { |
15 | - global $config; |
|
15 | + global $config; |
|
16 | 16 | $this->headers['From'] = self::$FROM; |
17 | 17 | $this->headers['Reply-To'] = "Jacob <{$config->admin_email}>"; |
18 | 18 | $this->headers['Bcc'] = "Jacob <{$config->admin_email}>"; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | public function setToAddress($email, $person = null) |
22 | 22 | { |
23 | - if($person) |
|
23 | + if ($person) |
|
24 | 24 | $this->to[] = "{$person} <{$email}>"; |
25 | 25 | else |
26 | 26 | $this->to[] = "{$email}"; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | public function send() |
43 | 43 | { |
44 | - if(!Loader::isLive()) |
|
44 | + if (!Loader::isLive()) |
|
45 | 45 | { |
46 | 46 | Debugger::logMessage("Email Failed:\n\n{$this->message}"); |
47 | 47 | return; |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | $subject = $this->subject; |
52 | 52 | $message = $this->message; |
53 | 53 | |
54 | - if(empty($to) || empty($subject) || empty($message)) |
|
54 | + if (empty($to) || empty($subject) || empty($message)) |
|
55 | 55 | { |
56 | 56 | Debugger::logMessage("Attempted to send an email without all of the required fields."); |
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | 60 | $header = ''; |
61 | - foreach($this->headers as $key => $value) |
|
61 | + foreach ($this->headers as $key => $value) |
|
62 | 62 | { |
63 | 63 | $header .= "{$key}: {$value}\r\n"; |
64 | 64 | } |
@@ -20,10 +20,11 @@ |
||
20 | 20 | |
21 | 21 | public function setToAddress($email, $person = null) |
22 | 22 | { |
23 | - if($person) |
|
24 | - $this->to[] = "{$person} <{$email}>"; |
|
25 | - else |
|
26 | - $this->to[] = "{$email}"; |
|
23 | + if($person) { |
|
24 | + $this->to[] = "{$person} <{$email}>"; |
|
25 | + } else { |
|
26 | + $this->to[] = "{$email}"; |
|
27 | + } |
|
27 | 28 | return $this; |
28 | 29 | } |
29 | 30 |
@@ -18,6 +18,9 @@ discard block |
||
18 | 18 | private $console; |
19 | 19 | private $profile = array(); |
20 | 20 | |
21 | + /** |
|
22 | + * @param Console $console |
|
23 | + */ |
|
21 | 24 | public function __construct($console) |
22 | 25 | { |
23 | 26 | $this->start_time = self::getMicrotime(); |
@@ -128,6 +131,9 @@ discard block |
||
128 | 131 | return $time[1] + $time[0]; |
129 | 132 | } |
130 | 133 | |
134 | + /** |
|
135 | + * @param integer $memory |
|
136 | + */ |
|
131 | 137 | private function get_readable_memory_usage($memory) |
132 | 138 | { |
133 | 139 | foreach(self::$MEMORY_SIZE_ARRAY as $key => $memory_size) |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | private function get_console_log() |
28 | 28 | { |
29 | 29 | $log = $this->console->getLog(); |
30 | - if(!isset($log['debugger_log'])) |
|
30 | + if (!isset($log['debugger_log'])) |
|
31 | 31 | return; |
32 | 32 | |
33 | - foreach($log['debugger_log'] as $key => $log_item) |
|
33 | + foreach ($log['debugger_log'] as $key => $log_item) |
|
34 | 34 | { |
35 | - switch($log_item['type']) |
|
35 | + switch ($log_item['type']) |
|
36 | 36 | { |
37 | 37 | case 'log' : |
38 | 38 | case 'error' : |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $included_files = $this->get_files(); |
56 | 56 | $file_array = array(); |
57 | 57 | |
58 | - foreach($included_files as $file) |
|
58 | + foreach ($included_files as $file) |
|
59 | 59 | { |
60 | 60 | $file_size = filesize($file); |
61 | 61 | $file_array[] = array( |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | $total_file_size = 0; |
75 | 75 | $largest_file_size = 0; |
76 | 76 | |
77 | - foreach($included_files as $file) |
|
77 | + foreach ($included_files as $file) |
|
78 | 78 | { |
79 | 79 | $file_size = filesize($file); |
80 | 80 | $total_file_size += $file_size; |
81 | - if($file_size > $largest_file_size) |
|
81 | + if ($file_size > $largest_file_size) |
|
82 | 82 | $largest_file_size = $file_size; |
83 | 83 | } |
84 | 84 | |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | |
131 | 131 | private function get_readable_memory_usage($memory) |
132 | 132 | { |
133 | - foreach(self::$MEMORY_SIZE_ARRAY as $key => $memory_size) |
|
133 | + foreach (self::$MEMORY_SIZE_ARRAY as $key => $memory_size) |
|
134 | 134 | { |
135 | - if($memory < 1024) |
|
135 | + if ($memory < 1024) |
|
136 | 136 | break; |
137 | - if(count(self::$MEMORY_SIZE_ARRAY) != $key + 1) |
|
137 | + if (count(self::$MEMORY_SIZE_ARRAY) != $key + 1) |
|
138 | 138 | $memory /= 1024; |
139 | 139 | } |
140 | 140 | |
141 | - if($memory_size == 'bytes') |
|
141 | + if ($memory_size == 'bytes') |
|
142 | 142 | return sprintf('%01d %s', $memory, $memory_size); |
143 | 143 | return sprintf('%01.2f %s', $memory, $memory_size); |
144 | 144 | } |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | |
155 | 155 | private function get_readable_time($time) |
156 | 156 | { |
157 | - if($time >= 60000) |
|
157 | + if ($time >= 60000) |
|
158 | 158 | return number_format(($time / 60000), 3, '.', '') . ' m'; |
159 | - else if($time >= 1000 && $time < 60000) |
|
159 | + else if ($time >= 1000 && $time < 60000) |
|
160 | 160 | return number_format(($time / 1000), 3, '.', '') . ' s'; |
161 | 161 | else |
162 | 162 | return number_format($time, 3, '.', '') . ' ms'; |
@@ -27,8 +27,9 @@ discard block |
||
27 | 27 | private function get_console_log() |
28 | 28 | { |
29 | 29 | $log = $this->console->getLog(); |
30 | - if(!isset($log['debugger_log'])) |
|
31 | - return; |
|
30 | + if(!isset($log['debugger_log'])) { |
|
31 | + return; |
|
32 | + } |
|
32 | 33 | |
33 | 34 | foreach($log['debugger_log'] as $key => $log_item) |
34 | 35 | { |
@@ -78,8 +79,9 @@ discard block |
||
78 | 79 | { |
79 | 80 | $file_size = filesize($file); |
80 | 81 | $total_file_size += $file_size; |
81 | - if($file_size > $largest_file_size) |
|
82 | - $largest_file_size = $file_size; |
|
82 | + if($file_size > $largest_file_size) { |
|
83 | + $largest_file_size = $file_size; |
|
84 | + } |
|
83 | 85 | } |
84 | 86 | |
85 | 87 | return array( |
@@ -132,14 +134,17 @@ discard block |
||
132 | 134 | { |
133 | 135 | foreach(self::$MEMORY_SIZE_ARRAY as $key => $memory_size) |
134 | 136 | { |
135 | - if($memory < 1024) |
|
136 | - break; |
|
137 | - if(count(self::$MEMORY_SIZE_ARRAY) != $key + 1) |
|
138 | - $memory /= 1024; |
|
137 | + if($memory < 1024) { |
|
138 | + break; |
|
139 | + } |
|
140 | + if(count(self::$MEMORY_SIZE_ARRAY) != $key + 1) { |
|
141 | + $memory /= 1024; |
|
142 | + } |
|
139 | 143 | } |
140 | 144 | |
141 | - if($memory_size == 'bytes') |
|
142 | - return sprintf('%01d %s', $memory, $memory_size); |
|
145 | + if($memory_size == 'bytes') { |
|
146 | + return sprintf('%01d %s', $memory, $memory_size); |
|
147 | + } |
|
143 | 148 | return sprintf('%01.2f %s', $memory, $memory_size); |
144 | 149 | } |
145 | 150 | |
@@ -154,12 +159,13 @@ discard block |
||
154 | 159 | |
155 | 160 | private function get_readable_time($time) |
156 | 161 | { |
157 | - if($time >= 60000) |
|
158 | - return number_format(($time / 60000), 3, '.', '') . ' m'; |
|
159 | - else if($time >= 1000 && $time < 60000) |
|
160 | - return number_format(($time / 1000), 3, '.', '') . ' s'; |
|
161 | - else |
|
162 | - return number_format($time, 3, '.', '') . ' ms'; |
|
162 | + if($time >= 60000) { |
|
163 | + return number_format(($time / 60000), 3, '.', '') . ' m'; |
|
164 | + } else if($time >= 1000 && $time < 60000) { |
|
165 | + return number_format(($time / 1000), 3, '.', '') . ' s'; |
|
166 | + } else { |
|
167 | + return number_format($time, 3, '.', '') . ' ms'; |
|
168 | + } |
|
163 | 169 | } |
164 | 170 | |
165 | 171 | private function collect_profile_array() |
@@ -34,6 +34,9 @@ |
||
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | |
37 | + /** |
|
38 | + * @param string $key |
|
39 | + */ |
|
37 | 40 | static function getGet($key = null) |
38 | 41 | { |
39 | 42 | if($key) |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | |
19 | 19 | static function getServer($key = null) |
20 | 20 | { |
21 | - if($key) |
|
21 | + if ($key) |
|
22 | 22 | { |
23 | - if(isset(self::$server[$key])) |
|
23 | + if (isset(self::$server[$key])) |
|
24 | 24 | return self::$server[$key]; |
25 | 25 | return false; |
26 | 26 | } |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | |
30 | 30 | static function isAjax() |
31 | 31 | { |
32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
32 | + if (self::getServer(self::$AJAX_REQUEST)) |
|
33 | 33 | return true; |
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | |
37 | 37 | static function getGet($key = null) |
38 | 38 | { |
39 | - if($key) |
|
39 | + if ($key) |
|
40 | 40 | { |
41 | - if(isset(self::$get[$key])) |
|
41 | + if (isset(self::$get[$key])) |
|
42 | 42 | return self::$get[$key]; |
43 | 43 | return false; |
44 | 44 | } |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | static function getPost($key = null) |
49 | 49 | { |
50 | - if($key) |
|
50 | + if ($key) |
|
51 | 51 | { |
52 | - if(isset(self::$post[$key])) |
|
52 | + if (isset(self::$post[$key])) |
|
53 | 53 | return self::$post[$key]; |
54 | 54 | return false; |
55 | 55 | } |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | { |
21 | 21 | if($key) |
22 | 22 | { |
23 | - if(isset(self::$server[$key])) |
|
24 | - return self::$server[$key]; |
|
23 | + if(isset(self::$server[$key])) { |
|
24 | + return self::$server[$key]; |
|
25 | + } |
|
25 | 26 | return false; |
26 | 27 | } |
27 | 28 | return self::$server; |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | static function isAjax() |
31 | 32 | { |
32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
33 | - return true; |
|
33 | + if(self::getServer(self::$AJAX_REQUEST)) { |
|
34 | + return true; |
|
35 | + } |
|
34 | 36 | return false; |
35 | 37 | } |
36 | 38 | |
@@ -38,8 +40,9 @@ discard block |
||
38 | 40 | { |
39 | 41 | if($key) |
40 | 42 | { |
41 | - if(isset(self::$get[$key])) |
|
42 | - return self::$get[$key]; |
|
43 | + if(isset(self::$get[$key])) { |
|
44 | + return self::$get[$key]; |
|
45 | + } |
|
43 | 46 | return false; |
44 | 47 | } |
45 | 48 | return self::$get; |
@@ -49,8 +52,9 @@ discard block |
||
49 | 52 | { |
50 | 53 | if($key) |
51 | 54 | { |
52 | - if(isset(self::$post[$key])) |
|
53 | - return self::$post[$key]; |
|
55 | + if(isset(self::$post[$key])) { |
|
56 | + return self::$post[$key]; |
|
57 | + } |
|
54 | 58 | return false; |
55 | 59 | } |
56 | 60 | return self::$post; |
@@ -38,6 +38,9 @@ discard block |
||
38 | 38 | self::$array['pieces'] = (array) $uri_array; |
39 | 39 | } |
40 | 40 | |
41 | + /** |
|
42 | + * @return string |
|
43 | + */ |
|
41 | 44 | static function getSite() |
42 | 45 | { |
43 | 46 | return self::$array['site']; |
@@ -66,6 +69,9 @@ discard block |
||
66 | 69 | return substr($file, strrpos($file, '.') + 1);; |
67 | 70 | } |
68 | 71 | |
72 | + /** |
|
73 | + * @param integer $piece |
|
74 | + */ |
|
69 | 75 | static function getPiece($piece = null) |
70 | 76 | { |
71 | 77 | if(!$piece) |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | static private function form_url_array($host, $uri) |
16 | 16 | { |
17 | 17 | $uri = substr($uri, 1); |
18 | - if(strpos($uri, '?')) |
|
18 | + if (strpos($uri, '?')) |
|
19 | 19 | $uri = substr($uri, 0, strpos($uri, '?')); |
20 | 20 | $uri_array = explode('/', $uri); |
21 | 21 | |
22 | - if(!Loader::isLive()) |
|
22 | + if (!Loader::isLive()) |
|
23 | 23 | $host = substr($host, strpos($host, '.') + 1); |
24 | 24 | |
25 | 25 | self::$array['host'] = $host; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | self::$array['base'] = 'http://' . (!Loader::isLive() ? 'dev.' : '') . $host . '/'; |
34 | 34 | self::$array['uri'] = '/' . implode('/', $uri_array); |
35 | 35 | |
36 | - if(end($uri_array) == '') |
|
36 | + if (end($uri_array) == '') |
|
37 | 37 | $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
38 | 38 | self::$array['pieces'] = (array) $uri_array; |
39 | 39 | } |
@@ -61,21 +61,21 @@ discard block |
||
61 | 61 | static function getExtension() |
62 | 62 | { |
63 | 63 | $file = self::getPiece(-1); |
64 | - if(substr($file, -1) == '/') |
|
64 | + if (substr($file, -1) == '/') |
|
65 | 65 | return false; |
66 | - return substr($file, strrpos($file, '.') + 1);; |
|
66 | + return substr($file, strrpos($file, '.') + 1); ; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | static function getPiece($piece = null) |
70 | 70 | { |
71 | - if(!$piece) |
|
71 | + if (!$piece) |
|
72 | 72 | return self::$array['pieces']; |
73 | 73 | |
74 | - if($piece == -1) |
|
74 | + if ($piece == -1) |
|
75 | 75 | return end(self::$array['pieces']); |
76 | 76 | |
77 | 77 | $piece = $piece - 1; |
78 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
78 | + if (array_key_exists($piece, self::$array['pieces'])) |
|
79 | 79 | return self::$array['pieces'][$piece]; |
80 | 80 | return; |
81 | 81 | } |
@@ -15,12 +15,14 @@ discard block |
||
15 | 15 | static private function form_url_array($host, $uri) |
16 | 16 | { |
17 | 17 | $uri = substr($uri, 1); |
18 | - if(strpos($uri, '?')) |
|
19 | - $uri = substr($uri, 0, strpos($uri, '?')); |
|
18 | + if(strpos($uri, '?')) { |
|
19 | + $uri = substr($uri, 0, strpos($uri, '?')); |
|
20 | + } |
|
20 | 21 | $uri_array = explode('/', $uri); |
21 | 22 | |
22 | - if(!Loader::isLive()) |
|
23 | - $host = substr($host, strpos($host, '.') + 1); |
|
23 | + if(!Loader::isLive()) { |
|
24 | + $host = substr($host, strpos($host, '.') + 1); |
|
25 | + } |
|
24 | 26 | |
25 | 27 | self::$array['host'] = $host; |
26 | 28 | |
@@ -33,8 +35,9 @@ discard block |
||
33 | 35 | self::$array['base'] = 'http://' . (!Loader::isLive() ? 'dev.' : '') . $host . '/'; |
34 | 36 | self::$array['uri'] = '/' . implode('/', $uri_array); |
35 | 37 | |
36 | - if(end($uri_array) == '') |
|
37 | - $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
38 | + if(end($uri_array) == '') { |
|
39 | + $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
40 | + } |
|
38 | 41 | self::$array['pieces'] = (array) $uri_array; |
39 | 42 | } |
40 | 43 | |
@@ -61,22 +64,26 @@ discard block |
||
61 | 64 | static function getExtension() |
62 | 65 | { |
63 | 66 | $file = self::getPiece(-1); |
64 | - if(substr($file, -1) == '/') |
|
65 | - return false; |
|
67 | + if(substr($file, -1) == '/') { |
|
68 | + return false; |
|
69 | + } |
|
66 | 70 | return substr($file, strrpos($file, '.') + 1);; |
67 | 71 | } |
68 | 72 | |
69 | 73 | static function getPiece($piece = null) |
70 | 74 | { |
71 | - if(!$piece) |
|
72 | - return self::$array['pieces']; |
|
75 | + if(!$piece) { |
|
76 | + return self::$array['pieces']; |
|
77 | + } |
|
73 | 78 | |
74 | - if($piece == -1) |
|
75 | - return end(self::$array['pieces']); |
|
79 | + if($piece == -1) { |
|
80 | + return end(self::$array['pieces']); |
|
81 | + } |
|
76 | 82 | |
77 | 83 | $piece = $piece - 1; |
78 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
79 | - return self::$array['pieces'][$piece]; |
|
84 | + if(array_key_exists($piece, self::$array['pieces'])) { |
|
85 | + return self::$array['pieces'][$piece]; |
|
86 | + } |
|
80 | 87 | return; |
81 | 88 | } |
82 | 89 |
@@ -72,6 +72,11 @@ |
||
72 | 72 | return $matches[0] == $string; |
73 | 73 | } |
74 | 74 | |
75 | + /** |
|
76 | + * @param string $type |
|
77 | + * @param string $key |
|
78 | + * @param string $validation |
|
79 | + */ |
|
75 | 80 | public static function checkRequest($type, $key, $validation, $strict = false) |
76 | 81 | { |
77 | 82 | switch($type) |
@@ -11,39 +11,39 @@ discard block |
||
11 | 11 | |
12 | 12 | public static function isBoolean($value, $strict = false) |
13 | 13 | { |
14 | - if($strict && ($value === true || $value === false)) |
|
14 | + if ($strict && ($value === true || $value === false)) |
|
15 | 15 | return true; |
16 | - if(!$strict && ((bool) $value === true || (bool) $value === false)) |
|
16 | + if (!$strict && ((bool) $value === true || (bool) $value === false)) |
|
17 | 17 | return true; |
18 | 18 | return false; |
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function isDate($value) |
22 | 22 | { |
23 | - if(strtotime($value) !== -1) |
|
23 | + if (strtotime($value) !== -1) |
|
24 | 24 | return true; |
25 | - if(date('y', $value) !== false) |
|
25 | + if (date('y', $value) !== false) |
|
26 | 26 | return true; |
27 | 27 | return false; |
28 | 28 | } |
29 | 29 | |
30 | 30 | public static function isInteger($value, $strict = false) |
31 | 31 | { |
32 | - if($strict) |
|
32 | + if ($strict) |
|
33 | 33 | return is_int($value); |
34 | 34 | return (int) $value == $value; |
35 | 35 | } |
36 | 36 | |
37 | 37 | public static function isIP($value) |
38 | 38 | { |
39 | - if(self::isInteger(ip2long($value))) |
|
39 | + if (self::isInteger(ip2long($value))) |
|
40 | 40 | return true; |
41 | 41 | return false; |
42 | 42 | } |
43 | 43 | |
44 | 44 | public static function isString($value, $strict = false) |
45 | 45 | { |
46 | - if($strict) |
|
46 | + if ($strict) |
|
47 | 47 | return is_string($value); |
48 | 48 | return (string) $value == $value; |
49 | 49 | } |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | private static function check_value($pattern, $string) |
68 | 68 | { |
69 | 69 | preg_match($pattern, $string, $matches); |
70 | - if(empty($matches)) |
|
70 | + if (empty($matches)) |
|
71 | 71 | return false; |
72 | 72 | return $matches[0] == $string; |
73 | 73 | } |
74 | 74 | |
75 | 75 | public static function checkRequest($type, $key, $validation, $strict = false) |
76 | 76 | { |
77 | - switch($type) |
|
77 | + switch ($type) |
|
78 | 78 | { |
79 | 79 | case 'server': |
80 | 80 | $value = Request::getServer($key); |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | break; |
85 | 85 | } |
86 | 86 | |
87 | - if($value == false) |
|
87 | + if ($value == false) |
|
88 | 88 | return false; |
89 | 89 | |
90 | - switch($validation) |
|
90 | + switch ($validation) |
|
91 | 91 | { |
92 | 92 | case 'boolean': |
93 | 93 | return self::isBoolean($value, $strict); |
@@ -11,40 +11,47 @@ discard block |
||
11 | 11 | |
12 | 12 | public static function isBoolean($value, $strict = false) |
13 | 13 | { |
14 | - if($strict && ($value === true || $value === false)) |
|
15 | - return true; |
|
16 | - if(!$strict && ((bool) $value === true || (bool) $value === false)) |
|
17 | - return true; |
|
14 | + if($strict && ($value === true || $value === false)) { |
|
15 | + return true; |
|
16 | + } |
|
17 | + if(!$strict && ((bool) $value === true || (bool) $value === false)) { |
|
18 | + return true; |
|
19 | + } |
|
18 | 20 | return false; |
19 | 21 | } |
20 | 22 | |
21 | 23 | public static function isDate($value) |
22 | 24 | { |
23 | - if(strtotime($value) !== -1) |
|
24 | - return true; |
|
25 | - if(date('y', $value) !== false) |
|
26 | - return true; |
|
25 | + if(strtotime($value) !== -1) { |
|
26 | + return true; |
|
27 | + } |
|
28 | + if(date('y', $value) !== false) { |
|
29 | + return true; |
|
30 | + } |
|
27 | 31 | return false; |
28 | 32 | } |
29 | 33 | |
30 | 34 | public static function isInteger($value, $strict = false) |
31 | 35 | { |
32 | - if($strict) |
|
33 | - return is_int($value); |
|
36 | + if($strict) { |
|
37 | + return is_int($value); |
|
38 | + } |
|
34 | 39 | return (int) $value == $value; |
35 | 40 | } |
36 | 41 | |
37 | 42 | public static function isIP($value) |
38 | 43 | { |
39 | - if(self::isInteger(ip2long($value))) |
|
40 | - return true; |
|
44 | + if(self::isInteger(ip2long($value))) { |
|
45 | + return true; |
|
46 | + } |
|
41 | 47 | return false; |
42 | 48 | } |
43 | 49 | |
44 | 50 | public static function isString($value, $strict = false) |
45 | 51 | { |
46 | - if($strict) |
|
47 | - return is_string($value); |
|
52 | + if($strict) { |
|
53 | + return is_string($value); |
|
54 | + } |
|
48 | 55 | return (string) $value == $value; |
49 | 56 | } |
50 | 57 | |
@@ -67,8 +74,9 @@ discard block |
||
67 | 74 | private static function check_value($pattern, $string) |
68 | 75 | { |
69 | 76 | preg_match($pattern, $string, $matches); |
70 | - if(empty($matches)) |
|
71 | - return false; |
|
77 | + if(empty($matches)) { |
|
78 | + return false; |
|
79 | + } |
|
72 | 80 | return $matches[0] == $string; |
73 | 81 | } |
74 | 82 | |
@@ -84,8 +92,9 @@ discard block |
||
84 | 92 | break; |
85 | 93 | } |
86 | 94 | |
87 | - if($value == false) |
|
88 | - return false; |
|
95 | + if($value == false) { |
|
96 | + return false; |
|
97 | + } |
|
89 | 98 | |
90 | 99 | switch($validation) |
91 | 100 | { |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | $handle = @fopen($configuration_path, 'r'); |
9 | 9 | if ($handle === false) { |
10 | - throw new RuntimeException("Could not load configuration"); |
|
10 | + throw new RuntimeException("Could not load configuration"); |
|
11 | 11 | } |
12 | 12 | $configuration = fread($handle, filesize($configuration_path)); |
13 | 13 | fclose($handle); |
@@ -15,34 +15,34 @@ discard block |
||
15 | 15 | $configuration = json_decode($configuration); |
16 | 16 | $last_json_error = json_last_error(); |
17 | 17 | if ($last_json_error !== JSON_ERROR_NONE) { |
18 | - throw new RuntimeException("Could not parse configuration - JSON error detected"); |
|
18 | + throw new RuntimeException("Could not parse configuration - JSON error detected"); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | // configure the db connections holder |
22 | 22 | $db_connections = new Aura\Sql\ConnectionLocator(); |
23 | 23 | $db_connections->setDefault(function () use ($configuration) { |
24 | - $connection = $configuration->database->slave; |
|
25 | - return new Aura\Sql\ExtendedPdo( |
|
26 | - "mysql:host={$connection->host}", |
|
27 | - $connection->user, |
|
28 | - $connection->password |
|
29 | - ); |
|
24 | + $connection = $configuration->database->slave; |
|
25 | + return new Aura\Sql\ExtendedPdo( |
|
26 | + "mysql:host={$connection->host}", |
|
27 | + $connection->user, |
|
28 | + $connection->password |
|
29 | + ); |
|
30 | 30 | }); |
31 | 31 | $db_connections->setWrite('master', function () use ($configuration) { |
32 | - $connection = $configuration->database->master; |
|
33 | - return new Aura\Sql\ExtendedPdo( |
|
34 | - "mysql:host={$connection->host}", |
|
35 | - $connection->user, |
|
36 | - $connection->password |
|
37 | - ); |
|
32 | + $connection = $configuration->database->master; |
|
33 | + return new Aura\Sql\ExtendedPdo( |
|
34 | + "mysql:host={$connection->host}", |
|
35 | + $connection->user, |
|
36 | + $connection->password |
|
37 | + ); |
|
38 | 38 | }); |
39 | 39 | $db_connections->setRead('slave', function () use ($configuration) { |
40 | - $connection = $configuration->database->slave; |
|
41 | - return new Aura\Sql\ExtendedPdo( |
|
42 | - "mysql:host={$connection->host}", |
|
43 | - $connection->user, |
|
44 | - $connection->password |
|
45 | - ); |
|
40 | + $connection = $configuration->database->slave; |
|
41 | + return new Aura\Sql\ExtendedPdo( |
|
42 | + "mysql:host={$connection->host}", |
|
43 | + $connection->user, |
|
44 | + $connection->password |
|
45 | + ); |
|
46 | 46 | }); |
47 | 47 | |
48 | 48 | // setup the service locator |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | // configure the db connections holder |
22 | 22 | $db_connections = new Aura\Sql\ConnectionLocator(); |
23 | -$db_connections->setDefault(function () use ($configuration) { |
|
23 | +$db_connections->setDefault(function() use ($configuration) { |
|
24 | 24 | $connection = $configuration->database->slave; |
25 | 25 | return new Aura\Sql\ExtendedPdo( |
26 | 26 | "mysql:host={$connection->host}", |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $connection->password |
29 | 29 | ); |
30 | 30 | }); |
31 | -$db_connections->setWrite('master', function () use ($configuration) { |
|
31 | +$db_connections->setWrite('master', function() use ($configuration) { |
|
32 | 32 | $connection = $configuration->database->master; |
33 | 33 | return new Aura\Sql\ExtendedPdo( |
34 | 34 | "mysql:host={$connection->host}", |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $connection->password |
37 | 37 | ); |
38 | 38 | }); |
39 | -$db_connections->setRead('slave', function () use ($configuration) { |
|
39 | +$db_connections->setRead('slave', function() use ($configuration) { |
|
40 | 40 | $connection = $configuration->database->slave; |
41 | 41 | return new Aura\Sql\ExtendedPdo( |
42 | 42 | "mysql:host={$connection->host}", |
@@ -153,9 +153,9 @@ |
||
153 | 153 | return self::run_query($query); |
154 | 154 | } |
155 | 155 | |
156 | - public static function getParentWatercourse($watercourse) |
|
157 | - { |
|
158 | - } |
|
156 | + public static function getParentWatercourse($watercourse) |
|
157 | + { |
|
158 | + } |
|
159 | 159 | |
160 | 160 | public static function getLogCountForWatercourse($watercourse) |
161 | 161 | { |