@@ -5,56 +5,56 @@ |
||
5 | 5 | final class ImperialUnitContent extends Content |
6 | 6 | { |
7 | 7 | |
8 | - protected function execute($type = '') |
|
9 | - { |
|
10 | - $number = floatval($this->content); |
|
11 | - $number *= 39.37; // convert to inches |
|
8 | + protected function execute($type = '') |
|
9 | + { |
|
10 | + $number = floatval($this->content); |
|
11 | + $number *= 39.37; // convert to inches |
|
12 | 12 | |
13 | - if ($type == '') { |
|
14 | - if ($number > (12 * 3 * 1760 * 5)) { |
|
15 | - $type = 'full miles'; |
|
16 | - } else if ($number > (12 * 3 * 1760 * .5)) { |
|
17 | - $type = 'tenth miles'; |
|
18 | - } else if ($number > (12 * 3 * 150)) { |
|
19 | - $type = 'yards'; |
|
20 | - } else if ($number > (12 * 10)) { |
|
21 | - $type = 'feet'; |
|
22 | - } else { |
|
23 | - $type = 'inches'; |
|
24 | - } |
|
25 | - } |
|
13 | + if ($type == '') { |
|
14 | + if ($number > (12 * 3 * 1760 * 5)) { |
|
15 | + $type = 'full miles'; |
|
16 | + } else if ($number > (12 * 3 * 1760 * .5)) { |
|
17 | + $type = 'tenth miles'; |
|
18 | + } else if ($number > (12 * 3 * 150)) { |
|
19 | + $type = 'yards'; |
|
20 | + } else if ($number > (12 * 10)) { |
|
21 | + $type = 'feet'; |
|
22 | + } else { |
|
23 | + $type = 'inches'; |
|
24 | + } |
|
25 | + } |
|
26 | 26 | |
27 | - switch ($type) { |
|
28 | - case 'full miles' : |
|
29 | - $this->content = number_format(round($number / (12 * 3 * 1760))) . ' miles'; |
|
30 | - break; |
|
31 | - case 'tenth miles' : |
|
32 | - $this->content = round($number / (12 * 3 * 1760), 1) . ' miles'; |
|
33 | - break; |
|
34 | - case 'yards' : |
|
35 | - $this->content = number_format(round($number / (12 * 3))) . ' yards'; |
|
36 | - break; |
|
37 | - case 'feet' : |
|
38 | - $this->content = number_format(round($number / 12)) . "'"; |
|
39 | - break; |
|
40 | - case 'inches' : |
|
41 | - $feet = floor($number / 12); |
|
27 | + switch ($type) { |
|
28 | + case 'full miles' : |
|
29 | + $this->content = number_format(round($number / (12 * 3 * 1760))) . ' miles'; |
|
30 | + break; |
|
31 | + case 'tenth miles' : |
|
32 | + $this->content = round($number / (12 * 3 * 1760), 1) . ' miles'; |
|
33 | + break; |
|
34 | + case 'yards' : |
|
35 | + $this->content = number_format(round($number / (12 * 3))) . ' yards'; |
|
36 | + break; |
|
37 | + case 'feet' : |
|
38 | + $this->content = number_format(round($number / 12)) . "'"; |
|
39 | + break; |
|
40 | + case 'inches' : |
|
41 | + $feet = floor($number / 12); |
|
42 | 42 | |
43 | - $inches = $number - $feet * 12; |
|
44 | - $inches = round($inches); |
|
43 | + $inches = $number - $feet * 12; |
|
44 | + $inches = round($inches); |
|
45 | 45 | |
46 | - if ($inches == 12) { |
|
47 | - $feet++; |
|
48 | - $inches = 0; |
|
49 | - } |
|
46 | + if ($inches == 12) { |
|
47 | + $feet++; |
|
48 | + $inches = 0; |
|
49 | + } |
|
50 | 50 | |
51 | - $this->content = ''; |
|
52 | - $this->content .= number_format($feet) . "'"; |
|
53 | - if (isset($inches) && $inches > 0) { |
|
54 | - $this->content .= " {$inches}\""; |
|
55 | - } |
|
56 | - break; |
|
57 | - } |
|
58 | - } |
|
51 | + $this->content = ''; |
|
52 | + $this->content .= number_format($feet) . "'"; |
|
53 | + if (isset($inches) && $inches > 0) { |
|
54 | + $this->content .= " {$inches}\""; |
|
55 | + } |
|
56 | + break; |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -11,9 +11,9 @@ |
||
11 | 11 | |
12 | 12 | protected function execute() |
13 | 13 | { |
14 | - foreach(self::$UNACCEPTABLE_CHARACTER_ARRAY as $match => $replace) |
|
14 | + foreach (self::$UNACCEPTABLE_CHARACTER_ARRAY as $match => $replace) |
|
15 | 15 | { |
16 | - if(stristr($this->content, $match)) |
|
16 | + if (stristr($this->content, $match)) |
|
17 | 17 | $this->content = str_replace($match, $replace, $this->content); |
18 | 18 | } |
19 | 19 | return; |
@@ -13,8 +13,9 @@ |
||
13 | 13 | { |
14 | 14 | foreach(self::$UNACCEPTABLE_CHARACTER_ARRAY as $match => $replace) |
15 | 15 | { |
16 | - if(stristr($this->content, $match)) |
|
17 | - $this->content = str_replace($match, $replace, $this->content); |
|
16 | + if(stristr($this->content, $match)) { |
|
17 | + $this->content = str_replace($match, $replace, $this->content); |
|
18 | + } |
|
18 | 19 | } |
19 | 20 | return; |
20 | 21 | } |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | |
11 | 11 | protected function execute() |
12 | 12 | { |
13 | - if(stristr($this->content, '#') === false) |
|
13 | + if (stristr($this->content, '#') === false) |
|
14 | 14 | return; |
15 | 15 | |
16 | 16 | // yeah yeah, i'm currently ignoring the link, whatevs |
17 | 17 | $parameters = func_get_args(); |
18 | - if(count($parameters) > 1 || (count($parameters) == 1 && !is_array($parameters[0]))) |
|
18 | + if (count($parameters) > 1 || (count($parameters) == 1 && !is_array($parameters[0]))) |
|
19 | 19 | { |
20 | 20 | trigger_error('Unexpected parameters passed into AutolinkTwitterHash!'); |
21 | 21 | return; |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | $parameters = array_shift($parameters); |
24 | 24 | |
25 | 25 | $found_hash = preg_match_all(self::$HASH_PATTERN, $this->content, $matches, PREG_SET_ORDER); |
26 | - if($found_hash === false || $found_hash === 0) |
|
26 | + if ($found_hash === false || $found_hash === 0) |
|
27 | 27 | return; |
28 | 28 | |
29 | - foreach($matches as $match) |
|
29 | + foreach ($matches as $match) |
|
30 | 30 | { |
31 | 31 | $replacement = $this->get_replacement_link($match[1], $match[0]); |
32 | 32 | $this->content = str_replace($match[0], $replacement, $this->content); |
@@ -10,8 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | protected function execute() |
12 | 12 | { |
13 | - if(stristr($this->content, '#') === false) |
|
14 | - return; |
|
13 | + if(stristr($this->content, '#') === false) { |
|
14 | + return; |
|
15 | + } |
|
15 | 16 | |
16 | 17 | // yeah yeah, i'm currently ignoring the link, whatevs |
17 | 18 | $parameters = func_get_args(); |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | $parameters = array_shift($parameters); |
24 | 25 | |
25 | 26 | $found_hash = preg_match_all(self::$HASH_PATTERN, $this->content, $matches, PREG_SET_ORDER); |
26 | - if($found_hash === false || $found_hash === 0) |
|
27 | - return; |
|
27 | + if($found_hash === false || $found_hash === 0) { |
|
28 | + return; |
|
29 | + } |
|
28 | 30 | |
29 | 31 | foreach($matches as $match) |
30 | 32 | { |
@@ -10,61 +10,61 @@ |
||
10 | 10 | $previous_time = strtotime($this->content); |
11 | 11 | $current_time = time(); |
12 | 12 | |
13 | - if($current_time <= $previous_time) |
|
13 | + if ($current_time <= $previous_time) |
|
14 | 14 | $this->content = 'few seconds ago'; |
15 | - else if(($current_time - $previous_time) < 30) |
|
15 | + else if (($current_time - $previous_time) < 30) |
|
16 | 16 | $this->content = 'few seconds ago'; |
17 | - else if(($current_time - $previous_time) < 1.5 * 60) |
|
17 | + else if (($current_time - $previous_time) < 1.5 * 60) |
|
18 | 18 | $this->content = 'a minute ago'; |
19 | - else if(($current_time - $previous_time) < 4 * 60) |
|
19 | + else if (($current_time - $previous_time) < 4 * 60) |
|
20 | 20 | $this->content = 'few minutes ago'; |
21 | - else if(($current_time - $previous_time) < 7 * 60) |
|
21 | + else if (($current_time - $previous_time) < 7 * 60) |
|
22 | 22 | $this->content = 'five minutes ago'; |
23 | - else if(($current_time - $previous_time) < 12 * 60) |
|
23 | + else if (($current_time - $previous_time) < 12 * 60) |
|
24 | 24 | $this->content = 'ten minutes ago'; |
25 | - else if(($current_time - $previous_time) < 17 * 60) |
|
25 | + else if (($current_time - $previous_time) < 17 * 60) |
|
26 | 26 | $this->content = 'fifteen minutes ago'; |
27 | - else if(($current_time - $previous_time) < 22 * 60) |
|
27 | + else if (($current_time - $previous_time) < 22 * 60) |
|
28 | 28 | $this->content = 'twenty minutes ago'; |
29 | - else if(($current_time - $previous_time) < 37 * 60) |
|
29 | + else if (($current_time - $previous_time) < 37 * 60) |
|
30 | 30 | $this->content = 'half hour ago'; |
31 | - else if(($current_time - $previous_time) < 52 * 60) |
|
31 | + else if (($current_time - $previous_time) < 52 * 60) |
|
32 | 32 | $this->content = 'forty-five minutes ago'; |
33 | - else if(($current_time - $previous_time) < 1.5 * 60 * 60) |
|
33 | + else if (($current_time - $previous_time) < 1.5 * 60 * 60) |
|
34 | 34 | $this->content = 'an hour ago'; |
35 | - else if(($current_time - $previous_time) < 2.5 * 60 * 60) |
|
35 | + else if (($current_time - $previous_time) < 2.5 * 60 * 60) |
|
36 | 36 | $this->content = 'two hours ago'; |
37 | - else if(($current_time - $previous_time) < 3.5 * 60 * 60) |
|
37 | + else if (($current_time - $previous_time) < 3.5 * 60 * 60) |
|
38 | 38 | $this->content = 'three hours ago'; |
39 | - else if(($current_time - $previous_time) < 4.5 * 60 * 60) |
|
39 | + else if (($current_time - $previous_time) < 4.5 * 60 * 60) |
|
40 | 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') |
|
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 | 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') |
|
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 | 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) |
|
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 | 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') |
|
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 | 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') |
|
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 | 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) |
|
51 | + else if (($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) |
|
52 | 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) |
|
53 | + else if (($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) |
|
54 | 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)) |
|
55 | + else if (($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) |
|
56 | 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) |
|
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 | 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) |
|
59 | + else if (($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) |
|
60 | 60 | $this->content = 'early last week'; |
61 | - else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) |
|
61 | + else if (($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) |
|
62 | 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)) |
|
63 | + else if (($current_time - $previous_time) < 1.25 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) |
|
64 | 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) |
|
65 | + else if (($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) |
|
66 | 66 | $this->content = 'last month'; |
67 | - else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) |
|
67 | + else if (($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) |
|
68 | 68 | $this->content = 'several months ago'; |
69 | 69 | else |
70 | 70 | $this->content = 'long ago'; |
@@ -10,64 +10,65 @@ |
||
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 |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | |
11 | 11 | protected function execute() |
12 | 12 | { |
13 | - if(stristr($this->content, '@') === false) |
|
13 | + if (stristr($this->content, '@') === false) |
|
14 | 14 | return; |
15 | 15 | |
16 | 16 | // yeah yeah, i'm currently ignoring the link, whatevs |
17 | 17 | $parameters = func_get_args(); |
18 | - if(count($parameters) > 1 || (count($parameters) == 1 && !is_array($parameters[0]))) |
|
18 | + if (count($parameters) > 1 || (count($parameters) == 1 && !is_array($parameters[0]))) |
|
19 | 19 | { |
20 | 20 | trigger_error('Unexpected parameters passed into AutolinkTwitterUser!'); |
21 | 21 | return; |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | $parameters = array_shift($parameters); |
24 | 24 | |
25 | 25 | $found_user = preg_match_all(self::$USER_PATTERN, $this->content, $matches, PREG_SET_ORDER); |
26 | - if($found_user === false || $found_user === 0) |
|
26 | + if ($found_user === false || $found_user === 0) |
|
27 | 27 | return; |
28 | 28 | |
29 | - foreach($matches as $match) |
|
29 | + foreach ($matches as $match) |
|
30 | 30 | { |
31 | 31 | $replacement = $this->get_replacement_link($match[1], $match[0]); |
32 | 32 | $this->content = str_replace($match[0], $replacement, $this->content); |
@@ -10,8 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | protected function execute() |
12 | 12 | { |
13 | - if(stristr($this->content, '@') === false) |
|
14 | - return; |
|
13 | + if(stristr($this->content, '@') === false) { |
|
14 | + return; |
|
15 | + } |
|
15 | 16 | |
16 | 17 | // yeah yeah, i'm currently ignoring the link, whatevs |
17 | 18 | $parameters = func_get_args(); |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | $parameters = array_shift($parameters); |
24 | 25 | |
25 | 26 | $found_user = preg_match_all(self::$USER_PATTERN, $this->content, $matches, PREG_SET_ORDER); |
26 | - if($found_user === false || $found_user === 0) |
|
27 | - return; |
|
27 | + if($found_user === false || $found_user === 0) { |
|
28 | + return; |
|
29 | + } |
|
28 | 30 | |
29 | 31 | foreach($matches as $match) |
30 | 32 | { |
@@ -22,13 +22,13 @@ |
||
22 | 22 | |
23 | 23 | public function activate() |
24 | 24 | { |
25 | - foreach($this->post_array as $post) |
|
25 | + foreach ($this->post_array as $post) |
|
26 | 26 | { |
27 | 27 | $blog_result = BlogCollector::getBlogByTitle($post->title); |
28 | - if($blog_result !== null) |
|
28 | + if ($blog_result !== null) |
|
29 | 29 | { |
30 | 30 | $comments = CommentCollector::getCommentCountForURL(2, $post->path); |
31 | - if($blog_result->comments != $comments) |
|
31 | + if ($blog_result->comments != $comments) |
|
32 | 32 | { |
33 | 33 | $query = sprintf(self::$UPDATE_COMMENTS_QUERY, $comments, $blog_result->id); |
34 | 34 | Database::execute($query); |
@@ -33,8 +33,7 @@ |
||
33 | 33 | $query = sprintf(self::$UPDATE_COMMENTS_QUERY, $comments, $blog_result->id); |
34 | 34 | Database::execute($query); |
35 | 35 | } |
36 | - } |
|
37 | - else |
|
36 | + } else |
|
38 | 37 | { |
39 | 38 | $title = Database::escape($post->title); |
40 | 39 | $category = Database::escape($post->category); |
@@ -13,23 +13,23 @@ discard block |
||
13 | 13 | |
14 | 14 | function __construct() |
15 | 15 | { |
16 | - if(Loader::isLive()) |
|
16 | + if (Loader::isLive()) |
|
17 | 17 | $handle[] = self::$live_root; |
18 | 18 | else |
19 | 19 | $handle[] = self::$test_root; |
20 | 20 | |
21 | 21 | $i = 0; |
22 | - while(isset($handle[$i])) |
|
22 | + while (isset($handle[$i])) |
|
23 | 23 | { |
24 | 24 | $path = $handle[$i]; |
25 | 25 | $fh = opendir($path); |
26 | - while(false !== ($file = readdir($fh))) |
|
26 | + while (false !== ($file = readdir($fh))) |
|
27 | 27 | { |
28 | - if($file != '.' && $file != '..') |
|
28 | + if ($file != '.' && $file != '..') |
|
29 | 29 | { |
30 | - if(is_dir("{$path}/{$file}")) |
|
30 | + if (is_dir("{$path}/{$file}")) |
|
31 | 31 | $handle[] = "{$path}/{$file}"; |
32 | - if($file == 'error.log') |
|
32 | + if ($file == 'error.log') |
|
33 | 33 | $this->error_files[] = "{$path}/{$file}"; |
34 | 34 | } |
35 | 35 | } |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | { |
43 | 43 | $message = ''; |
44 | 44 | |
45 | - if(count($this->error_files) > 0) |
|
45 | + if (count($this->error_files) > 0) |
|
46 | 46 | { |
47 | 47 | $message .= "Errors from flat-file logs.\n\n"; |
48 | - foreach($this->error_files as $error_file) |
|
48 | + foreach ($this->error_files as $error_file) |
|
49 | 49 | { |
50 | 50 | $contents = file_get_contents($error_file); |
51 | 51 | $message .= "{$error_file}\n{$contents}\n\n"; |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | $mail->setMessage($message); |
61 | 61 | $mail->send(); |
62 | 62 | |
63 | - if(count($this->error_files) > 0) |
|
63 | + if (count($this->error_files) > 0) |
|
64 | 64 | { |
65 | - foreach($this->error_files as $error_file) |
|
65 | + foreach ($this->error_files as $error_file) |
|
66 | 66 | { |
67 | 67 | // if(file_exists($error_file)) |
68 | 68 | // unlink($error_file); |
@@ -13,10 +13,11 @@ discard block |
||
13 | 13 | |
14 | 14 | function __construct() |
15 | 15 | { |
16 | - if(Loader::isLive()) |
|
17 | - $handle[] = self::$live_root; |
|
18 | - else |
|
19 | - $handle[] = self::$test_root; |
|
16 | + if(Loader::isLive()) { |
|
17 | + $handle[] = self::$live_root; |
|
18 | + } else { |
|
19 | + $handle[] = self::$test_root; |
|
20 | + } |
|
20 | 21 | |
21 | 22 | $i = 0; |
22 | 23 | while(isset($handle[$i])) |
@@ -27,10 +28,12 @@ discard block |
||
27 | 28 | { |
28 | 29 | if($file != '.' && $file != '..') |
29 | 30 | { |
30 | - if(is_dir("{$path}/{$file}")) |
|
31 | - $handle[] = "{$path}/{$file}"; |
|
32 | - if($file == 'error.log') |
|
33 | - $this->error_files[] = "{$path}/{$file}"; |
|
31 | + if(is_dir("{$path}/{$file}")) { |
|
32 | + $handle[] = "{$path}/{$file}"; |
|
33 | + } |
|
34 | + if($file == 'error.log') { |
|
35 | + $this->error_files[] = "{$path}/{$file}"; |
|
36 | + } |
|
34 | 37 | } |
35 | 38 | } |
36 | 39 | closedir($fh); |
@@ -50,9 +53,9 @@ discard block |
||
50 | 53 | $contents = file_get_contents($error_file); |
51 | 54 | $message .= "{$error_file}\n{$contents}\n\n"; |
52 | 55 | } |
53 | - } |
|
54 | - else |
|
55 | - $message = 'No errors found in the flat-files!'; |
|
56 | + } else { |
|
57 | + $message = 'No errors found in the flat-files!'; |
|
58 | + } |
|
56 | 59 | |
57 | 60 | $mail = new Mail(); |
58 | 61 | $mail->setToAddress('EMAIL', 'Jacob Emerick'); |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | |
20 | 20 | public function activate() |
21 | 21 | { |
22 | - if(!$this->xml) |
|
22 | + if (!$this->xml) |
|
23 | 23 | return $this->error('Could not connect to feed.'); |
24 | 24 | |
25 | - foreach($this->xml->channel->item as $item) |
|
25 | + foreach ($this->xml->channel->item as $item) |
|
26 | 26 | { |
27 | - if(strtotime($item->user_read_at) <= 0) |
|
27 | + if (strtotime($item->user_read_at) <= 0) |
|
28 | 28 | continue; |
29 | 29 | |
30 | 30 | $title = $item->title; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $date_added = date('Y-m-d H:i:s', strtotime($item->user_date_created)); |
43 | 43 | |
44 | 44 | $book_result = BookCollector::getBookByFields($title, $author); |
45 | - if($book_result !== null) |
|
45 | + if ($book_result !== null) |
|
46 | 46 | continue; |
47 | 47 | |
48 | 48 | $query = sprintf(self::$QUERY, $title, $author, $link, $description, $image, $date_read, $date_added); |
@@ -19,13 +19,15 @@ discard block |
||
19 | 19 | |
20 | 20 | public function activate() |
21 | 21 | { |
22 | - if(!$this->xml) |
|
23 | - return $this->error('Could not connect to feed.'); |
|
22 | + if(!$this->xml) { |
|
23 | + return $this->error('Could not connect to feed.'); |
|
24 | + } |
|
24 | 25 | |
25 | 26 | foreach($this->xml->channel->item as $item) |
26 | 27 | { |
27 | - if(strtotime($item->user_read_at) <= 0) |
|
28 | - continue; |
|
28 | + if(strtotime($item->user_read_at) <= 0) { |
|
29 | + continue; |
|
30 | + } |
|
29 | 31 | |
30 | 32 | $title = $item->title; |
31 | 33 | $title = trim($title); |
@@ -42,8 +44,9 @@ discard block |
||
42 | 44 | $date_added = date('Y-m-d H:i:s', strtotime($item->user_date_created)); |
43 | 45 | |
44 | 46 | $book_result = BookCollector::getBookByFields($title, $author); |
45 | - if($book_result !== null) |
|
46 | - continue; |
|
47 | + if($book_result !== null) { |
|
48 | + continue; |
|
49 | + } |
|
47 | 50 | |
48 | 51 | $query = sprintf(self::$QUERY, $title, $author, $link, $description, $image, $date_read, $date_added); |
49 | 52 | Database::execute($query); |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | |
21 | 21 | public function activate() |
22 | 22 | { |
23 | - if(!$this->json) |
|
23 | + if (!$this->json) |
|
24 | 24 | return $this->error('Could not connect to feed.'); |
25 | 25 | |
26 | 26 | $count = 0; |
27 | - foreach($this->json->entries as $entry) |
|
27 | + foreach ($this->json->entries as $entry) |
|
28 | 28 | { |
29 | 29 | $type = $entry->workout->activity_type; |
30 | 30 | $type = strtolower($type); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $date = date('Y-m-d H:i:s', strtotime($entry->at)); |
42 | 42 | |
43 | 43 | $distance_result = DistanceCollector::getDistanceByFields($date, $type, $distance); |
44 | - if($distance_result !== null) |
|
44 | + if ($distance_result !== null) |
|
45 | 45 | continue; |
46 | 46 | |
47 | 47 | $query = sprintf(self::$QUERY, $type, $distance, $url, $felt, $title, $message, $date); |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | |
21 | 21 | public function activate() |
22 | 22 | { |
23 | - if(!$this->json) |
|
24 | - return $this->error('Could not connect to feed.'); |
|
23 | + if(!$this->json) { |
|
24 | + return $this->error('Could not connect to feed.'); |
|
25 | + } |
|
25 | 26 | |
26 | 27 | $count = 0; |
27 | 28 | foreach($this->json->entries as $entry) |
@@ -41,8 +42,9 @@ discard block |
||
41 | 42 | $date = date('Y-m-d H:i:s', strtotime($entry->at)); |
42 | 43 | |
43 | 44 | $distance_result = DistanceCollector::getDistanceByFields($date, $type, $distance); |
44 | - if($distance_result !== null) |
|
45 | - continue; |
|
45 | + if($distance_result !== null) { |
|
46 | + continue; |
|
47 | + } |
|
46 | 48 | |
47 | 49 | $query = sprintf(self::$QUERY, $type, $distance, $url, $felt, $title, $message, $date); |
48 | 50 | Database::execute($query); |