Completed
Push — master ( 68e9dc...5e9262 )
by Jacob
03:50
created
controller/waterfalls/ContactController.class.inc.php 1 patch
Braces   +20 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('controller', 'waterfalls/DefaultPageController');
4 4
 
5
-final class ContactController extends DefaultPageController
6
-{
5
+final class ContactController extends DefaultPageController
6
+{
7 7
 
8 8
 	private static $TITLE = 'Contact Jacob Emerick | Waterfalls of the Keweenaw';
9 9
 	private static $DESCRIPTION = 'Contact page to reach Jacob Emerick by email or social networks';
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 		'waterfalls',
15 15
 		'Jacob Emerick');
16 16
 
17
-	protected function set_head_data()
18
-	{
17
+	protected function set_head_data()
18
+	{
19 19
 		$this->set_title(self::$TITLE);
20 20
 		$this->set_description(self::$DESCRIPTION);
21 21
 		$this->set_keywords(self::$KEYWORD_ARRAY);
@@ -23,27 +23,31 @@  discard block
 block discarded – undo
23 23
 		parent::set_head_data();
24 24
 	}
25 25
 
26
-	protected function set_body_data()
27
-	{
26
+	protected function set_body_data()
27
+	{
28 28
 		$this->set_body('form_container', $this->process_form());
29 29
 		$this->set_body('view', 'Contact');
30 30
 		
31 31
 		parent::set_body_data();
32 32
 	}
33 33
 
34
-	private function process_form()
35
-	{
36
-		if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!')
37
-			return (object) array('display' => 'normal');
34
+	private function process_form()
35
+	{
36
+		if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') {
37
+					return (object) array('display' => 'normal');
38
+		}
38 39
 		
39 40
 		Loader::load('utility', 'Validate');
40 41
 		$error_result = array();
41
-		if(!Validate::checkRequest('post', 'name', 'string'))
42
-			$error_result['name'] = 'please enter your name';
43
-		if(!Validate::checkRequest('post', 'email', 'string'))
44
-			$error_result['email'] = 'please enter a valid email';
45
-		if(!Validate::checkRequest('post', 'message', 'string'))
46
-			$error_result['message'] = 'please write a message';
42
+		if(!Validate::checkRequest('post', 'name', 'string')) {
43
+					$error_result['name'] = 'please enter your name';
44
+		}
45
+		if(!Validate::checkRequest('post', 'email', 'string')) {
46
+					$error_result['email'] = 'please enter a valid email';
47
+		}
48
+		if(!Validate::checkRequest('post', 'message', 'string')) {
49
+					$error_result['message'] = 'please write a message';
50
+		}
47 51
 		
48 52
 		$values = (object) array(
49 53
 			'name' => Request::getPost('name'),
Please login to merge, or discard this patch.
controller/waterfalls/MapController.class.inc.php 1 patch
Braces   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 Loader::load('controller', 'waterfalls/DefaultPageController');
4 4
 Loader::load('collector', 'waterfall/WaterfallCollector');
5 5
 
6
-final class MapController extends DefaultPageController
7
-{
6
+final class MapController extends DefaultPageController
7
+{
8 8
 
9 9
     private static $TITLE = 'Map of Upper Peninsula Waterfalls';
10 10
     private static $DESCRIPTION = '';
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
         'Upper Tahquamenon Falls',
18 18
     );
19 19
 
20
-    public function __construct()
21
-    {
20
+    public function __construct()
21
+    {
22 22
         parent::__construct();
23 23
 
24 24
         $this->add_js('https://maps.googleapis.com/maps/api/js?sensor=false');
25 25
         $this->add_waterfall_js();
26 26
     }
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_title(self::$TITLE . ' | ' . self::$WEBSITE_TITLE);
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
         $this->set_keywords(self::$KEYWORD_ARRAY);
35 35
     }
36 36
 
37
-    protected function set_body_data($page_type = 'wide')
38
-    {
37
+    protected function set_body_data($page_type = 'wide')
38
+    {
39 39
         parent::set_body_data($page_type);
40 40
         
41 41
         $this->set_head('full_page_map', true);
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
         $this->set_body('view', 'Map');
44 44
     }
45 45
 
46
-    private function fetch_waterfall_list()
47
-    {
46
+    private function fetch_waterfall_list()
47
+    {
48 48
         $list = WaterfallCollector::getMapList();
49 49
         array_walk($list, array($this, 'parse_waterfall'));
50 50
         return $list;
51 51
     }
52 52
 
53
-    private function parse_waterfall(&$waterfall)
54
-    {
53
+    private function parse_waterfall(&$waterfall)
54
+    {
55 55
         $waterfall = (object) array(
56 56
             'name'  => $waterfall->name,
57 57
             'latitude' => $waterfall->latitude,
Please login to merge, or discard this patch.
controller/waterfalls/CountyListController.class.inc.php 1 patch
Braces   +29 added lines, -28 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 Loader::load('collector', 'waterfall/CountyCollector');
4 4
 Loader::load('controller', 'waterfalls/DefaultWaterfallListController');
5 5
 
6
-final class CountyListController extends DefaultWaterfallListController
7
-{
6
+final class CountyListController extends DefaultWaterfallListController
7
+{
8 8
 
9 9
 	private static $DEFAULT_TITLE = '%s Waterfalls, Page %d of %d';
10 10
 	private static $DEFAULT_DESCRIPTION = 'Page %d of %d of awesome waterfalls in %s, located in the northwestern wilds of Micigan\'s Upper Peninsula.';
@@ -23,19 +23,20 @@  discard block
 block discarded – undo
23 23
 
24 24
 	private $county;
25 25
 
26
-	public function __construct()
27
-	{
26
+	public function __construct()
27
+	{
28 28
 		$path = URLDecode::getPiece(1);
29 29
 		$this->county = CountyCollector::getByAlias($path);
30 30
 		
31
-		if(!$this->county)
32
-			$this->eject();
31
+		if(!$this->county) {
32
+					$this->eject();
33
+		}
33 34
 		
34 35
 		parent::__construct();
35 36
 	}
36 37
 
37
-	protected function get_initial_meta()
38
-	{
38
+	protected function get_initial_meta()
39
+	{
39 40
 		$meta_array = array();
40 41
 		
41 42
 		$meta_array['title'] = "{$this->county->name} Waterfalls | " . self::$WEBSITE_TITLE;
@@ -45,8 +46,8 @@  discard block
 block discarded – undo
45 46
 		return $meta_array;
46 47
 	}
47 48
 
48
-	protected function get_subsequent_meta()
49
-	{
49
+	protected function get_subsequent_meta()
50
+	{
50 51
 		$meta_array = array();
51 52
 		
52 53
 		$meta_array['title'] = sprintf(self::$DEFAULT_TITLE . ' | ' . self::$WEBSITE_TITLE, $this->county->name, $this->page, $this->page_count);
@@ -56,15 +57,15 @@  discard block
 block discarded – undo
56 57
 		return $meta_array;
57 58
 	}
58 59
 
59
-	private function get_keyword_array()
60
-	{
60
+	private function get_keyword_array()
61
+	{
61 62
 		$keyword_array = self::$KEYWORD_ARRAY;
62 63
 		array_unshift($keyword_array, strtolower($this->county->name));
63 64
 		return $keyword_array;
64 65
 	}
65 66
 
66
-	protected function get_initial_introduction()
67
-	{
67
+	protected function get_initial_introduction()
68
+	{
68 69
 		$introduction = array();
69 70
 		
70 71
 		$introduction['title'] = $this->county->title;
@@ -74,39 +75,39 @@  discard block
 block discarded – undo
74 75
 		return $introduction;
75 76
 	}
76 77
 
77
-	protected function get_subsequent_introduction()
78
-	{
78
+	protected function get_subsequent_introduction()
79
+	{
79 80
 		return array(
80 81
 			'title' => sprintf(self::$DEFAULT_HEADER, $this->page, $this->county->name));
81 82
 	}
82 83
 
83
-	protected function get_item_count_per_page()
84
-	{
84
+	protected function get_item_count_per_page()
85
+	{
85 86
 		return self::$ITEM_COUNT_PER_PAGE;
86 87
 	}
87 88
 
88
-	protected function get_page_number_piece()
89
-	{
89
+	protected function get_page_number_piece()
90
+	{
90 91
 		return URLDecode::getPiece(2);
91 92
 	}
92 93
 
93
-	protected function get_item_result($total, $offset)
94
-	{
94
+	protected function get_item_result($total, $offset)
95
+	{
95 96
 		return CountyCollector::getLogListForCounty($this->county->id, $total, $offset);
96 97
 	}
97 98
 
98
-	protected function get_item_count_result()
99
-	{
99
+	protected function get_item_count_result()
100
+	{
100 101
 		return CountyCollector::getLogCountForCounty($this->county->id);
101 102
 	}
102 103
 
103
-	protected function get_list_description_pattern()
104
-	{
104
+	protected function get_list_description_pattern()
105
+	{
105 106
 		return str_replace('%COUNTY%', $this->county->name, self::$NAVIGATION_DESCRIPTION);
106 107
 	}
107 108
 
108
-	protected function get_list_link_root()
109
-	{
109
+	protected function get_list_link_root()
110
+	{
110 111
 		return sprintf(self::$LINK_ROOT, $this->county->alias);
111 112
 	}
112 113
 
Please login to merge, or discard this patch.
controller/waterfalls/AboutController.class.inc.php 1 patch
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('controller', 'waterfalls/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 Website | Waterfalls of the Keweenaw';
9 9
     private static $DESCRIPTION = 'A little bit about the website, the area, and the reason why someone would hunt down a hundred and fifty waterfalls in the Upper Peninsula.';
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
         'Jacob Emerick',
15 15
     );
16 16
 
17
-    protected function set_head_data()
18
-    {
17
+    protected function set_head_data()
18
+    {
19 19
         parent::set_head_data();
20 20
         
21 21
         $this->set_title(self::$TITLE);
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
         $this->set_keywords(self::$KEYWORD_ARRAY);
24 24
     }
25 25
 
26
-    protected function set_body_data($page_type = 'normal')
27
-    {
26
+    protected function set_body_data($page_type = 'normal')
27
+    {
28 28
         parent::set_body_data($page_type);
29 29
         
30 30
         $this->set_body('view', 'About');
Please login to merge, or discard this patch.
controller/waterfalls/WaterfallController.class.inc.php 1 patch
Braces   +34 added lines, -32 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
     'waterfall/LogCollector'));
8 8
 Loader::load('controller', 'waterfalls/DefaultPageController');
9 9
 
10
-final class WaterfallController extends DefaultPageController
11
-{
10
+final class WaterfallController extends DefaultPageController
11
+{
12 12
 
13 13
     private static $STANDARD_IMAGE_NODE = '<img src="/photo/%s/%s-size-standard.jpg" alt="%s" height="600" width="800" />';
14 14
 
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 
19 19
     private $waterfall;
20 20
 
21
-    public function __construct()
22
-    {
21
+    public function __construct()
22
+    {
23 23
         parent::__construct();
24 24
 
25 25
         $path_watercourse = URLDecode::getPiece(1);
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
         $this->add_waterfall_js();
40 40
     }
41 41
 
42
-    protected function set_head_data()
43
-    {
42
+    protected function set_head_data()
43
+    {
44 44
         parent::set_head_data();
45 45
 
46 46
         $this->set_title("{$this->waterfall->name} on {$this->waterfall->watercourse} | " . self::$WEBSITE_TITLE);
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
         $this->set_keywords((array) $this->waterfall->name);
49 49
     }
50 50
 
51
-    protected function set_body_data($page_type = 'normal')
52
-    {
51
+    protected function set_body_data($page_type = 'normal')
52
+    {
53 53
         parent::set_body_data($page_type);
54 54
 
55 55
         $body_data = $this->format_waterfall_data($this->waterfall);
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
         $this->set_body('view', 'Fall');
61 61
     }
62 62
 
63
-    private function format_waterfall_data($waterfall)
64
-    {
63
+    private function format_waterfall_data($waterfall)
64
+    {
65 65
         $waterfall_data = array();
66 66
         $waterfall_data['introduction'] = $this->get_waterfall_introduction($waterfall);
67 67
         $waterfall_data['name'] = $waterfall->name;
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
         return $waterfall_data;
78 78
     }
79 79
 
80
-    private function get_waterfall_introduction($waterfall)
81
-    {
80
+    private function get_waterfall_introduction($waterfall)
81
+    {
82 82
         return array(
83 83
             'path' => "/{$waterfall->watercourse_alias}/{$waterfall->alias}/",
84 84
             'name' => $waterfall->name,
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
         );
88 88
     }
89 89
 
90
-    private function get_main_watercourse($alias)
91
-    {
90
+    private function get_main_watercourse($alias)
91
+    {
92 92
         $watercourse = WatercourseCollector::getByAlias($alias);
93 93
         if ($watercourse->parent != 0) {
94 94
             $watercourse = WatercourseCollector::getById($watercourse->parent);
@@ -101,19 +101,20 @@  discard block
 block discarded – undo
101 101
         );
102 102
     }
103 103
 
104
-    private function format_waterfall_content($content)
105
-    {
104
+    private function format_waterfall_content($content)
105
+    {
106 106
         $content = Content::instance('FixInternalLink', $content)->activate();
107 107
         
108 108
         return $content;
109 109
     }
110 110
 
111
-    private function get_album()
112
-    {
111
+    private function get_album()
112
+    {
113 113
         $album = array();
114 114
         
115
-        if($this->waterfall->album == 0)
116
-            return $album;
115
+        if($this->waterfall->album == 0) {
116
+                    return $album;
117
+        }
117 118
         
118 119
         $photo_list = AlbumCollector::getPhotoListForAlbum($this->waterfall->album);
119 120
         foreach($photo_list as $photo)
@@ -122,10 +123,11 @@  discard block
 block discarded – undo
122 123
             $photo_array['full_link'] = sprintf(self::$FULL_IMAGE_LINK, $photo->category, $photo->name);
123 124
             $photo_array['description'] = $photo->description;
124 125
             
125
-            if($photo->height < $photo->width)
126
-                list($height, $width) = array(75, 100);
127
-            else
128
-                list($height, $width) = array(100, 75);
126
+            if($photo->height < $photo->width) {
127
+                            list($height, $width) = array(75, 100);
128
+            } else {
129
+                            list($height, $width) = array(100, 75);
130
+            }
129 131
             
130 132
             $photo_array['image_node'] = sprintf(
131 133
                 self::$THUMB_IMAGE_NODE,
@@ -141,8 +143,8 @@  discard block
 block discarded – undo
141 143
         return $album;
142 144
     }
143 145
 
144
-	private function get_sidebar($waterfall)
145
-	{
146
+	private function get_sidebar($waterfall)
147
+	{
146 148
 		$sidebar_data = array();
147 149
 		$sidebar_data['name'] = $waterfall->name;
148 150
 		$sidebar_data['watercourse'] = $waterfall->watercourse;
@@ -174,8 +176,8 @@  discard block
 block discarded – undo
174 176
 		return $sidebar_data;
175 177
 	}
176 178
 
177
-    private function get_journal_list($waterfall)
178
-    {
179
+    private function get_journal_list($waterfall)
180
+    {
179 181
         $list = array();
180 182
         $log_result = LogCollector::getLogListForWaterfall($waterfall);
181 183
         foreach ($log_result as $log_row) {
@@ -189,8 +191,8 @@  discard block
 block discarded – undo
189 191
         return $list;
190 192
     }
191 193
 
192
-    private function get_map_piece($waterfall)
193
-    {
194
+    private function get_map_piece($waterfall)
195
+    {
194 196
         $map_holder = array();
195 197
         
196 198
         $url = 'https://maps.googleapis.com/maps/api/staticmap';
@@ -211,8 +213,8 @@  discard block
 block discarded – undo
211 213
         return (object) $map_holder;
212 214
     }
213 215
 
214
-    private function get_nearby_list($waterfall)
215
-    {
216
+    private function get_nearby_list($waterfall)
217
+    {
216 218
         $nearby_list = array();
217 219
         
218 220
         $result = WaterfallCollector::getNearbyList($waterfall);
Please login to merge, or discard this patch.
controller/waterfalls/PeriodListController.class.inc.php 1 patch
Braces   +27 added lines, -26 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 Loader::load('collector', 'waterfall/PeriodCollector');
4 4
 Loader::load('controller', 'waterfalls/DefaultLogListController');
5 5
 
6
-final class PeriodListController extends DefaultLogListController
7
-{
6
+final class PeriodListController extends DefaultLogListController
7
+{
8 8
 
9 9
 	private static $DEFAULT_TITLE = '%s Hiking Stories, Page %d of %d';
10 10
 	private static $DEFAULT_DESCRIPTION = 'Page %d of %d of epic %s hiking stories written by Jacob Emerick, all about his adventures hunting waterfalls in the Upper Peninsula of Michigan';
@@ -21,19 +21,20 @@  discard block
 block discarded – undo
21 21
 
22 22
 	private $period;
23 23
 
24
-	public function __construct()
25
-	{
24
+	public function __construct()
25
+	{
26 26
 		$alias = URLDecode::getPiece(2);
27 27
 		$this->period = PeriodCollector::getByAlias($alias);
28 28
 		
29
-		if(!$this->period)
30
-			$this->eject();
29
+		if(!$this->period) {
30
+					$this->eject();
31
+		}
31 32
 		
32 33
 		parent::__construct();
33 34
 	}
34 35
 
35
-	protected function get_initial_meta()
36
-	{
36
+	protected function get_initial_meta()
37
+	{
37 38
 		$meta_array = array();
38 39
 		
39 40
 		$meta_array['title'] = "Hiking Stories - {$this->period->name} | " . self::$WEBSITE_TITLE;
@@ -43,8 +44,8 @@  discard block
 block discarded – undo
43 44
 		return $meta_array;
44 45
 	}
45 46
 
46
-	protected function get_subsequent_meta()
47
-	{
47
+	protected function get_subsequent_meta()
48
+	{
48 49
 		$meta_array = array();
49 50
 		
50 51
 		$meta_array['title'] = sprintf(self::$DEFAULT_TITLE . ' | ' . self::$WEBSITE_TITLE, $this->period->name, $this->page, $this->page_count);
@@ -54,15 +55,15 @@  discard block
 block discarded – undo
54 55
 		return $meta_array;
55 56
 	}
56 57
 
57
-	private function get_keyword_array()
58
-	{
58
+	private function get_keyword_array()
59
+	{
59 60
 		$keyword_array = self::$KEYWORD_ARRAY;
60 61
 		array_unshift($keyword_array, strtolower($this->period->name));
61 62
 		return $keyword_array;
62 63
 	}
63 64
 
64
-	protected function get_initial_introduction()
65
-	{
65
+	protected function get_initial_introduction()
66
+	{
66 67
 		$introduction = array();
67 68
 		
68 69
 		$introduction['title'] = $this->period->title;
@@ -72,37 +73,37 @@  discard block
 block discarded – undo
72 73
 		return $introduction;
73 74
 	}
74 75
 
75
-	protected function get_subsequent_introduction()
76
-	{
76
+	protected function get_subsequent_introduction()
77
+	{
77 78
 		return array(
78 79
 			'title' => sprintf(self::$DEFAULT_HEADER, $this->page, $this->period->name));
79 80
 	}
80 81
 
81
-	protected function get_page_number_piece()
82
-	{
82
+	protected function get_page_number_piece()
83
+	{
83 84
 		return URLDecode::getPiece(3);
84 85
 	}
85 86
 
86
-	protected function get_item_result($total, $offset)
87
-	{
87
+	protected function get_item_result($total, $offset)
88
+	{
88 89
 		return PeriodCollector::getLogListForPeriod($this->period->id, $total, $offset);
89 90
 	}
90 91
 
91
-	protected function get_item_count_result()
92
-	{
92
+	protected function get_item_count_result()
93
+	{
93 94
 		return PeriodCollector::getLogCountForPeriod($this->period->id);
94 95
 	}
95 96
 
96
-	protected function get_list_description_pattern()
97
-	{
97
+	protected function get_list_description_pattern()
98
+	{
98 99
 		$period = $this->period->name;
99 100
 		$period = strtolower($period);
100 101
 		$navigation_description = str_replace('%PERIOD%', $period, self::$NAVIGATION_DESCRIPTION);
101 102
 		return $navigation_description;
102 103
 	}
103 104
 
104
-	protected function get_list_link_root()
105
-	{
105
+	protected function get_list_link_root()
106
+	{
106 107
 		return sprintf(self::$LINK_ROOT, $this->period->alias);
107 108
 	}
108 109
 
Please login to merge, or discard this patch.
controller/Error404Controller.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', '/PageController');
4 4
 
5
-class Error404Controller extends PageController
6
-{
5
+class Error404Controller extends PageController
6
+{
7 7
 
8
-	protected function set_head_data()
9
-	{
8
+	protected function set_head_data()
9
+	{
10 10
 		$this->set_header_method('send404');
11 11
 		$this->add_css('normalize');
12 12
 		$this->add_css('404');
@@ -16,15 +16,15 @@  discard block
 block discarded – undo
16 16
 		$this->set_head('keywords', '');
17 17
 	}
18 18
 
19
-	protected function set_body_data()
20
-	{
19
+	protected function set_body_data()
20
+	{
21 21
 		$this->set_body('site_list', $this->get_sites());
22 22
 		
23 23
 		$this->set_body_view('/404');
24 24
 	}
25 25
 
26
-	private function get_sites()
27
-	{
26
+	private function get_sites()
27
+	{
28 28
     return [
29 29
       [
30 30
         'url' => 'https://home.jacobemerick.com/',
Please login to merge, or discard this patch.
utility/content/ElapsedTimeContent.class.inc.php 1 patch
Braces   +63 added lines, -62 removed lines patch added patch discarded remove patch
@@ -2,72 +2,73 @@
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-final class ElapsedTimeContent extends Content
6
-{
5
+final class ElapsedTimeContent extends Content
6
+{
7 7
 
8
-	protected function execute()
9
-	{
8
+	protected function execute()
9
+	{
10 10
 		$previous_time = strtotime($this->content);
11 11
 		$current_time = time();
12 12
 		
13
-		if($current_time <= $previous_time)
14
-			$this->content = 'few seconds ago';
15
-		else if(($current_time - $previous_time) < 30)
16
-			$this->content = 'few seconds ago';
17
-		else if(($current_time - $previous_time) < 1.5 * 60)
18
-			$this->content = 'a minute ago';
19
-		else if(($current_time - $previous_time) < 4 * 60)
20
-			$this->content = 'few minutes ago';
21
-		else if(($current_time - $previous_time) < 7 * 60)
22
-			$this->content = 'five minutes ago';
23
-		else if(($current_time - $previous_time) < 12 * 60)
24
-			$this->content = 'ten minutes ago';
25
-		else if(($current_time - $previous_time) < 17 * 60)
26
-			$this->content = 'fifteen minutes ago';
27
-		else if(($current_time - $previous_time) < 22 * 60)
28
-			$this->content = 'twenty minutes ago';
29
-		else if(($current_time - $previous_time) < 37 * 60)
30
-			$this->content = 'half hour ago';
31
-		else if(($current_time - $previous_time) < 52 * 60)
32
-			$this->content = 'forty-five minutes ago';
33
-		else if(($current_time - $previous_time) < 1.5 * 60 * 60)
34
-			$this->content = 'an hour ago';
35
-		else if(($current_time - $previous_time) < 2.5 * 60 * 60)
36
-			$this->content = 'two hours ago';
37
-		else if(($current_time - $previous_time) < 3.5 * 60 * 60)
38
-			$this->content = 'three hours ago';
39
-		else if(($current_time - $previous_time) < 4.5 * 60 * 60)
40
-			$this->content = 'few hours ago';
41
-		else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm')
42
-			$this->content = 'this afternoon';
43
-		else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am')
44
-			$this->content = 'this morning';
45
-		else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17)
46
-			$this->content = 'yesterday evening';
47
-		else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm')
48
-			$this->content = 'yesterday afternoon';
49
-		else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am')
50
-			$this->content = 'yesterday morning';
51
-		else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2)
52
-			$this->content = 'two days ago';
53
-		else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3)
54
-			$this->content = 'three days ago';
55
-		else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time))
56
-			$this->content = 'earlier this week';
57
-		else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3)
58
-			$this->content = 'late last week';
59
-		else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1)
60
-			$this->content = 'early last week';
61
-		else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60)
62
-			$this->content = 'few weeks ago';
63
-		else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time))
64
-			$this->content = 'earlier this month';
65
-		else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1)
66
-			$this->content = 'last month';
67
-		else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60)
68
-			$this->content = 'several months ago';
69
-		else
70
-			$this->content = 'long ago';
13
+		if($current_time <= $previous_time) {
14
+					$this->content = 'few seconds ago';
15
+		} else if(($current_time - $previous_time) < 30) {
16
+					$this->content = 'few seconds ago';
17
+		} else if(($current_time - $previous_time) < 1.5 * 60) {
18
+					$this->content = 'a minute ago';
19
+		} else if(($current_time - $previous_time) < 4 * 60) {
20
+					$this->content = 'few minutes ago';
21
+		} else if(($current_time - $previous_time) < 7 * 60) {
22
+					$this->content = 'five minutes ago';
23
+		} else if(($current_time - $previous_time) < 12 * 60) {
24
+					$this->content = 'ten minutes ago';
25
+		} else if(($current_time - $previous_time) < 17 * 60) {
26
+					$this->content = 'fifteen minutes ago';
27
+		} else if(($current_time - $previous_time) < 22 * 60) {
28
+					$this->content = 'twenty minutes ago';
29
+		} else if(($current_time - $previous_time) < 37 * 60) {
30
+					$this->content = 'half hour ago';
31
+		} else if(($current_time - $previous_time) < 52 * 60) {
32
+					$this->content = 'forty-five minutes ago';
33
+		} else if(($current_time - $previous_time) < 1.5 * 60 * 60) {
34
+					$this->content = 'an hour ago';
35
+		} else if(($current_time - $previous_time) < 2.5 * 60 * 60) {
36
+					$this->content = 'two hours ago';
37
+		} else if(($current_time - $previous_time) < 3.5 * 60 * 60) {
38
+					$this->content = 'three hours ago';
39
+		} else if(($current_time - $previous_time) < 4.5 * 60 * 60) {
40
+					$this->content = 'few hours ago';
41
+		} else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') {
42
+					$this->content = 'this afternoon';
43
+		} else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') {
44
+					$this->content = 'this morning';
45
+		} else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) {
46
+					$this->content = 'yesterday evening';
47
+		} else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') {
48
+					$this->content = 'yesterday afternoon';
49
+		} else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') {
50
+					$this->content = 'yesterday morning';
51
+		} else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) {
52
+					$this->content = 'two days ago';
53
+		} else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) {
54
+					$this->content = 'three days ago';
55
+		} else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) {
56
+					$this->content = 'earlier this week';
57
+		} else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) {
58
+					$this->content = 'late last week';
59
+		} else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) {
60
+					$this->content = 'early last week';
61
+		} else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) {
62
+					$this->content = 'few weeks ago';
63
+		} else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) {
64
+					$this->content = 'earlier this month';
65
+		} else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) {
66
+					$this->content = 'last month';
67
+		} else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) {
68
+					$this->content = 'several months ago';
69
+		} else {
70
+					$this->content = 'long ago';
71
+		}
71 72
 	}
72 73
 
73 74
 }
74 75
\ No newline at end of file
Please login to merge, or discard this patch.
utility/content/SmartTrimContent.class.inc.php 1 patch
Braces   +42 added lines, -36 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-class SmartTrimContent extends Content
6
-{
5
+class SmartTrimContent extends Content
6
+{
7 7
 
8 8
 	private static $EXCLUDE_TAGS = array(
9 9
 		'a',
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 
25 25
 	private $is_trimmed;
26 26
 
27
-	protected function execute()
28
-	{
27
+	protected function execute()
28
+	{
29 29
 		$args = func_get_args();
30 30
 		if(count($args) < 1)
31 31
 		{
@@ -33,37 +33,40 @@  discard block
 block discarded – undo
33 33
 			return;
34 34
 		}
35 35
 		
36
-		if(count($args) == 2)
37
-			$etc = $args[1];
38
-		else
39
-			$etc = self::$ETC;
36
+		if(count($args) == 2) {
37
+					$etc = $args[1];
38
+		} else {
39
+					$etc = self::$ETC;
40
+		}
40 41
 		
41 42
 		$length = $args[0];
42 43
 		
43
-		if($length < strlen($this->content))
44
-			$this->trim_string($length);
45
-        else
46
-            $etc = '';
44
+		if($length < strlen($this->content)) {
45
+					$this->trim_string($length);
46
+		} else {
47
+                    $etc = '';
48
+        }
47 49
 		$this->check_exclude_tags();
48 50
 		$this->close_tags($etc);
49 51
 	}
50 52
 
51
-	private function trim_string($length)
52
-	{
53
+	private function trim_string($length)
54
+	{
53 55
 		$content = $this->trim_html_string($this->content, $length);
54 56
 		
55 57
 		$last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET);
56 58
 		$last_left_bracket_position = strripos($content, self::$LEFT_BRACKET);
57
-		if($last_left_bracket_position > $last_right_bracket_position)
58
-			$content = substr($content, 0, $last_left_bracket_position);
59
+		if($last_left_bracket_position > $last_right_bracket_position) {
60
+					$content = substr($content, 0, $last_left_bracket_position);
61
+		}
59 62
 		$content = trim($content);
60 63
 		
61 64
 		$this->content = $content;
62 65
 		$this->is_trimmed = true;
63 66
 	}
64 67
 
65
-	private function trim_html_string($content, $length)
66
-	{
68
+	private function trim_html_string($content, $length)
69
+	{
67 70
 		$content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content);
68 71
 		preg_match_all(self::$HTML_TAG_PATTERN, $content, $matches, PREG_OFFSET_CAPTURE);
69 72
 		$content = strip_tags($content);
@@ -76,20 +79,22 @@  discard block
 block discarded – undo
76 79
 		foreach($matches[0] as $match)
77 80
 		{
78 81
 			$max_length += strlen($match[0]);
79
-			if($max_length <= $match[1])
80
-				break;
82
+			if($max_length <= $match[1]) {
83
+							break;
84
+			}
81 85
 			
82 86
 			$content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]);
83 87
 		}
84 88
 		
85
-		if(substr($content, -7) == '</p><p>')
86
-			$content = substr($content, 0, -7);
89
+		if(substr($content, -7) == '</p><p>') {
90
+					$content = substr($content, 0, -7);
91
+		}
87 92
 		
88 93
 		return $content;
89 94
 	}
90 95
 
91
-	private function check_exclude_tags()
92
-	{
96
+	private function check_exclude_tags()
97
+	{
93 98
 		$content = $this->content;
94 99
 		$tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS);
95 100
 		preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE);
@@ -105,8 +110,8 @@  discard block
 block discarded – undo
105 110
 		$this->content = $content;
106 111
 	}
107 112
 
108
-	private function close_tags($etc)
109
-	{
113
+	private function close_tags($etc)
114
+	{
110 115
 		$content = $this->content;
111 116
 		$tags_preg = $this->get_tags_preg(self::$INCLUDE_TAGS);
112 117
 		preg_match_all($tags_preg, $content, $matches);
@@ -118,9 +123,9 @@  discard block
 block discarded – undo
118 123
 			{
119 124
 				$key = array_search($tag, $open_tags);
120 125
 				unset($open_tags[$key]);
121
-			}
122
-			else
123
-				$open_tags[] = $tag;
126
+			} else {
127
+							$open_tags[] = $tag;
128
+			}
124 129
 		}
125 130
 		
126 131
 		$open_tags = array_reverse($open_tags);
@@ -128,19 +133,20 @@  discard block
 block discarded – undo
128 133
 		{
129 134
 			foreach($open_tags as $key => $open_tag)
130 135
 			{
131
-				if($key == count($open_tags) - 1)
132
-					$content .= $etc;
136
+				if($key == count($open_tags) - 1) {
137
+									$content .= $etc;
138
+				}
133 139
 				$content .= "</{$open_tag}>";
134 140
 			}
135
-		}
136
-		else
137
-			$content .= $etc;
141
+		} else {
142
+					$content .= $etc;
143
+		}
138 144
 		
139 145
 		$this->content = $content;
140 146
 	}
141 147
 
142
-	private function get_tags_preg($tag_array)
143
-	{
148
+	private function get_tags_preg($tag_array)
149
+	{
144 150
 		return '@</?(' . implode('|', $tag_array) . ')@';
145 151
 	}
146 152
 
Please login to merge, or discard this patch.