Completed
Pull Request — master (#5)
by Jacob
03:16
created
controller/waterfalls/MapController.class.inc.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -6,62 +6,62 @@
 block discarded – undo
6 6
 final class MapController extends DefaultPageController
7 7
 {
8 8
 
9
-    private static $TITLE = 'Map of Upper Peninsula Waterfalls';
10
-    private static $DESCRIPTION = '';
11
-    private static $KEYWORD_ARRAY = array();
9
+	private static $TITLE = 'Map of Upper Peninsula Waterfalls';
10
+	private static $DESCRIPTION = '';
11
+	private static $KEYWORD_ARRAY = array();
12 12
 
13
-    private static $HIDE_ON_INITIAL_LOAD_LIST = array(
14
-        'Lower Tahquamenon Falls',
15
-        'Rainbow Falls',
16
-        'Sandstone Falls',
17
-        'Upper Tahquamenon Falls',
18
-    );
13
+	private static $HIDE_ON_INITIAL_LOAD_LIST = array(
14
+		'Lower Tahquamenon Falls',
15
+		'Rainbow Falls',
16
+		'Sandstone Falls',
17
+		'Upper Tahquamenon Falls',
18
+	);
19 19
 
20
-    public function __construct()
21
-    {
22
-        parent::__construct();
20
+	public function __construct()
21
+	{
22
+		parent::__construct();
23 23
 
24
-        $this->add_js('https://maps.googleapis.com/maps/api/js?sensor=false');
25
-        $this->add_waterfall_js();
26
-    }
24
+		$this->add_js('https://maps.googleapis.com/maps/api/js?sensor=false');
25
+		$this->add_waterfall_js();
26
+	}
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_title(self::$TITLE . ' | ' . self::$WEBSITE_TITLE);
33
-        $this->set_description(self::$DESCRIPTION);
34
-        $this->set_keywords(self::$KEYWORD_ARRAY);
35
-    }
32
+		$this->set_title(self::$TITLE . ' | ' . self::$WEBSITE_TITLE);
33
+		$this->set_description(self::$DESCRIPTION);
34
+		$this->set_keywords(self::$KEYWORD_ARRAY);
35
+	}
36 36
 
37
-    protected function set_body_data($page_type = 'wide')
38
-    {
39
-        parent::set_body_data($page_type);
37
+	protected function set_body_data($page_type = 'wide')
38
+	{
39
+		parent::set_body_data($page_type);
40 40
         
41
-        $this->set_head('full_page_map', true);
42
-        $this->set_body('waterfall_list', $this->fetch_waterfall_list());
43
-        $this->set_body('view', 'Map');
44
-    }
41
+		$this->set_head('full_page_map', true);
42
+		$this->set_body('waterfall_list', $this->fetch_waterfall_list());
43
+		$this->set_body('view', 'Map');
44
+	}
45 45
 
46
-    private function fetch_waterfall_list()
47
-    {
48
-        $list = WaterfallCollector::getMapList();
49
-        array_walk($list, array($this, 'parse_waterfall'));
50
-        return $list;
51
-    }
46
+	private function fetch_waterfall_list()
47
+	{
48
+		$list = WaterfallCollector::getMapList();
49
+		array_walk($list, array($this, 'parse_waterfall'));
50
+		return $list;
51
+	}
52 52
 
53
-    private function parse_waterfall(&$waterfall)
54
-    {
55
-        $waterfall = (object) array(
56
-            'name'  => $waterfall->name,
57
-            'latitude' => $waterfall->latitude,
58
-            'longitude' => $waterfall->longitude,
59
-            'link' => "/{$waterfall->watercourse_alias}/{$waterfall->alias}/",
60
-            'image' => "/photo/{$waterfall->photo_category}/{$waterfall->photo}-size-medium.jpg",
61
-            'image_alt' => $waterfall->photo_description,
62
-            'watercourse' => $waterfall->watercourse,
63
-            'hide_on_initial_load' => (in_array($waterfall->name, self::$HIDE_ON_INITIAL_LOAD_LIST)),
64
-        );
65
-    }
53
+	private function parse_waterfall(&$waterfall)
54
+	{
55
+		$waterfall = (object) array(
56
+			'name'  => $waterfall->name,
57
+			'latitude' => $waterfall->latitude,
58
+			'longitude' => $waterfall->longitude,
59
+			'link' => "/{$waterfall->watercourse_alias}/{$waterfall->alias}/",
60
+			'image' => "/photo/{$waterfall->photo_category}/{$waterfall->photo}-size-medium.jpg",
61
+			'image_alt' => $waterfall->photo_description,
62
+			'watercourse' => $waterfall->watercourse,
63
+			'hide_on_initial_load' => (in_array($waterfall->name, self::$HIDE_ON_INITIAL_LOAD_LIST)),
64
+		);
65
+	}
66 66
 
67 67
 }
Please login to merge, or discard this patch.
controller/waterfalls/CompanionListController.class.inc.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 		$alias = URLDecode::getPiece(2);
28 28
 		$this->companion = CompanionCollector::getByAlias($alias);
29 29
 		
30
-		if(!$this->companion)
30
+		if (!$this->companion)
31 31
 			$this->eject();
32 32
 		
33 33
 		parent::__construct();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,9 @@
 block discarded – undo
27 27
 		$alias = URLDecode::getPiece(2);
28 28
 		$this->companion = CompanionCollector::getByAlias($alias);
29 29
 		
30
-		if(!$this->companion)
31
-			$this->eject();
30
+		if(!$this->companion) {
31
+					$this->eject();
32
+		}
32 33
 		
33 34
 		parent::__construct();
34 35
 	}
Please login to merge, or discard this patch.
controller/blog/AboutController.class.inc.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 		Loader::load('collector', 'blog/IntroductionCollector');
37 37
 		$introduction_result = IntroductionCollector::getRow('about');
38 38
 		
39
-		if($introduction_result !== null)
39
+		if ($introduction_result !== null)
40 40
 		{
41 41
 			$introduction = array();
42 42
 			$introduction['title'] = $introduction_result->title;
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@
 block discarded – undo
33 33
 
34 34
 	protected function get_introduction()
35 35
 	{
36
-        global $container;
37
-        $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
38
-        $introduction_result = $repository->findByType('about');
36
+		global $container;
37
+		$repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']);
38
+		$introduction_result = $repository->findByType('about');
39 39
 		
40 40
 		if($introduction_result !== null)
41 41
 		{
Please login to merge, or discard this patch.
controller/blog/SearchController.class.inc.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	{
46 46
 		parent::set_head_data();
47 47
 		
48
-		if($this->page == 1)
48
+		if ($this->page == 1)
49 49
 		{
50 50
 			$this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query)));
51 51
 			$this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query)));
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
 
64 64
 	protected function get_introduction()
65 65
 	{
66
-		if($this->total_pages > 1)
66
+		if ($this->total_pages > 1)
67 67
 			return array(
68 68
 				'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}.");
69
-		else if($this->total_pages == 1)
69
+		else if ($this->total_pages == 1)
70 70
 			return array(
71 71
 				'title' => "Posts from search '{$this->query}'.");
72 72
 		else
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	protected function get_page_number()
78 78
 	{
79 79
 		$page = URLDecode::getPiece(3);
80
-		if(isset($page) && is_numeric($page))
80
+		if (isset($page) && is_numeric($page))
81 81
 			return $page;
82 82
 		return 1;
83 83
 	}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	private $search_result;
86 86
 	private function get_search_result()
87 87
 	{
88
-		if(!isset($this->search_result))
88
+		if (!isset($this->search_result))
89 89
 		{
90 90
 			$posts = PostCollector::getMainList(self::$MAXIMUM_SEARCH_POSTS);
91 91
 			
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 
114 114
 	protected function get_list_next_link()
115 115
 	{
116
-		if($this->page == 1)
116
+		if ($this->page == 1)
117 117
 			return;
118
-		if($this->page == 2)
118
+		if ($this->page == 2)
119 119
 			return Content::instance('URLSafe', "/search/{$this->query}/")->activate();
120 120
 		return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate();
121 121
 	}
122 122
 
123 123
 	protected function get_list_prev_link()
124 124
 	{
125
-		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count())
125
+		if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count())
126 126
 			return;
127 127
 		return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate();
128 128
 	}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	private $total_post_count;
131 131
 	protected function get_total_post_count()
132 132
 	{
133
-		if(!isset($this->total_post_count))
133
+		if (!isset($this->total_post_count))
134 134
 			$this->total_post_count = count($this->get_search_result());
135 135
 		return $this->total_post_count;
136 136
 	}
Please login to merge, or discard this patch.
Braces   +26 added lines, -21 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@  discard block
 block discarded – undo
49 49
 		{
50 50
 			$this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query)));
51 51
 			$this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query)));
52
-		}
53
-		else
52
+		} else
54 53
 		{
55 54
 			$this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages));
56 55
 			$this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query)));
@@ -63,22 +62,24 @@  discard block
 block discarded – undo
63 62
 
64 63
 	protected function get_introduction()
65 64
 	{
66
-		if($this->total_pages > 1)
67
-			return array(
68
-				'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}.");
69
-		else if($this->total_pages == 1)
70
-			return array(
71
-				'title' => "Posts from search '{$this->query}'.");
72
-		else
73
-			return array(
74
-				'title' => "Sorry, '{$this->query}' didn't return any posts.");
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.");
74
+		}
75 75
 	}
76 76
 
77 77
 	protected function get_page_number()
78 78
 	{
79 79
 		$page = URLDecode::getPiece(3);
80
-		if(isset($page) && is_numeric($page))
81
-			return $page;
80
+		if(isset($page) && is_numeric($page)) {
81
+					return $page;
82
+		}
82 83
 		return 1;
83 84
 	}
84 85
 
@@ -113,25 +114,29 @@  discard block
 block discarded – undo
113 114
 
114 115
 	protected function get_list_next_link()
115 116
 	{
116
-		if($this->page == 1)
117
-			return;
118
-		if($this->page == 2)
119
-			return Content::instance('URLSafe', "/search/{$this->query}/")->activate();
117
+		if($this->page == 1) {
118
+					return;
119
+		}
120
+		if($this->page == 2) {
121
+					return Content::instance('URLSafe', "/search/{$this->query}/")->activate();
122
+		}
120 123
 		return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate();
121 124
 	}
122 125
 
123 126
 	protected function get_list_prev_link()
124 127
 	{
125
-		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count())
126
-			return;
128
+		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) {
129
+					return;
130
+		}
127 131
 		return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate();
128 132
 	}
129 133
 
130 134
 	private $total_post_count;
131 135
 	protected function get_total_post_count()
132 136
 	{
133
-		if(!isset($this->total_post_count))
134
-			$this->total_post_count = count($this->get_search_result());
137
+		if(!isset($this->total_post_count)) {
138
+					$this->total_post_count = count($this->get_search_result());
139
+		}
135 140
 		return $this->total_post_count;
136 141
 	}
137 142
 
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	{
35 35
 		$query = URLDecode::getPiece(2);
36 36
 		$query = urldecode($query);
37
-        $query = str_replace('-', ' ', $query);
37
+		$query = str_replace('-', ' ', $query);
38 38
 		
39 39
 		$this->query = $query;
40 40
 		
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	{
88 88
 		if(!isset($this->search_result))
89 89
 		{
90
-        global $container;
91
-        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
92
-        $posts = $repository->getActivePosts();
90
+		global $container;
91
+		$repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
92
+		$posts = $repository->getActivePosts();
93 93
 			
94 94
 			$this->search_result = Search::instance()
95 95
 				->setQuery($this->query)
Please login to merge, or discard this patch.
controller/blog/DefaultListController.class.inc.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,11 +56,11 @@
 block discarded – undo
56 56
 	final private function get_list_posts()
57 57
 	{
58 58
 		$post_array = array();
59
-		foreach($this->get_list_results() as $post)
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')
63
+		if (count($post_array) < 1 && URLDecode::getPiece(1) !== 'search')
64 64
 			$this->eject();
65 65
 		return $post_array;
66 66
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,8 +60,9 @@
 block discarded – undo
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/site/DefaultPageController.class.inc.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		$active_page = $this->get_active_page();
42 42
 		
43 43
 		$menu = array();
44
-		foreach(self::$MENU as $item)
44
+		foreach (self::$MENU as $item)
45 45
 		{
46 46
 			$menu[] = (object) array(
47 47
 				'name' => $item['name'],
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 	{
57 57
 		$current_uri = URLDecode::getPiece(1);
58 58
 		
59
-		if(!isset($current_uri))
59
+		if (!isset($current_uri))
60 60
 			return 'About';
61 61
 		
62 62
 		$menu = self::$MENU;
63
-		foreach($menu as $link)
63
+		foreach ($menu as $link)
64 64
 		{
65
-			if($link['uri'] == $current_uri)
65
+			if ($link['uri'] == $current_uri)
66 66
 				return $link['name'];
67 67
 		}
68 68
 		
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,14 +56,16 @@
 block discarded – undo
56 56
 	{
57 57
 		$current_uri = URLDecode::getPiece(1);
58 58
 		
59
-		if(!isset($current_uri))
60
-			return 'About';
59
+		if(!isset($current_uri)) {
60
+					return 'About';
61
+		}
61 62
 		
62 63
 		$menu = self::$MENU;
63 64
 		foreach($menu as $link)
64 65
 		{
65
-			if($link['uri'] == $current_uri)
66
-				return $link['name'];
66
+			if($link['uri'] == $current_uri) {
67
+							return $link['name'];
68
+			}
67 69
 		}
68 70
 		
69 71
 		return 'About';
Please login to merge, or discard this patch.
controller/site/ContactController.class.inc.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,17 +29,17 @@
 block discarded – undo
29 29
 
30 30
 	private function get_form_results()
31 31
 	{
32
-		if(!Request::hasPost())
32
+		if (!Request::hasPost())
33 33
 			return array();
34 34
 		
35
-		if(!Validate::checkRequest('post', 'name', 'string'))
35
+		if (!Validate::checkRequest('post', 'name', 'string'))
36 36
 			$error_message['name'] = 'Please enter a value for your name.';
37
-		if(!Validate::checkRequest('post', 'email', 'string'))
37
+		if (!Validate::checkRequest('post', 'email', 'string'))
38 38
 			$error_message['email'] = 'Please enter a valid email address.';
39
-		if(!Validate::checkRequest('post', 'message', 'string'))
39
+		if (!Validate::checkRequest('post', 'message', 'string'))
40 40
 			$error_message['message'] = 'Please enter a message.';
41 41
 		
42
-		if(!empty($error_message))
42
+		if (!empty($error_message))
43 43
 		{
44 44
 			return array(
45 45
 				'error_message' => $error_message,
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,15 +29,19 @@
 block discarded – undo
29 29
 
30 30
 	private function get_form_results()
31 31
 	{
32
-		if(!Request::hasPost())
33
-			return array();
32
+		if(!Request::hasPost()) {
33
+					return array();
34
+		}
34 35
 		
35
-		if(!Validate::checkRequest('post', 'name', 'string'))
36
-			$error_message['name'] = 'Please enter a value for your name.';
37
-		if(!Validate::checkRequest('post', 'email', 'string'))
38
-			$error_message['email'] = 'Please enter a valid email address.';
39
-		if(!Validate::checkRequest('post', 'message', 'string'))
40
-			$error_message['message'] = 'Please enter a message.';
36
+		if(!Validate::checkRequest('post', 'name', 'string')) {
37
+					$error_message['name'] = 'Please enter a value for your name.';
38
+		}
39
+		if(!Validate::checkRequest('post', 'email', 'string')) {
40
+					$error_message['email'] = 'Please enter a valid email address.';
41
+		}
42
+		if(!Validate::checkRequest('post', 'message', 'string')) {
43
+					$error_message['message'] = 'Please enter a message.';
44
+		}
41 45
 		
42 46
 		if(!empty($error_message))
43 47
 		{
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -46,16 +46,16 @@
 block discarded – undo
46 46
 				'value' => Request::getPost());
47 47
 		}
48 48
 
49
-    global $container;
50
-    $sent = $container['mail']
51
-      ->addTo($container['config']->admin_email)
52
-      ->setSubject('Site Contact')
53
-      ->setPlainMessage(
54
-        'Name: ' . Request::getPost('name') . "\n" .
55
-        'Email: ' . Request::getPost('email') . "\n" .
56
-        'Message: ' . Request::getPost('message')
57
-      )
58
-      ->send();
49
+	global $container;
50
+	$sent = $container['mail']
51
+	  ->addTo($container['config']->admin_email)
52
+	  ->setSubject('Site Contact')
53
+	  ->setPlainMessage(
54
+		'Name: ' . Request::getPost('name') . "\n" .
55
+		'Email: ' . Request::getPost('email') . "\n" .
56
+		'Message: ' . Request::getPost('message')
57
+	  )
58
+	  ->send();
59 59
 
60 60
 		return array(
61 61
 			'success_message' => "Thank you for your message, " . Request::getPost('name') . "! I'll get back to you as soon as possible.");
Please login to merge, or discard this patch.
controller/site/ChangelogController.class.inc.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 		Loader::load('collector', 'data/ChangelogCollector');
30 30
 		$changelog_result = ChangelogCollector::getLast20Changes();
31 31
 		
32
-		foreach($changelog_result as $change)
32
+		foreach ($changelog_result as $change)
33 33
 		{
34 34
 			$changelog[] = (object) array(
35 35
 				'date' => (object) array(
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@
 block discarded – undo
28 28
 
29 29
 	private function get_changelog()
30 30
 	{
31
-    global $container;
32
-    $changelogRepository = new MysqlChangelogRepository($container['db_connection_locator']);
33
-    $changelog_result = $changelogRepository->getChanges(40);
31
+	global $container;
32
+	$changelogRepository = new MysqlChangelogRepository($container['db_connection_locator']);
33
+	$changelog_result = $changelogRepository->getChanges(40);
34 34
 		
35 35
 		foreach($changelog_result as $change)
36 36
 		{
Please login to merge, or discard this patch.
module/form/CommentSubmitModule.class.inc.php 3 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 
27 27
 	public function activate()
28 28
 	{
29
-		if(!Request::hasPost())
29
+		if (!Request::hasPost())
30 30
 			return false;
31
-		if(!Request::getPost('submit') == 'Submit Comment')
31
+		if (!Request::getPost('submit') == 'Submit Comment')
32 32
 			return false;
33 33
 		
34 34
 		$errors = $this->fetch_errors();
35
-		if(count($errors) > 0)
35
+		if (count($errors) > 0)
36 36
 			return $errors;
37
-		if(Request::getPost('catch') !== '')
37
+		if (Request::getPost('catch') !== '')
38 38
 			return false;
39 39
 		
40 40
 		$page_id = $this->save_comment_page();
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
 	private function fetch_errors()
51 51
 	{
52 52
 		$errors = array();
53
-		if(!Validate::checkRequest('post', 'name', 'name'))
53
+		if (!Validate::checkRequest('post', 'name', 'name'))
54 54
 			$errors['name'] = 'You must include a valid name';
55
-		if(!Validate::checkRequest('post', 'email', 'email'))
55
+		if (!Validate::checkRequest('post', 'email', 'email'))
56 56
 			$errors['email'] = 'You must include a valid email';
57
-		if(Request::getPost('website') && !Validate::checkRequest('post', 'website', 'url'))
57
+		if (Request::getPost('website') && !Validate::checkRequest('post', 'website', 'url'))
58 58
 			$errors['website'] = 'Please enter a valid website';
59
-		if(!Validate::checkRequest('post', 'comment', 'string'))
59
+		if (!Validate::checkRequest('post', 'comment', 'string'))
60 60
 			$errors['comment'] = 'You must enter a comment';
61
-		if(Request::getPost('notify') && Request::getPost('notify') != 'check')
61
+		if (Request::getPost('notify') && Request::getPost('notify') != 'check')
62 62
 			$errors['notify'] = 'You entered an invalid notify request';
63
-		if(Request::getPost('reply') && !Validate::checkRequest('post', 'reply', 'integer'))
63
+		if (Request::getPost('reply') && !Validate::checkRequest('post', 'reply', 'integer'))
64 64
 			$errors['reply'] = 'You entered an invalid reply request';
65 65
 		
66 66
 		return $errors;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	private function save_comment_page()
70 70
 	{
71 71
 		$page_result = CommentCollector::getCommentPageByURL($this->path, $this->site);
72
-		if($page_result !== null)
72
+		if ($page_result !== null)
73 73
 			return $page_result->id;
74 74
 		
75 75
 		$query = "INSERT INTO `jpemeric_comment`.`comment_page` (`site`, `path`) VALUES ('%d', '%s')";
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			'name' => Request::getPost('name'),
86 86
 			'email' => Request::getPost('email'));
87 87
 		
88
-		if(Request::getPost('website') != '')
88
+		if (Request::getPost('website') != '')
89 89
 			$cookie_value['website'] = Request::getPost('website');
90 90
 		
91 91
 		$cookie_value = json_encode($cookie_value);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 			->save();
96 96
 		
97 97
 		$commenter_result = CommentCollector::getCommenterByFields(Request::getPost('name'), Request::getPost('email'), Request::getPost('website'));
98
-		if($commenter_result !== null)
98
+		if ($commenter_result !== null)
99 99
 			return $commenter_result->id;
100 100
 		
101 101
 		$query = "INSERT INTO `jpemeric_comment`.`commenter` (`name`,`email`,`url`) VALUES ('%s','%s','%s')";
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	private function save_comment()
113 113
 	{
114 114
 		$comment_result = CommentCollector::getCommentByBody(Request::getPost('comment'));
115
-		if($comment_result !== null)
115
+		if ($comment_result !== null)
116 116
 			return $comment_result->id;
117 117
 		
118 118
 		$query = "INSERT INTO `jpemeric_comment`.`comment` (`body`, `body_format`) VALUES ('%s', '%s')";
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		$query = "INSERT INTO `jpemeric_comment`.`comment_meta` (`commenter`,`comment`,`reply`,`notify`,`comment_page`,`date`,`display`) VALUES ('%d','%d','%d','%d','%d','%s','%d')";
134 134
 		
135 135
 		$reply = Database::escape(Request::getPost('type'));
136
-		if($reply == 'new')
136
+		if ($reply == 'new')
137 137
 			$reply = 0;
138 138
 		// else check to make sure value is legit
139 139
 		
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
 		
158 158
 		$commenter_result = CommentCollector::getCommenterByFields(Request::getPost('name'), Request::getPost('email'), Request::getPost('website'));
159 159
 		
160
-		if($commenter_result->trusted == 1)
160
+		if ($commenter_result->trusted == 1)
161 161
 		{
162 162
 			$notification_result = CommentCollector::getNotificationForPage($page);
163 163
 			
164
-			foreach($notification_result as $notification_row)
164
+			foreach ($notification_result as $notification_row)
165 165
 			{
166
-				if($notification_row->email == Request::getPost('email'))
166
+				if ($notification_row->email == Request::getPost('email'))
167 167
 					continue;
168 168
 				
169 169
 				$email_recipient_array[$notification_row->email] = array(
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
             $message = "Hello!\nThere has been a new comment on the page '{$this->page_title}' at Waterfalls of the Keweenaw. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!";
181 181
         }
182 182
         
183
-		foreach($email_recipient_array as $email_recipient)
183
+		foreach ($email_recipient_array as $email_recipient)
184 184
 		{
185 185
 			$mail = new Mail();
186 186
 			$mail->setToAddress($email_recipient['email'], $email_recipient['name']);
Please login to merge, or discard this patch.
Braces   +48 added lines, -32 removed lines patch added patch discarded remove patch
@@ -26,16 +26,20 @@  discard block
 block discarded – undo
26 26
 
27 27
 	public function activate()
28 28
 	{
29
-		if(!Request::hasPost())
30
-			return false;
31
-		if(!Request::getPost('submit') == 'Submit Comment')
32
-			return false;
29
+		if(!Request::hasPost()) {
30
+					return false;
31
+		}
32
+		if(!Request::getPost('submit') == 'Submit Comment') {
33
+					return false;
34
+		}
33 35
 		
34 36
 		$errors = $this->fetch_errors();
35
-		if(count($errors) > 0)
36
-			return $errors;
37
-		if(Request::getPost('catch') !== '')
38
-			return false;
37
+		if(count($errors) > 0) {
38
+					return $errors;
39
+		}
40
+		if(Request::getPost('catch') !== '') {
41
+					return false;
42
+		}
39 43
 		
40 44
 		$page_id = $this->save_comment_page();
41 45
 		$commenter_id = $this->save_commenter();
@@ -50,18 +54,24 @@  discard block
 block discarded – undo
50 54
 	private function fetch_errors()
51 55
 	{
52 56
 		$errors = array();
53
-		if(!Validate::checkRequest('post', 'name', 'name'))
54
-			$errors['name'] = 'You must include a valid name';
55
-		if(!Validate::checkRequest('post', 'email', 'email'))
56
-			$errors['email'] = 'You must include a valid email';
57
-		if(Request::getPost('website') && !Validate::checkRequest('post', 'website', 'url'))
58
-			$errors['website'] = 'Please enter a valid website';
59
-		if(!Validate::checkRequest('post', 'comment', 'string'))
60
-			$errors['comment'] = 'You must enter a comment';
61
-		if(Request::getPost('notify') && Request::getPost('notify') != 'check')
62
-			$errors['notify'] = 'You entered an invalid notify request';
63
-		if(Request::getPost('reply') && !Validate::checkRequest('post', 'reply', 'integer'))
64
-			$errors['reply'] = 'You entered an invalid reply request';
57
+		if(!Validate::checkRequest('post', 'name', 'name')) {
58
+					$errors['name'] = 'You must include a valid name';
59
+		}
60
+		if(!Validate::checkRequest('post', 'email', 'email')) {
61
+					$errors['email'] = 'You must include a valid email';
62
+		}
63
+		if(Request::getPost('website') && !Validate::checkRequest('post', 'website', 'url')) {
64
+					$errors['website'] = 'Please enter a valid website';
65
+		}
66
+		if(!Validate::checkRequest('post', 'comment', 'string')) {
67
+					$errors['comment'] = 'You must enter a comment';
68
+		}
69
+		if(Request::getPost('notify') && Request::getPost('notify') != 'check') {
70
+					$errors['notify'] = 'You entered an invalid notify request';
71
+		}
72
+		if(Request::getPost('reply') && !Validate::checkRequest('post', 'reply', 'integer')) {
73
+					$errors['reply'] = 'You entered an invalid reply request';
74
+		}
65 75
 		
66 76
 		return $errors;
67 77
 	}
@@ -69,8 +79,9 @@  discard block
 block discarded – undo
69 79
 	private function save_comment_page()
70 80
 	{
71 81
 		$page_result = CommentCollector::getCommentPageByURL($this->path, $this->site);
72
-		if($page_result !== null)
73
-			return $page_result->id;
82
+		if($page_result !== null) {
83
+					return $page_result->id;
84
+		}
74 85
 		
75 86
 		$query = "INSERT INTO `jpemeric_comment`.`comment_page` (`site`, `path`) VALUES ('%d', '%s')";
76 87
 		$query = sprintf($query, $this->site, $this->path);
@@ -85,8 +96,9 @@  discard block
 block discarded – undo
85 96
 			'name' => Request::getPost('name'),
86 97
 			'email' => Request::getPost('email'));
87 98
 		
88
-		if(Request::getPost('website') != '')
89
-			$cookie_value['website'] = Request::getPost('website');
99
+		if(Request::getPost('website') != '') {
100
+					$cookie_value['website'] = Request::getPost('website');
101
+		}
90 102
 		
91 103
 		$cookie_value = json_encode($cookie_value);
92 104
 		
@@ -95,8 +107,9 @@  discard block
 block discarded – undo
95 107
 			->save();
96 108
 		
97 109
 		$commenter_result = CommentCollector::getCommenterByFields(Request::getPost('name'), Request::getPost('email'), Request::getPost('website'));
98
-		if($commenter_result !== null)
99
-			return $commenter_result->id;
110
+		if($commenter_result !== null) {
111
+					return $commenter_result->id;
112
+		}
100 113
 		
101 114
 		$query = "INSERT INTO `jpemeric_comment`.`commenter` (`name`,`email`,`url`) VALUES ('%s','%s','%s')";
102 115
 		
@@ -112,8 +125,9 @@  discard block
 block discarded – undo
112 125
 	private function save_comment()
113 126
 	{
114 127
 		$comment_result = CommentCollector::getCommentByBody(Request::getPost('comment'));
115
-		if($comment_result !== null)
116
-			return $comment_result->id;
128
+		if($comment_result !== null) {
129
+					return $comment_result->id;
130
+		}
117 131
 		
118 132
 		$query = "INSERT INTO `jpemeric_comment`.`comment` (`body`, `body_format`) VALUES ('%s', '%s')";
119 133
 		
@@ -133,8 +147,9 @@  discard block
 block discarded – undo
133 147
 		$query = "INSERT INTO `jpemeric_comment`.`comment_meta` (`commenter`,`comment`,`reply`,`notify`,`comment_page`,`date`,`display`) VALUES ('%d','%d','%d','%d','%d','%s','%d')";
134 148
 		
135 149
 		$reply = Database::escape(Request::getPost('type'));
136
-		if($reply == 'new')
137
-			$reply = 0;
150
+		if($reply == 'new') {
151
+					$reply = 0;
152
+		}
138 153
 		// else check to make sure value is legit
139 154
 		
140 155
 		$notify = (Request::getPost('notify') == 'check') ? 1 : 0;
@@ -163,8 +178,9 @@  discard block
 block discarded – undo
163 178
 			
164 179
 			foreach($notification_result as $notification_row)
165 180
 			{
166
-				if($notification_row->email == Request::getPost('email'))
167
-					continue;
181
+				if($notification_row->email == Request::getPost('email')) {
182
+									continue;
183
+				}
168 184
 				
169 185
 				$email_recipient_array[$notification_row->email] = array(
170 186
 					'email' => $notification_row->email,
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -167,26 +167,26 @@
 block discarded – undo
167 167
 			}
168 168
 		}
169 169
         
170
-        $site = URLDecode::getSite();
170
+		$site = URLDecode::getSite();
171 171
         
172
-        if ($site == 'blog') {
173
-            $subject = "New Comment on Jacob Emerick's Blog";
174
-            $message = "Hello!\nThere has been a new comment on the post '{$this->page_title}' at Jacob Emerick's Blog. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!";
175
-        } else if ($site == 'waterfalls') {
176
-            $subject = "New Comment on Waterfalls of the Keweenaw";
177
-            $message = "Hello!\nThere has been a new comment on the page '{$this->page_title}' at Waterfalls of the Keweenaw. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!";
178
-        }
172
+		if ($site == 'blog') {
173
+			$subject = "New Comment on Jacob Emerick's Blog";
174
+			$message = "Hello!\nThere has been a new comment on the post '{$this->page_title}' at Jacob Emerick's Blog. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!";
175
+		} else if ($site == 'waterfalls') {
176
+			$subject = "New Comment on Waterfalls of the Keweenaw";
177
+			$message = "Hello!\nThere has been a new comment on the page '{$this->page_title}' at Waterfalls of the Keweenaw. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!";
178
+		}
179 179
 
180
-    global $container;
180
+	global $container;
181 181
 
182 182
 		foreach($email_recipient_array as $email_recipient)
183 183
 		{
184
-      $sent = $container['mail']
185
-        ->addTo($email_recipient['email'], $email_recipient['name'])
186
-        ->addBCC($container['config']->admin_email)
187
-        ->setSubject($subject)
188
-        ->setPlainMessage($message)
189
-        ->send();		
184
+	  $sent = $container['mail']
185
+		->addTo($email_recipient['email'], $email_recipient['name'])
186
+		->addBCC($container['config']->admin_email)
187
+		->setSubject($subject)
188
+		->setPlainMessage($message)
189
+		->send();		
190 190
 		}
191 191
 	}
192 192
 
Please login to merge, or discard this patch.