Completed
Push — master ( be7975...b1edf3 )
by Jacob
04:03
created
src/Domain/Stream/Post/MysqlPostRepository.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -7,132 +7,132 @@
 block discarded – undo
7 7
 class MysqlPostRepository implements PostRepositoryInterface
8 8
 {
9 9
 
10
-    /** @var  ConnectionLocator */
11
-    protected $connections;
12
-
13
-    /**
14
-     * @param ConnectonLocator $connections
15
-     */
16
-    public function __construct(ConnectionLocator $connections)
17
-    {
18
-        $this->connections = $connections;
19
-    }
20
-
21
-    /**
22
-     * @param integer $id
23
-     *
24
-     * @return array|false
25
-     */
26
-    public function getPostById($id)
27
-    {
28
-        $query = "
10
+	/** @var  ConnectionLocator */
11
+	protected $connections;
12
+
13
+	/**
14
+	 * @param ConnectonLocator $connections
15
+	 */
16
+	public function __construct(ConnectionLocator $connections)
17
+	{
18
+		$this->connections = $connections;
19
+	}
20
+
21
+	/**
22
+	 * @param integer $id
23
+	 *
24
+	 * @return array|false
25
+	 */
26
+	public function getPostById($id)
27
+	{
28
+		$query = "
29 29
             SELECT *
30 30
             FROM `jpemeric_stream`.`post`
31 31
             WHERE `id` = :id
32 32
             LIMIT 1";
33
-        $bindings = [
34
-            'id' => $id,
35
-        ];
36
-
37
-        return $this
38
-            ->connections
39
-            ->getRead()
40
-            ->fetchOne($query, $bindings);
41
-    }
42
-
43
-    /**
44
-     * @param string  $type
45
-     * @param integer $type_id
46
-     *
47
-     * @return array|false
48
-     */
49
-    public function getPostByType($type, $type_id)
50
-    {
51
-        $query = "
33
+		$bindings = [
34
+			'id' => $id,
35
+		];
36
+
37
+		return $this
38
+			->connections
39
+			->getRead()
40
+			->fetchOne($query, $bindings);
41
+	}
42
+
43
+	/**
44
+	 * @param string  $type
45
+	 * @param integer $type_id
46
+	 *
47
+	 * @return array|false
48
+	 */
49
+	public function getPostByType($type, $type_id)
50
+	{
51
+		$query = "
52 52
             SELECT *
53 53
             FROM `jpemeric_stream`.`post`
54 54
             WHERE `type` = :type && `type_id` = :type_id
55 55
             LIMIT 1";
56
-        $bindings = [
57
-            'type'    => $type,
58
-            'type_id' => $type_id,
59
-        ];
60
-
61
-        return $this
62
-            ->connections
63
-            ->getRead()
64
-            ->fetchOne($query, $bindings);
65
-    }
66
-
67
-    /**
68
-     * @param integer $limit
69
-     * @param integer $offset
70
-     *
71
-     * @return array|false
72
-     */
73
-    public function getPosts($limit = null, $offset = 0)
74
-    {
75
-        $query = "
56
+		$bindings = [
57
+			'type'    => $type,
58
+			'type_id' => $type_id,
59
+		];
60
+
61
+		return $this
62
+			->connections
63
+			->getRead()
64
+			->fetchOne($query, $bindings);
65
+	}
66
+
67
+	/**
68
+	 * @param integer $limit
69
+	 * @param integer $offset
70
+	 *
71
+	 * @return array|false
72
+	 */
73
+	public function getPosts($limit = null, $offset = 0)
74
+	{
75
+		$query = "
76 76
             SELECT *
77 77
             FROM `jpemeric_stream`.`post`
78 78
             ORDER BY `date` DESC";
79
-        if (!is_null($limit)) {
80
-            $query .= "
79
+		if (!is_null($limit)) {
80
+			$query .= "
81 81
             LIMIT {$offset}, {$limit}";
82
-        }
82
+		}
83 83
 
84
-        return $this
85
-            ->connections
86
-            ->getRead()
87
-            ->fetchAll($query);
88
-    }
84
+		return $this
85
+			->connections
86
+			->getRead()
87
+			->fetchAll($query);
88
+	}
89 89
 
90
-    public function getPostsCount()
91
-    {
92
-        $query = "
90
+	public function getPostsCount()
91
+	{
92
+		$query = "
93 93
             SELECT COUNT(1) AS `count`
94 94
             FROM `jpemeric_stream`.`post`";
95 95
 
96
-        return $this
97
-            ->connections
98
-            ->getRead()
99
-            ->fetchValue($query);
100
-    }
96
+		return $this
97
+			->connections
98
+			->getRead()
99
+			->fetchValue($query);
100
+	}
101 101
 
102
-    public function getPostsByTag($tag, $limit = null, $offset = 0)
103
-    {
104
-        $query = "
102
+	public function getPostsByTag($tag, $limit = null, $offset = 0)
103
+	{
104
+		$query = "
105 105
             SELECT *
106 106
             FROM `jpemeric_stream`.`post`
107 107
             WHERE `tag` = :tag
108 108
             ORDER BY `date` DESC";
109
-        if (!is_null($limit)) {
110
-            $query .= "
109
+		if (!is_null($limit)) {
110
+			$query .= "
111 111
             LIMIT {$offset}, {$limit}";
112
-        }
113
-        $bindings = [
114
-            'tag' => $tag,
115
-        ];
116
-
117
-        return $this
118
-            ->connections
119
-            ->getRead()
120
-            ->fetchAll($query, $bindings);
121
-    }
122
-
123
-    public function getPostsByTagCount($tag)
124
-    {
125
-        $query = "
112
+		}
113
+		$bindings = [
114
+			'tag' => $tag,
115
+		];
116
+
117
+		return $this
118
+			->connections
119
+			->getRead()
120
+			->fetchAll($query, $bindings);
121
+	}
122
+
123
+	public function getPostsByTagCount($tag)
124
+	{
125
+		$query = "
126 126
             SELECT COUNT(1) AS `count`
127 127
             FROM `jpemeric_stream`.`post`
128 128
             WHERE `tag` = :tag";
129
-        $bindings = [
130
-            'tag' => $tag,
131
-        ];
132
-
133
-        return $this
134
-            ->connections
135
-            ->getRead()
136
-            ->fetchAll($query, $bindings);
137
-    }
129
+		$bindings = [
130
+			'tag' => $tag,
131
+		];
132
+
133
+		return $this
134
+			->connections
135
+			->getRead()
136
+			->fetchAll($query, $bindings);
137
+	}
138 138
 }
Please login to merge, or discard this patch.
src/Domain/Stream/Post/PostRepositoryInterface.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,10 +4,10 @@
 block discarded – undo
4 4
 
5 5
 interface PostRepositoryInterface
6 6
 {
7
-    public function getPostById($id);
8
-    public function getPostByType($type, $type_id);
9
-    public function getPosts($limit = null, $offset = 0);
10
-    public function getPostsCount();
11
-    public function getPostsByTag($tag, $limit = null, $offset = 0);
12
-    public function getPostsByTagCount($tag);
7
+	public function getPostById($id);
8
+	public function getPostByType($type, $type_id);
9
+	public function getPosts($limit = null, $offset = 0);
10
+	public function getPostsCount();
11
+	public function getPostsByTag($tag, $limit = null, $offset = 0);
12
+	public function getPostsByTagCount($tag);
13 13
 }
Please login to merge, or discard this patch.
controller/PageController.class.inc.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 
61 61
 	protected function get_recent_activity()
62 62
 	{
63
-    global $container;
64
-    $activityRepository = new Jacobemerick\Web\Domain\Stream\Post\MysqlPostRepository($container['db_connection_locator']);
65
-    $post_result = $activityRepository->getPosts(5);
63
+	global $container;
64
+	$activityRepository = new Jacobemerick\Web\Domain\Stream\Post\MysqlPostRepository($container['db_connection_locator']);
65
+	$post_result = $activityRepository->getPosts(5);
66 66
 
67 67
 		$post_array = array();
68 68
 		foreach($post_result as $row)
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 					if(strlen($row->title) > 0)
126 126
 						$post->title .= " I was hiking up around the {$row->title} area.";
127 127
 				}
128
-                else if ($row->type == 'walking') {
129
-                    $post->title = "Walked {$row->distance} miles and felt {$row->felt}.";
130
-                }
128
+				else if ($row->type == 'walking') {
129
+					$post->title = "Walked {$row->distance} miles and felt {$row->felt}.";
130
+				}
131 131
 			break;
132 132
 			case 'hulu' :
133 133
 				$row = HuluCollector::getRow($raw_post->type_id);
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 				Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
195 195
 		}
196 196
         
197
-        if (URLDecode::getSite() == 'waterfalls') {
198
-            Loader::load('view', '/WaterfallFoot');
199
-        } else {
200
-            Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE));
201
-        }
197
+		if (URLDecode::getSite() == 'waterfalls') {
198
+			Loader::load('view', '/WaterfallFoot');
199
+		} else {
200
+			Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE));
201
+		}
202 202
 		
203 203
 		if($view == '/404' || $view == '/503')
204 204
 			exit;
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 			'date' => date('Y')));
41 41
 		
42 42
 		Loader::loadInstance('utility', 'Database');
43
-		if(Database::isConnected() === false)
43
+		if (Database::isConnected() === false)
44 44
 			$this->unavailable();
45 45
 	}
46 46
 
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
     $post_result = $activityRepository->getPosts(5);
66 66
 
67 67
 		$post_array = array();
68
-		foreach($post_result as $row)
68
+		foreach ($post_result as $row)
69 69
 		{
70
-			$post_array[] = $this->expand_post((object) $row);;
70
+			$post_array[] = $this->expand_post((object) $row); ;
71 71
 		}
72 72
 		
73 73
 		return $post_array;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		
87 87
 		$post = new stdclass();
88 88
 		
89
-		switch($raw_post->type)
89
+		switch ($raw_post->type)
90 90
 		{
91 91
 			case 'blog' :
92 92
 				$row = BlogCollector::getRow($raw_post->type_id);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				$post->title = "Blogged about {$category}: <a href=\"{$row->url}\">{$row->title}</a>.";
98 98
 				$post->comments = $row->comments;
99 99
 				
100
-				if($format == 'full')
100
+				if ($format == 'full')
101 101
 					$post->image = Content::instance('FetchFirstPhoto', $row->body)->activate(false, 'standard');
102 102
 			break;
103 103
 			case 'book' :
@@ -106,23 +106,23 @@  discard block
 block discarded – undo
106 106
 				$post->type = 'book';
107 107
 				$post->title = "Just finished reading {$row->title} by {$row->author}.";
108 108
 				
109
-				if($format == 'full')
109
+				if ($format == 'full')
110 110
 					$post->image = "<img alt=\"{$row->title} by {$row->author}\" src=\"{$row->image}\" />";
111 111
 			break;
112 112
 			case 'distance' :
113 113
 				$row = DistanceCollector::getRow($raw_post->type_id);
114 114
 				
115 115
 				$post->type = 'distance';
116
-				if($row->type == 'running')
116
+				if ($row->type == 'running')
117 117
 				{
118 118
 					$post->title = "Ran {$row->distance} miles and felt {$row->felt}.";
119
-					if(strlen($row->message) > 0)
119
+					if (strlen($row->message) > 0)
120 120
 						$post->title .= " Afterwards, I was all like '{$row->message}'.";
121 121
 				}
122
-				else if($row->type == 'hiking')
122
+				else if ($row->type == 'hiking')
123 123
 				{
124 124
 					$post->title = "Hiked {$row->distance} miles and felt {$row->felt}.";
125
-					if(strlen($row->title) > 0)
125
+					if (strlen($row->title) > 0)
126 126
 						$post->title .= " I was hiking up around the {$row->title} area.";
127 127
 				}
128 128
                 else if ($row->type == 'walking') {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 				
141 141
 				$post->type = 'twitter';
142 142
 				
143
-				if($format == 'full')
143
+				if ($format == 'full')
144 144
 					$post->title = $row->text_formatted_full;
145 145
 				else
146 146
 					$post->title = $row->text_formatted;
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 				
154 154
 				$post->type = 'youtube';
155 155
 				
156
-				if($format == 'full')
156
+				if ($format == 'full')
157 157
 					$post->title = "Favorited {$row->title} by {$row->author} on YouTube.";
158 158
 				else
159 159
 					$post->title = "Favorited <a href=\"http://www.youtube.com/watch?feature=player_embedded&v={$row->video_id}\" rel=\"nofollow\" target=\"_blank\" title=\"{$row->content}\">{$row->title}</a> by {$row->author} on YouTube.";
160 160
 				
161
-				if($format == 'full')
161
+				if ($format == 'full')
162 162
 					$post->embed_code = "<iframe src=\"http://www.youtube.com/embed/{$row->video_id}?rel=0\" frameborder=\"0\" allowfullscreen></iframe>";
163 163
 			break;
164 164
 		}
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
 		$headers = $this->headers;
187 187
 		Header::$headers();
188 188
 		Loader::load('view', '/Head', $this->data_array['head']);
189
-		foreach($this->body_view_array as $view)
189
+		foreach ($this->body_view_array as $view)
190 190
 		{
191
-			if(substr($view, 0, 1) == '/')
191
+			if (substr($view, 0, 1) == '/')
192 192
 				Loader::load('view', $view, $this->data_array['body']);
193 193
 			else
194 194
 				Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
             Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE));
201 201
         }
202 202
 		
203
-		if($view == '/404' || $view == '/503')
203
+		if ($view == '/404' || $view == '/503')
204 204
 			exit;
205 205
 	}
206 206
 
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 		
262 262
 		$js_array = array();
263 263
 		
264
-		if(count($this->js_array) > 0)
264
+		if (count($this->js_array) > 0)
265 265
 			$js_array = array_merge($js_array, $this->js_array);
266 266
 		
267
-		if(count($js_array) > 0)
267
+		if (count($js_array) > 0)
268 268
 			$js_array = Asset::getJS($js_array);
269 269
 		
270 270
 		$this->set_head('css_link_array', $css_array);
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 
279 279
 	protected function eject()
280 280
 	{
281
-		if(get_class($this) !== 'Error404Controller')
281
+		if (get_class($this) !== 'Error404Controller')
282 282
 			Loader::loadNew('controller', '/Error404Controller')->activate();
283 283
 	}
284 284
 
285 285
 	protected function unavailable()
286 286
 	{
287
-		if(get_class($this) !== 'Error503Controller')
287
+		if (get_class($this) !== 'Error503Controller')
288 288
 			Loader::loadNew('controller', '/Error503Controller')->activate();
289 289
 	}
290 290
 
291 291
 	protected function redirect($uri, $method = 301)
292 292
 	{
293
-		switch($method)
293
+		switch ($method)
294 294
 		{
295 295
 			case 301 :
296
-				if(get_class($this) !== 'Error301Controller')
296
+				if (get_class($this) !== 'Error301Controller')
297 297
 					Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
298 298
 				break;
299 299
 			case 303 :
300
-				if(get_class($this) !== 'Error303Controller')
300
+				if (get_class($this) !== 'Error303Controller')
301 301
 					Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
302 302
 				break;
303 303
 		}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	private $comment_errors;
318 318
 	protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title)
319 319
 	{
320
-		if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment')
320
+		if (Request::hasPost() && Request::getPost('submit') == 'Submit Comment')
321 321
 		{
322 322
 			$parameters = array($site_id, $path, $redirect_url, $page_title);
323 323
 			$this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate();
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		$comment_array = array();
336 336
 		$comment_result = CommentCollector::getCommentsForURL($site, $path, $commenter->id);
337 337
 		
338
-		foreach($comment_result as $comment)
338
+		foreach ($comment_result as $comment)
339 339
 		{
340 340
 			$comment_object = new stdclass();
341 341
 			$comment_object->id = $comment->id;
@@ -345,12 +345,12 @@  discard block
 block discarded – undo
345 345
 			$comment_object->url = $comment->url;
346 346
 			$comment_object->trusted = $comment->trusted;
347 347
 			
348
-			if($comment->reply == 0 && Request::getPost('type') == $comment->id)
348
+			if ($comment->reply == 0 && Request::getPost('type') == $comment->id)
349 349
 				$comment_object->errors = $this->comment_errors;
350 350
 			else
351 351
 				$comment_object->errors = array();
352 352
 			
353
-			if($comment->reply == 0)
353
+			if ($comment->reply == 0)
354 354
 			{
355 355
 				$comment_object->replies = array();
356 356
 				$comment_array[$comment->id] = $comment_object;
@@ -381,21 +381,21 @@  discard block
 block discarded – undo
381 381
 		$commenter->website = '';
382 382
 		
383 383
 		$commenter_cookie = Cookie::instance('Commenter');
384
-		if(!$commenter_cookie->exists())
384
+		if (!$commenter_cookie->exists())
385 385
 			return $commenter;
386 386
 		
387 387
 		$commenter_cookie_value = $commenter_cookie->getValue();
388 388
 		$commenter_cookie_value = json_decode($commenter_cookie_value);
389 389
 		
390
-		if($commenter_cookie_value === NULL)
390
+		if ($commenter_cookie_value === NULL)
391 391
 			return $commenter;
392 392
 		
393
-		if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email))
393
+		if (!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email))
394 394
 			return $commenter;
395 395
 		
396 396
 		$commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : ''));
397 397
 		
398
-		if($commenter_object === NULL)
398
+		if ($commenter_object === NULL)
399 399
 			return $commenter;
400 400
 		
401 401
 		$commenter->id = $commenter_object->id;
Please login to merge, or discard this patch.