Completed
Push — master ( 72ee7f...4775c0 )
by Jacob
03:43
created
utility/Search.class.inc.php 1 patch
Braces   +15 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,49 +1,44 @@  discard block
 block discarded – undo
1 1
 <?
2 2
 
3
-final class Search
4
-{
3
+final class Search
4
+{
5 5
 
6 6
 	private $query;
7 7
 	private $result;
8 8
 	private $weight;
9 9
 
10
-	function __construct()
11
-	{
10
+	function __construct() {
12 11
 		return $this;
13 12
 	}
14 13
 
15
-	public function setQuery($query)
16
-	{
14
+	public function setQuery($query) {
17 15
 		$this->query = $query;
18 16
 		return $this;
19 17
 	}
20 18
 
21
-	public function setResult($array)
22
-	{
19
+	public function setResult($array) {
23 20
 		$this->result = $array;
24 21
 		return $this;
25 22
 	}
26 23
 
27
-	public function setWeight($weight)
28
-	{
24
+	public function setWeight($weight) {
29 25
 		$this->weight = $weight;
30 26
 		return $this;
31 27
 	}
32 28
 
33
-	public static function instance()
34
-	{
29
+	public static function instance() {
35 30
 		$reflection = new ReflectionClass('Search');
36 31
 		return $reflection->newInstance();
37 32
 	}
38 33
 
39
-	public function perform()
40
-	{
34
+	public function perform() {
41 35
 		$weighted_array = array();
42 36
 		foreach($this->result as $row)
43 37
 		{
44 38
 			$weight = $this->get_search_weight($row);
45
-			if($weight > 0)
46
-				$weighted_array[$row['id']] = $weight;
39
+			if($weight > 0) {
40
+							$weighted_array[$row['id']] = $weight;
41
+			}
47 42
 		}
48 43
 		arsort($weighted_array);
49 44
 		
@@ -52,15 +47,15 @@  discard block
 block discarded – undo
52 47
 		{
53 48
 			foreach($this->result as $row)
54 49
 			{
55
-				if($row['id'] == $id)
56
-					$final_array[] = $row;
50
+				if($row['id'] == $id) {
51
+									$final_array[] = $row;
52
+				}
57 53
 			}
58 54
 		}
59 55
 		return $final_array;
60 56
 	}
61 57
 
62
-	private function get_search_weight($row)
63
-	{
58
+	private function get_search_weight($row) {
64 59
 		$weight = 0;
65 60
 		foreach($this->weight as $weight_array)
66 61
 		{
Please login to merge, or discard this patch.
utility/content/URLSafeContent.class.inc.php 1 patch
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,11 +2,10 @@
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-class URLSafeContent extends Content
6
-{
5
+class URLSafeContent extends Content
6
+{
7 7
 
8
-	protected function execute()
9
-	{
8
+	protected function execute() {
10 9
 		$this->content = strtolower(str_replace(' ', '-', $this->content));
11 10
 	}
12 11
 
Please login to merge, or discard this patch.
utility/content/MarkupCodeContent.class.inc.php 1 patch
Braces   +8 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-final class MarkupCodeContent extends Content
6
-{
5
+final class MarkupCodeContent extends Content
6
+{
7 7
 
8 8
 	private static $MARKUP_DELIMITER = '@<pre( rel="(.*?)")?>(.*?)</pre>@s';
9 9
 
10
-	protected function execute($title = '')
11
-	{
10
+	protected function execute($title = '') {
12 11
 		preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches);
13
-		if(count($matches[1]) == 0)
14
-			return;
12
+		if(count($matches[1]) == 0) {
13
+					return;
14
+		}
15 15
 		
16 16
 		foreach($matches[3] as $key => $match)
17 17
 		{
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
 		return;
26 26
 	}
27 27
 
28
-	private function wrap_in_list($content)
29
-	{
28
+	private function wrap_in_list($content) {
30 29
 		$content_array = explode("\n", $content);
31 30
 		
32 31
 		foreach($content_array as $key => $row)
@@ -44,8 +43,7 @@  discard block
 block discarded – undo
44 43
 		return $content;
45 44
 	}
46 45
 
47
-	private function highlight_code($content, $type)
48
-	{
46
+	private function highlight_code($content, $type) {
49 47
 		switch($type)
50 48
 		{
51 49
 			default :
Please login to merge, or discard this patch.
utility/content/SmartTrimContent.class.inc.php 1 patch
Braces   +36 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,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 	private $is_trimmed;
26 26
 
27
-	protected function execute()
28
-	{
27
+	protected function execute() {
29 28
 		$args = func_get_args();
30 29
 		if(count($args) < 1)
31 30
 		{
@@ -33,37 +32,38 @@  discard block
 block discarded – undo
33 32
 			return;
34 33
 		}
35 34
 		
36
-		if(count($args) == 2)
37
-			$etc = $args[1];
38
-		else
39
-			$etc = self::$ETC;
35
+		if(count($args) == 2) {
36
+					$etc = $args[1];
37
+		} else {
38
+					$etc = self::$ETC;
39
+		}
40 40
 		
41 41
 		$length = $args[0];
42 42
 		
43
-		if($length < strlen($this->content))
44
-			$this->trim_string($length);
45
-        else
46
-            $etc = '';
43
+		if($length < strlen($this->content)) {
44
+					$this->trim_string($length);
45
+		} else {
46
+                    $etc = '';
47
+        }
47 48
 		$this->check_exclude_tags();
48 49
 		$this->close_tags($etc);
49 50
 	}
50 51
 
51
-	private function trim_string($length)
52
-	{
52
+	private function trim_string($length) {
53 53
 		$content = $this->trim_html_string($this->content, $length);
54 54
 		
55 55
 		$last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET);
56 56
 		$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);
57
+		if($last_left_bracket_position > $last_right_bracket_position) {
58
+					$content = substr($content, 0, $last_left_bracket_position);
59
+		}
59 60
 		$content = trim($content);
60 61
 		
61 62
 		$this->content = $content;
62 63
 		$this->is_trimmed = true;
63 64
 	}
64 65
 
65
-	private function trim_html_string($content, $length)
66
-	{
66
+	private function trim_html_string($content, $length) {
67 67
 		$content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content);
68 68
 		preg_match_all(self::$HTML_TAG_PATTERN, $content, $matches, PREG_OFFSET_CAPTURE);
69 69
 		$content = strip_tags($content);
@@ -76,20 +76,21 @@  discard block
 block discarded – undo
76 76
 		foreach($matches[0] as $match)
77 77
 		{
78 78
 			$max_length += strlen($match[0]);
79
-			if($max_length <= $match[1])
80
-				break;
79
+			if($max_length <= $match[1]) {
80
+							break;
81
+			}
81 82
 			
82 83
 			$content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]);
83 84
 		}
84 85
 		
85
-		if(substr($content, -7) == '</p><p>')
86
-			$content = substr($content, 0, -7);
86
+		if(substr($content, -7) == '</p><p>') {
87
+					$content = substr($content, 0, -7);
88
+		}
87 89
 		
88 90
 		return $content;
89 91
 	}
90 92
 
91
-	private function check_exclude_tags()
92
-	{
93
+	private function check_exclude_tags() {
93 94
 		$content = $this->content;
94 95
 		$tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS);
95 96
 		preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE);
@@ -105,8 +106,7 @@  discard block
 block discarded – undo
105 106
 		$this->content = $content;
106 107
 	}
107 108
 
108
-	private function close_tags($etc)
109
-	{
109
+	private function close_tags($etc) {
110 110
 		$content = $this->content;
111 111
 		$tags_preg = $this->get_tags_preg(self::$INCLUDE_TAGS);
112 112
 		preg_match_all($tags_preg, $content, $matches);
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 			{
119 119
 				$key = array_search($tag, $open_tags);
120 120
 				unset($open_tags[$key]);
121
-			}
122
-			else
123
-				$open_tags[] = $tag;
121
+			} else {
122
+							$open_tags[] = $tag;
123
+			}
124 124
 		}
125 125
 		
126 126
 		$open_tags = array_reverse($open_tags);
@@ -128,19 +128,19 @@  discard block
 block discarded – undo
128 128
 		{
129 129
 			foreach($open_tags as $key => $open_tag)
130 130
 			{
131
-				if($key == count($open_tags) - 1)
132
-					$content .= $etc;
131
+				if($key == count($open_tags) - 1) {
132
+									$content .= $etc;
133
+				}
133 134
 				$content .= "</{$open_tag}>";
134 135
 			}
135
-		}
136
-		else
137
-			$content .= $etc;
136
+		} else {
137
+					$content .= $etc;
138
+		}
138 139
 		
139 140
 		$this->content = $content;
140 141
 	}
141 142
 
142
-	private function get_tags_preg($tag_array)
143
-	{
143
+	private function get_tags_preg($tag_array) {
144 144
 		return '@</?(' . implode('|', $tag_array) . ')@';
145 145
 	}
146 146
 
Please login to merge, or discard this patch.
utility/content/CleanCommentContent.class.inc.php 1 patch
Braces   +16 added lines, -22 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
-final class CleanCommentContent extends Content
6
-{
5
+final class CleanCommentContent extends Content
6
+{
7 7
 
8 8
 	private static $LINK_PATTERN = '@<a.*href=["\']([^"\']*)["\'].*>(.*)</a>@i';
9 9
 	private static $BOLD_PATTERN = '@<b.*>(.*)</b>@i';
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 	private $replacement_array = array();
24 24
 
25
-	protected function execute()
26
-	{
25
+	protected function execute() {
27 26
 		$this->process_element(self::$CODE_PATTERN, self::$CODE_REPLACE);
28 27
 		$this->process_element(self::$LINK_PATTERN, self::$LINK_REPLACE);
29 28
 		$this->process_element(self::$ITALIC_PATTERN, self::$ITALIC_REPLACE);
@@ -36,12 +35,12 @@  discard block
 block discarded – undo
36 35
 		$this->replace_element_patterns();
37 36
 	}
38 37
 
39
-	private function process_element($pattern, $replace)
40
-	{
38
+	private function process_element($pattern, $replace) {
41 39
 		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
42 40
 		
43
-		if($match_count < 1)
44
-			return;
41
+		if($match_count < 1) {
42
+					return;
43
+		}
45 44
 		
46 45
 		foreach($matches as $match)
47 46
 		{
@@ -54,13 +53,11 @@  discard block
 block discarded – undo
54 53
 		}
55 54
 	}
56 55
 
57
-	private function create_placeholder($text)
58
-	{
56
+	private function create_placeholder($text) {
59 57
 		return md5($text . rand());
60 58
 	}
61 59
 
62
-	private function create_full_match_pattern($text)
63
-	{
60
+	private function create_full_match_pattern($text) {
64 61
 		$pattern = '';
65 62
 		$pattern .= '@';
66 63
 		$pattern .= preg_quote($text, '@');
@@ -70,17 +67,16 @@  discard block
 block discarded – undo
70 67
 		return $pattern;
71 68
 	}
72 69
 
73
-	private function strip_extra_tags()
74
-	{
70
+	private function strip_extra_tags() {
75 71
 		$this->content = strip_tags($this->content);
76 72
 	}
77 73
 
78
-	private function link_unlinked_urls($pattern, $replace)
79
-	{
74
+	private function link_unlinked_urls($pattern, $replace) {
80 75
 		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
81 76
 		
82
-		if($match_count < 1)
83
-			return;
77
+		if($match_count < 1) {
78
+					return;
79
+		}
84 80
 		
85 81
 		foreach($matches as $match)
86 82
 		{
@@ -92,13 +88,11 @@  discard block
 block discarded – undo
92 88
 		}
93 89
 	}
94 90
 
95
-	private function add_line_breaks()
96
-	{
91
+	private function add_line_breaks() {
97 92
 		$this->content = preg_replace(self::$LINE_BREAK_PATTERN, self::$LINE_BREAK_REPLACE, $this->content);
98 93
 	}
99 94
 
100
-	private function replace_element_patterns()
101
-	{
95
+	private function replace_element_patterns() {
102 96
 		foreach($this->replacement_array as $key => $replace)
103 97
 		{
104 98
 			$this->content = str_replace($key, $replace, $this->content);
Please login to merge, or discard this patch.
utility/content/FetchFirstPhotoContent.class.inc.php 1 patch
Braces   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2,30 +2,28 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-final class FetchFirstPhotoContent extends Content
6
-{
5
+final class FetchFirstPhotoContent extends Content
6
+{
7 7
 
8 8
 	private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@';
9 9
 	private static $IMAGE_NODE = '<img src="%sphoto/%s/%s-size-%s.%s" height="%d" width="%d" alt="%s" />';
10 10
 	private static $DEFAULT_RETURN = '';
11 11
 
12
-	protected function execute($is_absolute = false, $size = 'thumb')
13
-	{
14
-		if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1)
15
-			$this->content = $this->get_thumb($match[1], $is_absolute, $size);
16
-		else
17
-			$this->content = self::$DEFAULT_RETURN;
12
+	protected function execute($is_absolute = false, $size = 'thumb') {
13
+		if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) {
14
+					$this->content = $this->get_thumb($match[1], $is_absolute, $size);
15
+		} else {
16
+					$this->content = self::$DEFAULT_RETURN;
17
+		}
18 18
 		return;
19 19
 	}
20 20
 
21
-	private function get_file_path($category, $photo, $size, $extension)
22
-	{
21
+	private function get_file_path($category, $photo, $size, $extension) {
23 22
 		$path = "{$category}/{$photo}-size-{$size}.{$extension}";
24 23
 		return Loader::getImagePath('photo', $path);
25 24
 	}
26 25
 
27
-	private function get_thumb($string, $is_absolute, $size)
28
-	{
26
+	private function get_thumb($string, $is_absolute, $size) {
29 27
 		list($category, $file_name) = explode('/', $string);
30 28
 		list($photo, $extension) = explode('.', $file_name);
31 29
 		
@@ -34,16 +32,18 @@  discard block
 block discarded – undo
34 32
 		
35 33
 		Loader::load('collector', 'image/PhotoCollector');
36 34
 		$photo_result = PhotoCollector::fetchRow($category, $photo);
37
-		if($photo_result == false)
38
-			return '';
35
+		if($photo_result == false) {
36
+					return '';
37
+		}
39 38
 		
40 39
 		$height = $file_size[1];
41 40
 		$width = $file_size[0];
42 41
 		$description = $photo_result->description;
43 42
 		
44 43
 		$domain = '/';
45
-		if($is_absolute)
46
-			$domain = Loader::getRootURL(URLDecode::getSite());
44
+		if($is_absolute) {
45
+					$domain = Loader::getRootURL(URLDecode::getSite());
46
+		}
47 47
 
48 48
 		return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description);
49 49
 	}
Please login to merge, or discard this patch.
utility/content/ImperialUnitContent.class.inc.php 1 patch
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,11 +2,10 @@
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-final class ImperialUnitContent extends Content
6
-{
5
+final class ImperialUnitContent extends Content
6
+{
7 7
 
8
-    protected function execute($type = '')
9
-    {
8
+    protected function execute($type = '') {
10 9
         $number = floatval($this->content);
11 10
         $number *= 39.37; // convert to inches
12 11
         
Please login to merge, or discard this patch.
utility/content/FixPhotoContent.class.inc.php 1 patch
Braces   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -2,15 +2,14 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-final class FixPhotoContent extends Content
6
-{
5
+final class FixPhotoContent extends Content
6
+{
7 7
 
8 8
 	private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@';
9 9
 	private static $ERROR_CONTENT = '<div class="photo-holder"><p class="photo-caption">Image (%s) could not be found!</p></div>';
10 10
 	private static $PHOTO_CONTENT = '<div class="photo-holder"><img src="%sphoto/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" /><p class="photo-caption">%s</p></div>';
11 11
 
12
-	protected function execute($is_absolute = false, $size = 'medium')
13
-	{
12
+	protected function execute($is_absolute = false, $size = 'medium') {
14 13
 		preg_match_all(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $matches);
15 14
 		foreach($matches[1] as $key => $match)
16 15
 		{
@@ -20,14 +19,12 @@  discard block
 block discarded – undo
20 19
 		return;
21 20
 	}
22 21
 
23
-	private function get_file_path($category, $photo, $size, $extension)
24
-	{
22
+	private function get_file_path($category, $photo, $size, $extension) {
25 23
 		$path = "{$category}/{$photo}-size-{$size}.{$extension}";
26 24
 		return Loader::getImagePath('photo', $path);
27 25
 	}
28 26
 
29
-	private function get_photo_content($string, $size, $is_absolute)
30
-	{
27
+	private function get_photo_content($string, $size, $is_absolute) {
31 28
 		list($category, $file_name) = explode('/', $string);
32 29
 		list($photo, $extension) = explode('.', $file_name);
33 30
 		
@@ -37,16 +34,18 @@  discard block
 block discarded – undo
37 34
 		
38 35
 		Loader::load('collector', 'image/PhotoCollector');
39 36
 		$photo_result = PhotoCollector::fetchRow($category, $photo);
40
-		if($photo_result == false)
41
-			return '';
37
+		if($photo_result == false) {
38
+					return '';
39
+		}
42 40
 		
43 41
 		$height = $file_size[1];
44 42
 		$width = $file_size[0];
45 43
 		$description = $photo_result->description;
46 44
         
47 45
 		$domain = '/';
48
-		if($is_absolute)
49
-			$domain = Loader::getRootUrl('blog');
46
+		if($is_absolute) {
47
+					$domain = Loader::getRootUrl('blog');
48
+		}
50 49
 		
51 50
 		return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description);
52 51
 	}
Please login to merge, or discard this patch.
utility/content/ElapsedTimeContent.class.inc.php 1 patch
Braces   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -2,72 +2,72 @@
 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() {
10 9
 		$previous_time = strtotime($this->content);
11 10
 		$current_time = time();
12 11
 		
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';
12
+		if($current_time <= $previous_time) {
13
+					$this->content = 'few seconds ago';
14
+		} else if(($current_time - $previous_time) < 30) {
15
+					$this->content = 'few seconds ago';
16
+		} else if(($current_time - $previous_time) < 1.5 * 60) {
17
+					$this->content = 'a minute ago';
18
+		} else if(($current_time - $previous_time) < 4 * 60) {
19
+					$this->content = 'few minutes ago';
20
+		} else if(($current_time - $previous_time) < 7 * 60) {
21
+					$this->content = 'five minutes ago';
22
+		} else if(($current_time - $previous_time) < 12 * 60) {
23
+					$this->content = 'ten minutes ago';
24
+		} else if(($current_time - $previous_time) < 17 * 60) {
25
+					$this->content = 'fifteen minutes ago';
26
+		} else if(($current_time - $previous_time) < 22 * 60) {
27
+					$this->content = 'twenty minutes ago';
28
+		} else if(($current_time - $previous_time) < 37 * 60) {
29
+					$this->content = 'half hour ago';
30
+		} else if(($current_time - $previous_time) < 52 * 60) {
31
+					$this->content = 'forty-five minutes ago';
32
+		} else if(($current_time - $previous_time) < 1.5 * 60 * 60) {
33
+					$this->content = 'an hour ago';
34
+		} else if(($current_time - $previous_time) < 2.5 * 60 * 60) {
35
+					$this->content = 'two hours ago';
36
+		} else if(($current_time - $previous_time) < 3.5 * 60 * 60) {
37
+					$this->content = 'three hours ago';
38
+		} else if(($current_time - $previous_time) < 4.5 * 60 * 60) {
39
+					$this->content = 'few hours ago';
40
+		} else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') {
41
+					$this->content = 'this afternoon';
42
+		} else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') {
43
+					$this->content = 'this morning';
44
+		} 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) {
45
+					$this->content = 'yesterday evening';
46
+		} else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') {
47
+					$this->content = 'yesterday afternoon';
48
+		} else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') {
49
+					$this->content = 'yesterday morning';
50
+		} else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) {
51
+					$this->content = 'two days ago';
52
+		} else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) {
53
+					$this->content = 'three days ago';
54
+		} else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) {
55
+					$this->content = 'earlier this week';
56
+		} 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) {
57
+					$this->content = 'late last week';
58
+		} else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) {
59
+					$this->content = 'early last week';
60
+		} else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) {
61
+					$this->content = 'few weeks ago';
62
+		} else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) {
63
+					$this->content = 'earlier this month';
64
+		} else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) {
65
+					$this->content = 'last month';
66
+		} else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) {
67
+					$this->content = 'several months ago';
68
+		} else {
69
+					$this->content = 'long ago';
70
+		}
71 71
 	}
72 72
 
73 73
 }
74 74
\ No newline at end of file
Please login to merge, or discard this patch.