@@ -35,6 +35,10 @@ |
||
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | + /** |
|
39 | + * @param string $handle_link |
|
40 | + * @param string $handle_display |
|
41 | + */ |
|
38 | 42 | private function get_replacement_link($handle_link, $handle_display) |
39 | 43 | { |
40 | 44 | return sprintf(self::$HASH_LINK, $handle_link, $handle_display); |
@@ -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 | { |
@@ -37,6 +37,9 @@ discard block |
||
37 | 37 | return; |
38 | 38 | } |
39 | 39 | |
40 | + /** |
|
41 | + * @param string[] $match |
|
42 | + */ |
|
40 | 43 | private function get_display_url($match) |
41 | 44 | { |
42 | 45 | $display_url = $this->check_for_redirect($match[0]); |
@@ -67,6 +70,9 @@ discard block |
||
67 | 70 | return $link; |
68 | 71 | } |
69 | 72 | |
73 | + /** |
|
74 | + * @return string |
|
75 | + */ |
|
70 | 76 | private function check_for_redirect($url) |
71 | 77 | { |
72 | 78 | $headers = @get_headers($url); |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | |
11 | 11 | protected function execute() |
12 | 12 | { |
13 | - if(stristr($this->content, 'http') === false) |
|
13 | + if (stristr($this->content, 'http') === false) |
|
14 | 14 | return; |
15 | 15 | |
16 | 16 | $parameters = func_get_args(); |
17 | - if(count($parameters) > 1 || (count($parameters) == 1 && !is_array($parameters[0]))) |
|
17 | + if (count($parameters) > 1 || (count($parameters) == 1 && !is_array($parameters[0]))) |
|
18 | 18 | { |
19 | 19 | trigger_error('Unexpected parameters passed into AutolinkTwitterURL!'); |
20 | 20 | return; |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | $parameters = array_shift($parameters); |
23 | 23 | |
24 | 24 | $found_link = preg_match_all(self::$LINK_PATTERN, $this->content, $matches, PREG_SET_ORDER); |
25 | - if($found_link === false || $found_link === 0) |
|
25 | + if ($found_link === false || $found_link === 0) |
|
26 | 26 | return; |
27 | 27 | |
28 | - foreach($matches as $match) |
|
28 | + foreach ($matches as $match) |
|
29 | 29 | { |
30 | 30 | $parameters['href'] = $match[0]; |
31 | 31 | $display_url = $this->get_display_url($match); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $display_url = $this->check_for_redirect($match[0]); |
43 | 43 | |
44 | - if(strlen($display_url) > (self::$DISPLAY_URL_LENGTH - 2)) |
|
44 | + if (strlen($display_url) > (self::$DISPLAY_URL_LENGTH - 2)) |
|
45 | 45 | { |
46 | 46 | $display_url = substr($display_url, 0, self::$DISPLAY_URL_LENGTH); |
47 | 47 | $display_url .= '...'; |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | private function get_replacement_link($parameters, $display_url) |
54 | 54 | { |
55 | 55 | $link = '<a'; |
56 | - foreach($parameters as $attribute => $value) |
|
56 | + foreach ($parameters as $attribute => $value) |
|
57 | 57 | { |
58 | 58 | $link .= ' '; |
59 | 59 | $link .= $attribute; |
60 | 60 | $link .= '='; |
61 | - $link .= '"' . $value .'"'; |
|
61 | + $link .= '"' . $value . '"'; |
|
62 | 62 | } |
63 | 63 | $link .= '>'; |
64 | 64 | $link .= $display_url; |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | private function check_for_redirect($url) |
71 | 71 | { |
72 | 72 | $headers = @get_headers($url); |
73 | - if($headers === false) |
|
73 | + if ($headers === false) |
|
74 | 74 | $headers = $this->get_headers($url); |
75 | 75 | |
76 | - if(stristr($headers[0], '301') !== false || stristr($headers[0], '302') !== false) |
|
76 | + if (stristr($headers[0], '301') !== false || stristr($headers[0], '302') !== false) |
|
77 | 77 | { |
78 | - foreach($headers as $header) |
|
78 | + foreach ($headers as $header) |
|
79 | 79 | { |
80 | - if(substr($header, 0, 9) == 'Location:') |
|
80 | + if (substr($header, 0, 9) == 'Location:') |
|
81 | 81 | break; |
82 | 82 | } |
83 | 83 |
@@ -10,8 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | protected function execute() |
12 | 12 | { |
13 | - if(stristr($this->content, 'http') === false) |
|
14 | - return; |
|
13 | + if(stristr($this->content, 'http') === false) { |
|
14 | + return; |
|
15 | + } |
|
15 | 16 | |
16 | 17 | $parameters = func_get_args(); |
17 | 18 | if(count($parameters) > 1 || (count($parameters) == 1 && !is_array($parameters[0]))) |
@@ -22,8 +23,9 @@ discard block |
||
22 | 23 | $parameters = array_shift($parameters); |
23 | 24 | |
24 | 25 | $found_link = preg_match_all(self::$LINK_PATTERN, $this->content, $matches, PREG_SET_ORDER); |
25 | - if($found_link === false || $found_link === 0) |
|
26 | - return; |
|
26 | + if($found_link === false || $found_link === 0) { |
|
27 | + return; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | foreach($matches as $match) |
29 | 31 | { |
@@ -70,15 +72,17 @@ discard block |
||
70 | 72 | private function check_for_redirect($url) |
71 | 73 | { |
72 | 74 | $headers = @get_headers($url); |
73 | - if($headers === false) |
|
74 | - $headers = $this->get_headers($url); |
|
75 | + if($headers === false) { |
|
76 | + $headers = $this->get_headers($url); |
|
77 | + } |
|
75 | 78 | |
76 | 79 | if(stristr($headers[0], '301') !== false || stristr($headers[0], '302') !== false) |
77 | 80 | { |
78 | 81 | foreach($headers as $header) |
79 | 82 | { |
80 | - if(substr($header, 0, 9) == 'Location:') |
|
81 | - break; |
|
83 | + if(substr($header, 0, 9) == 'Location:') { |
|
84 | + break; |
|
85 | + } |
|
82 | 86 | } |
83 | 87 | |
84 | 88 | $url = substr($header, 10); |
@@ -35,6 +35,10 @@ |
||
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | + /** |
|
39 | + * @param string $handle_link |
|
40 | + * @param string $handle_display |
|
41 | + */ |
|
38 | 42 | private function get_replacement_link($handle_link, $handle_display) |
39 | 43 | { |
40 | 44 | return sprintf(self::$USER_LINK, $handle_link, $handle_display); |
@@ -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 | { |
@@ -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); |
@@ -54,11 +58,17 @@ discard block |
||
54 | 58 | } |
55 | 59 | } |
56 | 60 | |
61 | + /** |
|
62 | + * @param string|null $text |
|
63 | + */ |
|
57 | 64 | private function create_placeholder($text) |
58 | 65 | { |
59 | 66 | return md5($text . rand()); |
60 | 67 | } |
61 | 68 | |
69 | + /** |
|
70 | + * @param string|null $text |
|
71 | + */ |
|
62 | 72 | private function create_full_match_pattern($text) |
63 | 73 | { |
64 | 74 | $pattern = ''; |
@@ -75,6 +85,10 @@ discard block |
||
75 | 85 | $this->content = strip_tags($this->content); |
76 | 86 | } |
77 | 87 | |
88 | + /** |
|
89 | + * @param string $pattern |
|
90 | + * @param string $replace |
|
91 | + */ |
|
78 | 92 | private function link_unlinked_urls($pattern, $replace) |
79 | 93 | { |
80 | 94 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
@@ -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 | { |
@@ -24,6 +24,11 @@ |
||
24 | 24 | return Loader::getImagePath('photo', $path); |
25 | 25 | } |
26 | 26 | |
27 | + /** |
|
28 | + * @param string $string |
|
29 | + * @param boolean $is_absolute |
|
30 | + * @param string $size |
|
31 | + */ |
|
27 | 32 | private function get_thumb($string, $is_absolute, $size) |
28 | 33 | { |
29 | 34 | list($category, $file_name) = explode('/', $string); |
@@ -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 | } |
@@ -18,6 +18,9 @@ |
||
18 | 18 | return; |
19 | 19 | } |
20 | 20 | |
21 | + /** |
|
22 | + * @param string $file_name |
|
23 | + */ |
|
21 | 24 | private function get_file_path($file_name) |
22 | 25 | { |
23 | 26 | return Loader::loadNew('utility', 'ImageOld', (array) $file_name)->getExternalLink(); |
@@ -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); |
@@ -23,6 +23,10 @@ |
||
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
26 | + /** |
|
27 | + * @param string $string |
|
28 | + * @param boolean $is_absolute |
|
29 | + */ |
|
26 | 30 | private function get_link($string, $is_absolute, $anchor = '') |
27 | 31 | { |
28 | 32 | list($type, $uri) = explode('/', $string, 2); |
@@ -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' : |
@@ -26,6 +26,11 @@ |
||
26 | 26 | return Loader::getImagePath('photo', $path); |
27 | 27 | } |
28 | 28 | |
29 | + /** |
|
30 | + * @param string $string |
|
31 | + * @param string $size |
|
32 | + * @param boolean $is_absolute |
|
33 | + */ |
|
29 | 34 | private function get_photo_content($string, $size, $is_absolute) |
30 | 35 | { |
31 | 36 | list($category, $file_name) = explode('/', $string); |
@@ -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 | } |
@@ -25,6 +25,9 @@ discard block |
||
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
28 | + /** |
|
29 | + * @param string $content |
|
30 | + */ |
|
28 | 31 | private function wrap_in_list($content) |
29 | 32 | { |
30 | 33 | $content_array = explode("\n", $content); |
@@ -44,6 +47,9 @@ discard block |
||
44 | 47 | return $content; |
45 | 48 | } |
46 | 49 | |
50 | + /** |
|
51 | + * @param string $type |
|
52 | + */ |
|
47 | 53 | private function highlight_code($content, $type) |
48 | 54 | { |
49 | 55 | switch($type) |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | protected function execute($title = '') |
11 | 11 | { |
12 | 12 | preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
13 | - if(count($matches[1]) == 0) |
|
13 | + if (count($matches[1]) == 0) |
|
14 | 14 | return; |
15 | 15 | |
16 | - foreach($matches[3] as $key => $match) |
|
16 | + foreach ($matches[3] as $key => $match) |
|
17 | 17 | { |
18 | 18 | $replacement = $match; |
19 | 19 | $replacement = $this->wrap_in_list($replacement); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | $content_array = explode("\n", $content); |
31 | 31 | |
32 | - foreach($content_array as $key => $row) |
|
32 | + foreach ($content_array as $key => $row) |
|
33 | 33 | { |
34 | 34 | $new_row = ($key % 2 == 0) ? '<li class="even">' : '<li class="odd">'; |
35 | 35 | $new_row .= '<p>'; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | private function highlight_code($content, $type) |
48 | 48 | { |
49 | - switch($type) |
|
49 | + switch ($type) |
|
50 | 50 | { |
51 | 51 | default : |
52 | 52 | return $content; |
@@ -10,8 +10,9 @@ |
||
10 | 10 | protected function execute($title = '') |
11 | 11 | { |
12 | 12 | preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
13 | - if(count($matches[1]) == 0) |
|
14 | - return; |
|
13 | + if(count($matches[1]) == 0) { |
|
14 | + return; |
|
15 | + } |
|
15 | 16 | |
16 | 17 | foreach($matches[3] as $key => $match) |
17 | 18 | { |