@@ -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); |
@@ -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 |
@@ -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 | } |
@@ -39,20 +39,20 @@ discard block |
||
39 | 39 | public function perform() |
40 | 40 | { |
41 | 41 | $weighted_array = array(); |
42 | - foreach($this->result as $row) |
|
42 | + foreach ($this->result as $row) |
|
43 | 43 | { |
44 | 44 | $weight = $this->get_search_weight($row); |
45 | - if($weight > 0) |
|
45 | + if ($weight > 0) |
|
46 | 46 | $weighted_array[$row->id] = $weight; |
47 | 47 | } |
48 | 48 | arsort($weighted_array); |
49 | 49 | |
50 | 50 | $final_array = array(); |
51 | - foreach($weighted_array as $id => $weight) |
|
51 | + foreach ($weighted_array as $id => $weight) |
|
52 | 52 | { |
53 | - foreach($this->result as $row) |
|
53 | + foreach ($this->result as $row) |
|
54 | 54 | { |
55 | - if($row->id == $id) |
|
55 | + if ($row->id == $id) |
|
56 | 56 | $final_array[] = $row; |
57 | 57 | } |
58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | private function get_search_weight($row) |
63 | 63 | { |
64 | 64 | $weight = 0; |
65 | - foreach($this->weight as $weight_array) |
|
65 | + foreach ($this->weight as $weight_array) |
|
66 | 66 | { |
67 | 67 | $text = $row->{$weight_array['field']}; |
68 | 68 | $weight += $weight_array['weight'] * substr_count(strtolower($text), strtolower($this->query)); |
@@ -56,11 +56,11 @@ |
||
56 | 56 | final private function get_list_posts() |
57 | 57 | { |
58 | 58 | $post_array = array(); |
59 | - foreach($this->get_list_results() as $post) |
|
59 | + foreach ($this->get_list_results() as $post) |
|
60 | 60 | { |
61 | 61 | $post_array[] = $this->format_post($post, true); |
62 | 62 | } |
63 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
63 | + if (count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
64 | 64 | $this->eject(); |
65 | 65 | return $post_array; |
66 | 66 | } |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | |
34 | 34 | private function process_form() |
35 | 35 | { |
36 | - if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
36 | + if (!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
37 | 37 | return (object) array('display' => 'normal'); |
38 | 38 | |
39 | 39 | Loader::load('utility', 'Validate'); |
40 | 40 | $error_result = array(); |
41 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
41 | + if (!Validate::checkRequest('post', 'name', 'string')) |
|
42 | 42 | $error_result['name'] = 'please enter your name'; |
43 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
43 | + if (!Validate::checkRequest('post', 'email', 'string')) |
|
44 | 44 | $error_result['email'] = 'please enter a valid email'; |
45 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
45 | + if (!Validate::checkRequest('post', 'message', 'string')) |
|
46 | 46 | $error_result['message'] = 'please write a message'; |
47 | 47 | |
48 | 48 | $values = (object) array( |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | 'email' => Request::getPost('email'), |
51 | 51 | 'message' => Request::getPost('message')); |
52 | 52 | |
53 | - if(count($error_result) > 0) |
|
53 | + if (count($error_result) > 0) |
|
54 | 54 | { |
55 | 55 | return (object) array( |
56 | 56 | 'display' => 'error', |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | parent::__construct(); |
21 | 21 | |
22 | 22 | $id = URLDecode::getPiece(2); |
23 | - if(!$id || !is_numeric($id)) |
|
23 | + if (!$id || !is_numeric($id)) |
|
24 | 24 | $this->eject(); |
25 | 25 | |
26 | 26 | $post = $this->postRepository->getPostById($id); |
27 | - if(!$post) |
|
27 | + if (!$post) |
|
28 | 28 | $this->eject(); |
29 | 29 | |
30 | - if(URLDecode::getPiece(1) != $post['type']) |
|
30 | + if (URLDecode::getPiece(1) != $post['type']) |
|
31 | 31 | $this->eject(); |
32 | 32 | |
33 | 33 | $this->post = $post; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | private function get_title() |
61 | 61 | { |
62 | - switch($this->post['type']) |
|
62 | + switch ($this->post['type']) |
|
63 | 63 | { |
64 | 64 | case 'blog' : |
65 | 65 | return 'Jacob blogged'; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | private function get_description() |
86 | 86 | { |
87 | - switch($this->post['type']) |
|
87 | + switch ($this->post['type']) |
|
88 | 88 | { |
89 | 89 | case 'blog' : |
90 | 90 | return 'Another awesome blog post from Jacob. Did I mention it was awesome?'; |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | |
19 | 19 | private static function get_router_name() |
20 | 20 | { |
21 | - if(Request::isAJAX()) |
|
21 | + if (Request::isAJAX()) |
|
22 | 22 | return 'AJAXRouter'; |
23 | 23 | |
24 | - switch(URLDecode::getSite()) |
|
24 | + switch (URLDecode::getSite()) |
|
25 | 25 | { |
26 | 26 | case 'ajax' : |
27 | 27 | return 'AjaxRouter'; |
@@ -66,36 +66,36 @@ discard block |
||
66 | 66 | |
67 | 67 | final protected function check_for_redirect($redirect_uri) |
68 | 68 | { |
69 | - foreach($this->get_redirect_array() as $check) |
|
69 | + foreach ($this->get_redirect_array() as $check) |
|
70 | 70 | { |
71 | 71 | $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
72 | 72 | } |
73 | 73 | |
74 | 74 | $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
75 | 75 | |
76 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
76 | + if ($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
77 | 77 | $redirect_uri .= '/'; |
78 | 78 | |
79 | 79 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
80 | 80 | $redirect_uri = 'http://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
81 | 81 | } |
82 | 82 | |
83 | - if($redirect_uri == URLDecode::getURI()) |
|
83 | + if ($redirect_uri == URLDecode::getURI()) |
|
84 | 84 | return; |
85 | 85 | |
86 | 86 | $controller_check = $redirect_uri; |
87 | - if(substr($redirect_uri, 0, 4) == 'http') |
|
87 | + if (substr($redirect_uri, 0, 4) == 'http') |
|
88 | 88 | $controller_check = preg_replace('@^http://([a-z\.]+)@', '', $redirect_uri); |
89 | 89 | |
90 | 90 | $controller = $this->get_controller($controller_check); |
91 | - if($controller == '/Error404Controller') |
|
91 | + if ($controller == '/Error404Controller') |
|
92 | 92 | { |
93 | 93 | Loader::loadNew('controller', '/Error404Controller') |
94 | 94 | ->activate(); |
95 | 95 | exit; |
96 | 96 | } |
97 | 97 | |
98 | - if(substr($redirect_uri, 0, 4) != 'http') |
|
98 | + if (substr($redirect_uri, 0, 4) != 'http') |
|
99 | 99 | { |
100 | 100 | $redirect_uri = substr($redirect_uri, 1); |
101 | 101 | $redirect_uri = URLDecode::getBase() . $redirect_uri; |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | |
113 | 113 | final private function get_controller($uri) |
114 | 114 | { |
115 | - foreach($this->get_direct_array() as $check) |
|
115 | + foreach ($this->get_direct_array() as $check) |
|
116 | 116 | { |
117 | - if($uri == $check->match) |
|
117 | + if ($uri == $check->match) |
|
118 | 118 | return "{$this->get_primary_folder()}/{$check->controller}"; |
119 | 119 | |
120 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
120 | + if (preg_match("@^{$check->match}$@", $uri)) |
|
121 | 121 | return "{$this->get_primary_folder()}/{$check->controller}"; |
122 | 122 | } |
123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | final private function get_primary_folder() |
128 | 128 | { |
129 | - if(Request::isAjax()) |
|
129 | + if (Request::isAjax()) |
|
130 | 130 | return 'ajax'; |
131 | 131 | |
132 | 132 | return URLDecode::getSite(); |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface PieceRepositoryInterface |
6 | 6 | { |
7 | - public function getPieces($limit = null, $offset= 0); |
|
7 | + public function getPieces($limit = null, $offset = 0); |
|
8 | 8 | } |