Completed
Push — master ( a1f655...a0345d )
by Jacob
08:14
created
controller/blog/SearchController.class.inc.php 1 patch
Braces   +48 added lines, -43 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 Loader::load('controller', 'blog/DefaultListController');
4 4
 Loader::load('utility', 'Search');
5 5
 
6
-final class SearchController extends DefaultListController
7
-{
6
+final class SearchController extends DefaultListController
7
+{
8 8
 
9 9
 	private static $TITLE_MAIN = "%s Search | Jacob Emerick's Blog";
10 10
 	private static $DESCRIPTION_MAIN = "Posts containing the phrase %s on Jacob Emerick's Blog.";
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 
30 30
 	private $query;
31 31
 
32
-	public function __construct()
33
-	{
32
+	public function __construct()
33
+	{
34 34
 		$query = URLDecode::getPiece(2);
35 35
 		$query = urldecode($query);
36 36
         $query = str_replace('-', ' ', $query);
@@ -40,16 +40,15 @@  discard block
 block discarded – undo
40 40
 		parent::__construct();
41 41
 	}
42 42
 
43
-	protected function set_head_data()
44
-	{
43
+	protected function set_head_data()
44
+	{
45 45
 		parent::set_head_data();
46 46
 		
47 47
 		if($this->page == 1)
48 48
 		{
49 49
 			$this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query)));
50 50
 			$this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query)));
51
-		}
52
-		else
51
+		} else
53 52
 		{
54 53
 			$this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages));
55 54
 			$this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query)));
@@ -60,30 +59,32 @@  discard block
 block discarded – undo
60 59
 		$this->set_keywords($keyword_array);
61 60
 	}
62 61
 
63
-	protected function get_introduction()
64
-	{
65
-		if($this->total_pages > 1)
66
-			return array(
67
-				'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}.");
68
-		else if($this->total_pages == 1)
69
-			return array(
70
-				'title' => "Posts from search '{$this->query}'.");
71
-		else
72
-			return array(
73
-				'title' => "Sorry, '{$this->query}' didn't return any posts.");
62
+	protected function get_introduction()
63
+	{
64
+		if($this->total_pages > 1) {
65
+					return array(
66
+				'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}.");
67
+		} else if($this->total_pages == 1) {
68
+					return array(
69
+				'title' => "Posts from search '{$this->query}'.");
70
+		} else {
71
+					return array(
72
+				'title' => "Sorry, '{$this->query}' didn't return any posts.");
73
+		}
74 74
 	}
75 75
 
76
-	protected function get_page_number()
77
-	{
76
+	protected function get_page_number()
77
+	{
78 78
 		$page = URLDecode::getPiece(3);
79
-		if(isset($page) && is_numeric($page))
80
-			return $page;
79
+		if(isset($page) && is_numeric($page)) {
80
+					return $page;
81
+		}
81 82
 		return 1;
82 83
 	}
83 84
 
84 85
 	private $search_result;
85
-	private function get_search_result()
86
-	{
86
+	private function get_search_result()
87
+	{
87 88
 		if(!isset($this->search_result))
88 89
 		{
89 90
         global $container;
@@ -99,40 +100,44 @@  discard block
 block discarded – undo
99 100
 		return $this->search_result;
100 101
 	}
101 102
 
102
-	protected function get_list_results()
103
-	{
103
+	protected function get_list_results()
104
+	{
104 105
 		return array_slice($this->get_search_result(), $this->offset, self::$POSTS_PER_PAGE);
105 106
 	}
106 107
 
107
-	protected function get_list_description()
108
-	{
108
+	protected function get_list_description()
109
+	{
109 110
 		$start = $this->offset + 1;
110 111
 		$end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count());
111 112
 		
112 113
 		return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->query);
113 114
 	}
114 115
 
115
-	protected function get_list_next_link()
116
-	{
117
-		if($this->page == 1)
118
-			return;
119
-		if($this->page == 2)
120
-			return Content::instance('URLSafe', "/search/{$this->query}/")->activate();
116
+	protected function get_list_next_link()
117
+	{
118
+		if($this->page == 1) {
119
+					return;
120
+		}
121
+		if($this->page == 2) {
122
+					return Content::instance('URLSafe', "/search/{$this->query}/")->activate();
123
+		}
121 124
 		return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate();
122 125
 	}
123 126
 
124
-	protected function get_list_prev_link()
125
-	{
126
-		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count())
127
-			return;
127
+	protected function get_list_prev_link()
128
+	{
129
+		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) {
130
+					return;
131
+		}
128 132
 		return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate();
129 133
 	}
130 134
 
131 135
 	private $total_post_count;
132
-	protected function get_total_post_count()
133
-	{
134
-		if(!isset($this->total_post_count))
135
-			$this->total_post_count = count($this->get_search_result());
136
+	protected function get_total_post_count()
137
+	{
138
+		if(!isset($this->total_post_count)) {
139
+					$this->total_post_count = count($this->get_search_result());
140
+		}
136 141
 		return $this->total_post_count;
137 142
 	}
138 143
 
Please login to merge, or discard this patch.
controller/blog/DefaultListController.class.inc.php 1 patch
Braces   +15 added lines, -14 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('controller', 'blog/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 = 10;
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();
@@ -26,24 +26,24 @@  discard block
 block discarded – undo
26 26
 	abstract protected function get_list_prev_link();
27 27
 	abstract protected function get_total_post_count();
28 28
 
29
-	protected function set_head_data()
30
-	{
29
+	protected function set_head_data()
30
+	{
31 31
 		parent::set_head_data();
32 32
 		
33 33
 		$this->set_head('next_link', $this->get_list_next_link());
34 34
 		$this->set_head('previous_link', $this->get_list_prev_link());
35 35
 	}
36 36
 
37
-	protected function set_body_data()
38
-	{
37
+	protected function set_body_data()
38
+	{
39 39
 		parent::set_body_data();
40 40
 		
41 41
 		$this->set_body('view', 'Listing');
42 42
 		$this->set_body('data', $this->get_list_body_data());
43 43
 	}
44 44
 
45
-	final private function get_list_body_data()
46
-	{
45
+	final private function get_list_body_data()
46
+	{
47 47
 		return array(
48 48
 			'posts' => $this->get_list_posts(),
49 49
 			'show_top_navigation' => ($this->page !== 1),
@@ -53,15 +53,16 @@  discard block
 block discarded – undo
53 53
 				'prev' => $this->get_list_prev_link()));
54 54
 	}
55 55
 
56
-	final private function get_list_posts()
57
-	{
56
+	final private function get_list_posts()
57
+	{
58 58
 		$post_array = array();
59 59
 		foreach($this->get_list_results() as $post)
60 60
 		{
61 61
 			$post_array[] = $this->format_post($post, true);
62 62
 		}
63
-		if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search')
64
-			$this->eject();
63
+		if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') {
64
+					$this->eject();
65
+		}
65 66
 		return $post_array;
66 67
 	}
67 68
 
Please login to merge, or discard this patch.
controller/blog/TagController.class.inc.php 1 patch
Braces   +36 added lines, -32 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('controller', 'blog/DefaultListController');
4 4
 
5
-final class TagController extends DefaultListController
6
-{
5
+final class TagController extends DefaultListController
6
+{
7 7
 
8 8
 	private static $TITLE_MAIN = "%s Tag | Jacob Emerick's Blog";
9 9
 	private static $DESCRIPTION_MAIN = "Posts tagged with %s on Jacob Emerick's Blog, a website about Upper Peninsula hiking and web development best practices.";
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 
22 22
 	private $tag;
23 23
 
24
-	public function __construct()
25
-	{
24
+	public function __construct()
25
+	{
26 26
 		$tag = URLDecode::getPiece(2);
27 27
 		$tag = str_replace('-', ' ', $tag);
28 28
 
@@ -30,24 +30,24 @@  discard block
 block discarded – undo
30 30
         $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
31 31
         $tag_result = $repository->findTagByTitle($tag);
32 32
 
33
-		if($tag_result === false)
34
-			$this->eject();
33
+		if($tag_result === false) {
34
+					$this->eject();
35
+		}
35 36
 		
36 37
 		$this->tag = $tag_result;
37 38
 		
38 39
 		parent::__construct();
39 40
 	}
40 41
 
41
-	protected function set_head_data()
42
-	{
42
+	protected function set_head_data()
43
+	{
43 44
 		parent::set_head_data();
44 45
 		
45 46
 		if($this->page == 1)
46 47
 		{
47 48
 			$this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->tag['tag'])));
48 49
 			$this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->tag['tag'])));
49
-		}
50
-		else
50
+		} else
51 51
 		{
52 52
 			$this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->tag['tag']), $this->page, $this->total_pages));
53 53
 			$this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->tag['tag'])));
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 		$this->set_keywords($keyword_array);
59 59
 	}
60 60
 
61
-	protected function get_introduction()
62
-	{
61
+	protected function get_introduction()
62
+	{
63 63
 		$tag = ucwords($this->tag['tag']);
64 64
 		
65 65
 		if($this->page == 1)
@@ -86,48 +86,52 @@  discard block
 block discarded – undo
86 86
 			'title' => "{$tag} posts, page {$this->page} of {$this->total_pages}.");
87 87
 	}
88 88
 
89
-	protected function get_page_number()
90
-	{
89
+	protected function get_page_number()
90
+	{
91 91
 		$page = URLDecode::getPiece(3);
92
-		if(isset($page) && is_numeric($page))
93
-			return $page;
92
+		if(isset($page) && is_numeric($page)) {
93
+					return $page;
94
+		}
94 95
 		return 1;
95 96
 	}
96 97
 
97
-	protected function get_list_results()
98
-	{
98
+	protected function get_list_results()
99
+	{
99 100
         global $container;
100 101
         $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
101 102
         return $repository->getActivePostsByTag($this->tag['id'], self::$POSTS_PER_PAGE, $this->offset);
102 103
 	}
103 104
 
104
-	protected function get_list_description()
105
-	{
105
+	protected function get_list_description()
106
+	{
106 107
 		$start = $this->offset + 1;
107 108
 		$end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count());
108 109
 		
109 110
 		return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->tag['tag']);
110 111
 	}
111 112
 
112
-	protected function get_list_next_link()
113
-	{
114
-		if($this->page == 1)
115
-			return;
116
-		if($this->page == 2)
117
-			return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate();
113
+	protected function get_list_next_link()
114
+	{
115
+		if($this->page == 1) {
116
+					return;
117
+		}
118
+		if($this->page == 2) {
119
+					return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate();
120
+		}
118 121
 		return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page - 1) . '/')->activate();
119 122
 	}
120 123
 
121
-	protected function get_list_prev_link()
122
-	{
123
-		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count())
124
-			return;
124
+	protected function get_list_prev_link()
125
+	{
126
+		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) {
127
+					return;
128
+		}
125 129
 		return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page + 1) . '/')->activate();
126 130
 	}
127 131
 
128 132
 	private $total_post_count;
129
-	protected function get_total_post_count()
130
-	{
133
+	protected function get_total_post_count()
134
+	{
131 135
 		if(!isset($this->total_post_count)) {
132 136
         global $container;
133 137
         $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
Please login to merge, or discard this patch.
controller/blog/AboutController.class.inc.php 1 patch
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('controller', 'blog/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 the Blog | Jacob Emerick';
9 9
 	private static $DESCRIPTION = "A little bit about the awesomeness on Jacob Emerick's Blog, diving into the topics covered, technology used, and methodology of writing new posts.";
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 		'blog',
16 16
 		'Jacob Emerick');
17 17
 
18
-	protected function set_head_data()
19
-	{
18
+	protected function set_head_data()
19
+	{
20 20
 		$this->set_title(self::$TITLE);
21 21
 		$this->set_description(self::$DESCRIPTION);
22 22
 		$this->set_keywords(self::$KEYWORD_ARRAY);
@@ -24,15 +24,15 @@  discard block
 block discarded – undo
24 24
 		parent::set_head_data();
25 25
 	}
26 26
 
27
-	protected function set_body_data()
28
-	{
27
+	protected function set_body_data()
28
+	{
29 29
 		$this->set_body('view', 'About');
30 30
 		
31 31
 		parent::set_body_data();
32 32
 	}
33 33
 
34
-	protected function get_introduction()
35
-	{
34
+	protected function get_introduction()
35
+	{
36 36
         global $container;
37 37
         $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
38 38
         $introduction_result = $repository->findByType('about');
Please login to merge, or discard this patch.
controller/portfolio/ResumeController.class.inc.php 1 patch
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,13 +2,13 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('controller', 'portfolio/DefaultPageController');
4 4
 
5
-class ResumeController extends DefaultPageController
6
-{
5
+class ResumeController extends DefaultPageController
6
+{
7 7
 
8 8
     protected $resume = 'resume-20160318.json';
9 9
 
10
-    protected function set_head_data()
11
-    {
10
+    protected function set_head_data()
11
+    {
12 12
         $this->set_title("Resume | Jacob Emerick's Portfolio");
13 13
         $this->set_description("Resume for Jacob Emerick, a software engineer extraordinaire");
14 14
         $this->set_keywords([
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
         ]);
22 22
     }
23 23
 
24
-    protected function set_body_data()
25
-    {
24
+    protected function set_body_data()
25
+    {
26 26
         $this->set_body('body_view', 'Resume');
27 27
 
28 28
         $resumePath = Loader::getRootURL('portfolio') . "/jsonresume/{$this->resume}";
Please login to merge, or discard this patch.
controller/portfolio/DefaultPageController.class.inc.php 1 patch
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,19 +2,19 @@  discard block
 block discarded – undo
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
-    public function __construct()
9
-    {
8
+    public function __construct()
9
+    {
10 10
         parent::__construct();
11 11
 
12 12
         $this->add_css('reset');
13 13
         $this->add_css('portfolio', 4);
14 14
     }
15 15
 
16
-    protected function set_body_data()
17
-    {
16
+    protected function set_body_data()
17
+    {
18 18
         $this->set_body('header_data', [
19 19
             'menu' => $this->get_menu(),
20 20
             'home_link' => Loader::getRootURL(),
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
         $this->set_body_view('Page');
25 25
     }
26 26
 
27
-    protected function get_menu()
28
-    {
27
+    protected function get_menu()
28
+    {
29 29
         $menu = [
30 30
             [
31 31
                 'name' => 'About',
Please login to merge, or discard this patch.
controller/portfolio/ProjectsController.class.inc.php 1 patch
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('controller', 'portfolio/DefaultPageController');
4 4
 
5
-class ProjectsController extends DefaultPageController
6
-{
5
+class ProjectsController extends DefaultPageController
6
+{
7 7
 
8
-    protected function set_head_data()
9
-    {
8
+    protected function set_head_data()
9
+    {
10 10
         $this->set_title("Projects Page | Jacob Emerick's Portfolio");
11 11
         $this->set_description("Collection of key open-source projects that Jacob has developed and maintained over the years.");
12 12
         $this->set_keywords([
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
         ]);
20 20
     }
21 21
 
22
-    protected function set_body_data()
23
-    {
22
+    protected function set_body_data()
23
+    {
24 24
         $this->set_body('body_view', 'Projects');
25 25
         $this->set_body('body_data', []);
26 26
 
Please login to merge, or discard this patch.
controller/portfolio/ContactController.class.inc.php 1 patch
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('controller', 'portfolio/DefaultPageController');
4 4
 
5
-class ContactController extends DefaultPageController
6
-{
5
+class ContactController extends DefaultPageController
6
+{
7 7
 
8
-    protected function set_head_data()
9
-    {
8
+    protected function set_head_data()
9
+    {
10 10
         $this->set_title("Contact Page | Jacob Emerick's Portfolio");
11 11
         $this->set_description("Contact page for Jacob Emerick's Portfolio");
12 12
         $this->set_keywords([
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
         ]);
20 20
     }
21 21
 
22
-    protected function set_body_data()
23
-    {
22
+    protected function set_body_data()
23
+    {
24 24
         $this->set_body('body_view', 'Contact');
25 25
 
26 26
         $body_data = [];
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
         parent::set_body_data();
34 34
     }
35 35
 
36
-    private function process_form_data()
37
-    {
36
+    private function process_form_data()
37
+    {
38 38
         $errors = [];
39 39
 
40 40
         if (
Please login to merge, or discard this patch.
controller/portfolio/AboutController.class.inc.php 1 patch
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.