@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | protected function execute() |
10 | 10 | { |
11 | 11 | $is_acceptable = true; |
12 | - foreach($this->getUnacceptableWords() as $unacceptableWord) |
|
12 | + foreach ($this->getUnacceptableWords() as $unacceptableWord) |
|
13 | 13 | { |
14 | - if(stristr($unacceptableWord->word, $this->content)) |
|
14 | + if (stristr($unacceptableWord->word, $this->content)) |
|
15 | 15 | $is_acceptable = false; |
16 | 16 | } |
17 | 17 | return $is_acceptable; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | private $unacceptableWords; |
21 | 21 | private function getUnacceptableWords() |
22 | 22 | { |
23 | - if(!$this->unacceptableWords) |
|
23 | + if (!$this->unacceptableWords) |
|
24 | 24 | $this->unacceptableWords = UnacceptableWordCollector::getWords(); |
25 | 25 | return $this->unacceptableWords; |
26 | 26 | } |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | $is_acceptable = true; |
12 | 12 | foreach($this->getUnacceptableWords() as $unacceptableWord) |
13 | 13 | { |
14 | - if(stristr($unacceptableWord->word, $this->content)) |
|
15 | - $is_acceptable = false; |
|
14 | + if(stristr($unacceptableWord->word, $this->content)) { |
|
15 | + $is_acceptable = false; |
|
16 | + } |
|
16 | 17 | } |
17 | 18 | return $is_acceptable; |
18 | 19 | } |
@@ -20,8 +21,9 @@ discard block |
||
20 | 21 | private $unacceptableWords; |
21 | 22 | private function getUnacceptableWords() |
22 | 23 | { |
23 | - if(!$this->unacceptableWords) |
|
24 | - $this->unacceptableWords = UnacceptableWordCollector::getWords(); |
|
24 | + if(!$this->unacceptableWords) { |
|
25 | + $this->unacceptableWords = UnacceptableWordCollector::getWords(); |
|
26 | + } |
|
25 | 27 | return $this->unacceptableWords; |
26 | 28 | } |
27 | 29 |
@@ -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 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | protected function execute($is_absolute = false) |
11 | 11 | { |
12 | 12 | preg_match_all(self::$IMAGE_PLACEHOLDER_MATCH, $this->content, $matches); |
13 | - foreach($matches[1] as $key => $match) |
|
13 | + foreach ($matches[1] as $key => $match) |
|
14 | 14 | { |
15 | 15 | $image_path = $this->get_file_path($match); |
16 | 16 | $this->content = str_replace($matches[0][$key], $image_path, $this->content); |
@@ -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); |
@@ -20,28 +20,28 @@ discard block |
||
20 | 20 | |
21 | 21 | public function activate() |
22 | 22 | { |
23 | - if(!$this->xml) |
|
23 | + if (!$this->xml) |
|
24 | 24 | return $this->error('Could not connect to feed.'); |
25 | 25 | |
26 | 26 | $count = 0; |
27 | - foreach($this->xml->channel->item as $item) |
|
27 | + foreach ($this->xml->channel->item as $item) |
|
28 | 28 | { |
29 | 29 | $date = date('Y-m-d H:i:s', strtotime($item->pubDate)); |
30 | 30 | |
31 | - if(preg_match_all('/((rated)|(wrote a review about)|(subscribed to)|(watched) )(.+)/', $item->title, $title_array) > 0) |
|
31 | + if (preg_match_all('/((rated)|(wrote a review about)|(subscribed to)|(watched) )(.+)/', $item->title, $title_array) > 0) |
|
32 | 32 | { |
33 | 33 | $video = array_pop($title_array); |
34 | 34 | $video = current($video); |
35 | 35 | $video = substr($video, 0, -1); |
36 | 36 | } |
37 | - else if(preg_match_all('/(.*) - (s\d+) | (e\d+) - (.*)/', $item->title, $title_array) > 0) |
|
37 | + else if (preg_match_all('/(.*) - (s\d+) | (e\d+) - (.*)/', $item->title, $title_array) > 0) |
|
38 | 38 | $video = "{$title_array[1][0]}: {$title_array[4][1]}"; |
39 | 39 | else |
40 | 40 | $video = $item->title; |
41 | 41 | |
42 | 42 | $url = $item->link; |
43 | 43 | |
44 | - if($item->category == 'Vote') |
|
44 | + if ($item->category == 'Vote') |
|
45 | 45 | { |
46 | 46 | $description = stristr($video, 'and gave it'); |
47 | 47 | $description = substr($description, 12); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | else |
54 | 54 | $description = ''; |
55 | 55 | |
56 | - switch($item->category) |
|
56 | + switch ($item->category) |
|
57 | 57 | { |
58 | 58 | case 'ActivityViewedVideo' : |
59 | 59 | $action = 1; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | $hulu_result = HuluCollector::getHuluByFields($video, $action); |
76 | - if($hulu_result !== null) |
|
76 | + if ($hulu_result !== null) |
|
77 | 77 | continue; |
78 | 78 | |
79 | 79 | $display = ( |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | |
21 | 21 | public function activate() |
22 | 22 | { |
23 | - if(!$this->xml) |
|
24 | - return $this->error('Could not connect to feed.'); |
|
23 | + if(!$this->xml) { |
|
24 | + return $this->error('Could not connect to feed.'); |
|
25 | + } |
|
25 | 26 | |
26 | 27 | $count = 0; |
27 | 28 | foreach($this->xml->channel->item as $item) |
@@ -33,11 +34,11 @@ discard block |
||
33 | 34 | $video = array_pop($title_array); |
34 | 35 | $video = current($video); |
35 | 36 | $video = substr($video, 0, -1); |
36 | - } |
|
37 | - else if(preg_match_all('/(.*) - (s\d+) | (e\d+) - (.*)/', $item->title, $title_array) > 0) |
|
38 | - $video = "{$title_array[1][0]}: {$title_array[4][1]}"; |
|
39 | - else |
|
40 | - $video = $item->title; |
|
37 | + } else if(preg_match_all('/(.*) - (s\d+) | (e\d+) - (.*)/', $item->title, $title_array) > 0) { |
|
38 | + $video = "{$title_array[1][0]}: {$title_array[4][1]}"; |
|
39 | + } else { |
|
40 | + $video = $item->title; |
|
41 | + } |
|
41 | 42 | |
42 | 43 | $url = $item->link; |
43 | 44 | |
@@ -49,9 +50,9 @@ discard block |
||
49 | 50 | $description = substr($description, 0, 1); |
50 | 51 | $text = substr($video, 0, strpos($video, 'and gave it') - 1); |
51 | 52 | $video = trim($video); |
52 | - } |
|
53 | - else |
|
54 | - $description = ''; |
|
53 | + } else { |
|
54 | + $description = ''; |
|
55 | + } |
|
55 | 56 | |
56 | 57 | switch($item->category) |
57 | 58 | { |
@@ -73,8 +74,9 @@ discard block |
||
73 | 74 | } |
74 | 75 | |
75 | 76 | $hulu_result = HuluCollector::getHuluByFields($video, $action); |
76 | - if($hulu_result !== null) |
|
77 | - continue; |
|
77 | + if($hulu_result !== null) { |
|
78 | + continue; |
|
79 | + } |
|
78 | 80 | |
79 | 81 | $display = ( |
80 | 82 | Content::instance('Acceptable', $video)->check() === true && |