@@ -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 | } |
@@ -3,78 +3,78 @@ |
||
3 | 3 | class Request |
4 | 4 | { |
5 | 5 | |
6 | - private static $server = array(); |
|
7 | - private static $get = array(); |
|
8 | - private static $post = array(); |
|
6 | + private static $server = array(); |
|
7 | + private static $get = array(); |
|
8 | + private static $post = array(); |
|
9 | 9 | |
10 | - private static $AJAX_REQUEST = 'HTTP_X_REQUESTED_WITH'; |
|
10 | + private static $AJAX_REQUEST = 'HTTP_X_REQUESTED_WITH'; |
|
11 | 11 | |
12 | - static function init() |
|
13 | - { |
|
14 | - self::make_server(); |
|
15 | - self::make_get(); |
|
16 | - self::make_post(); |
|
17 | - } |
|
12 | + static function init() |
|
13 | + { |
|
14 | + self::make_server(); |
|
15 | + self::make_get(); |
|
16 | + self::make_post(); |
|
17 | + } |
|
18 | 18 | |
19 | - static function getServer($key = null) |
|
20 | - { |
|
21 | - if($key) |
|
22 | - { |
|
23 | - if(isset(self::$server[$key])) |
|
24 | - return self::$server[$key]; |
|
25 | - return false; |
|
26 | - } |
|
27 | - return self::$server; |
|
28 | - } |
|
19 | + static function getServer($key = null) |
|
20 | + { |
|
21 | + if($key) |
|
22 | + { |
|
23 | + if(isset(self::$server[$key])) |
|
24 | + return self::$server[$key]; |
|
25 | + return false; |
|
26 | + } |
|
27 | + return self::$server; |
|
28 | + } |
|
29 | 29 | |
30 | - static function isAjax() |
|
31 | - { |
|
32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
33 | - return true; |
|
34 | - return false; |
|
35 | - } |
|
30 | + static function isAjax() |
|
31 | + { |
|
32 | + if(self::getServer(self::$AJAX_REQUEST)) |
|
33 | + return true; |
|
34 | + return false; |
|
35 | + } |
|
36 | 36 | |
37 | - static function getGet($key = null) |
|
38 | - { |
|
39 | - if($key) |
|
40 | - { |
|
41 | - if(isset(self::$get[$key])) |
|
42 | - return self::$get[$key]; |
|
43 | - return false; |
|
44 | - } |
|
45 | - return self::$get; |
|
46 | - } |
|
37 | + static function getGet($key = null) |
|
38 | + { |
|
39 | + if($key) |
|
40 | + { |
|
41 | + if(isset(self::$get[$key])) |
|
42 | + return self::$get[$key]; |
|
43 | + return false; |
|
44 | + } |
|
45 | + return self::$get; |
|
46 | + } |
|
47 | 47 | |
48 | - static function getPost($key = null) |
|
49 | - { |
|
50 | - if($key) |
|
51 | - { |
|
52 | - if(isset(self::$post[$key])) |
|
53 | - return self::$post[$key]; |
|
54 | - return false; |
|
55 | - } |
|
56 | - return self::$post; |
|
57 | - } |
|
48 | + static function getPost($key = null) |
|
49 | + { |
|
50 | + if($key) |
|
51 | + { |
|
52 | + if(isset(self::$post[$key])) |
|
53 | + return self::$post[$key]; |
|
54 | + return false; |
|
55 | + } |
|
56 | + return self::$post; |
|
57 | + } |
|
58 | 58 | |
59 | - public static function hasPost() |
|
60 | - { |
|
61 | - return is_array(self::$post) && !empty(self::$post); |
|
62 | - } |
|
59 | + public static function hasPost() |
|
60 | + { |
|
61 | + return is_array(self::$post) && !empty(self::$post); |
|
62 | + } |
|
63 | 63 | |
64 | - static function make_server() |
|
65 | - { |
|
66 | - self::$server = $_SERVER; |
|
67 | - } |
|
64 | + static function make_server() |
|
65 | + { |
|
66 | + self::$server = $_SERVER; |
|
67 | + } |
|
68 | 68 | |
69 | - static function make_get() |
|
70 | - { |
|
71 | - self::$get = $_GET; |
|
72 | - } |
|
69 | + static function make_get() |
|
70 | + { |
|
71 | + self::$get = $_GET; |
|
72 | + } |
|
73 | 73 | |
74 | - static function make_post() |
|
75 | - { |
|
76 | - self::$post = $_POST; |
|
77 | - } |
|
74 | + static function make_post() |
|
75 | + { |
|
76 | + self::$post = $_POST; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | } |
80 | 80 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class Request |
|
4 | -{ |
|
3 | +class Request |
|
4 | +{ |
|
5 | 5 | |
6 | 6 | private static $server = array(); |
7 | 7 | private static $get = array(); |
@@ -9,70 +9,74 @@ discard block |
||
9 | 9 | |
10 | 10 | private static $AJAX_REQUEST = 'HTTP_X_REQUESTED_WITH'; |
11 | 11 | |
12 | - static function init() |
|
13 | - { |
|
12 | + static function init() |
|
13 | + { |
|
14 | 14 | self::make_server(); |
15 | 15 | self::make_get(); |
16 | 16 | self::make_post(); |
17 | 17 | } |
18 | 18 | |
19 | - static function getServer($key = null) |
|
20 | - { |
|
19 | + static function getServer($key = null) |
|
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; |
28 | 29 | } |
29 | 30 | |
30 | - static function isAjax() |
|
31 | - { |
|
32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
33 | - return true; |
|
31 | + static function isAjax() |
|
32 | + { |
|
33 | + if(self::getServer(self::$AJAX_REQUEST)) { |
|
34 | + return true; |
|
35 | + } |
|
34 | 36 | return false; |
35 | 37 | } |
36 | 38 | |
37 | - static function getGet($key = null) |
|
38 | - { |
|
39 | + static function getGet($key = null) |
|
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; |
46 | 49 | } |
47 | 50 | |
48 | - static function getPost($key = null) |
|
49 | - { |
|
51 | + static function getPost($key = null) |
|
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; |
57 | 61 | } |
58 | 62 | |
59 | - public static function hasPost() |
|
60 | - { |
|
63 | + public static function hasPost() |
|
64 | + { |
|
61 | 65 | return is_array(self::$post) && !empty(self::$post); |
62 | 66 | } |
63 | 67 | |
64 | - static function make_server() |
|
65 | - { |
|
68 | + static function make_server() |
|
69 | + { |
|
66 | 70 | self::$server = $_SERVER; |
67 | 71 | } |
68 | 72 | |
69 | - static function make_get() |
|
70 | - { |
|
73 | + static function make_get() |
|
74 | + { |
|
71 | 75 | self::$get = $_GET; |
72 | 76 | } |
73 | 77 | |
74 | - static function make_post() |
|
75 | - { |
|
78 | + static function make_post() |
|
79 | + { |
|
76 | 80 | self::$post = $_POST; |
77 | 81 | } |
78 | 82 |
@@ -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) |
@@ -131,6 +131,9 @@ |
||
131 | 131 | self::send($array); |
132 | 132 | } |
133 | 133 | |
134 | + /** |
|
135 | + * @param string[] $array |
|
136 | + */ |
|
134 | 137 | private static function send($array, $gzip = true) |
135 | 138 | { |
136 | 139 | if($gzip) |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | 'Cache-Control: no-cache', |
11 | 11 | 'Content-Language: en', |
12 | 12 | 'Content-Type: application/json', |
13 | - 'Expires: ' . self::get_date(time() - 1), |
|
14 | - 'Last-Modified: ' . self::get_date(), |
|
13 | + 'Expires: '.self::get_date(time() - 1), |
|
14 | + 'Last-Modified: '.self::get_date(), |
|
15 | 15 | 'X-Powered-By: jacobemerick.com'); |
16 | 16 | self::send($array); |
17 | 17 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | 'Cache-Control: no-cache', |
24 | 24 | 'Content-Language: en', |
25 | 25 | 'Content-Type: text/html', |
26 | - 'Expires: ' . self::get_date(time() - 1), |
|
27 | - 'Last-Modified: ' . self::get_date(), |
|
26 | + 'Expires: '.self::get_date(time() - 1), |
|
27 | + 'Last-Modified: '.self::get_date(), |
|
28 | 28 | 'X-Powered-By: jacobemerick.com'); |
29 | 29 | self::send($array); |
30 | 30 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | 'Cache-Control: no-cache', |
43 | 43 | 'Content-Language: en', |
44 | 44 | 'Content-Type: text/html', |
45 | - 'Expires: ' . self::get_date(time() - 1), |
|
46 | - 'Last-Modified: ' . self::get_date(), |
|
45 | + 'Expires: '.self::get_date(time() - 1), |
|
46 | + 'Last-Modified: '.self::get_date(), |
|
47 | 47 | 'X-Powered-By: jacobemerick.com'); |
48 | 48 | self::send($array); |
49 | 49 | } |
@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | 'Cache-Control: no-cache', |
56 | 56 | 'Content-Language: en', |
57 | 57 | 'Content-Type: text/html', |
58 | - 'Expires: ' . self::get_date(time() - 1), |
|
59 | - 'Last-Modified: ' . self::get_date(), |
|
58 | + 'Expires: '.self::get_date(time() - 1), |
|
59 | + 'Last-Modified: '.self::get_date(), |
|
60 | 60 | 'X-Powered-By: jacobemerick.com'); |
61 | 61 | self::send($array); |
62 | 62 | } |
63 | 63 | |
64 | 64 | private static function send($array, $gzip = true) |
65 | 65 | { |
66 | - if($gzip) |
|
66 | + if ($gzip) |
|
67 | 67 | self::start_gzipping(); |
68 | 68 | |
69 | - foreach($array as $row) |
|
69 | + foreach ($array as $row) |
|
70 | 70 | { |
71 | 71 | header($row, TRUE); |
72 | 72 | } |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | |
75 | 75 | private static function get_date($timestamp = false) |
76 | 76 | { |
77 | - if($timestamp == 0) |
|
77 | + if ($timestamp == 0) |
|
78 | 78 | $timestamp = time(); |
79 | 79 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
80 | 80 | } |
81 | 81 | |
82 | 82 | private static function start_gzipping() |
83 | 83 | { |
84 | - if(!ob_start('ob_gzhandler')) |
|
84 | + if (!ob_start('ob_gzhandler')) |
|
85 | 85 | ob_start(); |
86 | 86 | } |
87 | 87 |
@@ -3,86 +3,86 @@ |
||
3 | 3 | final class Header |
4 | 4 | { |
5 | 5 | |
6 | - public static function sendJSON() |
|
7 | - { |
|
8 | - $array = array( |
|
9 | - 'HTTP/1.1 200 OK', |
|
10 | - 'Cache-Control: no-cache', |
|
11 | - 'Content-Language: en', |
|
12 | - 'Content-Type: application/json', |
|
13 | - 'Expires: ' . self::get_date(time() - 1), |
|
14 | - 'Last-Modified: ' . self::get_date(), |
|
15 | - 'X-Powered-By: jacobemerick.com'); |
|
16 | - self::send($array); |
|
17 | - } |
|
6 | + public static function sendJSON() |
|
7 | + { |
|
8 | + $array = array( |
|
9 | + 'HTTP/1.1 200 OK', |
|
10 | + 'Cache-Control: no-cache', |
|
11 | + 'Content-Language: en', |
|
12 | + 'Content-Type: application/json', |
|
13 | + 'Expires: ' . self::get_date(time() - 1), |
|
14 | + 'Last-Modified: ' . self::get_date(), |
|
15 | + 'X-Powered-By: jacobemerick.com'); |
|
16 | + self::send($array); |
|
17 | + } |
|
18 | 18 | |
19 | - public static function sendHTML() |
|
20 | - { |
|
21 | - $array = array( |
|
22 | - 'HTTP/1.1 200 OK', |
|
23 | - 'Cache-Control: no-cache', |
|
24 | - 'Content-Language: en', |
|
25 | - 'Content-Type: text/html', |
|
26 | - 'Expires: ' . self::get_date(time() - 1), |
|
27 | - 'Last-Modified: ' . self::get_date(), |
|
28 | - 'X-Powered-By: jacobemerick.com'); |
|
29 | - self::send($array); |
|
30 | - } |
|
19 | + public static function sendHTML() |
|
20 | + { |
|
21 | + $array = array( |
|
22 | + 'HTTP/1.1 200 OK', |
|
23 | + 'Cache-Control: no-cache', |
|
24 | + 'Content-Language: en', |
|
25 | + 'Content-Type: text/html', |
|
26 | + 'Expires: ' . self::get_date(time() - 1), |
|
27 | + 'Last-Modified: ' . self::get_date(), |
|
28 | + 'X-Powered-By: jacobemerick.com'); |
|
29 | + self::send($array); |
|
30 | + } |
|
31 | 31 | |
32 | - public static function redirect($location, $method = 301) |
|
33 | - { |
|
34 | - header("Location: {$location}", TRUE, $method); |
|
35 | - exit(); |
|
36 | - } |
|
32 | + public static function redirect($location, $method = 301) |
|
33 | + { |
|
34 | + header("Location: {$location}", TRUE, $method); |
|
35 | + exit(); |
|
36 | + } |
|
37 | 37 | |
38 | - public static function send404() |
|
39 | - { |
|
40 | - $array = array( |
|
41 | - 'HTTP/1.1 404 Not Found', |
|
42 | - 'Cache-Control: no-cache', |
|
43 | - 'Content-Language: en', |
|
44 | - 'Content-Type: text/html', |
|
45 | - 'Expires: ' . self::get_date(time() - 1), |
|
46 | - 'Last-Modified: ' . self::get_date(), |
|
47 | - 'X-Powered-By: jacobemerick.com'); |
|
48 | - self::send($array); |
|
49 | - } |
|
38 | + public static function send404() |
|
39 | + { |
|
40 | + $array = array( |
|
41 | + 'HTTP/1.1 404 Not Found', |
|
42 | + 'Cache-Control: no-cache', |
|
43 | + 'Content-Language: en', |
|
44 | + 'Content-Type: text/html', |
|
45 | + 'Expires: ' . self::get_date(time() - 1), |
|
46 | + 'Last-Modified: ' . self::get_date(), |
|
47 | + 'X-Powered-By: jacobemerick.com'); |
|
48 | + self::send($array); |
|
49 | + } |
|
50 | 50 | |
51 | - public static function send503() |
|
52 | - { |
|
53 | - $array = array( |
|
54 | - 'HTTP/1.1 503 Service Unavailable', |
|
55 | - 'Cache-Control: no-cache', |
|
56 | - 'Content-Language: en', |
|
57 | - 'Content-Type: text/html', |
|
58 | - 'Expires: ' . self::get_date(time() - 1), |
|
59 | - 'Last-Modified: ' . self::get_date(), |
|
60 | - 'X-Powered-By: jacobemerick.com'); |
|
61 | - self::send($array); |
|
62 | - } |
|
51 | + public static function send503() |
|
52 | + { |
|
53 | + $array = array( |
|
54 | + 'HTTP/1.1 503 Service Unavailable', |
|
55 | + 'Cache-Control: no-cache', |
|
56 | + 'Content-Language: en', |
|
57 | + 'Content-Type: text/html', |
|
58 | + 'Expires: ' . self::get_date(time() - 1), |
|
59 | + 'Last-Modified: ' . self::get_date(), |
|
60 | + 'X-Powered-By: jacobemerick.com'); |
|
61 | + self::send($array); |
|
62 | + } |
|
63 | 63 | |
64 | - private static function send($array, $gzip = true) |
|
65 | - { |
|
66 | - if($gzip) |
|
67 | - self::start_gzipping(); |
|
64 | + private static function send($array, $gzip = true) |
|
65 | + { |
|
66 | + if($gzip) |
|
67 | + self::start_gzipping(); |
|
68 | 68 | |
69 | - foreach($array as $row) |
|
70 | - { |
|
71 | - header($row, TRUE); |
|
72 | - } |
|
73 | - } |
|
69 | + foreach($array as $row) |
|
70 | + { |
|
71 | + header($row, TRUE); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - private static function get_date($timestamp = false) |
|
76 | - { |
|
77 | - if($timestamp == 0) |
|
78 | - $timestamp = time(); |
|
79 | - return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
|
80 | - } |
|
75 | + private static function get_date($timestamp = false) |
|
76 | + { |
|
77 | + if($timestamp == 0) |
|
78 | + $timestamp = time(); |
|
79 | + return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
|
80 | + } |
|
81 | 81 | |
82 | - private static function start_gzipping() |
|
83 | - { |
|
84 | - if(!ob_start('ob_gzhandler')) |
|
82 | + private static function start_gzipping() |
|
83 | + { |
|
84 | + if(!ob_start('ob_gzhandler')) |
|
85 | 85 | ob_start(); |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | 88 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <? |
2 | 2 | |
3 | -final class Header |
|
4 | -{ |
|
3 | +final class Header |
|
4 | +{ |
|
5 | 5 | |
6 | - public static function sendJSON() |
|
7 | - { |
|
6 | + public static function sendJSON() |
|
7 | + { |
|
8 | 8 | $array = array( |
9 | 9 | 'HTTP/1.1 200 OK', |
10 | 10 | 'Cache-Control: no-cache', |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | self::send($array); |
17 | 17 | } |
18 | 18 | |
19 | - public static function sendHTML() |
|
20 | - { |
|
19 | + public static function sendHTML() |
|
20 | + { |
|
21 | 21 | $array = array( |
22 | 22 | 'HTTP/1.1 200 OK', |
23 | 23 | 'Cache-Control: no-cache', |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | self::send($array); |
30 | 30 | } |
31 | 31 | |
32 | - public static function redirect($location, $method = 301) |
|
33 | - { |
|
32 | + public static function redirect($location, $method = 301) |
|
33 | + { |
|
34 | 34 | header("Location: {$location}", TRUE, $method); |
35 | 35 | exit(); |
36 | 36 | } |
37 | 37 | |
38 | - public static function send404() |
|
39 | - { |
|
38 | + public static function send404() |
|
39 | + { |
|
40 | 40 | $array = array( |
41 | 41 | 'HTTP/1.1 404 Not Found', |
42 | 42 | 'Cache-Control: no-cache', |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | self::send($array); |
49 | 49 | } |
50 | 50 | |
51 | - public static function send503() |
|
52 | - { |
|
51 | + public static function send503() |
|
52 | + { |
|
53 | 53 | $array = array( |
54 | 54 | 'HTTP/1.1 503 Service Unavailable', |
55 | 55 | 'Cache-Control: no-cache', |
@@ -61,10 +61,11 @@ discard block |
||
61 | 61 | self::send($array); |
62 | 62 | } |
63 | 63 | |
64 | - private static function send($array, $gzip = true) |
|
65 | - { |
|
66 | - if($gzip) |
|
67 | - self::start_gzipping(); |
|
64 | + private static function send($array, $gzip = true) |
|
65 | + { |
|
66 | + if($gzip) { |
|
67 | + self::start_gzipping(); |
|
68 | + } |
|
68 | 69 | |
69 | 70 | foreach($array as $row) |
70 | 71 | { |
@@ -72,17 +73,19 @@ discard block |
||
72 | 73 | } |
73 | 74 | } |
74 | 75 | |
75 | - private static function get_date($timestamp = false) |
|
76 | - { |
|
77 | - if($timestamp == 0) |
|
78 | - $timestamp = time(); |
|
76 | + private static function get_date($timestamp = false) |
|
77 | + { |
|
78 | + if($timestamp == 0) { |
|
79 | + $timestamp = time(); |
|
80 | + } |
|
79 | 81 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
80 | 82 | } |
81 | 83 | |
82 | - private static function start_gzipping() |
|
83 | - { |
|
84 | - if(!ob_start('ob_gzhandler')) |
|
85 | - ob_start(); |
|
84 | + private static function start_gzipping() |
|
85 | + { |
|
86 | + if(!ob_start('ob_gzhandler')) { |
|
87 | + ob_start(); |
|
88 | + } |
|
86 | 89 | } |
87 | 90 | |
88 | 91 | } |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface LogRepositoryInterface |
6 | 6 | { |
7 | - public function getActiveLogs($limit = null, $offset= 0); |
|
7 | + public function getActiveLogs($limit = null, $offset = 0); |
|
8 | 8 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Jacobemerick\Web\Domain\Waterfall\Log; |
4 | 4 | |
5 | -interface LogRepositoryInterface |
|
6 | -{ |
|
5 | +interface LogRepositoryInterface |
|
6 | +{ |
|
7 | 7 | public function getActiveLogs($limit = null, $offset= 0); |
8 | 8 | } |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface WaterfallRepositoryInterface |
6 | 6 | { |
7 | - public function getWaterfalls($limit = null, $offset= 0); |
|
7 | + public function getWaterfalls($limit = null, $offset = 0); |
|
8 | 8 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Jacobemerick\Web\Domain\Waterfall\Waterfall; |
4 | 4 | |
5 | -interface WaterfallRepositoryInterface |
|
6 | -{ |
|
5 | +interface WaterfallRepositoryInterface |
|
6 | +{ |
|
7 | 7 | public function getWaterfalls($limit = null, $offset= 0); |
8 | 8 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | protected $connections; |
12 | 12 | |
13 | 13 | /** |
14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
14 | + * @param ConnectionLocator $connections |
|
15 | 15 | */ |
16 | 16 | public function __construct(ConnectionLocator $connections) |
17 | 17 | { |
@@ -41,6 +41,9 @@ discard block |
||
41 | 41 | ->fetchOne($query, $bindings); |
42 | 42 | } |
43 | 43 | |
44 | + /** |
|
45 | + * @param integer $limit |
|
46 | + */ |
|
44 | 47 | public function getActivePosts($limit = null, $offset = 0) |
45 | 48 | { |
46 | 49 | $query = " |
@@ -79,6 +82,9 @@ discard block |
||
79 | 82 | ->fetchValue($query, $bindings); |
80 | 83 | } |
81 | 84 | |
85 | + /** |
|
86 | + * @param integer $limit |
|
87 | + */ |
|
82 | 88 | public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
83 | 89 | { |
84 | 90 | $query = " |
@@ -122,6 +128,9 @@ discard block |
||
122 | 128 | ->fetchValue($query, $bindings); |
123 | 129 | } |
124 | 130 | |
131 | + /** |
|
132 | + * @param integer $limit |
|
133 | + */ |
|
125 | 134 | public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
126 | 135 | { |
127 | 136 | $query = " |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | use Aura\Sql\ConnectionLocator; |
6 | 6 | |
7 | -class MysqlPostRepository implements PostRepositoryInterface |
|
8 | -{ |
|
7 | +class MysqlPostRepository implements PostRepositoryInterface |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
11 | 11 | protected $connections; |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
15 | 15 | */ |
16 | - public function __construct(ConnectionLocator $connections) |
|
17 | - { |
|
16 | + public function __construct(ConnectionLocator $connections) |
|
17 | + { |
|
18 | 18 | $this->connections = $connections; |
19 | 19 | } |
20 | 20 | |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array|false |
25 | 25 | */ |
26 | - public function findPostByPath($path) |
|
27 | - { |
|
26 | + public function findPostByPath($path) |
|
27 | + { |
|
28 | 28 | $query = " |
29 | 29 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
30 | 30 | FROM `jpemeric_blog`.`post` |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | ->fetchOne($query, $bindings); |
42 | 42 | } |
43 | 43 | |
44 | - public function getActivePosts($limit = null, $offset = 0) |
|
45 | - { |
|
44 | + public function getActivePosts($limit = null, $offset = 0) |
|
45 | + { |
|
46 | 46 | $query = " |
47 | 47 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
48 | 48 | FROM `jpemeric_blog`.`post` |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | ->fetchAll($query, $bindings); |
64 | 64 | } |
65 | 65 | |
66 | - public function getActivePostsCount() |
|
67 | - { |
|
66 | + public function getActivePostsCount() |
|
67 | + { |
|
68 | 68 | $query = " |
69 | 69 | SELECT COUNT(1) AS `count` |
70 | 70 | FROM `jpemeric_blog`.`post` |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | ->fetchValue($query, $bindings); |
80 | 80 | } |
81 | 81 | |
82 | - public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
|
83 | - { |
|
82 | + public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
|
83 | + { |
|
84 | 84 | $query = " |
85 | 85 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
86 | 86 | FROM `jpemeric_blog`.`post` |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | ->fetchAll($query, $bindings); |
105 | 105 | } |
106 | 106 | |
107 | - public function getActivePostsCountByTag($tag) |
|
108 | - { |
|
107 | + public function getActivePostsCountByTag($tag) |
|
108 | + { |
|
109 | 109 | $query = " |
110 | 110 | SELECT COUNT(1) AS `count` |
111 | 111 | FROM `jpemeric_blog`.`post` |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | ->fetchValue($query, $bindings); |
124 | 124 | } |
125 | 125 | |
126 | - public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
|
127 | - { |
|
126 | + public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
|
127 | + { |
|
128 | 128 | $query = " |
129 | 129 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
130 | 130 | FROM `jpemeric_blog`.`post` |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | ->fetchAll($query, $bindings); |
147 | 147 | } |
148 | 148 | |
149 | - public function getActivePostsCountByCategory($category) |
|
150 | - { |
|
149 | + public function getActivePostsCountByCategory($category) |
|
150 | + { |
|
151 | 151 | $query = " |
152 | 152 | SELECT COUNT(1) AS `count` |
153 | 153 | FROM `jpemeric_blog`.`post` |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | ->fetchValue($query, $bindings); |
164 | 164 | } |
165 | 165 | |
166 | - public function getActivePostsByRelatedTags($post, $limit = 4) |
|
167 | - { |
|
166 | + public function getActivePostsByRelatedTags($post, $limit = 4) |
|
167 | + { |
|
168 | 168 | $query = " |
169 | 169 | SELECT `id`, `title`, `path`, `date`, `body`, `category`, COUNT(1) AS `count` |
170 | 170 | FROM `jpemeric_blog`.`post` |
@@ -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)); |
@@ -3,71 +3,71 @@ |
||
3 | 3 | final class Search |
4 | 4 | { |
5 | 5 | |
6 | - private $query; |
|
7 | - private $result; |
|
8 | - private $weight; |
|
6 | + private $query; |
|
7 | + private $result; |
|
8 | + private $weight; |
|
9 | 9 | |
10 | - function __construct() |
|
11 | - { |
|
12 | - return $this; |
|
13 | - } |
|
10 | + function __construct() |
|
11 | + { |
|
12 | + return $this; |
|
13 | + } |
|
14 | 14 | |
15 | - public function setQuery($query) |
|
16 | - { |
|
17 | - $this->query = $query; |
|
18 | - return $this; |
|
19 | - } |
|
15 | + public function setQuery($query) |
|
16 | + { |
|
17 | + $this->query = $query; |
|
18 | + return $this; |
|
19 | + } |
|
20 | 20 | |
21 | - public function setResult($array) |
|
22 | - { |
|
23 | - $this->result = $array; |
|
24 | - return $this; |
|
25 | - } |
|
21 | + public function setResult($array) |
|
22 | + { |
|
23 | + $this->result = $array; |
|
24 | + return $this; |
|
25 | + } |
|
26 | 26 | |
27 | - public function setWeight($weight) |
|
28 | - { |
|
29 | - $this->weight = $weight; |
|
30 | - return $this; |
|
31 | - } |
|
27 | + public function setWeight($weight) |
|
28 | + { |
|
29 | + $this->weight = $weight; |
|
30 | + return $this; |
|
31 | + } |
|
32 | 32 | |
33 | - public static function instance() |
|
34 | - { |
|
35 | - $reflection = new ReflectionClass('Search'); |
|
36 | - return $reflection->newInstance(); |
|
37 | - } |
|
33 | + public static function instance() |
|
34 | + { |
|
35 | + $reflection = new ReflectionClass('Search'); |
|
36 | + return $reflection->newInstance(); |
|
37 | + } |
|
38 | 38 | |
39 | - public function perform() |
|
40 | - { |
|
41 | - $weighted_array = array(); |
|
42 | - foreach($this->result as $row) |
|
43 | - { |
|
44 | - $weight = $this->get_search_weight($row); |
|
45 | - if($weight > 0) |
|
46 | - $weighted_array[$row['id']] = $weight; |
|
47 | - } |
|
48 | - arsort($weighted_array); |
|
39 | + public function perform() |
|
40 | + { |
|
41 | + $weighted_array = array(); |
|
42 | + foreach($this->result as $row) |
|
43 | + { |
|
44 | + $weight = $this->get_search_weight($row); |
|
45 | + if($weight > 0) |
|
46 | + $weighted_array[$row['id']] = $weight; |
|
47 | + } |
|
48 | + arsort($weighted_array); |
|
49 | 49 | |
50 | - $final_array = array(); |
|
51 | - foreach($weighted_array as $id => $weight) |
|
52 | - { |
|
53 | - foreach($this->result as $row) |
|
54 | - { |
|
55 | - if($row['id'] == $id) |
|
56 | - $final_array[] = $row; |
|
57 | - } |
|
58 | - } |
|
59 | - return $final_array; |
|
60 | - } |
|
50 | + $final_array = array(); |
|
51 | + foreach($weighted_array as $id => $weight) |
|
52 | + { |
|
53 | + foreach($this->result as $row) |
|
54 | + { |
|
55 | + if($row['id'] == $id) |
|
56 | + $final_array[] = $row; |
|
57 | + } |
|
58 | + } |
|
59 | + return $final_array; |
|
60 | + } |
|
61 | 61 | |
62 | - private function get_search_weight($row) |
|
63 | - { |
|
64 | - $weight = 0; |
|
65 | - foreach($this->weight as $weight_array) |
|
66 | - { |
|
67 | - $text = $row[$weight_array['field']]; |
|
68 | - $weight += $weight_array['weight'] * substr_count(strtolower($text), strtolower($this->query)); |
|
69 | - } |
|
70 | - return $weight; |
|
71 | - } |
|
62 | + private function get_search_weight($row) |
|
63 | + { |
|
64 | + $weight = 0; |
|
65 | + foreach($this->weight as $weight_array) |
|
66 | + { |
|
67 | + $text = $row[$weight_array['field']]; |
|
68 | + $weight += $weight_array['weight'] * substr_count(strtolower($text), strtolower($this->query)); |
|
69 | + } |
|
70 | + return $weight; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | } |
@@ -1,49 +1,50 @@ discard block |
||
1 | 1 | <? |
2 | 2 | |
3 | -final class Search |
|
4 | -{ |
|
3 | +final class Search |
|
4 | +{ |
|
5 | 5 | |
6 | 6 | private $query; |
7 | 7 | private $result; |
8 | 8 | private $weight; |
9 | 9 | |
10 | - function __construct() |
|
11 | - { |
|
10 | + function __construct() |
|
11 | + { |
|
12 | 12 | return $this; |
13 | 13 | } |
14 | 14 | |
15 | - public function setQuery($query) |
|
16 | - { |
|
15 | + public function setQuery($query) |
|
16 | + { |
|
17 | 17 | $this->query = $query; |
18 | 18 | return $this; |
19 | 19 | } |
20 | 20 | |
21 | - public function setResult($array) |
|
22 | - { |
|
21 | + public function setResult($array) |
|
22 | + { |
|
23 | 23 | $this->result = $array; |
24 | 24 | return $this; |
25 | 25 | } |
26 | 26 | |
27 | - public function setWeight($weight) |
|
28 | - { |
|
27 | + public function setWeight($weight) |
|
28 | + { |
|
29 | 29 | $this->weight = $weight; |
30 | 30 | return $this; |
31 | 31 | } |
32 | 32 | |
33 | - public static function instance() |
|
34 | - { |
|
33 | + public static function instance() |
|
34 | + { |
|
35 | 35 | $reflection = new ReflectionClass('Search'); |
36 | 36 | return $reflection->newInstance(); |
37 | 37 | } |
38 | 38 | |
39 | - public function perform() |
|
40 | - { |
|
39 | + public function perform() |
|
40 | + { |
|
41 | 41 | $weighted_array = array(); |
42 | 42 | foreach($this->result as $row) |
43 | 43 | { |
44 | 44 | $weight = $this->get_search_weight($row); |
45 | - if($weight > 0) |
|
46 | - $weighted_array[$row['id']] = $weight; |
|
45 | + if($weight > 0) { |
|
46 | + $weighted_array[$row['id']] = $weight; |
|
47 | + } |
|
47 | 48 | } |
48 | 49 | arsort($weighted_array); |
49 | 50 | |
@@ -52,15 +53,16 @@ discard block |
||
52 | 53 | { |
53 | 54 | foreach($this->result as $row) |
54 | 55 | { |
55 | - if($row['id'] == $id) |
|
56 | - $final_array[] = $row; |
|
56 | + if($row['id'] == $id) { |
|
57 | + $final_array[] = $row; |
|
58 | + } |
|
57 | 59 | } |
58 | 60 | } |
59 | 61 | return $final_array; |
60 | 62 | } |
61 | 63 | |
62 | - private function get_search_weight($row) |
|
63 | - { |
|
64 | + private function get_search_weight($row) |
|
65 | + { |
|
64 | 66 | $weight = 0; |
65 | 67 | foreach($this->weight as $weight_array) |
66 | 68 | { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | ], |
27 | 27 | ]; |
28 | 28 | |
29 | - return array_map(function ($row) { |
|
29 | + return array_map(function($row) { |
|
30 | 30 | return (object) $row; |
31 | 31 | }, $paths); |
32 | 32 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | ], |
49 | 49 | ]; |
50 | 50 | |
51 | - return array_map(function ($row) { |
|
51 | + return array_map(function($row) { |
|
52 | 52 | return (object) $row; |
53 | 53 | }, $paths); |
54 | 54 | } |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('router', 'Router'); |
4 | 4 | |
5 | -class PortfolioRouter extends Router |
|
6 | -{ |
|
5 | +class PortfolioRouter extends Router |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
8 | + protected function get_redirect_array() |
|
9 | + { |
|
10 | 10 | $paths = [ |
11 | 11 | [ |
12 | 12 | 'pattern' => '@/index.(html|htm|php)$@', |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | }, $paths); |
32 | 32 | } |
33 | 33 | |
34 | - protected function get_direct_array() |
|
35 | - { |
|
34 | + protected function get_direct_array() |
|
35 | + { |
|
36 | 36 | $paths = [ |
37 | 37 | [ |
38 | 38 | 'match' => '/', |
@@ -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'; |
@@ -65,42 +65,42 @@ discard block |
||
65 | 65 | |
66 | 66 | final protected function check_for_redirect($redirect_uri) |
67 | 67 | { |
68 | - foreach($this->get_redirect_array() as $check) |
|
68 | + foreach ($this->get_redirect_array() as $check) |
|
69 | 69 | { |
70 | 70 | $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
74 | 74 | |
75 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
75 | + if ($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
76 | 76 | $redirect_uri .= '/'; |
77 | 77 | |
78 | 78 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
79 | 79 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
80 | - $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
|
80 | + $redirect_uri = $protocol.'://'.(!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 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
89 | - $controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri); |
|
89 | + $controller_check = preg_replace('@^'.$protocol.'://([a-z\.]+)@', '', $redirect_uri); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $controller = $this->get_controller($controller_check); |
93 | - if($controller == '/Error404Controller') |
|
93 | + if ($controller == '/Error404Controller') |
|
94 | 94 | { |
95 | 95 | Loader::loadNew('controller', '/Error404Controller') |
96 | 96 | ->activate(); |
97 | 97 | exit; |
98 | 98 | } |
99 | 99 | |
100 | - if(substr($redirect_uri, 0, 4) != 'http') |
|
100 | + if (substr($redirect_uri, 0, 4) != 'http') |
|
101 | 101 | { |
102 | 102 | $redirect_uri = substr($redirect_uri, 1); |
103 | - $redirect_uri = URLDecode::getBase() . $redirect_uri; |
|
103 | + $redirect_uri = URLDecode::getBase().$redirect_uri; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | Loader::loadNew('controller', '/Error301Controller', (array) $redirect_uri) |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | |
115 | 115 | final private function get_controller($uri) |
116 | 116 | { |
117 | - foreach($this->get_direct_array() as $check) |
|
117 | + foreach ($this->get_direct_array() as $check) |
|
118 | 118 | { |
119 | - if($uri == $check->match) |
|
119 | + if ($uri == $check->match) |
|
120 | 120 | return "{$this->get_primary_folder()}/{$check->controller}"; |
121 | 121 | |
122 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
122 | + if (preg_match("@^{$check->match}$@", $uri)) |
|
123 | 123 | return "{$this->get_primary_folder()}/{$check->controller}"; |
124 | 124 | } |
125 | 125 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | final private function get_primary_folder() |
130 | 130 | { |
131 | - if(Request::isAjax()) |
|
131 | + if (Request::isAjax()) |
|
132 | 132 | return 'ajax'; |
133 | 133 | |
134 | 134 | return URLDecode::getSite(); |
@@ -1,144 +1,144 @@ |
||
1 | 1 | <? |
2 | 2 | |
3 | 3 | Loader::load('utility', array( |
4 | - 'Request', |
|
5 | - 'URLDecode')); |
|
4 | + 'Request', |
|
5 | + 'URLDecode')); |
|
6 | 6 | |
7 | 7 | abstract class Router |
8 | 8 | { |
9 | 9 | |
10 | - public function __construct() {} |
|
10 | + public function __construct() {} |
|
11 | 11 | |
12 | - public static function instance() |
|
13 | - { |
|
14 | - $router_name = self::get_router_name(); |
|
15 | - $router = Loader::loadNew('router', $router_name); |
|
16 | - $router->route(); |
|
17 | - } |
|
12 | + public static function instance() |
|
13 | + { |
|
14 | + $router_name = self::get_router_name(); |
|
15 | + $router = Loader::loadNew('router', $router_name); |
|
16 | + $router->route(); |
|
17 | + } |
|
18 | 18 | |
19 | - private static function get_router_name() |
|
20 | - { |
|
21 | - if(Request::isAJAX()) |
|
22 | - return 'AJAXRouter'; |
|
19 | + private static function get_router_name() |
|
20 | + { |
|
21 | + if(Request::isAJAX()) |
|
22 | + return 'AJAXRouter'; |
|
23 | 23 | |
24 | - switch(URLDecode::getSite()) |
|
25 | - { |
|
26 | - case 'ajax' : |
|
27 | - return 'AjaxRouter'; |
|
28 | - break; |
|
29 | - case 'blog' : |
|
30 | - return 'BlogRouter'; |
|
31 | - break; |
|
32 | - case 'home' : |
|
33 | - return 'HomeRouter'; |
|
34 | - break; |
|
35 | - case 'lifestream' : |
|
36 | - return 'LifestreamRouter'; |
|
37 | - break; |
|
38 | - case 'portfolio' : |
|
39 | - return 'PortfolioRouter'; |
|
40 | - break; |
|
41 | - case 'site' : |
|
42 | - return 'SiteRouter'; |
|
43 | - break; |
|
44 | - case 'waterfalls' : |
|
45 | - return 'WaterfallRouter'; |
|
46 | - break; |
|
47 | - } |
|
24 | + switch(URLDecode::getSite()) |
|
25 | + { |
|
26 | + case 'ajax' : |
|
27 | + return 'AjaxRouter'; |
|
28 | + break; |
|
29 | + case 'blog' : |
|
30 | + return 'BlogRouter'; |
|
31 | + break; |
|
32 | + case 'home' : |
|
33 | + return 'HomeRouter'; |
|
34 | + break; |
|
35 | + case 'lifestream' : |
|
36 | + return 'LifestreamRouter'; |
|
37 | + break; |
|
38 | + case 'portfolio' : |
|
39 | + return 'PortfolioRouter'; |
|
40 | + break; |
|
41 | + case 'site' : |
|
42 | + return 'SiteRouter'; |
|
43 | + break; |
|
44 | + case 'waterfalls' : |
|
45 | + return 'WaterfallRouter'; |
|
46 | + break; |
|
47 | + } |
|
48 | 48 | |
49 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
50 | - } |
|
49 | + Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
50 | + } |
|
51 | 51 | |
52 | - protected function route() |
|
53 | - { |
|
54 | - $uri = URLDecode::getURI(); |
|
52 | + protected function route() |
|
53 | + { |
|
54 | + $uri = URLDecode::getURI(); |
|
55 | 55 | |
56 | - $this->check_for_redirect($uri); |
|
56 | + $this->check_for_redirect($uri); |
|
57 | 57 | |
58 | - $controller = $this->get_controller($uri); |
|
59 | - Loader::loadNew('controller', $controller) |
|
60 | - ->activate(); |
|
61 | - } |
|
58 | + $controller = $this->get_controller($uri); |
|
59 | + Loader::loadNew('controller', $controller) |
|
60 | + ->activate(); |
|
61 | + } |
|
62 | 62 | |
63 | - abstract protected function get_redirect_array(); |
|
64 | - abstract protected function get_direct_array(); |
|
63 | + abstract protected function get_redirect_array(); |
|
64 | + abstract protected function get_direct_array(); |
|
65 | 65 | |
66 | - final protected function check_for_redirect($redirect_uri) |
|
67 | - { |
|
68 | - foreach($this->get_redirect_array() as $check) |
|
69 | - { |
|
70 | - $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
|
71 | - } |
|
66 | + final protected function check_for_redirect($redirect_uri) |
|
67 | + { |
|
68 | + foreach($this->get_redirect_array() as $check) |
|
69 | + { |
|
70 | + $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
|
71 | + } |
|
72 | 72 | |
73 | - $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
|
73 | + $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
|
74 | 74 | |
75 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
76 | - $redirect_uri .= '/'; |
|
75 | + if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
76 | + $redirect_uri .= '/'; |
|
77 | 77 | |
78 | 78 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
79 | 79 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
80 | 80 | $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
81 | 81 | } |
82 | 82 | |
83 | - if($redirect_uri == URLDecode::getURI()) |
|
84 | - return; |
|
83 | + if($redirect_uri == URLDecode::getURI()) |
|
84 | + return; |
|
85 | 85 | |
86 | - $controller_check = $redirect_uri; |
|
87 | - if(substr($redirect_uri, 0, 4) == 'http') { |
|
88 | - $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
|
89 | - $controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri); |
|
86 | + $controller_check = $redirect_uri; |
|
87 | + if(substr($redirect_uri, 0, 4) == 'http') { |
|
88 | + $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
|
89 | + $controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri); |
|
90 | 90 | } |
91 | 91 | |
92 | - $controller = $this->get_controller($controller_check); |
|
93 | - if($controller == '/Error404Controller') |
|
94 | - { |
|
95 | - Loader::loadNew('controller', '/Error404Controller') |
|
96 | - ->activate(); |
|
97 | - exit; |
|
98 | - } |
|
92 | + $controller = $this->get_controller($controller_check); |
|
93 | + if($controller == '/Error404Controller') |
|
94 | + { |
|
95 | + Loader::loadNew('controller', '/Error404Controller') |
|
96 | + ->activate(); |
|
97 | + exit; |
|
98 | + } |
|
99 | 99 | |
100 | - if(substr($redirect_uri, 0, 4) != 'http') |
|
101 | - { |
|
102 | - $redirect_uri = substr($redirect_uri, 1); |
|
103 | - $redirect_uri = URLDecode::getBase() . $redirect_uri; |
|
104 | - } |
|
100 | + if(substr($redirect_uri, 0, 4) != 'http') |
|
101 | + { |
|
102 | + $redirect_uri = substr($redirect_uri, 1); |
|
103 | + $redirect_uri = URLDecode::getBase() . $redirect_uri; |
|
104 | + } |
|
105 | 105 | |
106 | - Loader::loadNew('controller', '/Error301Controller', (array) $redirect_uri) |
|
107 | - ->activate(); |
|
108 | - } |
|
106 | + Loader::loadNew('controller', '/Error301Controller', (array) $redirect_uri) |
|
107 | + ->activate(); |
|
108 | + } |
|
109 | 109 | |
110 | - protected function check_for_special_redirect($uri) |
|
111 | - { |
|
112 | - return $uri; |
|
113 | - } |
|
110 | + protected function check_for_special_redirect($uri) |
|
111 | + { |
|
112 | + return $uri; |
|
113 | + } |
|
114 | 114 | |
115 | - final private function get_controller($uri) |
|
116 | - { |
|
117 | - foreach($this->get_direct_array() as $check) |
|
118 | - { |
|
119 | - if($uri == $check->match) |
|
120 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
115 | + final private function get_controller($uri) |
|
116 | + { |
|
117 | + foreach($this->get_direct_array() as $check) |
|
118 | + { |
|
119 | + if($uri == $check->match) |
|
120 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
121 | 121 | |
122 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
123 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
124 | - } |
|
122 | + if(preg_match("@^{$check->match}$@", $uri)) |
|
123 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
124 | + } |
|
125 | 125 | |
126 | - return '/Error404Controller'; |
|
127 | - } |
|
126 | + return '/Error404Controller'; |
|
127 | + } |
|
128 | 128 | |
129 | - final private function get_primary_folder() |
|
130 | - { |
|
131 | - if(Request::isAjax()) |
|
132 | - return 'ajax'; |
|
129 | + final private function get_primary_folder() |
|
130 | + { |
|
131 | + if(Request::isAjax()) |
|
132 | + return 'ajax'; |
|
133 | 133 | |
134 | - return URLDecode::getSite(); |
|
135 | - } |
|
134 | + return URLDecode::getSite(); |
|
135 | + } |
|
136 | 136 | |
137 | - private function requires_trailing_slash() |
|
138 | - { |
|
139 | - return ( |
|
140 | - URLDecode::getExtension() != 'json' && |
|
137 | + private function requires_trailing_slash() |
|
138 | + { |
|
139 | + return ( |
|
140 | + URLDecode::getExtension() != 'json' && |
|
141 | 141 | strstr(URLDecode::getURI(), '#') === false); |
142 | - } |
|
142 | + } |
|
143 | 143 | |
144 | 144 | } |
@@ -4,22 +4,25 @@ discard block |
||
4 | 4 | 'Request', |
5 | 5 | 'URLDecode')); |
6 | 6 | |
7 | -abstract class Router |
|
8 | -{ |
|
7 | +abstract class Router |
|
8 | +{ |
|
9 | 9 | |
10 | - public function __construct() {} |
|
10 | + public function __construct() |
|
11 | + { |
|
12 | +} |
|
11 | 13 | |
12 | - public static function instance() |
|
13 | - { |
|
14 | + public static function instance() |
|
15 | + { |
|
14 | 16 | $router_name = self::get_router_name(); |
15 | 17 | $router = Loader::loadNew('router', $router_name); |
16 | 18 | $router->route(); |
17 | 19 | } |
18 | 20 | |
19 | - private static function get_router_name() |
|
20 | - { |
|
21 | - if(Request::isAJAX()) |
|
22 | - return 'AJAXRouter'; |
|
21 | + private static function get_router_name() |
|
22 | + { |
|
23 | + if(Request::isAJAX()) { |
|
24 | + return 'AJAXRouter'; |
|
25 | + } |
|
23 | 26 | |
24 | 27 | switch(URLDecode::getSite()) |
25 | 28 | { |
@@ -49,8 +52,8 @@ discard block |
||
49 | 52 | Loader::loadNew('controller', '/Error404Controller')->activate(); |
50 | 53 | } |
51 | 54 | |
52 | - protected function route() |
|
53 | - { |
|
55 | + protected function route() |
|
56 | + { |
|
54 | 57 | $uri = URLDecode::getURI(); |
55 | 58 | |
56 | 59 | $this->check_for_redirect($uri); |
@@ -63,8 +66,8 @@ discard block |
||
63 | 66 | abstract protected function get_redirect_array(); |
64 | 67 | abstract protected function get_direct_array(); |
65 | 68 | |
66 | - final protected function check_for_redirect($redirect_uri) |
|
67 | - { |
|
69 | + final protected function check_for_redirect($redirect_uri) |
|
70 | + { |
|
68 | 71 | foreach($this->get_redirect_array() as $check) |
69 | 72 | { |
70 | 73 | $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
@@ -72,16 +75,18 @@ discard block |
||
72 | 75 | |
73 | 76 | $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
74 | 77 | |
75 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
76 | - $redirect_uri .= '/'; |
|
78 | + if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') { |
|
79 | + $redirect_uri .= '/'; |
|
80 | + } |
|
77 | 81 | |
78 | 82 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
79 | 83 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
80 | 84 | $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
81 | 85 | } |
82 | 86 | |
83 | - if($redirect_uri == URLDecode::getURI()) |
|
84 | - return; |
|
87 | + if($redirect_uri == URLDecode::getURI()) { |
|
88 | + return; |
|
89 | + } |
|
85 | 90 | |
86 | 91 | $controller_check = $redirect_uri; |
87 | 92 | if(substr($redirect_uri, 0, 4) == 'http') { |
@@ -107,35 +112,38 @@ discard block |
||
107 | 112 | ->activate(); |
108 | 113 | } |
109 | 114 | |
110 | - protected function check_for_special_redirect($uri) |
|
111 | - { |
|
115 | + protected function check_for_special_redirect($uri) |
|
116 | + { |
|
112 | 117 | return $uri; |
113 | 118 | } |
114 | 119 | |
115 | - final private function get_controller($uri) |
|
116 | - { |
|
120 | + final private function get_controller($uri) |
|
121 | + { |
|
117 | 122 | foreach($this->get_direct_array() as $check) |
118 | 123 | { |
119 | - if($uri == $check->match) |
|
120 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
124 | + if($uri == $check->match) { |
|
125 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
126 | + } |
|
121 | 127 | |
122 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
123 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
128 | + if(preg_match("@^{$check->match}$@", $uri)) { |
|
129 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
130 | + } |
|
124 | 131 | } |
125 | 132 | |
126 | 133 | return '/Error404Controller'; |
127 | 134 | } |
128 | 135 | |
129 | - final private function get_primary_folder() |
|
130 | - { |
|
131 | - if(Request::isAjax()) |
|
132 | - return 'ajax'; |
|
136 | + final private function get_primary_folder() |
|
137 | + { |
|
138 | + if(Request::isAjax()) { |
|
139 | + return 'ajax'; |
|
140 | + } |
|
133 | 141 | |
134 | 142 | return URLDecode::getSite(); |
135 | 143 | } |
136 | 144 | |
137 | - private function requires_trailing_slash() |
|
138 | - { |
|
145 | + private function requires_trailing_slash() |
|
146 | + { |
|
139 | 147 | return ( |
140 | 148 | URLDecode::getExtension() != 'json' && |
141 | 149 | strstr(URLDecode::getURI(), '#') === false); |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $namespace = 'lifestream'; |
4 | -require_once __DIR__ . '/../../bootstrap.php'; |
|
4 | +require_once __DIR__.'/../../bootstrap.php'; |
|
5 | 5 | |
6 | 6 | // route |
7 | 7 | Loader::loadInstance('router', 'Router'); |