@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'lifestream/DefaultPageController'); |
4 | 4 | |
5 | -final class PostController extends DefaultPageController |
|
6 | -{ |
|
5 | +final class PostController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE = "Post %d | %s Activity | Jacob Emerick's Lifestream"; |
9 | 9 | private static $DESCRIPTION = "Post %d of %s activity on Jacob Emerick's Lifestream."; |
@@ -15,26 +15,29 @@ discard block |
||
15 | 15 | |
16 | 16 | private $post; |
17 | 17 | |
18 | - public function __construct() |
|
19 | - { |
|
18 | + public function __construct() |
|
19 | + { |
|
20 | 20 | parent::__construct(); |
21 | 21 | |
22 | 22 | $id = URLDecode::getPiece(2); |
23 | - if(!$id || !is_numeric($id)) |
|
24 | - $this->eject(); |
|
23 | + if(!$id || !is_numeric($id)) { |
|
24 | + $this->eject(); |
|
25 | + } |
|
25 | 26 | |
26 | 27 | $post = $this->activityRepository->getActivityById($id); |
27 | - if(!$post) |
|
28 | - $this->eject(); |
|
28 | + if(!$post) { |
|
29 | + $this->eject(); |
|
30 | + } |
|
29 | 31 | |
30 | - if(URLDecode::getPiece(1) != $post['type']) |
|
31 | - $this->eject(); |
|
32 | + if(URLDecode::getPiece(1) != $post['type']) { |
|
33 | + $this->eject(); |
|
34 | + } |
|
32 | 35 | |
33 | 36 | $this->post = $post; |
34 | 37 | } |
35 | 38 | |
36 | - protected function set_head_data() |
|
37 | - { |
|
39 | + protected function set_head_data() |
|
40 | + { |
|
38 | 41 | $this->set_title(sprintf(self::$TITLE, $this->post['id'], ucwords($this->post['type']))); |
39 | 42 | $this->set_description(sprintf(self::$DESCRIPTION, $this->post['id'], ucwords($this->post['type']))); |
40 | 43 | |
@@ -45,8 +48,8 @@ discard block |
||
45 | 48 | parent::set_head_data(); |
46 | 49 | } |
47 | 50 | |
48 | - protected function set_body_data() |
|
49 | - { |
|
51 | + protected function set_body_data() |
|
52 | + { |
|
50 | 53 | $this->set_body('title', $this->get_title()); |
51 | 54 | $this->set_body('description', $this->get_description()); |
52 | 55 | |
@@ -57,8 +60,8 @@ discard block |
||
57 | 60 | parent::set_body_data(); |
58 | 61 | } |
59 | 62 | |
60 | - private function get_title() |
|
61 | - { |
|
63 | + private function get_title() |
|
64 | + { |
|
62 | 65 | switch($this->post['type']) |
63 | 66 | { |
64 | 67 | case 'blog' : |
@@ -85,8 +88,8 @@ discard block |
||
85 | 88 | } |
86 | 89 | } |
87 | 90 | |
88 | - private function get_description() |
|
89 | - { |
|
91 | + private function get_description() |
|
92 | + { |
|
90 | 93 | switch($this->post['type']) |
91 | 94 | { |
92 | 95 | case 'blog' : |
@@ -3,27 +3,27 @@ |
||
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | Loader::load('utility', 'Content'); |
5 | 5 | |
6 | -abstract class DefaultPageController extends PageController |
|
7 | -{ |
|
6 | +abstract class DefaultPageController extends PageController |
|
7 | +{ |
|
8 | 8 | |
9 | 9 | protected $activityRepository; |
10 | 10 | |
11 | - public function __construct() |
|
12 | - { |
|
11 | + public function __construct() |
|
12 | + { |
|
13 | 13 | parent::__construct(); |
14 | 14 | |
15 | 15 | global $container; |
16 | 16 | $this->activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
17 | 17 | } |
18 | 18 | |
19 | - protected function set_head_data() |
|
20 | - { |
|
19 | + protected function set_head_data() |
|
20 | + { |
|
21 | 21 | $this->add_css('normalize'); |
22 | 22 | $this->add_css('lifestream', 2); |
23 | 23 | } |
24 | 24 | |
25 | - protected function set_body_data() |
|
26 | - { |
|
25 | + protected function set_body_data() |
|
26 | + { |
|
27 | 27 | $this->set_body_view('Page'); |
28 | 28 | } |
29 | 29 |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'lifestream/DefaultListController'); |
4 | 4 | |
5 | -final class HomeController extends DefaultListController |
|
6 | -{ |
|
5 | +final class HomeController extends DefaultListController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE = "Jacob Emerick's Lifestream"; |
9 | 9 | private static $DESCRIPTION = 'Lifestream for Jacob Emerick, a combination of his latest twitter, youtube, running, reading, and blogging activity.'; |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | |
19 | 19 | private static $LIST_DESCRIPTION = 'viewing %d - %d of %d total activities'; |
20 | 20 | |
21 | - protected function set_head_data() |
|
22 | - { |
|
21 | + protected function set_head_data() |
|
22 | + { |
|
23 | 23 | $this->set_title(self::$TITLE); |
24 | 24 | $this->set_description(self::$DESCRIPTION); |
25 | 25 | $this->set_keywords(self::$KEYWORD_ARRAY); |
@@ -27,56 +27,61 @@ discard block |
||
27 | 27 | parent::set_head_data(); |
28 | 28 | } |
29 | 29 | |
30 | - protected function set_body_data() |
|
31 | - { |
|
30 | + protected function set_body_data() |
|
31 | + { |
|
32 | 32 | $this->set_body('title', "What's Jacob Up To?"); |
33 | 33 | $this->set_body('description', "A combination of Jacob Emerick's tweets, runs, reads, blogs, and YouTubes all in <em>one awesome lifestream</em>."); |
34 | 34 | |
35 | 35 | parent::set_body_data(); |
36 | 36 | } |
37 | 37 | |
38 | - protected function get_page_number() |
|
39 | - { |
|
38 | + protected function get_page_number() |
|
39 | + { |
|
40 | 40 | $page = URLDecode::getPiece(2); |
41 | - if(isset($page) && is_numeric($page)) |
|
42 | - return $page; |
|
41 | + if(isset($page) && is_numeric($page)) { |
|
42 | + return $page; |
|
43 | + } |
|
43 | 44 | return 1; |
44 | 45 | } |
45 | 46 | |
46 | - protected function get_list_results() |
|
47 | - { |
|
47 | + protected function get_list_results() |
|
48 | + { |
|
48 | 49 | return $this->activityRepository->getActivities(self::$POSTS_PER_PAGE, $this->offset); |
49 | 50 | } |
50 | 51 | |
51 | - protected function get_list_description() |
|
52 | - { |
|
52 | + protected function get_list_description() |
|
53 | + { |
|
53 | 54 | $start = $this->offset + 1; |
54 | 55 | $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
55 | 56 | |
56 | 57 | return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
57 | 58 | } |
58 | 59 | |
59 | - protected function get_list_next_link() |
|
60 | - { |
|
61 | - if($this->page == 1) |
|
62 | - return; |
|
63 | - if($this->page == 2) |
|
64 | - return Loader::getRootUrl('lifestream'); |
|
60 | + protected function get_list_next_link() |
|
61 | + { |
|
62 | + if($this->page == 1) { |
|
63 | + return; |
|
64 | + } |
|
65 | + if($this->page == 2) { |
|
66 | + return Loader::getRootUrl('lifestream'); |
|
67 | + } |
|
65 | 68 | return Loader::getRootUrl('lifestream') . 'page/' . ($this->page - 1) . '/'; |
66 | 69 | } |
67 | 70 | |
68 | - protected function get_list_prev_link() |
|
69 | - { |
|
70 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
71 | - return; |
|
71 | + protected function get_list_prev_link() |
|
72 | + { |
|
73 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) { |
|
74 | + return; |
|
75 | + } |
|
72 | 76 | return Loader::getRootUrl('lifestream') . 'page/' . ($this->page + 1) . '/'; |
73 | 77 | } |
74 | 78 | |
75 | 79 | private $total_post_count; |
76 | - protected function get_total_post_count() |
|
77 | - { |
|
78 | - if(!isset($this->total_post_count)) |
|
79 | - $this->total_post_count = $this->activityRepository->getActivitiesCount(); |
|
80 | + protected function get_total_post_count() |
|
81 | + { |
|
82 | + if(!isset($this->total_post_count)) { |
|
83 | + $this->total_post_count = $this->activityRepository->getActivitiesCount(); |
|
84 | + } |
|
80 | 85 | return $this->total_post_count; |
81 | 86 | } |
82 | 87 |
@@ -2,16 +2,16 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'lifestream/DefaultPageController'); |
4 | 4 | |
5 | -abstract class DefaultListController extends DefaultPageController |
|
6 | -{ |
|
5 | +abstract class DefaultListController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | protected static $POSTS_PER_PAGE = 15; |
9 | 9 | |
10 | 10 | protected $page; |
11 | 11 | protected $offset; |
12 | 12 | |
13 | - public function __construct() |
|
14 | - { |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | 15 | parent::__construct(); |
16 | 16 | |
17 | 17 | $this->page = $this->get_page_number(); |
@@ -25,24 +25,24 @@ discard block |
||
25 | 25 | abstract protected function get_list_prev_link(); |
26 | 26 | abstract protected function get_total_post_count(); |
27 | 27 | |
28 | - protected function set_head_data() |
|
29 | - { |
|
28 | + protected function set_head_data() |
|
29 | + { |
|
30 | 30 | parent::set_head_data(); |
31 | 31 | |
32 | 32 | $this->set_head('next_link', $this->get_list_next_link()); |
33 | 33 | $this->set_head('previous_link', $this->get_list_prev_link()); |
34 | 34 | } |
35 | 35 | |
36 | - protected function set_body_data() |
|
37 | - { |
|
36 | + protected function set_body_data() |
|
37 | + { |
|
38 | 38 | parent::set_body_data(); |
39 | 39 | |
40 | 40 | $this->set_body('view', 'Listing'); |
41 | 41 | $this->set_body('data', $this->get_list_body_data()); |
42 | 42 | } |
43 | 43 | |
44 | - final private function get_list_body_data() |
|
45 | - { |
|
44 | + final private function get_list_body_data() |
|
45 | + { |
|
46 | 46 | return array( |
47 | 47 | 'posts' => $this->get_list_posts(), |
48 | 48 | 'type' => 'list', |
@@ -52,15 +52,16 @@ discard block |
||
52 | 52 | 'prev' => $this->get_list_prev_link())); |
53 | 53 | } |
54 | 54 | |
55 | - final private function get_list_posts() |
|
56 | - { |
|
55 | + final private function get_list_posts() |
|
56 | + { |
|
57 | 57 | $post_array = array(); |
58 | 58 | foreach($this->get_list_results() as $post) |
59 | 59 | { |
60 | 60 | $post_array[] = $this->expand_post($post, 'full'); |
61 | 61 | } |
62 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
63 | - $this->eject(); |
|
62 | + if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') { |
|
63 | + $this->eject(); |
|
64 | + } |
|
64 | 65 | return $post_array; |
65 | 66 | } |
66 | 67 |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'lifestream/DefaultListController'); |
4 | 4 | |
5 | -final class TagController extends DefaultListController |
|
6 | -{ |
|
5 | +final class TagController extends DefaultListController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE = "%s Activity | Jacob Emerick's Lifestream"; |
9 | 9 | private static $DESCRIPTION = "%s activity on Jacob Emerick's lifestream, all nice and paginated in one awesome website."; |
@@ -17,15 +17,15 @@ discard block |
||
17 | 17 | |
18 | 18 | private $tag; |
19 | 19 | |
20 | - public function __construct() |
|
21 | - { |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | 22 | parent::__construct(); |
23 | 23 | |
24 | 24 | $this->tag = URLDecode::getPiece(1); |
25 | 25 | } |
26 | 26 | |
27 | - protected function set_head_data() |
|
28 | - { |
|
27 | + protected function set_head_data() |
|
28 | + { |
|
29 | 29 | $this->set_title(sprintf(self::$TITLE, ucwords($this->tag))); |
30 | 30 | $this->set_description(sprintf(self::$DESCRIPTION, ucwords($this->tag))); |
31 | 31 | |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | parent::set_head_data(); |
37 | 37 | } |
38 | 38 | |
39 | - protected function set_body_data() |
|
40 | - { |
|
39 | + protected function set_body_data() |
|
40 | + { |
|
41 | 41 | $this->set_body('title', $this->get_title()); |
42 | 42 | $this->set_body('description', $this->get_description()); |
43 | 43 | |
44 | 44 | parent::set_body_data(); |
45 | 45 | } |
46 | 46 | |
47 | - private function get_title() |
|
48 | - { |
|
47 | + private function get_title() |
|
48 | + { |
|
49 | 49 | switch($this->tag) |
50 | 50 | { |
51 | 51 | case 'blog' : |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - private function get_description() |
|
76 | - { |
|
75 | + private function get_description() |
|
76 | + { |
|
77 | 77 | switch($this->tag) |
78 | 78 | { |
79 | 79 | case 'blog' : |
@@ -100,48 +100,53 @@ discard block |
||
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - protected function get_page_number() |
|
104 | - { |
|
103 | + protected function get_page_number() |
|
104 | + { |
|
105 | 105 | $page = URLDecode::getPiece(3); |
106 | - if(isset($page) && is_numeric($page)) |
|
107 | - return $page; |
|
106 | + if(isset($page) && is_numeric($page)) { |
|
107 | + return $page; |
|
108 | + } |
|
108 | 109 | return 1; |
109 | 110 | } |
110 | 111 | |
111 | - protected function get_list_results() |
|
112 | - { |
|
112 | + protected function get_list_results() |
|
113 | + { |
|
113 | 114 | return $this->activityRepository->getActivitiesByType($this->tag, self::$POSTS_PER_PAGE, $this->offset); |
114 | 115 | } |
115 | 116 | |
116 | - protected function get_list_description() |
|
117 | - { |
|
117 | + protected function get_list_description() |
|
118 | + { |
|
118 | 119 | $start = $this->offset + 1; |
119 | 120 | $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
120 | 121 | |
121 | 122 | return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->tag); |
122 | 123 | } |
123 | 124 | |
124 | - protected function get_list_next_link() |
|
125 | - { |
|
126 | - if($this->page == 1) |
|
127 | - return; |
|
128 | - if($this->page == 2) |
|
129 | - return Loader::getRootUrl('lifestream') . $this->tag . '/'; |
|
125 | + protected function get_list_next_link() |
|
126 | + { |
|
127 | + if($this->page == 1) { |
|
128 | + return; |
|
129 | + } |
|
130 | + if($this->page == 2) { |
|
131 | + return Loader::getRootUrl('lifestream') . $this->tag . '/'; |
|
132 | + } |
|
130 | 133 | return Loader::getRootUrl('lifestream') . $this->tag . '/page/' . ($this->page - 1) . '/'; |
131 | 134 | } |
132 | 135 | |
133 | - protected function get_list_prev_link() |
|
134 | - { |
|
135 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
136 | - return; |
|
136 | + protected function get_list_prev_link() |
|
137 | + { |
|
138 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) { |
|
139 | + return; |
|
140 | + } |
|
137 | 141 | return Loader::getRootUrl('lifestream') . $this->tag . '/page/' . ($this->page + 1) . '/'; |
138 | 142 | } |
139 | 143 | |
140 | 144 | private $total_post_count; |
141 | - protected function get_total_post_count() |
|
142 | - { |
|
143 | - if(!isset($this->total_post_count)) |
|
144 | - $this->total_post_count = $this->activityRepository->getActivitiesByTypeCount($this->tag); |
|
145 | + protected function get_total_post_count() |
|
146 | + { |
|
147 | + if(!isset($this->total_post_count)) { |
|
148 | + $this->total_post_count = $this->activityRepository->getActivitiesByTypeCount($this->tag); |
|
149 | + } |
|
145 | 150 | return $this->total_post_count; |
146 | 151 | } |
147 | 152 |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'lifestream/DefaultPageController'); |
4 | 4 | |
5 | -final class AboutController extends DefaultPageController |
|
6 | -{ |
|
5 | +final class AboutController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE = "About | What's a Lifestream?"; |
9 | 9 | private static $DESCRIPTION = 'A breakdown of what a lifestream is, why Jacob Emerick made one, and how he made it.'; |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | 'Jacob Emerick', |
17 | 17 | 'jpemeric'); |
18 | 18 | |
19 | - protected function set_head_data() |
|
20 | - { |
|
19 | + protected function set_head_data() |
|
20 | + { |
|
21 | 21 | $this->set_title(self::$TITLE); |
22 | 22 | $this->set_description(self::$DESCRIPTION); |
23 | 23 | $this->set_keywords(self::$KEYWORD_ARRAY); |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | parent::set_head_data(); |
26 | 26 | } |
27 | 27 | |
28 | - protected function set_body_data() |
|
29 | - { |
|
28 | + protected function set_body_data() |
|
29 | + { |
|
30 | 30 | $this->set_body('title', "WHAT'S A LIFESTREAM?"); |
31 | 31 | $this->set_body('type', 'about'); |
32 | 32 | $this->set_body('view', 'About'); |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | 'Header', |
5 | 5 | 'Request')); |
6 | 6 | |
7 | -abstract class AJAXController |
|
8 | -{ |
|
7 | +abstract class AJAXController |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | private static $RESPONSE_HEADER = 'sendJSON'; |
11 | 11 | |
@@ -13,18 +13,20 @@ discard block |
||
13 | 13 | |
14 | 14 | abstract protected function set_data(); |
15 | 15 | |
16 | - function __construct() {} |
|
16 | + function __construct() |
|
17 | + { |
|
18 | +} |
|
17 | 19 | |
18 | - public function activate() |
|
19 | - { |
|
20 | + public function activate() |
|
21 | + { |
|
20 | 22 | call_user_func(array('Header', self::$RESPONSE_HEADER)); |
21 | 23 | |
22 | 24 | $this->set_data(); |
23 | 25 | echo $this->response_as_json(); |
24 | 26 | } |
25 | 27 | |
26 | - protected function set_response($message, $type = 'internal') |
|
27 | - { |
|
28 | + protected function set_response($message, $type = 'internal') |
|
29 | + { |
|
28 | 30 | switch($type) |
29 | 31 | { |
30 | 32 | case 'internal' : |
@@ -38,21 +40,21 @@ discard block |
||
38 | 40 | } |
39 | 41 | } |
40 | 42 | |
41 | - protected function fail_response($message) |
|
42 | - { |
|
43 | + protected function fail_response($message) |
|
44 | + { |
|
43 | 45 | $this->set_response($message, 'error'); |
44 | 46 | return false; |
45 | 47 | } |
46 | 48 | |
47 | - protected function eject($message) |
|
48 | - { |
|
49 | + protected function eject($message) |
|
50 | + { |
|
49 | 51 | $this->fail_response($message); |
50 | 52 | echo $this->response_as_json(); |
51 | 53 | exit(); |
52 | 54 | } |
53 | 55 | |
54 | - private function response_as_json() |
|
55 | - { |
|
56 | + private function response_as_json() |
|
57 | + { |
|
56 | 58 | return json_encode($this->response); |
57 | 59 | } |
58 | 60 |
@@ -2,16 +2,20 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -class Error301Controller extends PageController |
|
6 | -{ |
|
5 | +class Error301Controller extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | - public function __construct($uri) |
|
9 | - { |
|
8 | + public function __construct($uri) |
|
9 | + { |
|
10 | 10 | Header::redirect($uri); |
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | - protected function set_head_data() {} |
|
15 | - protected function set_body_data() {} |
|
14 | + protected function set_head_data() |
|
15 | + { |
|
16 | +} |
|
17 | + protected function set_body_data() |
|
18 | + { |
|
19 | +} |
|
16 | 20 | |
17 | 21 | } |
@@ -2,17 +2,17 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -abstract class DefaultPageController extends PageController |
|
6 | -{ |
|
5 | +abstract class DefaultPageController extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | 10 | $this->add_css('normalize'); |
11 | 11 | $this->add_css('home'); |
12 | 12 | } |
13 | 13 | |
14 | - protected function set_body_data() |
|
15 | - { |
|
14 | + protected function set_body_data() |
|
15 | + { |
|
16 | 16 | $this->set_body('activity_array', $this->get_recent_activity()); |
17 | 17 | } |
18 | 18 |