@@ -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 | {
|
@@ -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 | {
|
@@ -36,6 +36,10 @@ discard block |
||
| 36 | 36 | $this->replace_element_patterns(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | + /** |
|
| 40 | + * @param string $pattern |
|
| 41 | + * @param string $replace |
|
| 42 | + */ |
|
| 39 | 43 | private function process_element($pattern, $replace) |
| 40 | 44 | {
|
| 41 | 45 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
@@ -75,6 +79,10 @@ discard block |
||
| 75 | 79 | $this->content = strip_tags($this->content); |
| 76 | 80 | } |
| 77 | 81 | |
| 82 | + /** |
|
| 83 | + * @param string $pattern |
|
| 84 | + * @param string $replace |
|
| 85 | + */ |
|
| 78 | 86 | private function link_unlinked_urls($pattern, $replace) |
| 79 | 87 | {
|
| 80 | 88 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
@@ -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,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); |
@@ -72,38 +72,38 @@ |
||
| 72 | 72 | |
| 73 | 73 | break; |
| 74 | 74 | case 'falls' : |
| 75 | - $pieces = explode('/', $uri);
|
|
| 76 | - if (count($pieces) == 1) {
|
|
| 77 | - Loader::load('collector', 'waterfall/WatercourseCollector');
|
|
| 78 | - list ($watercourse_alias) = $pieces; |
|
| 79 | - $watercourse = WatercourseCollector::getByAlias($watercourse_alias); |
|
| 75 | + $pieces = explode('/', $uri);
|
|
| 76 | + if (count($pieces) == 1) {
|
|
| 77 | + Loader::load('collector', 'waterfall/WatercourseCollector');
|
|
| 78 | + list ($watercourse_alias) = $pieces; |
|
| 79 | + $watercourse = WatercourseCollector::getByAlias($watercourse_alias); |
|
| 80 | 80 | |
| 81 | - if ($watercourse == null) {
|
|
| 82 | - return; |
|
| 83 | - } |
|
| 81 | + if ($watercourse == null) {
|
|
| 82 | + return; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/';
|
|
| 86 | - $link .= "{$watercourse->alias}/";
|
|
| 85 | + $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/';
|
|
| 86 | + $link .= "{$watercourse->alias}/";
|
|
| 87 | 87 | |
| 88 | - if ($anchor == '') {
|
|
| 89 | - $anchor = $watercourse->name; |
|
| 90 | - } |
|
| 91 | - } else if (count($pieces) == 2) {
|
|
| 92 | - Loader::load('collector', 'waterfall/WaterfallCollector');
|
|
| 93 | - list ($watercourse_alias, $waterfall_alias) = $pieces; |
|
| 94 | - $waterfall = WaterfallCollector::getByAlias($watercourse_alias, $waterfall_alias); |
|
| 88 | + if ($anchor == '') {
|
|
| 89 | + $anchor = $watercourse->name; |
|
| 90 | + } |
|
| 91 | + } else if (count($pieces) == 2) {
|
|
| 92 | + Loader::load('collector', 'waterfall/WaterfallCollector');
|
|
| 93 | + list ($watercourse_alias, $waterfall_alias) = $pieces; |
|
| 94 | + $waterfall = WaterfallCollector::getByAlias($watercourse_alias, $waterfall_alias); |
|
| 95 | 95 | |
| 96 | - if ($waterfall == null) {
|
|
| 97 | - return; |
|
| 98 | - } |
|
| 96 | + if ($waterfall == null) {
|
|
| 97 | + return; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/';
|
|
| 101 | - $link .= "{$waterfall->watercourse_alias}/{$waterfall->alias}/";
|
|
| 100 | + $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/';
|
|
| 101 | + $link .= "{$waterfall->watercourse_alias}/{$waterfall->alias}/";
|
|
| 102 | 102 | |
| 103 | - if ($anchor == '') {
|
|
| 104 | - $anchor = $waterfall->name; |
|
| 105 | - } |
|
| 106 | - } |
|
| 103 | + if ($anchor == '') {
|
|
| 104 | + $anchor = $waterfall->name; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | break; |
| 108 | 108 | default : |
| 109 | 109 | break; |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | protected function execute($is_absolute = true) |
| 13 | 13 | {
|
| 14 | 14 | preg_match_all(self::$LINK_PLACEHOLDER_MATCH, $this->content, $matches); |
| 15 | - foreach($matches[1] as $key => $match) |
|
| 15 | + foreach ($matches[1] as $key => $match) |
|
| 16 | 16 | {
|
| 17 | - if(isset($matches[3][$key])) |
|
| 17 | + if (isset($matches[3][$key])) |
|
| 18 | 18 | $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
| 19 | 19 | else |
| 20 | 20 | $link_content = $this->get_link($match, $is_absolute); |
@@ -29,19 +29,19 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $link = ''; |
| 31 | 31 | |
| 32 | - switch($type) |
|
| 32 | + switch ($type) |
|
| 33 | 33 | {
|
| 34 | 34 | case 'blog' : |
| 35 | 35 | Loader::load('collector', 'blog/PostCollector');
|
| 36 | 36 | $post = PostCollector::getPostByURI($uri); |
| 37 | 37 | |
| 38 | - if($post === NULL) |
|
| 38 | + if ($post === NULL) |
|
| 39 | 39 | return; |
| 40 | 40 | |
| 41 | 41 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/';
|
| 42 | 42 | $link .= "{$post->category}/{$post->path}/";
|
| 43 | 43 | |
| 44 | - if($anchor == '') |
|
| 44 | + if ($anchor == '') |
|
| 45 | 45 | $anchor = $post->title; |
| 46 | 46 | |
| 47 | 47 | break; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/';
|
| 50 | 50 | $link .= "tag/{$uri}/";
|
| 51 | 51 | |
| 52 | - if($anchor == '') |
|
| 52 | + if ($anchor == '') |
|
| 53 | 53 | {
|
| 54 | 54 | $anchor = $uri; |
| 55 | 55 | $anchor = str_replace('-', ' ', $anchor);
|
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | Loader::load('collector', 'waterfall/LogCollector');
|
| 62 | 62 | $log = LogCollector::getByAlias($uri); |
| 63 | 63 | |
| 64 | - if($log === NULL) |
|
| 64 | + if ($log === NULL) |
|
| 65 | 65 | return; |
| 66 | 66 | |
| 67 | 67 | $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/';
|
| 68 | 68 | $link .= "journal/{$log->alias}/";
|
| 69 | 69 | |
| 70 | - if($anchor == '') |
|
| 70 | + if ($anchor == '') |
|
| 71 | 71 | $anchor = $log->title; |
| 72 | 72 | |
| 73 | 73 | break; |
@@ -14,10 +14,11 @@ discard block |
||
| 14 | 14 | preg_match_all(self::$LINK_PLACEHOLDER_MATCH, $this->content, $matches); |
| 15 | 15 | foreach($matches[1] as $key => $match) |
| 16 | 16 | {
|
| 17 | - if(isset($matches[3][$key])) |
|
| 18 | - $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
|
| 19 | - else |
|
| 20 | - $link_content = $this->get_link($match, $is_absolute); |
|
| 17 | + if(isset($matches[3][$key])) {
|
|
| 18 | + $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
|
| 19 | + } else {
|
|
| 20 | + $link_content = $this->get_link($match, $is_absolute); |
|
| 21 | + } |
|
| 21 | 22 | $this->content = str_replace($matches[0][$key], $link_content, $this->content); |
| 22 | 23 | } |
| 23 | 24 | return; |
@@ -35,14 +36,16 @@ discard block |
||
| 35 | 36 | Loader::load('collector', 'blog/PostCollector');
|
| 36 | 37 | $post = PostCollector::getPostByURI($uri); |
| 37 | 38 | |
| 38 | - if($post === NULL) |
|
| 39 | - return; |
|
| 39 | + if($post === NULL) {
|
|
| 40 | + return; |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/';
|
| 42 | 44 | $link .= "{$post->category}/{$post->path}/";
|
| 43 | 45 | |
| 44 | - if($anchor == '') |
|
| 45 | - $anchor = $post->title; |
|
| 46 | + if($anchor == '') {
|
|
| 47 | + $anchor = $post->title; |
|
| 48 | + } |
|
| 46 | 49 | |
| 47 | 50 | break; |
| 48 | 51 | case 'blog-tag' : |
@@ -61,14 +64,16 @@ discard block |
||
| 61 | 64 | Loader::load('collector', 'waterfall/LogCollector');
|
| 62 | 65 | $log = LogCollector::getByAlias($uri); |
| 63 | 66 | |
| 64 | - if($log === NULL) |
|
| 65 | - return; |
|
| 67 | + if($log === NULL) {
|
|
| 68 | + return; |
|
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/';
|
| 68 | 72 | $link .= "journal/{$log->alias}/";
|
| 69 | 73 | |
| 70 | - if($anchor == '') |
|
| 71 | - $anchor = $log->title; |
|
| 74 | + if($anchor == '') {
|
|
| 75 | + $anchor = $log->title; |
|
| 76 | + } |
|
| 72 | 77 | |
| 73 | 78 | break; |
| 74 | 79 | case 'falls' : |
@@ -23,6 +23,9 @@ |
||
| 23 | 23 | return; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | + /** |
|
| 27 | + * @param boolean $is_absolute |
|
| 28 | + */ |
|
| 26 | 29 | private function get_link($string, $is_absolute, $anchor = '') |
| 27 | 30 | {
|
| 28 | 31 | list($type, $uri) = explode('/', $string, 2);
|
@@ -44,9 +44,9 @@ |
||
| 44 | 44 | $width = $file_size[0]; |
| 45 | 45 | $description = $photo_result->description; |
| 46 | 46 | |
| 47 | - if ($description == '') {
|
|
| 48 | - Debugger::logMessage("No description for {$category}/{$photo}");
|
|
| 49 | - } |
|
| 47 | + if ($description == '') {
|
|
| 48 | + Debugger::logMessage("No description for {$category}/{$photo}");
|
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | $domain = '/'; |
| 52 | 52 | if($is_absolute) |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | protected function execute($is_absolute = false, $size = 'medium') |
| 13 | 13 | {
|
| 14 | 14 | preg_match_all(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $matches); |
| 15 | - foreach($matches[1] as $key => $match) |
|
| 15 | + foreach ($matches[1] as $key => $match) |
|
| 16 | 16 | {
|
| 17 | 17 | $photo_content = $this->get_photo_content($match, $size, $is_absolute); |
| 18 | 18 | $this->content = str_replace($matches[0][$key], $photo_content, $this->content); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | Loader::load('collector', 'image/PhotoCollector');
|
| 39 | 39 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
| 40 | - if($photo_result == false) |
|
| 40 | + if ($photo_result == false) |
|
| 41 | 41 | return ''; |
| 42 | 42 | |
| 43 | 43 | $height = $file_size[1]; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $domain = '/'; |
| 52 | - if($is_absolute) |
|
| 52 | + if ($is_absolute) |
|
| 53 | 53 | $domain = Loader::getRootUrl('blog');
|
| 54 | 54 | |
| 55 | 55 | return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description); |
@@ -37,8 +37,9 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | Loader::load('collector', 'image/PhotoCollector');
|
| 39 | 39 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
| 40 | - if($photo_result == false) |
|
| 41 | - return ''; |
|
| 40 | + if($photo_result == false) {
|
|
| 41 | + return ''; |
|
| 42 | + } |
|
| 42 | 43 | |
| 43 | 44 | $height = $file_size[1]; |
| 44 | 45 | $width = $file_size[0]; |
@@ -49,8 +50,9 @@ discard block |
||
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | $domain = '/'; |
| 52 | - if($is_absolute) |
|
| 53 | - $domain = Loader::getRootUrl('blog');
|
|
| 53 | + if($is_absolute) {
|
|
| 54 | + $domain = Loader::getRootUrl('blog');
|
|
| 55 | + } |
|
| 54 | 56 | |
| 55 | 57 | return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description); |
| 56 | 58 | } |
@@ -26,6 +26,10 @@ |
||
| 26 | 26 | return Loader::getImagePath('photo', $path);
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | + /** |
|
| 30 | + * @param string $size |
|
| 31 | + * @param boolean $is_absolute |
|
| 32 | + */ |
|
| 29 | 33 | private function get_photo_content($string, $size, $is_absolute) |
| 30 | 34 | {
|
| 31 | 35 | list($category, $file_name) = explode('/', $string);
|
@@ -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 | } |
@@ -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 |
@@ -22,10 +22,10 @@ |
||
| 22 | 22 | |
| 23 | 23 | protected function getDomain() |
| 24 | 24 | {
|
| 25 | - $site = URLDecode::getSite(); |
|
| 26 | - if ($site == 'waterfalls' && Loader::isLive()) {
|
|
| 27 | - return 'waterfallsofthekeweenaw.com'; |
|
| 28 | - } |
|
| 25 | + $site = URLDecode::getSite(); |
|
| 26 | + if ($site == 'waterfalls' && Loader::isLive()) {
|
|
| 27 | + return 'waterfallsofthekeweenaw.com'; |
|
| 28 | + } |
|
| 29 | 29 | return self::$COOKIE_DOMAIN; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -6,8 +6,8 @@ |
||
| 6 | 6 | {
|
| 7 | 7 | |
| 8 | 8 | private static $COOKIE_NAME = 'commenter'; |
| 9 | - private static $COOKIE_DURATION = 31536000; // one year |
|
| 10 | - private static $COOKIE_DOMAIN = 'jacobemerick.com'; |
|
| 9 | + private static $COOKIE_DURATION = 31536000; // one year |
|
| 10 | + private static $COOKIE_DOMAIN = 'jacobemerick.com'; |
|
| 11 | 11 | private static $COOKIE_PATH = '/'; |
| 12 | 12 | |
| 13 | 13 | protected function getName() |