@@ -5,63 +5,63 @@ |
||
5 | 5 | abstract class DefaultListController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - protected static $POSTS_PER_PAGE = 15; |
|
8 | + protected static $POSTS_PER_PAGE = 15; |
|
9 | 9 | |
10 | - protected $page; |
|
11 | - protected $offset; |
|
10 | + protected $page; |
|
11 | + protected $offset; |
|
12 | 12 | |
13 | - public function __construct() |
|
14 | - { |
|
15 | - parent::__construct(); |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + parent::__construct(); |
|
16 | 16 | |
17 | - $this->page = $this->get_page_number(); |
|
18 | - $this->offset = ($this->page - 1) * self::$POSTS_PER_PAGE; |
|
19 | - } |
|
17 | + $this->page = $this->get_page_number(); |
|
18 | + $this->offset = ($this->page - 1) * self::$POSTS_PER_PAGE; |
|
19 | + } |
|
20 | 20 | |
21 | - abstract protected function get_page_number(); |
|
22 | - abstract protected function get_list_results(); |
|
23 | - abstract protected function get_list_description(); |
|
24 | - abstract protected function get_list_next_link(); |
|
25 | - abstract protected function get_list_prev_link(); |
|
26 | - abstract protected function get_total_post_count(); |
|
21 | + abstract protected function get_page_number(); |
|
22 | + abstract protected function get_list_results(); |
|
23 | + abstract protected function get_list_description(); |
|
24 | + abstract protected function get_list_next_link(); |
|
25 | + abstract protected function get_list_prev_link(); |
|
26 | + abstract protected function get_total_post_count(); |
|
27 | 27 | |
28 | - protected function set_head_data() |
|
29 | - { |
|
30 | - parent::set_head_data(); |
|
28 | + protected function set_head_data() |
|
29 | + { |
|
30 | + parent::set_head_data(); |
|
31 | 31 | |
32 | - $this->set_head('next_link', $this->get_list_next_link()); |
|
33 | - $this->set_head('previous_link', $this->get_list_prev_link()); |
|
34 | - } |
|
32 | + $this->set_head('next_link', $this->get_list_next_link()); |
|
33 | + $this->set_head('previous_link', $this->get_list_prev_link()); |
|
34 | + } |
|
35 | 35 | |
36 | - protected function set_body_data() |
|
37 | - { |
|
38 | - parent::set_body_data(); |
|
36 | + protected function set_body_data() |
|
37 | + { |
|
38 | + parent::set_body_data(); |
|
39 | 39 | |
40 | - $this->set_body('view', 'Listing'); |
|
41 | - $this->set_body('data', $this->get_list_body_data()); |
|
42 | - } |
|
40 | + $this->set_body('view', 'Listing'); |
|
41 | + $this->set_body('data', $this->get_list_body_data()); |
|
42 | + } |
|
43 | 43 | |
44 | - final private function get_list_body_data() |
|
45 | - { |
|
46 | - return array( |
|
47 | - 'posts' => $this->get_list_posts(), |
|
48 | - 'type' => 'list', |
|
49 | - 'pagination' => array( |
|
50 | - 'description' => $this->get_list_description(), |
|
51 | - 'next' => $this->get_list_next_link(), |
|
52 | - 'prev' => $this->get_list_prev_link())); |
|
53 | - } |
|
44 | + final private function get_list_body_data() |
|
45 | + { |
|
46 | + return array( |
|
47 | + 'posts' => $this->get_list_posts(), |
|
48 | + 'type' => 'list', |
|
49 | + 'pagination' => array( |
|
50 | + 'description' => $this->get_list_description(), |
|
51 | + 'next' => $this->get_list_next_link(), |
|
52 | + 'prev' => $this->get_list_prev_link())); |
|
53 | + } |
|
54 | 54 | |
55 | - final private function get_list_posts() |
|
56 | - { |
|
57 | - $post_array = array(); |
|
58 | - foreach($this->get_list_results() as $post) |
|
59 | - { |
|
60 | - $post_array[] = $this->expand_post($post, 'full'); |
|
61 | - } |
|
62 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
63 | - $this->eject(); |
|
64 | - return $post_array; |
|
65 | - } |
|
55 | + final private function get_list_posts() |
|
56 | + { |
|
57 | + $post_array = array(); |
|
58 | + foreach($this->get_list_results() as $post) |
|
59 | + { |
|
60 | + $post_array[] = $this->expand_post($post, 'full'); |
|
61 | + } |
|
62 | + if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
63 | + $this->eject(); |
|
64 | + return $post_array; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | abstract class DefaultPageController extends PageController |
7 | 7 | { |
8 | 8 | |
9 | - protected $activityRepository; |
|
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 | - } |
|
18 | - |
|
19 | - protected function set_head_data() |
|
20 | - { |
|
21 | - $this->add_css('normalize'); |
|
22 | - $this->add_css('lifestream', 2); |
|
23 | - } |
|
24 | - |
|
25 | - protected function set_body_data() |
|
26 | - { |
|
27 | - $this->set_body_view('Page'); |
|
28 | - } |
|
17 | + } |
|
18 | + |
|
19 | + protected function set_head_data() |
|
20 | + { |
|
21 | + $this->add_css('normalize'); |
|
22 | + $this->add_css('lifestream', 2); |
|
23 | + } |
|
24 | + |
|
25 | + protected function set_body_data() |
|
26 | + { |
|
27 | + $this->set_body_view('Page'); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | } |
@@ -5,33 +5,33 @@ |
||
5 | 5 | final class AboutController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE = "About | What's a Lifestream?"; |
|
9 | - private static $DESCRIPTION = 'A breakdown of what a lifestream is, why Jacob Emerick made one, and how he made it.'; |
|
8 | + private static $TITLE = "About | What's a Lifestream?"; |
|
9 | + private static $DESCRIPTION = 'A breakdown of what a lifestream is, why Jacob Emerick made one, and how he made it.'; |
|
10 | 10 | |
11 | - private static $KEYWORD_ARRAY = array( |
|
12 | - 'about', |
|
13 | - 'lifestream', |
|
14 | - 'feed', |
|
15 | - 'activity stream', |
|
16 | - 'Jacob Emerick', |
|
17 | - 'jpemeric'); |
|
11 | + private static $KEYWORD_ARRAY = array( |
|
12 | + 'about', |
|
13 | + 'lifestream', |
|
14 | + 'feed', |
|
15 | + 'activity stream', |
|
16 | + 'Jacob Emerick', |
|
17 | + 'jpemeric'); |
|
18 | 18 | |
19 | - protected function set_head_data() |
|
20 | - { |
|
21 | - $this->set_title(self::$TITLE); |
|
22 | - $this->set_description(self::$DESCRIPTION); |
|
23 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
19 | + protected function set_head_data() |
|
20 | + { |
|
21 | + $this->set_title(self::$TITLE); |
|
22 | + $this->set_description(self::$DESCRIPTION); |
|
23 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
24 | 24 | |
25 | - parent::set_head_data(); |
|
26 | - } |
|
25 | + parent::set_head_data(); |
|
26 | + } |
|
27 | 27 | |
28 | - protected function set_body_data() |
|
29 | - { |
|
30 | - $this->set_body('title', "WHAT'S A LIFESTREAM?"); |
|
31 | - $this->set_body('type', 'about'); |
|
32 | - $this->set_body('view', 'About'); |
|
28 | + protected function set_body_data() |
|
29 | + { |
|
30 | + $this->set_body('title', "WHAT'S A LIFESTREAM?"); |
|
31 | + $this->set_body('type', 'about'); |
|
32 | + $this->set_body('view', 'About'); |
|
33 | 33 | |
34 | - parent::set_body_data(); |
|
35 | - } |
|
34 | + parent::set_body_data(); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | \ No newline at end of file |
@@ -5,79 +5,79 @@ |
||
5 | 5 | final class HomeController extends DefaultListController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE = "Jacob Emerick's Lifestream"; |
|
9 | - private static $DESCRIPTION = 'Lifestream for Jacob Emerick, a combination of his latest twitter, youtube, running, reading, and blogging activity.'; |
|
8 | + private static $TITLE = "Jacob Emerick's Lifestream"; |
|
9 | + private static $DESCRIPTION = 'Lifestream for Jacob Emerick, a combination of his latest twitter, youtube, running, reading, and blogging activity.'; |
|
10 | 10 | |
11 | - private static $KEYWORD_ARRAY = array( |
|
12 | - 'lifestream', |
|
13 | - 'activity stream', |
|
14 | - 'Jacob Emerick', |
|
15 | - 'jacobemerick', |
|
16 | - 'jpemeric', |
|
17 | - 'twitter'); |
|
11 | + private static $KEYWORD_ARRAY = array( |
|
12 | + 'lifestream', |
|
13 | + 'activity stream', |
|
14 | + 'Jacob Emerick', |
|
15 | + 'jacobemerick', |
|
16 | + 'jpemeric', |
|
17 | + 'twitter'); |
|
18 | 18 | |
19 | - private static $LIST_DESCRIPTION = 'viewing %d - %d of %d total activities'; |
|
19 | + private static $LIST_DESCRIPTION = 'viewing %d - %d of %d total activities'; |
|
20 | 20 | |
21 | - protected function set_head_data() |
|
22 | - { |
|
23 | - $this->set_title(self::$TITLE); |
|
24 | - $this->set_description(self::$DESCRIPTION); |
|
25 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
21 | + protected function set_head_data() |
|
22 | + { |
|
23 | + $this->set_title(self::$TITLE); |
|
24 | + $this->set_description(self::$DESCRIPTION); |
|
25 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
26 | 26 | |
27 | - parent::set_head_data(); |
|
28 | - } |
|
27 | + parent::set_head_data(); |
|
28 | + } |
|
29 | 29 | |
30 | - protected function set_body_data() |
|
31 | - { |
|
32 | - $this->set_body('title', "What's Jacob Up To?"); |
|
33 | - $this->set_body('description', "A combination of Jacob Emerick's tweets, runs, reads, blogs, and YouTubes all in <em>one awesome lifestream</em>."); |
|
30 | + protected function set_body_data() |
|
31 | + { |
|
32 | + $this->set_body('title', "What's Jacob Up To?"); |
|
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 | - parent::set_body_data(); |
|
36 | - } |
|
35 | + parent::set_body_data(); |
|
36 | + } |
|
37 | 37 | |
38 | - protected function get_page_number() |
|
39 | - { |
|
40 | - $page = URLDecode::getPiece(2); |
|
41 | - if(isset($page) && is_numeric($page)) |
|
42 | - return $page; |
|
43 | - return 1; |
|
44 | - } |
|
38 | + protected function get_page_number() |
|
39 | + { |
|
40 | + $page = URLDecode::getPiece(2); |
|
41 | + if(isset($page) && is_numeric($page)) |
|
42 | + return $page; |
|
43 | + return 1; |
|
44 | + } |
|
45 | 45 | |
46 | - protected function get_list_results() |
|
47 | - { |
|
46 | + protected function get_list_results() |
|
47 | + { |
|
48 | 48 | return $this->activityRepository->getActivities(self::$POSTS_PER_PAGE, $this->offset); |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - protected function get_list_description() |
|
52 | - { |
|
53 | - $start = $this->offset + 1; |
|
54 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
51 | + protected function get_list_description() |
|
52 | + { |
|
53 | + $start = $this->offset + 1; |
|
54 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
55 | 55 | |
56 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
|
57 | - } |
|
56 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
|
57 | + } |
|
58 | 58 | |
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'); |
|
65 | - return Loader::getRootUrl('lifestream') . 'page/' . ($this->page - 1) . '/'; |
|
66 | - } |
|
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'); |
|
65 | + return Loader::getRootUrl('lifestream') . 'page/' . ($this->page - 1) . '/'; |
|
66 | + } |
|
67 | 67 | |
68 | - protected function get_list_prev_link() |
|
69 | - { |
|
70 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
71 | - return; |
|
72 | - return Loader::getRootUrl('lifestream') . 'page/' . ($this->page + 1) . '/'; |
|
73 | - } |
|
68 | + protected function get_list_prev_link() |
|
69 | + { |
|
70 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
71 | + return; |
|
72 | + return Loader::getRootUrl('lifestream') . 'page/' . ($this->page + 1) . '/'; |
|
73 | + } |
|
74 | 74 | |
75 | - 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 | - return $this->total_post_count; |
|
81 | - } |
|
75 | + 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 | + return $this->total_post_count; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | } |
@@ -5,20 +5,20 @@ |
||
5 | 5 | class Error503Controller extends PageController |
6 | 6 | { |
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
10 | - $this->set_header_method('send503'); |
|
11 | - $this->add_css('normalize'); |
|
12 | - $this->add_css('503'); |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | + $this->set_header_method('send503'); |
|
11 | + $this->add_css('normalize'); |
|
12 | + $this->add_css('503'); |
|
13 | 13 | |
14 | - $this->set_title("Jacob Emerick's 503 Page"); |
|
15 | - $this->set_description('Global 503 page for sites under jacobemerick.com. Page not found!'); |
|
16 | - $this->set_keywords(array()); |
|
17 | - } |
|
14 | + $this->set_title("Jacob Emerick's 503 Page"); |
|
15 | + $this->set_description('Global 503 page for sites under jacobemerick.com. Page not found!'); |
|
16 | + $this->set_keywords(array()); |
|
17 | + } |
|
18 | 18 | |
19 | - protected function set_body_data() |
|
20 | - { |
|
21 | - $this->set_body_view('/503'); |
|
22 | - } |
|
19 | + protected function set_body_data() |
|
20 | + { |
|
21 | + $this->set_body_view('/503'); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
@@ -5,13 +5,13 @@ |
||
5 | 5 | class Error301Controller extends PageController |
6 | 6 | { |
7 | 7 | |
8 | - public function __construct($uri) |
|
9 | - { |
|
10 | - Header::redirect($uri); |
|
11 | - exit; |
|
12 | - } |
|
8 | + public function __construct($uri) |
|
9 | + { |
|
10 | + Header::redirect($uri); |
|
11 | + exit; |
|
12 | + } |
|
13 | 13 | |
14 | - protected function set_head_data() {} |
|
15 | - protected function set_body_data() {} |
|
14 | + protected function set_head_data() {} |
|
15 | + protected function set_body_data() {} |
|
16 | 16 | |
17 | 17 | } |
@@ -1,60 +1,60 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | Loader::load('utility', array( |
4 | - 'Header', |
|
5 | - 'Request')); |
|
4 | + 'Header', |
|
5 | + 'Request')); |
|
6 | 6 | |
7 | 7 | abstract class AJAXController |
8 | 8 | { |
9 | 9 | |
10 | - private static $RESPONSE_HEADER = 'sendJSON'; |
|
10 | + private static $RESPONSE_HEADER = 'sendJSON'; |
|
11 | 11 | |
12 | - private $response = array(); |
|
12 | + private $response = array(); |
|
13 | 13 | |
14 | - abstract protected function set_data(); |
|
14 | + abstract protected function set_data(); |
|
15 | 15 | |
16 | - function __construct() {} |
|
16 | + function __construct() {} |
|
17 | 17 | |
18 | - public function activate() |
|
19 | - { |
|
20 | - call_user_func(array('Header', self::$RESPONSE_HEADER)); |
|
18 | + public function activate() |
|
19 | + { |
|
20 | + call_user_func(array('Header', self::$RESPONSE_HEADER)); |
|
21 | 21 | |
22 | - $this->set_data(); |
|
23 | - echo $this->response_as_json(); |
|
24 | - } |
|
25 | - |
|
26 | - protected function set_response($message, $type = 'internal') |
|
27 | - { |
|
28 | - switch($type) |
|
29 | - { |
|
30 | - case 'internal' : |
|
31 | - $this->response['internal'] = $message; |
|
32 | - break; |
|
33 | - case 'error' : |
|
34 | - $this->response['error'] = $message; |
|
35 | - default : |
|
36 | - $this->response[$type] = $message; |
|
37 | - break; |
|
38 | - } |
|
39 | - } |
|
40 | - |
|
41 | - protected function fail_response($message) |
|
42 | - { |
|
43 | - $this->set_response($message, 'error'); |
|
44 | - return false; |
|
45 | - } |
|
46 | - |
|
47 | - protected function eject($message) |
|
48 | - { |
|
49 | - $this->fail_response($message); |
|
50 | - echo $this->response_as_json(); |
|
51 | - exit(); |
|
52 | - } |
|
53 | - |
|
54 | - private function response_as_json() |
|
55 | - { |
|
56 | - return json_encode($this->response); |
|
57 | - } |
|
22 | + $this->set_data(); |
|
23 | + echo $this->response_as_json(); |
|
24 | + } |
|
25 | + |
|
26 | + protected function set_response($message, $type = 'internal') |
|
27 | + { |
|
28 | + switch($type) |
|
29 | + { |
|
30 | + case 'internal' : |
|
31 | + $this->response['internal'] = $message; |
|
32 | + break; |
|
33 | + case 'error' : |
|
34 | + $this->response['error'] = $message; |
|
35 | + default : |
|
36 | + $this->response[$type] = $message; |
|
37 | + break; |
|
38 | + } |
|
39 | + } |
|
40 | + |
|
41 | + protected function fail_response($message) |
|
42 | + { |
|
43 | + $this->set_response($message, 'error'); |
|
44 | + return false; |
|
45 | + } |
|
46 | + |
|
47 | + protected function eject($message) |
|
48 | + { |
|
49 | + $this->fail_response($message); |
|
50 | + echo $this->response_as_json(); |
|
51 | + exit(); |
|
52 | + } |
|
53 | + |
|
54 | + private function response_as_json() |
|
55 | + { |
|
56 | + return json_encode($this->response); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | } |
60 | 60 |
@@ -5,15 +5,15 @@ |
||
5 | 5 | abstract class DefaultPageController extends PageController |
6 | 6 | { |
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
10 | - $this->add_css('normalize'); |
|
11 | - $this->add_css('home'); |
|
12 | - } |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | + $this->add_css('normalize'); |
|
11 | + $this->add_css('home'); |
|
12 | + } |
|
13 | 13 | |
14 | - protected function set_body_data() |
|
15 | - { |
|
16 | - $this->set_body('activity_array', $this->get_recent_activity()); |
|
17 | - } |
|
14 | + protected function set_body_data() |
|
15 | + { |
|
16 | + $this->set_body('activity_array', $this->get_recent_activity()); |
|
17 | + } |
|
18 | 18 | |
19 | 19 | } |
@@ -5,32 +5,32 @@ |
||
5 | 5 | final class AboutController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE = 'About | Jacob Emerick'; |
|
9 | - private static $DESCRIPTION = 'Some basic information about Jacob Emerick and his past, web development, and hiking adventures'; |
|
8 | + private static $TITLE = 'About | Jacob Emerick'; |
|
9 | + private static $DESCRIPTION = 'Some basic information about Jacob Emerick and his past, web development, and hiking adventures'; |
|
10 | 10 | |
11 | - private static $KEYWORD_ARRAY = array( |
|
12 | - 'Jacob Emerick', |
|
13 | - 'jacobemerick', |
|
14 | - 'jpemeric', |
|
15 | - 'about', |
|
16 | - 'bio', |
|
17 | - 'web developer', |
|
18 | - 'hiker'); |
|
11 | + private static $KEYWORD_ARRAY = array( |
|
12 | + 'Jacob Emerick', |
|
13 | + 'jacobemerick', |
|
14 | + 'jpemeric', |
|
15 | + 'about', |
|
16 | + 'bio', |
|
17 | + 'web developer', |
|
18 | + 'hiker'); |
|
19 | 19 | |
20 | - protected function set_head_data() |
|
21 | - { |
|
22 | - $this->set_title(self::$TITLE); |
|
23 | - $this->set_description(self::$DESCRIPTION); |
|
24 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
20 | + protected function set_head_data() |
|
21 | + { |
|
22 | + $this->set_title(self::$TITLE); |
|
23 | + $this->set_description(self::$DESCRIPTION); |
|
24 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
25 | 25 | |
26 | - parent::set_head_data(); |
|
27 | - } |
|
26 | + parent::set_head_data(); |
|
27 | + } |
|
28 | 28 | |
29 | - protected function set_body_data() |
|
30 | - { |
|
31 | - $this->set_body_view('About'); |
|
29 | + protected function set_body_data() |
|
30 | + { |
|
31 | + $this->set_body_view('About'); |
|
32 | 32 | |
33 | - parent::set_body_data(); |
|
34 | - } |
|
33 | + parent::set_body_data(); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | \ No newline at end of file |