@@ -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 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | protected function execute($is_absolute = false, $size = 'thumb') |
13 | 13 | { |
14 | - if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
14 | + if (preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
15 | 15 | $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
16 | 16 | else |
17 | 17 | $this->content = self::$DEFAULT_RETURN; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | Loader::load('collector', 'image/PhotoCollector'); |
36 | 36 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
37 | - if($photo_result == false) |
|
37 | + if ($photo_result == false) |
|
38 | 38 | return ''; |
39 | 39 | |
40 | 40 | $height = $file_size[1]; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $description = $photo_result->description; |
43 | 43 | |
44 | 44 | $domain = '/'; |
45 | - if($is_absolute) |
|
45 | + if ($is_absolute) |
|
46 | 46 | $domain = Loader::getRootUrl(); |
47 | 47 | |
48 | 48 | return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
@@ -11,10 +11,11 @@ discard block |
||
11 | 11 | |
12 | 12 | protected function execute($is_absolute = false, $size = 'thumb') |
13 | 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; |
|
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; |
|
18 | + } |
|
18 | 19 | return; |
19 | 20 | } |
20 | 21 | |
@@ -34,16 +35,18 @@ discard block |
||
34 | 35 | |
35 | 36 | Loader::load('collector', 'image/PhotoCollector'); |
36 | 37 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
37 | - if($photo_result == false) |
|
38 | - return ''; |
|
38 | + if($photo_result == false) { |
|
39 | + return ''; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | $height = $file_size[1]; |
41 | 43 | $width = $file_size[0]; |
42 | 44 | $description = $photo_result->description; |
43 | 45 | |
44 | 46 | $domain = '/'; |
45 | - if($is_absolute) |
|
46 | - $domain = Loader::getRootUrl(); |
|
47 | + if($is_absolute) { |
|
48 | + $domain = Loader::getRootUrl(); |
|
49 | + } |
|
47 | 50 | |
48 | 51 | return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
49 | 52 | } |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | { |
41 | 41 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
42 | 42 | |
43 | - if($match_count < 1) |
|
43 | + if ($match_count < 1) |
|
44 | 44 | return; |
45 | 45 | |
46 | - foreach($matches as $match) |
|
46 | + foreach ($matches as $match) |
|
47 | 47 | { |
48 | 48 | $full_match = array_shift($match); |
49 | 49 | $placeholder = $this->create_placeholder($full_match); |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | { |
80 | 80 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
81 | 81 | |
82 | - if($match_count < 1) |
|
82 | + if ($match_count < 1) |
|
83 | 83 | return; |
84 | 84 | |
85 | - foreach($matches as $match) |
|
85 | + foreach ($matches as $match) |
|
86 | 86 | { |
87 | 87 | $full_match = array_shift($match); |
88 | 88 | $full_match_pattern = $this->create_full_match_pattern($full_match); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | private function replace_element_patterns() |
101 | 101 | { |
102 | - foreach($this->replacement_array as $key => $replace) |
|
102 | + foreach ($this->replacement_array as $key => $replace) |
|
103 | 103 | { |
104 | 104 | $this->content = str_replace($key, $replace, $this->content); |
105 | 105 | } |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | { |
41 | 41 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
42 | 42 | |
43 | - if($match_count < 1) |
|
44 | - return; |
|
43 | + if($match_count < 1) { |
|
44 | + return; |
|
45 | + } |
|
45 | 46 | |
46 | 47 | foreach($matches as $match) |
47 | 48 | { |
@@ -79,8 +80,9 @@ discard block |
||
79 | 80 | { |
80 | 81 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
81 | 82 | |
82 | - if($match_count < 1) |
|
83 | - return; |
|
83 | + if($match_count < 1) { |
|
84 | + return; |
|
85 | + } |
|
84 | 86 | |
85 | 87 | foreach($matches as $match) |
86 | 88 | { |
@@ -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,21 +20,21 @@ |
||
20 | 20 | private static $USER_MENTION_LINK = '<a href="https://twitter.com/%1$s" rel="nofollow" target="_blank" title="%2$s (%1$s) on Twitter">@%1$s</a>'; |
21 | 21 | private static $MEDIA_LINK = '<a class="photo" href="%s" rel="nofollow" target="_blank" title="%s"><img src="%s:%s" alt="%s" height="%s" width="%s" /></a>'; |
22 | 22 | |
23 | - private $consumer_key; |
|
24 | - private $consumer_secret; |
|
25 | - private $access_token; |
|
26 | - private $access_secret; |
|
23 | + private $consumer_key; |
|
24 | + private $consumer_secret; |
|
25 | + private $access_token; |
|
26 | + private $access_secret; |
|
27 | 27 | |
28 | 28 | private $json; |
29 | 29 | |
30 | 30 | public function __construct() |
31 | 31 | { |
32 | - global $config; |
|
32 | + global $config; |
|
33 | 33 | |
34 | - $this->consumer_key = $config->twitter->consumer_key; |
|
35 | - $this->consumer_secret = $config->twitter->consumer_secret; |
|
36 | - $this->access_token = $config->twitter->access_token; |
|
37 | - $this->access_secret = $config->twitter->access_secret; |
|
34 | + $this->consumer_key = $config->twitter->consumer_key; |
|
35 | + $this->consumer_secret = $config->twitter->consumer_secret; |
|
36 | + $this->access_token = $config->twitter->access_token; |
|
37 | + $this->access_secret = $config->twitter->access_secret; |
|
38 | 38 | |
39 | 39 | $json = $this->get_data(); |
40 | 40 |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | private $oauth_array; |
84 | 84 | private function get_oauth_array() |
85 | 85 | { |
86 | - if(!isset($this->oauth_array)) |
|
86 | + if (!isset($this->oauth_array)) |
|
87 | 87 | { |
88 | 88 | $this->oauth_array = array( |
89 | 89 | 'screen_name' => self::$SCREEN_NAME, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $encoded_array = array(); |
118 | 118 | ksort($array); |
119 | - foreach($array as $key => $value) |
|
119 | + foreach ($array as $key => $value) |
|
120 | 120 | { |
121 | 121 | $value = rawurlencode($value); |
122 | 122 | $value = ($wrap_values) ? '"' . $value . '"' : $value; |
@@ -127,27 +127,27 @@ discard block |
||
127 | 127 | |
128 | 128 | public function activate() |
129 | 129 | { |
130 | - if(!$this->json) |
|
130 | + if (!$this->json) |
|
131 | 131 | return $this->error('Could not connect to twitter json feed.'); |
132 | 132 | |
133 | 133 | $count = 0; |
134 | - foreach($this->json as $status) |
|
134 | + foreach ($this->json as $status) |
|
135 | 135 | { |
136 | 136 | $text = Database::escape($status->text); |
137 | 137 | $date = date('Y-m-d H:i:s', strtotime($status->created_at)); |
138 | 138 | |
139 | 139 | $tweet_result = TwitterCollector::getTweetByFields($date, $text); |
140 | - if($tweet_result !== null) |
|
140 | + if ($tweet_result !== null) |
|
141 | 141 | { |
142 | 142 | $favorites = (int) $status->favorite_count; |
143 | - if($favorites != 0 && $tweet_result->favorites != $favorites) |
|
143 | + if ($favorites != 0 && $tweet_result->favorites != $favorites) |
|
144 | 144 | { |
145 | 145 | $query = sprintf(self::$UPDATE_FAVORITES_QUERY, $favorites, $tweet_result->id); |
146 | 146 | Database::execute($query); |
147 | 147 | } |
148 | 148 | |
149 | 149 | $retweets = (int) $status->retweet_count; |
150 | - if($retweets != 0 && $tweet_result->retweets != $retweets) |
|
150 | + if ($retweets != 0 && $tweet_result->retweets != $retweets) |
|
151 | 151 | { |
152 | 152 | $query = sprintf(self::$UPDATE_RETWEETS_QUERY, $retweets, $tweet_result->id); |
153 | 153 | Database::execute($query); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | { |
158 | 158 | $twitter_id = (string) $status->id_str; |
159 | 159 | |
160 | - if(isset($status->retweeted_status)) |
|
160 | + if (isset($status->retweeted_status)) |
|
161 | 161 | { |
162 | 162 | $text_formatted = $this->get_formatted($status->retweeted_status->text, $status->retweeted_status->entities); |
163 | 163 | $text_formatted_full = $this->get_formatted($status->retweeted_status->text, $status->retweeted_status->entities, 'full'); |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | |
201 | 201 | private function get_source($source) |
202 | 202 | { |
203 | - if(stristr($source, 'tweetdeck')) |
|
203 | + if (stristr($source, 'tweetdeck')) |
|
204 | 204 | return 'tweetdeck'; |
205 | - if(stristr($source, 'windows phone')) |
|
205 | + if (stristr($source, 'windows phone')) |
|
206 | 206 | return 'phone'; |
207 | 207 | else |
208 | 208 | return ''; |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | private function get_formatted($text, $entities, $type = 'short') |
212 | 212 | { |
213 | 213 | $holder = array(); |
214 | - foreach($entities as $entity_type => $entity_collection) |
|
214 | + foreach ($entities as $entity_type => $entity_collection) |
|
215 | 215 | { |
216 | - foreach($entity_collection as $entity) |
|
216 | + foreach ($entity_collection as $entity) |
|
217 | 217 | { |
218 | 218 | $start = $entity->indices[0]; |
219 | 219 | $end = $entity->indices[1]; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | krsort($holder); |
230 | 230 | |
231 | - foreach($holder as $entity) |
|
231 | + foreach ($holder as $entity) |
|
232 | 232 | { |
233 | 233 | $text = mb_substr($text, 0, $entity->start, 'UTF-8') . $entity->replace . mb_substr($text, $entity->end, 5000, 'UTF-8'); |
234 | 234 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | private function get_replace_text($entity_type, $entity, $type) |
243 | 243 | { |
244 | - switch($entity_type) |
|
244 | + switch ($entity_type) |
|
245 | 245 | { |
246 | 246 | case 'hashtags' : |
247 | 247 | $replace = sprintf(self::$HASHTAG_LINK, $entity->text); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $replace = sprintf(self::$USER_MENTION_LINK, $entity->screen_name, $entity->name); |
254 | 254 | break; |
255 | 255 | case 'media' : |
256 | - if($type == 'full') |
|
256 | + if ($type == 'full') |
|
257 | 257 | $replace = sprintf(self::$MEDIA_LINK, $entity->url, $entity->display_url, $entity->media_url, 'large', 'Photo from Twitter', $entity->sizes->large->h, $entity->sizes->large->w); |
258 | 258 | else |
259 | 259 | $replace = sprintf(self::$URL_LINK, $entity->url, $entity->expanded_url, $entity->display_url); |
@@ -127,8 +127,9 @@ discard block |
||
127 | 127 | |
128 | 128 | public function activate() |
129 | 129 | { |
130 | - if(!$this->json) |
|
131 | - return $this->error('Could not connect to twitter json feed.'); |
|
130 | + if(!$this->json) { |
|
131 | + return $this->error('Could not connect to twitter json feed.'); |
|
132 | + } |
|
132 | 133 | |
133 | 134 | $count = 0; |
134 | 135 | foreach($this->json as $status) |
@@ -152,8 +153,7 @@ discard block |
||
152 | 153 | $query = sprintf(self::$UPDATE_RETWEETS_QUERY, $retweets, $tweet_result->id); |
153 | 154 | Database::execute($query); |
154 | 155 | } |
155 | - } |
|
156 | - else |
|
156 | + } else |
|
157 | 157 | { |
158 | 158 | $twitter_id = (string) $status->id_str; |
159 | 159 | |
@@ -164,8 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | $text_formatted = $this->prepend_original_user($status->retweeted_status->user, $text_formatted); |
166 | 166 | $text_formatted_full = $this->prepend_original_user($status->retweeted_status->user, $text_formatted_full); |
167 | - } |
|
168 | - else |
|
167 | + } else |
|
169 | 168 | { |
170 | 169 | $text_formatted = $this->get_formatted($status->text, $status->entities); |
171 | 170 | $text_formatted_full = $this->get_formatted($status->text, $status->entities, 'full'); |
@@ -200,12 +199,14 @@ discard block |
||
200 | 199 | |
201 | 200 | private function get_source($source) |
202 | 201 | { |
203 | - if(stristr($source, 'tweetdeck')) |
|
204 | - return 'tweetdeck'; |
|
205 | - if(stristr($source, 'windows phone')) |
|
206 | - return 'phone'; |
|
207 | - else |
|
208 | - return ''; |
|
202 | + if(stristr($source, 'tweetdeck')) { |
|
203 | + return 'tweetdeck'; |
|
204 | + } |
|
205 | + if(stristr($source, 'windows phone')) { |
|
206 | + return 'phone'; |
|
207 | + } else { |
|
208 | + return ''; |
|
209 | + } |
|
209 | 210 | } |
210 | 211 | |
211 | 212 | private function get_formatted($text, $entities, $type = 'short') |
@@ -253,10 +254,11 @@ discard block |
||
253 | 254 | $replace = sprintf(self::$USER_MENTION_LINK, $entity->screen_name, $entity->name); |
254 | 255 | break; |
255 | 256 | case 'media' : |
256 | - if($type == 'full') |
|
257 | - $replace = sprintf(self::$MEDIA_LINK, $entity->url, $entity->display_url, $entity->media_url, 'large', 'Photo from Twitter', $entity->sizes->large->h, $entity->sizes->large->w); |
|
258 | - else |
|
259 | - $replace = sprintf(self::$URL_LINK, $entity->url, $entity->expanded_url, $entity->display_url); |
|
257 | + if($type == 'full') { |
|
258 | + $replace = sprintf(self::$MEDIA_LINK, $entity->url, $entity->display_url, $entity->media_url, 'large', 'Photo from Twitter', $entity->sizes->large->h, $entity->sizes->large->w); |
|
259 | + } else { |
|
260 | + $replace = sprintf(self::$URL_LINK, $entity->url, $entity->expanded_url, $entity->display_url); |
|
261 | + } |
|
260 | 262 | break; |
261 | 263 | default : |
262 | 264 | $replace = ''; |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | |
62 | 62 | private function remove_existing($result, $type) |
63 | 63 | { |
64 | - foreach($result as $key => $row) |
|
64 | + foreach ($result as $key => $row) |
|
65 | 65 | { |
66 | 66 | $stream_result = ActivityCollector::getPostByFields($row->id, $type); |
67 | - if($stream_result) |
|
67 | + if ($stream_result) |
|
68 | 68 | unset($result[$key]); |
69 | 69 | } |
70 | 70 | return $result; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | private function add_posts($result, $type) |
74 | 74 | { |
75 | - foreach($result as $row) |
|
75 | + foreach ($result as $row) |
|
76 | 76 | { |
77 | 77 | $query = sprintf(self::$QUERY, $type, $row->id, $row->date); |
78 | 78 | Database::execute($query); |
@@ -64,8 +64,9 @@ |
||
64 | 64 | foreach($result as $key => $row) |
65 | 65 | { |
66 | 66 | $stream_result = ActivityCollector::getPostByFields($row->id, $type); |
67 | - if($stream_result) |
|
68 | - unset($result[$key]); |
|
67 | + if($stream_result) { |
|
68 | + unset($result[$key]); |
|
69 | + } |
|
69 | 70 | } |
70 | 71 | return $result; |
71 | 72 | } |
@@ -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 && |
@@ -20,18 +20,18 @@ |
||
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 youtube xml feed.'); |
25 | 25 | |
26 | 26 | $count = 0; |
27 | - foreach($this->xml->entry as $entry) |
|
27 | + foreach ($this->xml->entry as $entry) |
|
28 | 28 | { |
29 | 29 | $video_id = $entry->id; |
30 | 30 | $video_id = explode('/', $video_id); |
31 | 31 | $video_id = array_pop($video_id); |
32 | 32 | |
33 | 33 | $video_exists = YouTubeCollector::checkForVideoByVideoID($video_id); |
34 | - if($video_exists) |
|
34 | + if ($video_exists) |
|
35 | 35 | continue; |
36 | 36 | |
37 | 37 | $title = Database::escape($entry->title); |
@@ -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 youtube xml feed.'); |
|
23 | + if(!$this->xml) { |
|
24 | + return $this->error('Could not connect to youtube xml feed.'); |
|
25 | + } |
|
25 | 26 | |
26 | 27 | $count = 0; |
27 | 28 | foreach($this->xml->entry as $entry) |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | $video_id = array_pop($video_id); |
32 | 33 | |
33 | 34 | $video_exists = YouTubeCollector::checkForVideoByVideoID($video_id); |
34 | - if($video_exists) |
|
35 | - continue; |
|
35 | + if($video_exists) { |
|
36 | + continue; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $title = Database::escape($entry->title); |
38 | 40 | $content = Database::escape($entry->content); |