@@ -2,11 +2,11 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('controller', 'portfolio/DefaultPageController'); |
| 4 | 4 | |
| 5 | -class AboutController extends DefaultPageController |
|
| 6 | -{ |
|
| 5 | +class AboutController extends DefaultPageController |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | - protected function set_head_data() |
|
| 9 | - { |
|
| 8 | + protected function set_head_data() |
|
| 9 | + {
|
|
| 10 | 10 | $this->set_title("Jacob Emerick's Portfolio"); |
| 11 | 11 | $this->set_description("Jacob Emerick's Portfolio - collection of programming projects and resume"); |
| 12 | 12 | $this->set_keywords([ |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | ]); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - protected function set_body_data() |
|
| 24 | - { |
|
| 23 | + protected function set_body_data() |
|
| 24 | + {
|
|
| 25 | 25 | $this->set_body('body_view', 'About'); |
| 26 | 26 | $this->set_body('body_data', []); |
| 27 | 27 | |
@@ -2,16 +2,20 @@ |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('controller', '/PageController'); |
| 4 | 4 | |
| 5 | -class Error303Controller extends PageController |
|
| 6 | -{ |
|
| 5 | +class Error303Controller extends PageController |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | - public function __construct($uri) |
|
| 9 | - { |
|
| 8 | + public function __construct($uri) |
|
| 9 | + {
|
|
| 10 | 10 | Header::redirect($uri, 303); |
| 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,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('utility', 'Header'); |
| 4 | 4 | |
| 5 | -abstract class PageController |
|
| 6 | -{ |
|
| 5 | +abstract class PageController |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $TRACKING_CODE = 'UA-11745070-1'; |
| 9 | 9 | |
@@ -20,12 +20,18 @@ discard block |
||
| 20 | 20 | private $data_array = array(); |
| 21 | 21 | private $body_view_array = array(); |
| 22 | 22 | |
| 23 | - protected function set_head_data() {} |
|
| 24 | - protected function set_body_data() {} |
|
| 25 | - protected function set_data() {} |
|
| 23 | + protected function set_head_data() |
|
| 24 | + {
|
|
| 25 | +} |
|
| 26 | + protected function set_body_data() |
|
| 27 | + {
|
|
| 28 | +} |
|
| 29 | + protected function set_data() |
|
| 30 | + {
|
|
| 31 | +} |
|
| 26 | 32 | |
| 27 | - public function __construct() |
|
| 28 | - { |
|
| 33 | + public function __construct() |
|
| 34 | + {
|
|
| 29 | 35 | $this->set_header_method('sendHTML'); |
| 30 | 36 | |
| 31 | 37 | $this->set_head('google_verification', 'sgAISiuoWfK54KXnOfm2oU4vQdad8eyNCQX7LkZ1OxM'); |
@@ -38,8 +44,8 @@ discard block |
||
| 38 | 44 | 'date' => date('Y'))); |
| 39 | 45 | } |
| 40 | 46 | |
| 41 | - protected function get_domain_container() |
|
| 42 | - { |
|
| 47 | + protected function get_domain_container() |
|
| 48 | + {
|
|
| 43 | 49 | $domain_container = new stdclass(); |
| 44 | 50 | |
| 45 | 51 | $domain_container->blog = Loader::getRootUrl('blog'); |
@@ -52,8 +58,8 @@ discard block |
||
| 52 | 58 | return $domain_container; |
| 53 | 59 | } |
| 54 | 60 | |
| 55 | - protected function get_recent_activity() |
|
| 56 | - { |
|
| 61 | + protected function get_recent_activity() |
|
| 62 | + {
|
|
| 57 | 63 | global $container; |
| 58 | 64 | $activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
| 59 | 65 | $post_result = $activityRepository->getActivities(5); |
@@ -66,8 +72,8 @@ discard block |
||
| 66 | 72 | return $post_array; |
| 67 | 73 | } |
| 68 | 74 | |
| 69 | - protected function expand_post($raw_post, $format = 'short') |
|
| 70 | - { |
|
| 75 | + protected function expand_post($raw_post, $format = 'short') |
|
| 76 | + {
|
|
| 71 | 77 | $post = [ |
| 72 | 78 | 'type' => $raw_post['type'], |
| 73 | 79 | 'title' => ($format == 'short') ? $raw_post['message'] : $raw_post['message_long'], |
@@ -84,8 +90,8 @@ discard block |
||
| 84 | 90 | return (object) $post; |
| 85 | 91 | } |
| 86 | 92 | |
| 87 | - public function activate() |
|
| 88 | - { |
|
| 93 | + public function activate() |
|
| 94 | + {
|
|
| 89 | 95 | $this->set_head_data(); |
| 90 | 96 | $this->set_body_data(); |
| 91 | 97 | $this->set_data(); |
@@ -97,10 +103,11 @@ discard block |
||
| 97 | 103 | Loader::load('view', '/Head', $this->data_array['head']); |
| 98 | 104 | foreach($this->body_view_array as $view) |
| 99 | 105 | { |
| 100 | - if(substr($view, 0, 1) == '/') |
|
| 101 | - Loader::load('view', $view, $this->data_array['body']); |
|
| 102 | - else |
|
| 103 | - Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
| 106 | + if(substr($view, 0, 1) == '/') {
|
|
| 107 | + Loader::load('view', $view, $this->data_array['body']);
|
|
| 108 | + } else {
|
|
| 109 | + Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
|
|
| 110 | + } |
|
| 104 | 111 | } |
| 105 | 112 | |
| 106 | 113 | if (URLDecode::getSite() == 'waterfalls') { |
@@ -109,62 +116,63 @@ discard block |
||
| 109 | 116 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
| 110 | 117 | } |
| 111 | 118 | |
| 112 | - if($view == '/404' || $view == '/503') |
|
| 113 | - exit; |
|
| 119 | + if($view == '/404' || $view == '/503') {
|
|
| 120 | + exit; |
|
| 121 | + } |
|
| 114 | 122 | } |
| 115 | 123 | |
| 116 | - protected function set_header_method($method) |
|
| 117 | - { |
|
| 124 | + protected function set_header_method($method) |
|
| 125 | + {
|
|
| 118 | 126 | $this->headers = $method; |
| 119 | 127 | } |
| 120 | 128 | |
| 121 | - protected function set_title($value) |
|
| 122 | - { |
|
| 129 | + protected function set_title($value) |
|
| 130 | + {
|
|
| 123 | 131 | $this->set_head('title', $value); |
| 124 | 132 | } |
| 125 | 133 | |
| 126 | - protected function set_author($value) |
|
| 127 | - { |
|
| 134 | + protected function set_author($value) |
|
| 135 | + {
|
|
| 128 | 136 | $this->set_head('author', $value); |
| 129 | 137 | } |
| 130 | 138 | |
| 131 | - protected function set_description($value) |
|
| 132 | - { |
|
| 139 | + protected function set_description($value) |
|
| 140 | + {
|
|
| 133 | 141 | $this->set_head('description', $value); |
| 134 | 142 | } |
| 135 | 143 | |
| 136 | - protected function set_keywords($array) |
|
| 137 | - { |
|
| 144 | + protected function set_keywords($array) |
|
| 145 | + {
|
|
| 138 | 146 | $this->set_head('keywords', implode(', ', $array)); |
| 139 | 147 | } |
| 140 | 148 | |
| 141 | - protected function set_canonical($url) |
|
| 142 | - { |
|
| 149 | + protected function set_canonical($url) |
|
| 150 | + {
|
|
| 143 | 151 | $this->set_head('canonical', $url); |
| 144 | 152 | } |
| 145 | 153 | |
| 146 | - protected function set_head($set, $value) |
|
| 147 | - { |
|
| 154 | + protected function set_head($set, $value) |
|
| 155 | + {
|
|
| 148 | 156 | $this->data_array['head'][$set] = $value; |
| 149 | 157 | } |
| 150 | 158 | |
| 151 | - protected function set_body($set, $value) |
|
| 152 | - { |
|
| 159 | + protected function set_body($set, $value) |
|
| 160 | + {
|
|
| 153 | 161 | $this->data_array['body'][$set] = $value; |
| 154 | 162 | } |
| 155 | 163 | |
| 156 | - protected function add_css($file, $version = 1) |
|
| 157 | - { |
|
| 164 | + protected function add_css($file, $version = 1) |
|
| 165 | + {
|
|
| 158 | 166 | $this->css_array[] = [$file, $version]; |
| 159 | 167 | } |
| 160 | 168 | |
| 161 | - protected function add_js($file) |
|
| 162 | - { |
|
| 169 | + protected function add_js($file) |
|
| 170 | + {
|
|
| 163 | 171 | $this->js_array[] = $file; |
| 164 | 172 | } |
| 165 | 173 | |
| 166 | - private function load_assets() |
|
| 167 | - { |
|
| 174 | + private function load_assets() |
|
| 175 | + {
|
|
| 168 | 176 | $css_array = array_map(function ($stylesheet) { |
| 169 | 177 | $path = "/css/{$stylesheet[0]}.css"; |
| 170 | 178 | if ($stylesheet[1] > 1) { |
@@ -183,40 +191,44 @@ discard block |
||
| 183 | 191 | $this->set_head('js_link_array', $js_array); |
| 184 | 192 | } |
| 185 | 193 | |
| 186 | - protected function set_body_view($view) |
|
| 187 | - { |
|
| 194 | + protected function set_body_view($view) |
|
| 195 | + {
|
|
| 188 | 196 | $this->body_view_array[] = $view; |
| 189 | 197 | } |
| 190 | 198 | |
| 191 | - protected function eject() |
|
| 192 | - { |
|
| 193 | - if(get_class($this) !== 'Error404Controller') |
|
| 194 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 199 | + protected function eject() |
|
| 200 | + {
|
|
| 201 | + if(get_class($this) !== 'Error404Controller') {
|
|
| 202 | + Loader::loadNew('controller', '/Error404Controller')->activate();
|
|
| 203 | + } |
|
| 195 | 204 | } |
| 196 | 205 | |
| 197 | - protected function unavailable() |
|
| 198 | - { |
|
| 199 | - if(get_class($this) !== 'Error503Controller') |
|
| 200 | - Loader::loadNew('controller', '/Error503Controller')->activate(); |
|
| 206 | + protected function unavailable() |
|
| 207 | + {
|
|
| 208 | + if(get_class($this) !== 'Error503Controller') {
|
|
| 209 | + Loader::loadNew('controller', '/Error503Controller')->activate();
|
|
| 210 | + } |
|
| 201 | 211 | } |
| 202 | 212 | |
| 203 | - protected function redirect($uri, $method = 301) |
|
| 204 | - { |
|
| 213 | + protected function redirect($uri, $method = 301) |
|
| 214 | + {
|
|
| 205 | 215 | switch($method) |
| 206 | 216 | { |
| 207 | 217 | case 301 : |
| 208 | - if(get_class($this) !== 'Error301Controller') |
|
| 209 | - Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
|
| 218 | + if(get_class($this) !== 'Error301Controller') {
|
|
| 219 | + Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
|
|
| 220 | + } |
|
| 210 | 221 | break; |
| 211 | 222 | case 303 : |
| 212 | - if(get_class($this) !== 'Error303Controller') |
|
| 213 | - Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
|
| 223 | + if(get_class($this) !== 'Error303Controller') {
|
|
| 224 | + Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
|
|
| 225 | + } |
|
| 214 | 226 | break; |
| 215 | 227 | } |
| 216 | 228 | } |
| 217 | 229 | |
| 218 | - final protected function get_parsed_date($date) |
|
| 219 | - { |
|
| 230 | + final protected function get_parsed_date($date) |
|
| 231 | + {
|
|
| 220 | 232 | $parsed_date = new stdclass(); |
| 221 | 233 | |
| 222 | 234 | $parsed_date->stamp = date('c', strtotime($date)); |
@@ -227,8 +239,8 @@ discard block |
||
| 227 | 239 | } |
| 228 | 240 | |
| 229 | 241 | private $comment_errors; |
| 230 | - protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
|
| 231 | - { |
|
| 242 | + protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
|
| 243 | + {
|
|
| 232 | 244 | if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
| 233 | 245 | { |
| 234 | 246 | $parameters = array($site_id, $path, $redirect_url, $page_title); |
@@ -238,8 +250,8 @@ discard block |
||
| 238 | 250 | return; |
| 239 | 251 | } |
| 240 | 252 | |
| 241 | - protected function get_comment_array($site, $path) |
|
| 242 | - { |
|
| 253 | + protected function get_comment_array($site, $path) |
|
| 254 | + {
|
|
| 243 | 255 | Loader::load('collector', 'comment/CommentCollector'); |
| 244 | 256 | |
| 245 | 257 | $commenter = $this->get_commenter(); |
@@ -257,18 +269,19 @@ discard block |
||
| 257 | 269 | $comment_object->url = $comment->url; |
| 258 | 270 | $comment_object->trusted = $comment->trusted; |
| 259 | 271 | |
| 260 | - if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
| 261 | - $comment_object->errors = $this->comment_errors; |
|
| 262 | - else |
|
| 263 | - $comment_object->errors = array(); |
|
| 272 | + if($comment->reply == 0 && Request::getPost('type') == $comment->id) {
|
|
| 273 | + $comment_object->errors = $this->comment_errors; |
|
| 274 | + } else {
|
|
| 275 | + $comment_object->errors = array(); |
|
| 276 | + } |
|
| 264 | 277 | |
| 265 | 278 | if($comment->reply == 0) |
| 266 | 279 | { |
| 267 | 280 | $comment_object->replies = array(); |
| 268 | 281 | $comment_array[$comment->id] = $comment_object; |
| 269 | - } |
|
| 270 | - else |
|
| 271 | - $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
| 282 | + } else {
|
|
| 283 | + $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
| 284 | + } |
|
| 272 | 285 | } |
| 273 | 286 | |
| 274 | 287 | $comment_count = CommentCollector::getCommentCountForURL($site, $path); |
@@ -280,8 +293,8 @@ discard block |
||
| 280 | 293 | 'comment_count' => $comment_count); |
| 281 | 294 | } |
| 282 | 295 | |
| 283 | - private function get_commenter() |
|
| 284 | - { |
|
| 296 | + private function get_commenter() |
|
| 297 | + {
|
|
| 285 | 298 | Loader::load('collector', 'comment/CommentCollector'); |
| 286 | 299 | |
| 287 | 300 | $commenter = new stdclass(); |
@@ -297,16 +310,19 @@ discard block |
||
| 297 | 310 | |
| 298 | 311 | $commenter_cookie_value = json_decode($_COOKIE['commenter']); |
| 299 | 312 | |
| 300 | - if($commenter_cookie_value === NULL) |
|
| 301 | - return $commenter; |
|
| 313 | + if($commenter_cookie_value === NULL) {
|
|
| 314 | + return $commenter; |
|
| 315 | + } |
|
| 302 | 316 | |
| 303 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
| 304 | - return $commenter; |
|
| 317 | + if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) {
|
|
| 318 | + return $commenter; |
|
| 319 | + } |
|
| 305 | 320 | |
| 306 | 321 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
| 307 | 322 | |
| 308 | - if($commenter_object === NULL) |
|
| 309 | - return $commenter; |
|
| 323 | + if($commenter_object === NULL) {
|
|
| 324 | + return $commenter; |
|
| 325 | + } |
|
| 310 | 326 | |
| 311 | 327 | $commenter->id = $commenter_object->id; |
| 312 | 328 | $commenter->name = $commenter_object->name; |
@@ -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 | |