@@ -2,15 +2,14 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('utility', 'Content'); |
4 | 4 | |
5 | -final class FixPhotoContent extends Content |
|
6 | -{ |
|
5 | +final class FixPhotoContent extends Content |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@'; |
9 | 9 | private static $ERROR_CONTENT = '<div class="photo-holder"><p class="photo-caption">Image (%s) could not be found!</p></div>'; |
10 | 10 | private static $PHOTO_CONTENT = '<div class="photo-holder"><img src="%sphoto/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" /><p class="photo-caption">%s</p></div>'; |
11 | 11 | |
12 | - protected function execute($is_absolute = false, $size = 'medium') |
|
13 | - { |
|
12 | + protected function execute($is_absolute = false, $size = 'medium') { |
|
14 | 13 | preg_match_all(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $matches); |
15 | 14 | foreach($matches[1] as $key => $match) |
16 | 15 | { |
@@ -20,14 +19,12 @@ discard block |
||
20 | 19 | return; |
21 | 20 | } |
22 | 21 | |
23 | - private function get_file_path($category, $photo, $size, $extension) |
|
24 | - { |
|
22 | + private function get_file_path($category, $photo, $size, $extension) { |
|
25 | 23 | $path = "{$category}/{$photo}-size-{$size}.{$extension}"; |
26 | 24 | return Loader::getImagePath('photo', $path); |
27 | 25 | } |
28 | 26 | |
29 | - private function get_photo_content($string, $size, $is_absolute) |
|
30 | - { |
|
27 | + private function get_photo_content($string, $size, $is_absolute) { |
|
31 | 28 | list($category, $file_name) = explode('/', $string); |
32 | 29 | list($photo, $extension) = explode('.', $file_name); |
33 | 30 | |
@@ -37,16 +34,18 @@ discard block |
||
37 | 34 | |
38 | 35 | Loader::load('collector', 'image/PhotoCollector'); |
39 | 36 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
40 | - if($photo_result == false) |
|
41 | - return ''; |
|
37 | + if($photo_result == false) { |
|
38 | + return ''; |
|
39 | + } |
|
42 | 40 | |
43 | 41 | $height = $file_size[1]; |
44 | 42 | $width = $file_size[0]; |
45 | 43 | $description = $photo_result->description; |
46 | 44 | |
47 | 45 | $domain = '/'; |
48 | - if($is_absolute) |
|
49 | - $domain = Loader::getRootUrl('blog'); |
|
46 | + if($is_absolute) { |
|
47 | + $domain = Loader::getRootUrl('blog'); |
|
48 | + } |
|
50 | 49 | |
51 | 50 | return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description); |
52 | 51 | } |
@@ -2,72 +2,72 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('utility', 'Content'); |
4 | 4 | |
5 | -final class ElapsedTimeContent extends Content |
|
6 | -{ |
|
5 | +final class ElapsedTimeContent extends Content |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function execute() |
|
9 | - { |
|
8 | + protected function execute() { |
|
10 | 9 | $previous_time = strtotime($this->content); |
11 | 10 | $current_time = time(); |
12 | 11 | |
13 | - if($current_time <= $previous_time) |
|
14 | - $this->content = 'few seconds ago'; |
|
15 | - else if(($current_time - $previous_time) < 30) |
|
16 | - $this->content = 'few seconds ago'; |
|
17 | - else if(($current_time - $previous_time) < 1.5 * 60) |
|
18 | - $this->content = 'a minute ago'; |
|
19 | - else if(($current_time - $previous_time) < 4 * 60) |
|
20 | - $this->content = 'few minutes ago'; |
|
21 | - else if(($current_time - $previous_time) < 7 * 60) |
|
22 | - $this->content = 'five minutes ago'; |
|
23 | - else if(($current_time - $previous_time) < 12 * 60) |
|
24 | - $this->content = 'ten minutes ago'; |
|
25 | - else if(($current_time - $previous_time) < 17 * 60) |
|
26 | - $this->content = 'fifteen minutes ago'; |
|
27 | - else if(($current_time - $previous_time) < 22 * 60) |
|
28 | - $this->content = 'twenty minutes ago'; |
|
29 | - else if(($current_time - $previous_time) < 37 * 60) |
|
30 | - $this->content = 'half hour ago'; |
|
31 | - else if(($current_time - $previous_time) < 52 * 60) |
|
32 | - $this->content = 'forty-five minutes ago'; |
|
33 | - else if(($current_time - $previous_time) < 1.5 * 60 * 60) |
|
34 | - $this->content = 'an hour ago'; |
|
35 | - else if(($current_time - $previous_time) < 2.5 * 60 * 60) |
|
36 | - $this->content = 'two hours ago'; |
|
37 | - else if(($current_time - $previous_time) < 3.5 * 60 * 60) |
|
38 | - $this->content = 'three hours ago'; |
|
39 | - else if(($current_time - $previous_time) < 4.5 * 60 * 60) |
|
40 | - $this->content = 'few hours ago'; |
|
41 | - else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') |
|
42 | - $this->content = 'this afternoon'; |
|
43 | - else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') |
|
44 | - $this->content = 'this morning'; |
|
45 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) |
|
46 | - $this->content = 'yesterday evening'; |
|
47 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') |
|
48 | - $this->content = 'yesterday afternoon'; |
|
49 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') |
|
50 | - $this->content = 'yesterday morning'; |
|
51 | - else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) |
|
52 | - $this->content = 'two days ago'; |
|
53 | - else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) |
|
54 | - $this->content = 'three days ago'; |
|
55 | - else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) |
|
56 | - $this->content = 'earlier this week'; |
|
57 | - else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) |
|
58 | - $this->content = 'late last week'; |
|
59 | - else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) |
|
60 | - $this->content = 'early last week'; |
|
61 | - else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) |
|
62 | - $this->content = 'few weeks ago'; |
|
63 | - else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) |
|
64 | - $this->content = 'earlier this month'; |
|
65 | - else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) |
|
66 | - $this->content = 'last month'; |
|
67 | - else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) |
|
68 | - $this->content = 'several months ago'; |
|
69 | - else |
|
70 | - $this->content = 'long ago'; |
|
12 | + if($current_time <= $previous_time) { |
|
13 | + $this->content = 'few seconds ago'; |
|
14 | + } else if(($current_time - $previous_time) < 30) { |
|
15 | + $this->content = 'few seconds ago'; |
|
16 | + } else if(($current_time - $previous_time) < 1.5 * 60) { |
|
17 | + $this->content = 'a minute ago'; |
|
18 | + } else if(($current_time - $previous_time) < 4 * 60) { |
|
19 | + $this->content = 'few minutes ago'; |
|
20 | + } else if(($current_time - $previous_time) < 7 * 60) { |
|
21 | + $this->content = 'five minutes ago'; |
|
22 | + } else if(($current_time - $previous_time) < 12 * 60) { |
|
23 | + $this->content = 'ten minutes ago'; |
|
24 | + } else if(($current_time - $previous_time) < 17 * 60) { |
|
25 | + $this->content = 'fifteen minutes ago'; |
|
26 | + } else if(($current_time - $previous_time) < 22 * 60) { |
|
27 | + $this->content = 'twenty minutes ago'; |
|
28 | + } else if(($current_time - $previous_time) < 37 * 60) { |
|
29 | + $this->content = 'half hour ago'; |
|
30 | + } else if(($current_time - $previous_time) < 52 * 60) { |
|
31 | + $this->content = 'forty-five minutes ago'; |
|
32 | + } else if(($current_time - $previous_time) < 1.5 * 60 * 60) { |
|
33 | + $this->content = 'an hour ago'; |
|
34 | + } else if(($current_time - $previous_time) < 2.5 * 60 * 60) { |
|
35 | + $this->content = 'two hours ago'; |
|
36 | + } else if(($current_time - $previous_time) < 3.5 * 60 * 60) { |
|
37 | + $this->content = 'three hours ago'; |
|
38 | + } else if(($current_time - $previous_time) < 4.5 * 60 * 60) { |
|
39 | + $this->content = 'few hours ago'; |
|
40 | + } else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') { |
|
41 | + $this->content = 'this afternoon'; |
|
42 | + } else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') { |
|
43 | + $this->content = 'this morning'; |
|
44 | + } else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) { |
|
45 | + $this->content = 'yesterday evening'; |
|
46 | + } else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') { |
|
47 | + $this->content = 'yesterday afternoon'; |
|
48 | + } else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') { |
|
49 | + $this->content = 'yesterday morning'; |
|
50 | + } else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) { |
|
51 | + $this->content = 'two days ago'; |
|
52 | + } else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) { |
|
53 | + $this->content = 'three days ago'; |
|
54 | + } else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) { |
|
55 | + $this->content = 'earlier this week'; |
|
56 | + } else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) { |
|
57 | + $this->content = 'late last week'; |
|
58 | + } else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) { |
|
59 | + $this->content = 'early last week'; |
|
60 | + } else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) { |
|
61 | + $this->content = 'few weeks ago'; |
|
62 | + } else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) { |
|
63 | + $this->content = 'earlier this month'; |
|
64 | + } else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) { |
|
65 | + $this->content = 'last month'; |
|
66 | + } else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) { |
|
67 | + $this->content = 'several months ago'; |
|
68 | + } else { |
|
69 | + $this->content = 'long ago'; |
|
70 | + } |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | } |
74 | 74 | \ No newline at end of file |
@@ -2,29 +2,28 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('utility', 'Content'); |
4 | 4 | |
5 | -final class FixInternalLinkContent extends Content |
|
6 | -{ |
|
5 | +final class FixInternalLinkContent extends Content |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $LINK_PLACEHOLDER_MATCH = '@{{link="([a-z0-9/-]*)"( anchor="([a-zA-Z0-9\s]*)")?}}@'; |
9 | 9 | private static $ERROR_CONTENT = '<span>%s</span>'; |
10 | 10 | private static $LINK_CONTENT = '<a href="%s" target="_blank" />%s</a>'; |
11 | 11 | |
12 | - protected function execute($is_absolute = true) |
|
13 | - { |
|
12 | + protected function execute($is_absolute = true) { |
|
14 | 13 | preg_match_all(self::$LINK_PLACEHOLDER_MATCH, $this->content, $matches); |
15 | 14 | foreach($matches[1] as $key => $match) |
16 | 15 | { |
17 | - if(isset($matches[3][$key])) |
|
18 | - $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
|
19 | - else |
|
20 | - $link_content = $this->get_link($match, $is_absolute); |
|
16 | + if(isset($matches[3][$key])) { |
|
17 | + $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
|
18 | + } else { |
|
19 | + $link_content = $this->get_link($match, $is_absolute); |
|
20 | + } |
|
21 | 21 | $this->content = str_replace($matches[0][$key], $link_content, $this->content); |
22 | 22 | } |
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
26 | - private function get_link($string, $is_absolute, $anchor = '') |
|
27 | - { |
|
26 | + private function get_link($string, $is_absolute, $anchor = '') { |
|
28 | 27 | list($type, $uri) = explode('/', $string, 2); |
29 | 28 | |
30 | 29 | $link = ''; |
@@ -36,14 +35,16 @@ discard block |
||
36 | 35 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
37 | 36 | $post = $repository->findPostByPath($uri); |
38 | 37 | |
39 | - if($post === NULL) |
|
40 | - return; |
|
38 | + if($post === NULL) { |
|
39 | + return; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
43 | 43 | $link .= "{$post['category']}/{$post['path']}/"; |
44 | 44 | |
45 | - if($anchor == '') |
|
46 | - $anchor = $post['title']; |
|
45 | + if($anchor == '') { |
|
46 | + $anchor = $post['title']; |
|
47 | + } |
|
47 | 48 | |
48 | 49 | break; |
49 | 50 | case 'blog-tag' : |
@@ -62,14 +63,16 @@ discard block |
||
62 | 63 | Loader::load('collector', 'waterfall/LogCollector'); |
63 | 64 | $log = LogCollector::getByAlias($uri); |
64 | 65 | |
65 | - if($log === NULL) |
|
66 | - return; |
|
66 | + if($log === NULL) { |
|
67 | + return; |
|
68 | + } |
|
67 | 69 | |
68 | 70 | $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
69 | 71 | $link .= "journal/{$log->alias}/"; |
70 | 72 | |
71 | - if($anchor == '') |
|
72 | - $anchor = $log->title; |
|
73 | + if($anchor == '') { |
|
74 | + $anchor = $log->title; |
|
75 | + } |
|
73 | 76 | |
74 | 77 | break; |
75 | 78 | case 'falls' : |
@@ -1,42 +1,37 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -abstract class Content |
|
4 | -{ |
|
3 | +abstract class Content |
|
4 | +{ |
|
5 | 5 | |
6 | 6 | protected $original_content; |
7 | 7 | protected $content; |
8 | 8 | |
9 | - function __construct($content) |
|
10 | - { |
|
9 | + function __construct($content) { |
|
11 | 10 | $this->original_content = $content; |
12 | 11 | $this->content = $content; |
13 | 12 | } |
14 | 13 | |
15 | - public function getOriginal() |
|
16 | - { |
|
14 | + public function getOriginal() { |
|
17 | 15 | return $this->original_content; |
18 | 16 | } |
19 | 17 | |
20 | 18 | abstract protected function execute(); |
21 | 19 | |
22 | - public function activate() |
|
23 | - { |
|
20 | + public function activate() { |
|
24 | 21 | $args = func_get_args(); |
25 | 22 | call_user_func_array(array($this, 'execute'), $args); |
26 | 23 | |
27 | 24 | return $this->content; |
28 | 25 | } |
29 | 26 | |
30 | - public function check() |
|
31 | - { |
|
27 | + public function check() { |
|
32 | 28 | $args = func_get_args(); |
33 | 29 | $return = call_user_func_array(array($this, 'execute'), $args); |
34 | 30 | |
35 | 31 | return $return; |
36 | 32 | } |
37 | 33 | |
38 | - public static function instance($class, $content) |
|
39 | - { |
|
34 | + public static function instance($class, $content) { |
|
40 | 35 | $class_name = "{$class}Content"; |
41 | 36 | Loader::load('utility', "content/{$class_name}"); |
42 | 37 | return new $class_name($content); |
@@ -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,65 @@ 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() { |
|
14 | 13 | self::make_server(); |
15 | 14 | self::make_get(); |
16 | 15 | self::make_post(); |
17 | 16 | } |
18 | 17 | |
19 | - static function getServer($key = null) |
|
20 | - { |
|
18 | + static function getServer($key = null) { |
|
21 | 19 | if($key) |
22 | 20 | { |
23 | - if(isset(self::$server[$key])) |
|
24 | - return self::$server[$key]; |
|
21 | + if(isset(self::$server[$key])) { |
|
22 | + return self::$server[$key]; |
|
23 | + } |
|
25 | 24 | return false; |
26 | 25 | } |
27 | 26 | return self::$server; |
28 | 27 | } |
29 | 28 | |
30 | - static function isAjax() |
|
31 | - { |
|
32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
33 | - return true; |
|
29 | + static function isAjax() { |
|
30 | + if(self::getServer(self::$AJAX_REQUEST)) { |
|
31 | + return true; |
|
32 | + } |
|
34 | 33 | return false; |
35 | 34 | } |
36 | 35 | |
37 | - static function getGet($key = null) |
|
38 | - { |
|
36 | + static function getGet($key = null) { |
|
39 | 37 | if($key) |
40 | 38 | { |
41 | - if(isset(self::$get[$key])) |
|
42 | - return self::$get[$key]; |
|
39 | + if(isset(self::$get[$key])) { |
|
40 | + return self::$get[$key]; |
|
41 | + } |
|
43 | 42 | return false; |
44 | 43 | } |
45 | 44 | return self::$get; |
46 | 45 | } |
47 | 46 | |
48 | - static function getPost($key = null) |
|
49 | - { |
|
47 | + static function getPost($key = null) { |
|
50 | 48 | if($key) |
51 | 49 | { |
52 | - if(isset(self::$post[$key])) |
|
53 | - return self::$post[$key]; |
|
50 | + if(isset(self::$post[$key])) { |
|
51 | + return self::$post[$key]; |
|
52 | + } |
|
54 | 53 | return false; |
55 | 54 | } |
56 | 55 | return self::$post; |
57 | 56 | } |
58 | 57 | |
59 | - public static function hasPost() |
|
60 | - { |
|
58 | + public static function hasPost() { |
|
61 | 59 | return is_array(self::$post) && !empty(self::$post); |
62 | 60 | } |
63 | 61 | |
64 | - static function make_server() |
|
65 | - { |
|
62 | + static function make_server() { |
|
66 | 63 | self::$server = $_SERVER; |
67 | 64 | } |
68 | 65 | |
69 | - static function make_get() |
|
70 | - { |
|
66 | + static function make_get() { |
|
71 | 67 | self::$get = $_GET; |
72 | 68 | } |
73 | 69 | |
74 | - static function make_post() |
|
75 | - { |
|
70 | + static function make_post() { |
|
76 | 71 | self::$post = $_POST; |
77 | 72 | } |
78 | 73 |
@@ -1,10 +1,9 @@ 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() { |
|
8 | 7 | $array = array( |
9 | 8 | 'HTTP/1.1 200 OK', |
10 | 9 | 'Cache-Control: no-cache', |
@@ -16,8 +15,7 @@ discard block |
||
16 | 15 | self::send($array); |
17 | 16 | } |
18 | 17 | |
19 | - public static function sendHTML() |
|
20 | - { |
|
18 | + public static function sendHTML() { |
|
21 | 19 | $array = array( |
22 | 20 | 'HTTP/1.1 200 OK', |
23 | 21 | 'Cache-Control: no-cache', |
@@ -29,14 +27,12 @@ discard block |
||
29 | 27 | self::send($array); |
30 | 28 | } |
31 | 29 | |
32 | - public static function redirect($location, $method = 301) |
|
33 | - { |
|
30 | + public static function redirect($location, $method = 301) { |
|
34 | 31 | header("Location: {$location}", TRUE, $method); |
35 | 32 | exit(); |
36 | 33 | } |
37 | 34 | |
38 | - public static function send404() |
|
39 | - { |
|
35 | + public static function send404() { |
|
40 | 36 | $array = array( |
41 | 37 | 'HTTP/1.1 404 Not Found', |
42 | 38 | 'Cache-Control: no-cache', |
@@ -48,8 +44,7 @@ discard block |
||
48 | 44 | self::send($array); |
49 | 45 | } |
50 | 46 | |
51 | - public static function send503() |
|
52 | - { |
|
47 | + public static function send503() { |
|
53 | 48 | $array = array( |
54 | 49 | 'HTTP/1.1 503 Service Unavailable', |
55 | 50 | 'Cache-Control: no-cache', |
@@ -61,10 +56,10 @@ discard block |
||
61 | 56 | self::send($array); |
62 | 57 | } |
63 | 58 | |
64 | - private static function send($array, $gzip = true) |
|
65 | - { |
|
66 | - if($gzip) |
|
67 | - self::start_gzipping(); |
|
59 | + private static function send($array, $gzip = true) { |
|
60 | + if($gzip) { |
|
61 | + self::start_gzipping(); |
|
62 | + } |
|
68 | 63 | |
69 | 64 | foreach($array as $row) |
70 | 65 | { |
@@ -72,17 +67,17 @@ discard block |
||
72 | 67 | } |
73 | 68 | } |
74 | 69 | |
75 | - private static function get_date($timestamp = false) |
|
76 | - { |
|
77 | - if($timestamp == 0) |
|
78 | - $timestamp = time(); |
|
70 | + private static function get_date($timestamp = false) { |
|
71 | + if($timestamp == 0) { |
|
72 | + $timestamp = time(); |
|
73 | + } |
|
79 | 74 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
80 | 75 | } |
81 | 76 | |
82 | - private static function start_gzipping() |
|
83 | - { |
|
84 | - if(!ob_start('ob_gzhandler')) |
|
85 | - ob_start(); |
|
77 | + private static function start_gzipping() { |
|
78 | + if(!ob_start('ob_gzhandler')) { |
|
79 | + ob_start(); |
|
80 | + } |
|
86 | 81 | } |
87 | 82 | |
88 | 83 | } |
@@ -2,78 +2,76 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('utility', 'Request'); |
4 | 4 | |
5 | -class Validate |
|
6 | -{ |
|
5 | +class Validate |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $NAME_REGEX = '@[a-z\s\'-]+@i'; |
9 | 9 | private static $EMAIL_REGEX = '@(?:[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")\@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])@i'; |
10 | 10 | private static $URL_REGEX = '@((https?|ftp)\:\/\/)?([a-z0-9-.]*)\.([a-z]{2,3})(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:\@&%=+\/\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?@i'; |
11 | 11 | |
12 | - public static function isBoolean($value, $strict = false) |
|
13 | - { |
|
14 | - if($strict && ($value === true || $value === false)) |
|
15 | - return true; |
|
16 | - if(!$strict && ((bool) $value === true || (bool) $value === false)) |
|
17 | - return true; |
|
12 | + public static function isBoolean($value, $strict = false) { |
|
13 | + if($strict && ($value === true || $value === false)) { |
|
14 | + return true; |
|
15 | + } |
|
16 | + if(!$strict && ((bool) $value === true || (bool) $value === false)) { |
|
17 | + return true; |
|
18 | + } |
|
18 | 19 | return false; |
19 | 20 | } |
20 | 21 | |
21 | - public static function isDate($value) |
|
22 | - { |
|
23 | - if(strtotime($value) !== -1) |
|
24 | - return true; |
|
25 | - if(date('y', $value) !== false) |
|
26 | - return true; |
|
22 | + public static function isDate($value) { |
|
23 | + if(strtotime($value) !== -1) { |
|
24 | + return true; |
|
25 | + } |
|
26 | + if(date('y', $value) !== false) { |
|
27 | + return true; |
|
28 | + } |
|
27 | 29 | return false; |
28 | 30 | } |
29 | 31 | |
30 | - public static function isInteger($value, $strict = false) |
|
31 | - { |
|
32 | - if($strict) |
|
33 | - return is_int($value); |
|
32 | + public static function isInteger($value, $strict = false) { |
|
33 | + if($strict) { |
|
34 | + return is_int($value); |
|
35 | + } |
|
34 | 36 | return (int) $value == $value; |
35 | 37 | } |
36 | 38 | |
37 | - public static function isIP($value) |
|
38 | - { |
|
39 | - if(self::isInteger(ip2long($value))) |
|
40 | - return true; |
|
39 | + public static function isIP($value) { |
|
40 | + if(self::isInteger(ip2long($value))) { |
|
41 | + return true; |
|
42 | + } |
|
41 | 43 | return false; |
42 | 44 | } |
43 | 45 | |
44 | - public static function isString($value, $strict = false) |
|
45 | - { |
|
46 | - if($strict) |
|
47 | - return is_string($value); |
|
46 | + public static function isString($value, $strict = false) { |
|
47 | + if($strict) { |
|
48 | + return is_string($value); |
|
49 | + } |
|
48 | 50 | return (string) $value == $value; |
49 | 51 | } |
50 | 52 | |
51 | - public static function isURL($value) |
|
52 | - { |
|
53 | + public static function isURL($value) { |
|
53 | 54 | return true; |
54 | 55 | return self::check_value(self::$URL_REGEX, $value); |
55 | 56 | } |
56 | 57 | |
57 | - public static function isName($value) |
|
58 | - { |
|
58 | + public static function isName($value) { |
|
59 | 59 | return self::check_value(self::$NAME_REGEX, $value); |
60 | 60 | } |
61 | 61 | |
62 | - public static function isEmail($value) |
|
63 | - { |
|
62 | + public static function isEmail($value) { |
|
64 | 63 | return self::check_value(self::$EMAIL_REGEX, $value); |
65 | 64 | } |
66 | 65 | |
67 | - private static function check_value($pattern, $string) |
|
68 | - { |
|
66 | + private static function check_value($pattern, $string) { |
|
69 | 67 | preg_match($pattern, $string, $matches); |
70 | - if(empty($matches)) |
|
71 | - return false; |
|
68 | + if(empty($matches)) { |
|
69 | + return false; |
|
70 | + } |
|
72 | 71 | return $matches[0] == $string; |
73 | 72 | } |
74 | 73 | |
75 | - public static function checkRequest($type, $key, $validation, $strict = false) |
|
76 | - { |
|
74 | + public static function checkRequest($type, $key, $validation, $strict = false) { |
|
77 | 75 | switch($type) |
78 | 76 | { |
79 | 77 | case 'server': |
@@ -84,8 +82,9 @@ discard block |
||
84 | 82 | break; |
85 | 83 | } |
86 | 84 | |
87 | - if($value == false) |
|
88 | - return false; |
|
85 | + if($value == false) { |
|
86 | + return false; |
|
87 | + } |
|
89 | 88 | |
90 | 89 | switch($validation) |
91 | 90 | { |
@@ -5,11 +5,10 @@ discard block |
||
5 | 5 | 'waterfall/WaterfallCollector')); |
6 | 6 | Loader::load('router', 'Router'); |
7 | 7 | |
8 | -class WaterfallRouter extends Router |
|
9 | -{ |
|
8 | +class WaterfallRouter extends Router |
|
9 | +{ |
|
10 | 10 | |
11 | - protected function get_redirect_array() |
|
12 | - { |
|
11 | + protected function get_redirect_array() { |
|
13 | 12 | return array( |
14 | 13 | (object) array( |
15 | 14 | 'pattern' => '@/index.(html|htm|php)$@', |
@@ -71,8 +70,7 @@ discard block |
||
71 | 70 | ); |
72 | 71 | } |
73 | 72 | |
74 | - protected function check_for_special_redirect($uri) |
|
75 | - { |
|
73 | + protected function check_for_special_redirect($uri) { |
|
76 | 74 | if (preg_match('@^/falls/([a-z\'-]+)(/?)$@', $uri, $matches)) { |
77 | 75 | $alias = $matches[1]; |
78 | 76 | $alias = str_replace("'", '', $alias); |
@@ -128,8 +126,7 @@ discard block |
||
128 | 126 | return $uri; |
129 | 127 | } |
130 | 128 | |
131 | - protected function get_direct_array() |
|
132 | - { |
|
129 | + protected function get_direct_array() { |
|
133 | 130 | return array( |
134 | 131 | (object) array( |
135 | 132 | 'match' => '/', |
@@ -2,19 +2,17 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('router', 'Router'); |
4 | 4 | |
5 | -final class HomeRouter extends Router |
|
6 | -{ |
|
5 | +final class HomeRouter extends Router |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
8 | + protected function get_redirect_array() { |
|
10 | 9 | return array( |
11 | 10 | (object) array( |
12 | 11 | 'pattern' => '@/index.(html|htm|php)$@', |
13 | 12 | 'replace' => '')); |
14 | 13 | } |
15 | 14 | |
16 | - protected function get_direct_array() |
|
17 | - { |
|
15 | + protected function get_direct_array() { |
|
18 | 16 | return array( |
19 | 17 | (object) array( |
20 | 18 | 'match' => '/', |