@@ -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 | { |
@@ -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' : |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | protected function execute() |
10 | 10 | { |
11 | 11 | $is_acceptable = true; |
12 | - foreach($this->getUnacceptableWords() as $unacceptableWord) |
|
12 | + foreach ($this->getUnacceptableWords() as $unacceptableWord) |
|
13 | 13 | { |
14 | - if(stristr($unacceptableWord->word, $this->content)) |
|
14 | + if (stristr($unacceptableWord->word, $this->content)) |
|
15 | 15 | $is_acceptable = false; |
16 | 16 | } |
17 | 17 | return $is_acceptable; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | private $unacceptableWords; |
21 | 21 | private function getUnacceptableWords() |
22 | 22 | { |
23 | - if(!$this->unacceptableWords) |
|
23 | + if (!$this->unacceptableWords) |
|
24 | 24 | $this->unacceptableWords = UnacceptableWordCollector::getWords(); |
25 | 25 | return $this->unacceptableWords; |
26 | 26 | } |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | $is_acceptable = true; |
12 | 12 | foreach($this->getUnacceptableWords() as $unacceptableWord) |
13 | 13 | { |
14 | - if(stristr($unacceptableWord->word, $this->content)) |
|
15 | - $is_acceptable = false; |
|
14 | + if(stristr($unacceptableWord->word, $this->content)) { |
|
15 | + $is_acceptable = false; |
|
16 | + } |
|
16 | 17 | } |
17 | 18 | return $is_acceptable; |
18 | 19 | } |
@@ -20,8 +21,9 @@ discard block |
||
20 | 21 | private $unacceptableWords; |
21 | 22 | private function getUnacceptableWords() |
22 | 23 | { |
23 | - if(!$this->unacceptableWords) |
|
24 | - $this->unacceptableWords = UnacceptableWordCollector::getWords(); |
|
24 | + if(!$this->unacceptableWords) { |
|
25 | + $this->unacceptableWords = UnacceptableWordCollector::getWords(); |
|
26 | + } |
|
25 | 27 | return $this->unacceptableWords; |
26 | 28 | } |
27 | 29 |
@@ -5,56 +5,56 @@ |
||
5 | 5 | final class ImperialUnitContent extends Content |
6 | 6 | { |
7 | 7 | |
8 | - protected function execute($type = '') |
|
9 | - { |
|
10 | - $number = floatval($this->content); |
|
11 | - $number *= 39.37; // convert to inches |
|
8 | + protected function execute($type = '') |
|
9 | + { |
|
10 | + $number = floatval($this->content); |
|
11 | + $number *= 39.37; // convert to inches |
|
12 | 12 | |
13 | - if ($type == '') { |
|
14 | - if ($number > (12 * 3 * 1760 * 5)) { |
|
15 | - $type = 'full miles'; |
|
16 | - } else if ($number > (12 * 3 * 1760 * .5)) { |
|
17 | - $type = 'tenth miles'; |
|
18 | - } else if ($number > (12 * 3 * 150)) { |
|
19 | - $type = 'yards'; |
|
20 | - } else if ($number > (12 * 10)) { |
|
21 | - $type = 'feet'; |
|
22 | - } else { |
|
23 | - $type = 'inches'; |
|
24 | - } |
|
25 | - } |
|
13 | + if ($type == '') { |
|
14 | + if ($number > (12 * 3 * 1760 * 5)) { |
|
15 | + $type = 'full miles'; |
|
16 | + } else if ($number > (12 * 3 * 1760 * .5)) { |
|
17 | + $type = 'tenth miles'; |
|
18 | + } else if ($number > (12 * 3 * 150)) { |
|
19 | + $type = 'yards'; |
|
20 | + } else if ($number > (12 * 10)) { |
|
21 | + $type = 'feet'; |
|
22 | + } else { |
|
23 | + $type = 'inches'; |
|
24 | + } |
|
25 | + } |
|
26 | 26 | |
27 | - switch ($type) { |
|
28 | - case 'full miles' : |
|
29 | - $this->content = number_format(round($number / (12 * 3 * 1760))) . ' miles'; |
|
30 | - break; |
|
31 | - case 'tenth miles' : |
|
32 | - $this->content = round($number / (12 * 3 * 1760), 1) . ' miles'; |
|
33 | - break; |
|
34 | - case 'yards' : |
|
35 | - $this->content = number_format(round($number / (12 * 3))) . ' yards'; |
|
36 | - break; |
|
37 | - case 'feet' : |
|
38 | - $this->content = number_format(round($number / 12)) . "'"; |
|
39 | - break; |
|
40 | - case 'inches' : |
|
41 | - $feet = floor($number / 12); |
|
27 | + switch ($type) { |
|
28 | + case 'full miles' : |
|
29 | + $this->content = number_format(round($number / (12 * 3 * 1760))) . ' miles'; |
|
30 | + break; |
|
31 | + case 'tenth miles' : |
|
32 | + $this->content = round($number / (12 * 3 * 1760), 1) . ' miles'; |
|
33 | + break; |
|
34 | + case 'yards' : |
|
35 | + $this->content = number_format(round($number / (12 * 3))) . ' yards'; |
|
36 | + break; |
|
37 | + case 'feet' : |
|
38 | + $this->content = number_format(round($number / 12)) . "'"; |
|
39 | + break; |
|
40 | + case 'inches' : |
|
41 | + $feet = floor($number / 12); |
|
42 | 42 | |
43 | - $inches = $number - $feet * 12; |
|
44 | - $inches = round($inches); |
|
43 | + $inches = $number - $feet * 12; |
|
44 | + $inches = round($inches); |
|
45 | 45 | |
46 | - if ($inches == 12) { |
|
47 | - $feet++; |
|
48 | - $inches = 0; |
|
49 | - } |
|
46 | + if ($inches == 12) { |
|
47 | + $feet++; |
|
48 | + $inches = 0; |
|
49 | + } |
|
50 | 50 | |
51 | - $this->content = ''; |
|
52 | - $this->content .= number_format($feet) . "'"; |
|
53 | - if (isset($inches) && $inches > 0) { |
|
54 | - $this->content .= " {$inches}\""; |
|
55 | - } |
|
56 | - break; |
|
57 | - } |
|
58 | - } |
|
51 | + $this->content = ''; |
|
52 | + $this->content .= number_format($feet) . "'"; |
|
53 | + if (isset($inches) && $inches > 0) { |
|
54 | + $this->content .= " {$inches}\""; |
|
55 | + } |
|
56 | + break; |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | protected function execute($is_absolute = false) |
11 | 11 | { |
12 | 12 | preg_match_all(self::$IMAGE_PLACEHOLDER_MATCH, $this->content, $matches); |
13 | - foreach($matches[1] as $key => $match) |
|
13 | + foreach ($matches[1] as $key => $match) |
|
14 | 14 | { |
15 | 15 | $image_path = $this->get_file_path($match); |
16 | 16 | $this->content = str_replace($matches[0][$key], $image_path, $this->content); |
@@ -42,8 +42,8 @@ |
||
42 | 42 | |
43 | 43 | if($length < strlen($this->content)) |
44 | 44 | $this->trim_string($length); |
45 | - else |
|
46 | - $etc = ''; |
|
45 | + else |
|
46 | + $etc = ''; |
|
47 | 47 | $this->check_exclude_tags(); |
48 | 48 | $this->close_tags($etc); |
49 | 49 | } |
@@ -27,20 +27,20 @@ discard block |
||
27 | 27 | protected function execute() |
28 | 28 | { |
29 | 29 | $args = func_get_args(); |
30 | - if(count($args) < 1) |
|
30 | + if (count($args) < 1) |
|
31 | 31 | { |
32 | 32 | trigger_error('Someone called SmartTrimContent w/o defining a length... bad!'); |
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | - if(count($args) == 2) |
|
36 | + if (count($args) == 2) |
|
37 | 37 | $etc = $args[1]; |
38 | 38 | else |
39 | 39 | $etc = self::$ETC; |
40 | 40 | |
41 | 41 | $length = $args[0]; |
42 | 42 | |
43 | - if($length < strlen($this->content)) |
|
43 | + if ($length < strlen($this->content)) |
|
44 | 44 | $this->trim_string($length); |
45 | 45 | else |
46 | 46 | $etc = ''; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | $last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET); |
56 | 56 | $last_left_bracket_position = strripos($content, self::$LEFT_BRACKET); |
57 | - if($last_left_bracket_position > $last_right_bracket_position) |
|
57 | + if ($last_left_bracket_position > $last_right_bracket_position) |
|
58 | 58 | $content = substr($content, 0, $last_left_bracket_position); |
59 | 59 | $content = trim($content); |
60 | 60 | |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | $content = current($content); |
74 | 74 | |
75 | 75 | $max_length = $length; |
76 | - foreach($matches[0] as $match) |
|
76 | + foreach ($matches[0] as $match) |
|
77 | 77 | { |
78 | 78 | $max_length += strlen($match[0]); |
79 | - if($max_length <= $match[1]) |
|
79 | + if ($max_length <= $match[1]) |
|
80 | 80 | break; |
81 | 81 | |
82 | 82 | $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
83 | 83 | } |
84 | 84 | |
85 | - if(substr($content, -7) == '</p><p>') |
|
85 | + if (substr($content, -7) == '</p><p>') |
|
86 | 86 | $content = substr($content, 0, -7); |
87 | 87 | |
88 | 88 | return $content; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS); |
95 | 95 | preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE); |
96 | 96 | |
97 | - if(count($matches[1]) % 2 == 1) |
|
97 | + if (count($matches[1]) % 2 == 1) |
|
98 | 98 | { |
99 | 99 | $cut_tag = end($matches[1]); |
100 | 100 | $cut_tag_position = $cut_tag[1] - 1; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | preg_match_all($tags_preg, $content, $matches); |
113 | 113 | $open_tags = array(); |
114 | 114 | |
115 | - foreach($matches[1] as $tag) |
|
115 | + foreach ($matches[1] as $tag) |
|
116 | 116 | { |
117 | - if(in_array($tag, $open_tags)) |
|
117 | + if (in_array($tag, $open_tags)) |
|
118 | 118 | { |
119 | 119 | $key = array_search($tag, $open_tags); |
120 | 120 | unset($open_tags[$key]); |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | $open_tags = array_reverse($open_tags); |
127 | - if(count($open_tags) > 0) |
|
127 | + if (count($open_tags) > 0) |
|
128 | 128 | { |
129 | - foreach($open_tags as $key => $open_tag) |
|
129 | + foreach ($open_tags as $key => $open_tag) |
|
130 | 130 | { |
131 | - if($key == count($open_tags) - 1) |
|
131 | + if ($key == count($open_tags) - 1) |
|
132 | 132 | $content .= $etc; |
133 | 133 | $content .= "</{$open_tag}>"; |
134 | 134 | } |
@@ -33,17 +33,19 @@ discard block |
||
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | - if(count($args) == 2) |
|
37 | - $etc = $args[1]; |
|
38 | - else |
|
39 | - $etc = self::$ETC; |
|
36 | + if(count($args) == 2) { |
|
37 | + $etc = $args[1]; |
|
38 | + } else { |
|
39 | + $etc = self::$ETC; |
|
40 | + } |
|
40 | 41 | |
41 | 42 | $length = $args[0]; |
42 | 43 | |
43 | - if($length < strlen($this->content)) |
|
44 | - $this->trim_string($length); |
|
45 | - else |
|
46 | - $etc = ''; |
|
44 | + if($length < strlen($this->content)) { |
|
45 | + $this->trim_string($length); |
|
46 | + } else { |
|
47 | + $etc = ''; |
|
48 | + } |
|
47 | 49 | $this->check_exclude_tags(); |
48 | 50 | $this->close_tags($etc); |
49 | 51 | } |
@@ -54,8 +56,9 @@ discard block |
||
54 | 56 | |
55 | 57 | $last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET); |
56 | 58 | $last_left_bracket_position = strripos($content, self::$LEFT_BRACKET); |
57 | - if($last_left_bracket_position > $last_right_bracket_position) |
|
58 | - $content = substr($content, 0, $last_left_bracket_position); |
|
59 | + if($last_left_bracket_position > $last_right_bracket_position) { |
|
60 | + $content = substr($content, 0, $last_left_bracket_position); |
|
61 | + } |
|
59 | 62 | $content = trim($content); |
60 | 63 | |
61 | 64 | $this->content = $content; |
@@ -76,14 +79,16 @@ discard block |
||
76 | 79 | foreach($matches[0] as $match) |
77 | 80 | { |
78 | 81 | $max_length += strlen($match[0]); |
79 | - if($max_length <= $match[1]) |
|
80 | - break; |
|
82 | + if($max_length <= $match[1]) { |
|
83 | + break; |
|
84 | + } |
|
81 | 85 | |
82 | 86 | $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
83 | 87 | } |
84 | 88 | |
85 | - if(substr($content, -7) == '</p><p>') |
|
86 | - $content = substr($content, 0, -7); |
|
89 | + if(substr($content, -7) == '</p><p>') { |
|
90 | + $content = substr($content, 0, -7); |
|
91 | + } |
|
87 | 92 | |
88 | 93 | return $content; |
89 | 94 | } |
@@ -118,9 +123,9 @@ discard block |
||
118 | 123 | { |
119 | 124 | $key = array_search($tag, $open_tags); |
120 | 125 | unset($open_tags[$key]); |
121 | - } |
|
122 | - else |
|
123 | - $open_tags[] = $tag; |
|
126 | + } else { |
|
127 | + $open_tags[] = $tag; |
|
128 | + } |
|
124 | 129 | } |
125 | 130 | |
126 | 131 | $open_tags = array_reverse($open_tags); |
@@ -128,13 +133,14 @@ discard block |
||
128 | 133 | { |
129 | 134 | foreach($open_tags as $key => $open_tag) |
130 | 135 | { |
131 | - if($key == count($open_tags) - 1) |
|
132 | - $content .= $etc; |
|
136 | + if($key == count($open_tags) - 1) { |
|
137 | + $content .= $etc; |
|
138 | + } |
|
133 | 139 | $content .= "</{$open_tag}>"; |
134 | 140 | } |
135 | - } |
|
136 | - else |
|
137 | - $content .= $etc; |
|
141 | + } else { |
|
142 | + $content .= $etc; |
|
143 | + } |
|
138 | 144 | |
139 | 145 | $this->content = $content; |
140 | 146 | } |
@@ -11,9 +11,9 @@ |
||
11 | 11 | |
12 | 12 | protected function execute() |
13 | 13 | { |
14 | - foreach(self::$UNACCEPTABLE_CHARACTER_ARRAY as $match => $replace) |
|
14 | + foreach (self::$UNACCEPTABLE_CHARACTER_ARRAY as $match => $replace) |
|
15 | 15 | { |
16 | - if(stristr($this->content, $match)) |
|
16 | + if (stristr($this->content, $match)) |
|
17 | 17 | $this->content = str_replace($match, $replace, $this->content); |
18 | 18 | } |
19 | 19 | return; |
@@ -13,8 +13,9 @@ |
||
13 | 13 | { |
14 | 14 | foreach(self::$UNACCEPTABLE_CHARACTER_ARRAY as $match => $replace) |
15 | 15 | { |
16 | - if(stristr($this->content, $match)) |
|
17 | - $this->content = str_replace($match, $replace, $this->content); |
|
16 | + if(stristr($this->content, $match)) { |
|
17 | + $this->content = str_replace($match, $replace, $this->content); |
|
18 | + } |
|
18 | 19 | } |
19 | 20 | return; |
20 | 21 | } |
@@ -10,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); |
@@ -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 | { |