@@ -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); |
@@ -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); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | private function create_placeholder($text) |
| 58 | 58 | { |
| 59 | - return md5($text . rand()); |
|
| 59 | + return md5($text.rand()); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | private function create_full_match_pattern($text) |
@@ -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 | } |
@@ -5,104 +5,104 @@ |
||
| 5 | 5 | final class CleanCommentContent extends Content |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $LINK_PATTERN = '@<a.*href=["\']([^"\']*)["\'].*>(.*)</a>@i'; |
|
| 9 | - private static $BOLD_PATTERN = '@<b.*>(.*)</b>@i'; |
|
| 10 | - private static $ITALIC_PATTERN = '@<i.*>(.*)</i>@i'; |
|
| 11 | - private static $CODE_PATTERN = '@<pre[^>]*>(.*)</pre>@is'; |
|
| 8 | + private static $LINK_PATTERN = '@<a.*href=["\']([^"\']*)["\'].*>(.*)</a>@i'; |
|
| 9 | + private static $BOLD_PATTERN = '@<b.*>(.*)</b>@i'; |
|
| 10 | + private static $ITALIC_PATTERN = '@<i.*>(.*)</i>@i'; |
|
| 11 | + private static $CODE_PATTERN = '@<pre[^>]*>(.*)</pre>@is'; |
|
| 12 | 12 | |
| 13 | - private static $LINK_REPLACE = '<a href="%s" rel="nofollow" target="_blank">%s</a>'; |
|
| 14 | - private static $BOLD_REPLACE = '<b>%s</b>'; |
|
| 15 | - private static $ITALIC_REPLACE = '<i>%s</i>'; |
|
| 16 | - private static $CODE_REPLACE = '<pre>%s</pre>'; |
|
| 13 | + private static $LINK_REPLACE = '<a href="%s" rel="nofollow" target="_blank">%s</a>'; |
|
| 14 | + private static $BOLD_REPLACE = '<b>%s</b>'; |
|
| 15 | + private static $ITALIC_REPLACE = '<i>%s</i>'; |
|
| 16 | + private static $CODE_REPLACE = '<pre>%s</pre>'; |
|
| 17 | 17 | |
| 18 | - private static $URL_PATTERN = '@(https?://[a-z0-9\.-]+\.[a-z]{2,6}[^\s]*[^\.,\?\!;\s]+)@i'; |
|
| 19 | - private static $LINE_BREAK_PATTERN = '@([\r\n]+)@'; |
|
| 18 | + private static $URL_PATTERN = '@(https?://[a-z0-9\.-]+\.[a-z]{2,6}[^\s]*[^\.,\?\!;\s]+)@i'; |
|
| 19 | + private static $LINE_BREAK_PATTERN = '@([\r\n]+)@'; |
|
| 20 | 20 | |
| 21 | - private static $LINE_BREAK_REPLACE = '<br />'; |
|
| 21 | + private static $LINE_BREAK_REPLACE = '<br />'; |
|
| 22 | 22 | |
| 23 | - private $replacement_array = array(); |
|
| 23 | + private $replacement_array = array(); |
|
| 24 | 24 | |
| 25 | - protected function execute() |
|
| 26 | - { |
|
| 27 | - $this->process_element(self::$CODE_PATTERN, self::$CODE_REPLACE); |
|
| 28 | - $this->process_element(self::$LINK_PATTERN, self::$LINK_REPLACE); |
|
| 29 | - $this->process_element(self::$ITALIC_PATTERN, self::$ITALIC_REPLACE); |
|
| 30 | - $this->process_element(self::$BOLD_PATTERN, self::$BOLD_REPLACE); |
|
| 25 | + protected function execute() |
|
| 26 | + { |
|
| 27 | + $this->process_element(self::$CODE_PATTERN, self::$CODE_REPLACE); |
|
| 28 | + $this->process_element(self::$LINK_PATTERN, self::$LINK_REPLACE); |
|
| 29 | + $this->process_element(self::$ITALIC_PATTERN, self::$ITALIC_REPLACE); |
|
| 30 | + $this->process_element(self::$BOLD_PATTERN, self::$BOLD_REPLACE); |
|
| 31 | 31 | |
| 32 | - $this->strip_extra_tags(); |
|
| 32 | + $this->strip_extra_tags(); |
|
| 33 | 33 | |
| 34 | - $this->link_unlinked_urls(self::$URL_PATTERN, self::$LINK_REPLACE); |
|
| 35 | - $this->add_line_breaks(); |
|
| 36 | - $this->replace_element_patterns(); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - private function process_element($pattern, $replace) |
|
| 40 | - { |
|
| 41 | - $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
|
| 34 | + $this->link_unlinked_urls(self::$URL_PATTERN, self::$LINK_REPLACE); |
|
| 35 | + $this->add_line_breaks(); |
|
| 36 | + $this->replace_element_patterns(); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + private function process_element($pattern, $replace) |
|
| 40 | + { |
|
| 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 | - foreach($matches as $match) |
|
| 47 | - { |
|
| 48 | - $full_match = array_shift($match); |
|
| 49 | - $placeholder = $this->create_placeholder($full_match); |
|
| 50 | - $full_match_pattern = $this->create_full_match_pattern($full_match); |
|
| 46 | + foreach($matches as $match) |
|
| 47 | + { |
|
| 48 | + $full_match = array_shift($match); |
|
| 49 | + $placeholder = $this->create_placeholder($full_match); |
|
| 50 | + $full_match_pattern = $this->create_full_match_pattern($full_match); |
|
| 51 | 51 | |
| 52 | - $this->content = preg_replace($full_match_pattern, $placeholder, $this->content, 1); |
|
| 53 | - $this->replacement_array[$placeholder] = vsprintf($replace, $match); |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - private function create_placeholder($text) |
|
| 58 | - { |
|
| 59 | - return md5($text . rand()); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - private function create_full_match_pattern($text) |
|
| 63 | - { |
|
| 64 | - $pattern = ''; |
|
| 65 | - $pattern .= '@'; |
|
| 66 | - $pattern .= preg_quote($text, '@'); |
|
| 67 | - $pattern .= '@'; |
|
| 68 | - $pattern .= 'i'; |
|
| 52 | + $this->content = preg_replace($full_match_pattern, $placeholder, $this->content, 1); |
|
| 53 | + $this->replacement_array[$placeholder] = vsprintf($replace, $match); |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + private function create_placeholder($text) |
|
| 58 | + { |
|
| 59 | + return md5($text . rand()); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + private function create_full_match_pattern($text) |
|
| 63 | + { |
|
| 64 | + $pattern = ''; |
|
| 65 | + $pattern .= '@'; |
|
| 66 | + $pattern .= preg_quote($text, '@'); |
|
| 67 | + $pattern .= '@'; |
|
| 68 | + $pattern .= 'i'; |
|
| 69 | 69 | |
| 70 | - return $pattern; |
|
| 71 | - } |
|
| 70 | + return $pattern; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - private function strip_extra_tags() |
|
| 74 | - { |
|
| 75 | - $this->content = strip_tags($this->content); |
|
| 76 | - } |
|
| 73 | + private function strip_extra_tags() |
|
| 74 | + { |
|
| 75 | + $this->content = strip_tags($this->content); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - private function link_unlinked_urls($pattern, $replace) |
|
| 79 | - { |
|
| 80 | - $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
|
| 78 | + private function link_unlinked_urls($pattern, $replace) |
|
| 79 | + { |
|
| 80 | + $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
|
| 81 | 81 | |
| 82 | - if($match_count < 1) |
|
| 83 | - return; |
|
| 82 | + if($match_count < 1) |
|
| 83 | + return; |
|
| 84 | 84 | |
| 85 | - foreach($matches as $match) |
|
| 86 | - { |
|
| 87 | - $full_match = array_shift($match); |
|
| 88 | - $full_match_pattern = $this->create_full_match_pattern($full_match); |
|
| 89 | - $replace = sprintf($replace, $match[0], $match[0]); |
|
| 85 | + foreach($matches as $match) |
|
| 86 | + { |
|
| 87 | + $full_match = array_shift($match); |
|
| 88 | + $full_match_pattern = $this->create_full_match_pattern($full_match); |
|
| 89 | + $replace = sprintf($replace, $match[0], $match[0]); |
|
| 90 | 90 | |
| 91 | - $this->content = preg_replace($full_match_pattern, $replace, $this->content, 1); |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - private function add_line_breaks() |
|
| 96 | - { |
|
| 97 | - $this->content = preg_replace(self::$LINE_BREAK_PATTERN, self::$LINE_BREAK_REPLACE, $this->content); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - private function replace_element_patterns() |
|
| 101 | - { |
|
| 102 | - foreach($this->replacement_array as $key => $replace) |
|
| 103 | - { |
|
| 104 | - $this->content = str_replace($key, $replace, $this->content); |
|
| 105 | - } |
|
| 106 | - } |
|
| 91 | + $this->content = preg_replace($full_match_pattern, $replace, $this->content, 1); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + private function add_line_breaks() |
|
| 96 | + { |
|
| 97 | + $this->content = preg_replace(self::$LINE_BREAK_PATTERN, self::$LINE_BREAK_REPLACE, $this->content); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + private function replace_element_patterns() |
|
| 101 | + { |
|
| 102 | + foreach($this->replacement_array as $key => $replace) |
|
| 103 | + { |
|
| 104 | + $this->content = str_replace($key, $replace, $this->content); |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | } |
| 109 | 109 | \ No newline at end of file |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', 'Content'); |
| 4 | 4 | |
| 5 | -final class CleanCommentContent extends Content |
|
| 6 | -{ |
|
| 5 | +final class CleanCommentContent extends Content |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $LINK_PATTERN = '@<a.*href=["\']([^"\']*)["\'].*>(.*)</a>@i'; |
| 9 | 9 | private static $BOLD_PATTERN = '@<b.*>(.*)</b>@i'; |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | private $replacement_array = array(); |
| 24 | 24 | |
| 25 | - protected function execute() |
|
| 26 | - { |
|
| 25 | + protected function execute() |
|
| 26 | + {
|
|
| 27 | 27 | $this->process_element(self::$CODE_PATTERN, self::$CODE_REPLACE); |
| 28 | 28 | $this->process_element(self::$LINK_PATTERN, self::$LINK_REPLACE); |
| 29 | 29 | $this->process_element(self::$ITALIC_PATTERN, self::$ITALIC_REPLACE); |
@@ -36,12 +36,13 @@ discard block |
||
| 36 | 36 | $this->replace_element_patterns(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - private function process_element($pattern, $replace) |
|
| 40 | - { |
|
| 39 | + private function process_element($pattern, $replace) |
|
| 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 | { |
@@ -54,13 +55,13 @@ discard block |
||
| 54 | 55 | } |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - private function create_placeholder($text) |
|
| 58 | - { |
|
| 58 | + private function create_placeholder($text) |
|
| 59 | + {
|
|
| 59 | 60 | return md5($text . rand()); |
| 60 | 61 | } |
| 61 | 62 | |
| 62 | - private function create_full_match_pattern($text) |
|
| 63 | - { |
|
| 63 | + private function create_full_match_pattern($text) |
|
| 64 | + {
|
|
| 64 | 65 | $pattern = ''; |
| 65 | 66 | $pattern .= '@'; |
| 66 | 67 | $pattern .= preg_quote($text, '@'); |
@@ -70,17 +71,18 @@ discard block |
||
| 70 | 71 | return $pattern; |
| 71 | 72 | } |
| 72 | 73 | |
| 73 | - private function strip_extra_tags() |
|
| 74 | - { |
|
| 74 | + private function strip_extra_tags() |
|
| 75 | + {
|
|
| 75 | 76 | $this->content = strip_tags($this->content); |
| 76 | 77 | } |
| 77 | 78 | |
| 78 | - private function link_unlinked_urls($pattern, $replace) |
|
| 79 | - { |
|
| 79 | + private function link_unlinked_urls($pattern, $replace) |
|
| 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 | { |
@@ -92,13 +94,13 @@ discard block |
||
| 92 | 94 | } |
| 93 | 95 | } |
| 94 | 96 | |
| 95 | - private function add_line_breaks() |
|
| 96 | - { |
|
| 97 | + private function add_line_breaks() |
|
| 98 | + {
|
|
| 97 | 99 | $this->content = preg_replace(self::$LINE_BREAK_PATTERN, self::$LINE_BREAK_REPLACE, $this->content); |
| 98 | 100 | } |
| 99 | 101 | |
| 100 | - private function replace_element_patterns() |
|
| 101 | - { |
|
| 102 | + private function replace_element_patterns() |
|
| 103 | + {
|
|
| 102 | 104 | foreach($this->replacement_array as $key => $replace) |
| 103 | 105 | { |
| 104 | 106 | $this->content = str_replace($key, $replace, $this->content); |
@@ -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);
|
@@ -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; |
@@ -5,74 +5,74 @@ discard block |
||
| 5 | 5 | final class FixInternalLinkContent extends Content |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $LINK_PLACEHOLDER_MATCH = '@{{link="([a-z0-9/-]*)"( anchor="([a-zA-Z0-9\s]*)")?}}@'; |
|
| 9 | - private static $ERROR_CONTENT = '<span>%s</span>'; |
|
| 10 | - private static $LINK_CONTENT = '<a href="%s" target="_blank" />%s</a>'; |
|
| 8 | + private static $LINK_PLACEHOLDER_MATCH = '@{{link="([a-z0-9/-]*)"( anchor="([a-zA-Z0-9\s]*)")?}}@'; |
|
| 9 | + private static $ERROR_CONTENT = '<span>%s</span>'; |
|
| 10 | + private static $LINK_CONTENT = '<a href="%s" target="_blank" />%s</a>'; |
|
| 11 | 11 | |
| 12 | - protected function execute($is_absolute = true) |
|
| 13 | - { |
|
| 14 | - preg_match_all(self::$LINK_PLACEHOLDER_MATCH, $this->content, $matches); |
|
| 15 | - foreach($matches[1] as $key => $match) |
|
| 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); |
|
| 21 | - $this->content = str_replace($matches[0][$key], $link_content, $this->content); |
|
| 22 | - } |
|
| 23 | - return; |
|
| 24 | - } |
|
| 12 | + protected function execute($is_absolute = true) |
|
| 13 | + { |
|
| 14 | + preg_match_all(self::$LINK_PLACEHOLDER_MATCH, $this->content, $matches); |
|
| 15 | + foreach($matches[1] as $key => $match) |
|
| 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); |
|
| 21 | + $this->content = str_replace($matches[0][$key], $link_content, $this->content); |
|
| 22 | + } |
|
| 23 | + return; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - private function get_link($string, $is_absolute, $anchor = '') |
|
| 27 | - { |
|
| 28 | - list($type, $uri) = explode('/', $string, 2); |
|
| 26 | + private function get_link($string, $is_absolute, $anchor = '') |
|
| 27 | + { |
|
| 28 | + list($type, $uri) = explode('/', $string, 2); |
|
| 29 | 29 | |
| 30 | - $link = ''; |
|
| 30 | + $link = ''; |
|
| 31 | 31 | |
| 32 | - switch($type) |
|
| 33 | - { |
|
| 34 | - case 'blog' : |
|
| 32 | + switch($type) |
|
| 33 | + { |
|
| 34 | + case 'blog' : |
|
| 35 | 35 | global $container; |
| 36 | 36 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 37 | 37 | $post = $repository->findPostByPath($uri); |
| 38 | 38 | |
| 39 | - if($post === NULL) |
|
| 40 | - return; |
|
| 39 | + if($post === NULL) |
|
| 40 | + return; |
|
| 41 | 41 | |
| 42 | - $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
|
| 43 | - $link .= "{$post['category']}/{$post['path']}/"; |
|
| 42 | + $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
|
| 43 | + $link .= "{$post['category']}/{$post['path']}/"; |
|
| 44 | 44 | |
| 45 | - if($anchor == '') |
|
| 46 | - $anchor = $post['title']; |
|
| 45 | + if($anchor == '') |
|
| 46 | + $anchor = $post['title']; |
|
| 47 | 47 | |
| 48 | - break; |
|
| 49 | - case 'blog-tag' : |
|
| 50 | - $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
|
| 51 | - $link .= "tag/{$uri}/"; |
|
| 48 | + break; |
|
| 49 | + case 'blog-tag' : |
|
| 50 | + $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
|
| 51 | + $link .= "tag/{$uri}/"; |
|
| 52 | 52 | |
| 53 | - if($anchor == '') |
|
| 54 | - { |
|
| 55 | - $anchor = $uri; |
|
| 56 | - $anchor = str_replace('-', ' ', $anchor); |
|
| 57 | - $anchor = ucwords($anchor); |
|
| 58 | - } |
|
| 53 | + if($anchor == '') |
|
| 54 | + { |
|
| 55 | + $anchor = $uri; |
|
| 56 | + $anchor = str_replace('-', ' ', $anchor); |
|
| 57 | + $anchor = ucwords($anchor); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - break; |
|
| 61 | - case 'journal' : |
|
| 62 | - Loader::load('collector', 'waterfall/LogCollector'); |
|
| 63 | - $log = LogCollector::getByAlias($uri); |
|
| 60 | + break; |
|
| 61 | + case 'journal' : |
|
| 62 | + Loader::load('collector', 'waterfall/LogCollector'); |
|
| 63 | + $log = LogCollector::getByAlias($uri); |
|
| 64 | 64 | |
| 65 | - if($log === NULL) |
|
| 66 | - return; |
|
| 65 | + if($log === NULL) |
|
| 66 | + return; |
|
| 67 | 67 | |
| 68 | - $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
|
| 69 | - $link .= "journal/{$log->alias}/"; |
|
| 68 | + $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
|
| 69 | + $link .= "journal/{$log->alias}/"; |
|
| 70 | 70 | |
| 71 | - if($anchor == '') |
|
| 72 | - $anchor = $log->title; |
|
| 71 | + if($anchor == '') |
|
| 72 | + $anchor = $log->title; |
|
| 73 | 73 | |
| 74 | - break; |
|
| 75 | - case 'falls' : |
|
| 74 | + break; |
|
| 75 | + case 'falls' : |
|
| 76 | 76 | $pieces = explode('/', $uri); |
| 77 | 77 | if (count($pieces) == 1) { |
| 78 | 78 | Loader::load('collector', 'waterfall/WatercourseCollector'); |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | $anchor = $waterfall->name; |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | - break; |
|
| 109 | - default : |
|
| 110 | - break; |
|
| 111 | - } |
|
| 108 | + break; |
|
| 109 | + default : |
|
| 110 | + break; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - return sprintf(self::$LINK_CONTENT, $link, $anchor); |
|
| 114 | - } |
|
| 113 | + return sprintf(self::$LINK_CONTENT, $link, $anchor); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | } |
@@ -2,29 +2,30 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', 'Content'); |
| 4 | 4 | |
| 5 | -final class FixInternalLinkContent extends Content |
|
| 6 | -{ |
|
| 5 | +final class FixInternalLinkContent extends Content |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $LINK_PLACEHOLDER_MATCH = '@{{link="([a-z0-9/-]*)"( anchor="([a-zA-Z0-9\s]*)")?}}@'; |
| 9 | 9 | private static $ERROR_CONTENT = '<span>%s</span>'; |
| 10 | 10 | private static $LINK_CONTENT = '<a href="%s" target="_blank" />%s</a>'; |
| 11 | 11 | |
| 12 | - protected function execute($is_absolute = true) |
|
| 13 | - { |
|
| 12 | + protected function execute($is_absolute = true) |
|
| 13 | + {
|
|
| 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; |
| 24 | 25 | } |
| 25 | 26 | |
| 26 | - private function get_link($string, $is_absolute, $anchor = '') |
|
| 27 | - { |
|
| 27 | + private function get_link($string, $is_absolute, $anchor = '') |
|
| 28 | + {
|
|
| 28 | 29 | list($type, $uri) = explode('/', $string, 2); |
| 29 | 30 | |
| 30 | 31 | $link = ''; |
@@ -36,14 +37,16 @@ discard block |
||
| 36 | 37 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 37 | 38 | $post = $repository->findPostByPath($uri); |
| 38 | 39 | |
| 39 | - if($post === NULL) |
|
| 40 | - return; |
|
| 40 | + if($post === NULL) {
|
|
| 41 | + return; |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
| 43 | 45 | $link .= "{$post['category']}/{$post['path']}/"; |
| 44 | 46 | |
| 45 | - if($anchor == '') |
|
| 46 | - $anchor = $post['title']; |
|
| 47 | + if($anchor == '') {
|
|
| 48 | + $anchor = $post['title']; |
|
| 49 | + } |
|
| 47 | 50 | |
| 48 | 51 | break; |
| 49 | 52 | case 'blog-tag' : |
@@ -62,14 +65,16 @@ discard block |
||
| 62 | 65 | Loader::load('collector', 'waterfall/LogCollector'); |
| 63 | 66 | $log = LogCollector::getByAlias($uri); |
| 64 | 67 | |
| 65 | - if($log === NULL) |
|
| 66 | - return; |
|
| 68 | + if($log === NULL) {
|
|
| 69 | + return; |
|
| 70 | + } |
|
| 67 | 71 | |
| 68 | 72 | $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
| 69 | 73 | $link .= "journal/{$log->alias}/"; |
| 70 | 74 | |
| 71 | - if($anchor == '') |
|
| 72 | - $anchor = $log->title; |
|
| 75 | + if($anchor == '') {
|
|
| 76 | + $anchor = $log->title; |
|
| 77 | + } |
|
| 73 | 78 | |
| 74 | 79 | break; |
| 75 | 80 | case 'falls' : |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | interface PostRepository |
| 6 | 6 | { |
| 7 | 7 | public function findPostByPath($category, $path); |
| 8 | - public function getActivePosts($limit = null, $offset= 0); |
|
| 8 | + public function getActivePosts($limit = null, $offset = 0); |
|
| 9 | 9 | public function getActivePostsCount(); |
| 10 | 10 | public function getActivePostsByTag($tag, $limit = null, $offset = 0); |
| 11 | 11 | public function getActivePostsCountByTag($tag); |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Jacobemerick\Web\Domain\Blog\Post; |
| 4 | 4 | |
| 5 | -interface PostRepositoryInterface |
|
| 6 | -{ |
|
| 5 | +interface PostRepositoryInterface |
|
| 6 | +{
|
|
| 7 | 7 | public function findPostByPath($path); |
| 8 | 8 | public function getActivePosts($limit = null, $offset= 0); |
| 9 | 9 | public function getActivePostsCount(); |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | protected function check_for_special_redirect($uri) |
| 47 | 47 | { |
| 48 | - if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches)) |
|
| 48 | + if (preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches)) |
|
| 49 | 49 | { |
| 50 | 50 | Loader::load('collector', 'blog/PostCollector'); |
| 51 | 51 | $post = PostCollector::getPostByURI($matches[2]); |
| 52 | - if(!$post) |
|
| 52 | + if (!$post) |
|
| 53 | 53 | { |
| 54 | 54 | Loader::loadNew('controller', '/Error404Controller') |
| 55 | 55 | ->activate(); |
@@ -61,21 +61,21 @@ discard block |
||
| 61 | 61 | else |
| 62 | 62 | { |
| 63 | 63 | $post_uri = URLDecode::getPiece(1); |
| 64 | - if($post_uri !== null) |
|
| 64 | + if ($post_uri !== null) |
|
| 65 | 65 | { |
| 66 | 66 | Loader::load('collector', 'blog/PostCollector'); |
| 67 | 67 | $post = PostCollector::getPostByURI($post_uri); |
| 68 | 68 | |
| 69 | - if($post != false) |
|
| 69 | + if ($post != false) |
|
| 70 | 70 | { |
| 71 | 71 | Loader::load('utility', 'Content'); |
| 72 | 72 | $uri = Content::instance('URLSafe', "/{$post->category}/{$post->title_url}/")->activate(); |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | - if($uri == '/search/') |
|
| 76 | + if ($uri == '/search/') |
|
| 77 | 77 | { |
| 78 | - if(Request::getGet('submit') == 'Submit Search' && Request::getGet('search')) |
|
| 78 | + if (Request::getGet('submit') == 'Submit Search' && Request::getGet('search')) |
|
| 79 | 79 | { |
| 80 | 80 | $uri .= Request::getGet('search'); |
| 81 | 81 | $uri .= '/'; |
@@ -5,121 +5,121 @@ |
||
| 5 | 5 | class BlogRouter extends Router |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - protected function get_redirect_array() |
|
| 9 | - { |
|
| 10 | - return array( |
|
| 11 | - (object) array( |
|
| 12 | - 'pattern' => '@^/page_([0-9]+)/$@', |
|
| 13 | - 'replace' => '/$1/'), |
|
| 14 | - (object) array( |
|
| 15 | - 'pattern' => '@/index.(html|htm|php)$@', |
|
| 16 | - 'replace' => '/'), |
|
| 17 | - (object) array( |
|
| 18 | - 'pattern' => '@^/([0-9]{4})-([a-z]+)/$@', |
|
| 19 | - 'replace' => '/'), |
|
| 20 | - (object) array( |
|
| 21 | - 'pattern' => '@^/([0-9]{4})-([a-z]+)/([0-9]+)/$@', |
|
| 22 | - 'replace' => '/'), |
|
| 23 | - (object) array( |
|
| 24 | - 'pattern' => '@^/month_([a-z]{3,})_([0-9]{4})(/?)$@', |
|
| 25 | - 'replace' => '/'), |
|
| 26 | - (object) array( |
|
| 27 | - 'pattern' => '@^/month_([a-z]{3,})_([0-9]{4})/page_([0-9]+)(/?)$@', |
|
| 28 | - 'replace' => '/'), |
|
| 29 | - (object) array( |
|
| 30 | - 'pattern' => '@^/category_([a-z-]+)(/?)$@', |
|
| 31 | - 'replace' => '/$1/'), |
|
| 32 | - (object) array( |
|
| 33 | - 'pattern' => '@^/category_([a-z-]+)/page_([0-9]+)(/?)$@', |
|
| 34 | - 'replace' => '/$1/$2/'), |
|
| 35 | - (object) array( |
|
| 36 | - 'pattern' => '@^/tag_([a-z-]+)(/?)$@', |
|
| 37 | - 'replace' => '/tag/$1/'), |
|
| 38 | - (object) array( |
|
| 39 | - 'pattern' => '@^/tag_([a-z-]+)/page_([0-9]+)(/?)$@', |
|
| 40 | - 'replace' => '/tag/$1/$2/'), |
|
| 41 | - (object) array( |
|
| 42 | - 'pattern' => '@^/blog/(.*)$@', |
|
| 43 | - 'replace' => '/$1')); |
|
| 44 | - } |
|
| 8 | + protected function get_redirect_array() |
|
| 9 | + { |
|
| 10 | + return array( |
|
| 11 | + (object) array( |
|
| 12 | + 'pattern' => '@^/page_([0-9]+)/$@', |
|
| 13 | + 'replace' => '/$1/'), |
|
| 14 | + (object) array( |
|
| 15 | + 'pattern' => '@/index.(html|htm|php)$@', |
|
| 16 | + 'replace' => '/'), |
|
| 17 | + (object) array( |
|
| 18 | + 'pattern' => '@^/([0-9]{4})-([a-z]+)/$@', |
|
| 19 | + 'replace' => '/'), |
|
| 20 | + (object) array( |
|
| 21 | + 'pattern' => '@^/([0-9]{4})-([a-z]+)/([0-9]+)/$@', |
|
| 22 | + 'replace' => '/'), |
|
| 23 | + (object) array( |
|
| 24 | + 'pattern' => '@^/month_([a-z]{3,})_([0-9]{4})(/?)$@', |
|
| 25 | + 'replace' => '/'), |
|
| 26 | + (object) array( |
|
| 27 | + 'pattern' => '@^/month_([a-z]{3,})_([0-9]{4})/page_([0-9]+)(/?)$@', |
|
| 28 | + 'replace' => '/'), |
|
| 29 | + (object) array( |
|
| 30 | + 'pattern' => '@^/category_([a-z-]+)(/?)$@', |
|
| 31 | + 'replace' => '/$1/'), |
|
| 32 | + (object) array( |
|
| 33 | + 'pattern' => '@^/category_([a-z-]+)/page_([0-9]+)(/?)$@', |
|
| 34 | + 'replace' => '/$1/$2/'), |
|
| 35 | + (object) array( |
|
| 36 | + 'pattern' => '@^/tag_([a-z-]+)(/?)$@', |
|
| 37 | + 'replace' => '/tag/$1/'), |
|
| 38 | + (object) array( |
|
| 39 | + 'pattern' => '@^/tag_([a-z-]+)/page_([0-9]+)(/?)$@', |
|
| 40 | + 'replace' => '/tag/$1/$2/'), |
|
| 41 | + (object) array( |
|
| 42 | + 'pattern' => '@^/blog/(.*)$@', |
|
| 43 | + 'replace' => '/$1')); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - protected function check_for_special_redirect($uri) |
|
| 47 | - { |
|
| 48 | - if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches)) |
|
| 49 | - { |
|
| 46 | + protected function check_for_special_redirect($uri) |
|
| 47 | + { |
|
| 48 | + if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches)) |
|
| 49 | + { |
|
| 50 | 50 | global $container; |
| 51 | 51 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 52 | 52 | $post = $repository->findPostByPath($matches[2]); |
| 53 | 53 | |
| 54 | - if(!$post) |
|
| 55 | - { |
|
| 56 | - Loader::loadNew('controller', '/Error404Controller') |
|
| 57 | - ->activate(); |
|
| 58 | - } |
|
| 54 | + if(!$post) |
|
| 55 | + { |
|
| 56 | + Loader::loadNew('controller', '/Error404Controller') |
|
| 57 | + ->activate(); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - Loader::load('utility', 'Content'); |
|
| 61 | - $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
|
| 62 | - } |
|
| 63 | - else |
|
| 64 | - { |
|
| 65 | - $post_uri = URLDecode::getPiece(1); |
|
| 66 | - if($post_uri !== null) |
|
| 67 | - { |
|
| 60 | + Loader::load('utility', 'Content'); |
|
| 61 | + $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
|
| 62 | + } |
|
| 63 | + else |
|
| 64 | + { |
|
| 65 | + $post_uri = URLDecode::getPiece(1); |
|
| 66 | + if($post_uri !== null) |
|
| 67 | + { |
|
| 68 | 68 | global $container; |
| 69 | 69 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 70 | 70 | $post = $repository->findPostByPath($post_uri); |
| 71 | 71 | |
| 72 | - if($post != false) |
|
| 73 | - { |
|
| 74 | - Loader::load('utility', 'Content'); |
|
| 75 | - $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - if($uri == '/search/') |
|
| 80 | - { |
|
| 81 | - if(Request::getGet('submit') == 'Submit Search' && Request::getGet('search')) |
|
| 82 | - { |
|
| 83 | - $uri .= Request::getGet('search'); |
|
| 84 | - $uri .= '/'; |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - return $uri; |
|
| 88 | - } |
|
| 72 | + if($post != false) |
|
| 73 | + { |
|
| 74 | + Loader::load('utility', 'Content'); |
|
| 75 | + $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + if($uri == '/search/') |
|
| 80 | + { |
|
| 81 | + if(Request::getGet('submit') == 'Submit Search' && Request::getGet('search')) |
|
| 82 | + { |
|
| 83 | + $uri .= Request::getGet('search'); |
|
| 84 | + $uri .= '/'; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + return $uri; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - protected function get_direct_array() |
|
| 91 | - { |
|
| 92 | - return array( |
|
| 93 | - (object) array( |
|
| 94 | - 'match' => '/', |
|
| 95 | - 'controller' => 'HomeController'), |
|
| 96 | - (object) array( |
|
| 97 | - 'match' => '/([0-9]+)/', |
|
| 98 | - 'controller' => 'HomeController'), |
|
| 99 | - (object) array( |
|
| 100 | - 'match' => '/about/', |
|
| 101 | - 'controller' => 'AboutController'), |
|
| 102 | - (object) array( |
|
| 103 | - 'match' => '/(hiking|personal|web-development)/', |
|
| 104 | - 'controller' => 'CategoryController'), |
|
| 105 | - (object) array( |
|
| 106 | - 'match' => '/(hiking|personal|web-development)/([0-9]+)/', |
|
| 107 | - 'controller' => 'CategoryController'), |
|
| 108 | - (object) array( |
|
| 109 | - 'match' => '/tag/([a-z0-9-]+)/', |
|
| 110 | - 'controller' => 'TagController'), |
|
| 111 | - (object) array( |
|
| 112 | - 'match' => '/tag/([a-z-]+)/([0-9]+)/', |
|
| 113 | - 'controller' => 'TagController'), |
|
| 114 | - (object) array( |
|
| 115 | - 'match' => '/search/([a-z0-9-]+)/', |
|
| 116 | - 'controller' => 'SearchController'), |
|
| 117 | - (object) array( |
|
| 118 | - 'match' => '/search/([a-z0-9-]+)/([0-9]+)/', |
|
| 119 | - 'controller' => 'SearchController'), |
|
| 120 | - (object) array( |
|
| 121 | - 'match' => '/([a-z-]+)/([a-z0-9-]+)/', |
|
| 122 | - 'controller' => 'PostController')); |
|
| 123 | - } |
|
| 90 | + protected function get_direct_array() |
|
| 91 | + { |
|
| 92 | + return array( |
|
| 93 | + (object) array( |
|
| 94 | + 'match' => '/', |
|
| 95 | + 'controller' => 'HomeController'), |
|
| 96 | + (object) array( |
|
| 97 | + 'match' => '/([0-9]+)/', |
|
| 98 | + 'controller' => 'HomeController'), |
|
| 99 | + (object) array( |
|
| 100 | + 'match' => '/about/', |
|
| 101 | + 'controller' => 'AboutController'), |
|
| 102 | + (object) array( |
|
| 103 | + 'match' => '/(hiking|personal|web-development)/', |
|
| 104 | + 'controller' => 'CategoryController'), |
|
| 105 | + (object) array( |
|
| 106 | + 'match' => '/(hiking|personal|web-development)/([0-9]+)/', |
|
| 107 | + 'controller' => 'CategoryController'), |
|
| 108 | + (object) array( |
|
| 109 | + 'match' => '/tag/([a-z0-9-]+)/', |
|
| 110 | + 'controller' => 'TagController'), |
|
| 111 | + (object) array( |
|
| 112 | + 'match' => '/tag/([a-z-]+)/([0-9]+)/', |
|
| 113 | + 'controller' => 'TagController'), |
|
| 114 | + (object) array( |
|
| 115 | + 'match' => '/search/([a-z0-9-]+)/', |
|
| 116 | + 'controller' => 'SearchController'), |
|
| 117 | + (object) array( |
|
| 118 | + 'match' => '/search/([a-z0-9-]+)/([0-9]+)/', |
|
| 119 | + 'controller' => 'SearchController'), |
|
| 120 | + (object) array( |
|
| 121 | + 'match' => '/([a-z-]+)/([a-z0-9-]+)/', |
|
| 122 | + 'controller' => 'PostController')); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | } |
@@ -2,11 +2,11 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('router', 'Router'); |
| 4 | 4 | |
| 5 | -class BlogRouter extends Router |
|
| 6 | -{ |
|
| 5 | +class BlogRouter extends Router |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | - protected function get_redirect_array() |
|
| 9 | - { |
|
| 8 | + protected function get_redirect_array() |
|
| 9 | + {
|
|
| 10 | 10 | return array( |
| 11 | 11 | (object) array( |
| 12 | 12 | 'pattern' => '@^/page_([0-9]+)/$@', |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | 'replace' => '/$1')); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - protected function check_for_special_redirect($uri) |
|
| 47 | - { |
|
| 46 | + protected function check_for_special_redirect($uri) |
|
| 47 | + {
|
|
| 48 | 48 | if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches)) |
| 49 | 49 | { |
| 50 | 50 | global $container; |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | Loader::load('utility', 'Content'); |
| 61 | 61 | $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
| 62 | - } |
|
| 63 | - else |
|
| 62 | + } else |
|
| 64 | 63 | { |
| 65 | 64 | $post_uri = URLDecode::getPiece(1); |
| 66 | 65 | if($post_uri !== null) |
@@ -87,8 +86,8 @@ discard block |
||
| 87 | 86 | return $uri; |
| 88 | 87 | } |
| 89 | 88 | |
| 90 | - protected function get_direct_array() |
|
| 91 | - { |
|
| 89 | + protected function get_direct_array() |
|
| 90 | + {
|
|
| 92 | 91 | return array( |
| 93 | 92 | (object) array( |
| 94 | 93 | 'match' => '/', |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | |
| 29 | 29 | protected function set_response($message, $type = 'internal') |
| 30 | 30 | { |
| 31 | - switch($type) |
|
| 31 | + switch ($type) |
|
| 32 | 32 | { |
| 33 | 33 | case 'internal' : |
| 34 | 34 | $this->response['internal'] = $message; |
@@ -1,60 +1,60 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', array( |
| 4 | - 'Header', |
|
| 5 | - 'Request')); |
|
| 4 | + 'Header', |
|
| 5 | + 'Request')); |
|
| 6 | 6 | |
| 7 | 7 | abstract class AJAXController |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - private static $RESPONSE_HEADER = 'sendJSON'; |
|
| 10 | + private static $RESPONSE_HEADER = 'sendJSON'; |
|
| 11 | 11 | |
| 12 | - private $response = array(); |
|
| 12 | + private $response = array(); |
|
| 13 | 13 | |
| 14 | - abstract protected function set_data(); |
|
| 14 | + abstract protected function set_data(); |
|
| 15 | 15 | |
| 16 | - function __construct() {} |
|
| 16 | + function __construct() {} |
|
| 17 | 17 | |
| 18 | - public function activate() |
|
| 19 | - { |
|
| 20 | - call_user_func(array('Header', self::$RESPONSE_HEADER)); |
|
| 18 | + public function activate() |
|
| 19 | + { |
|
| 20 | + call_user_func(array('Header', self::$RESPONSE_HEADER)); |
|
| 21 | 21 | |
| 22 | - $this->set_data(); |
|
| 23 | - echo $this->response_as_json(); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - protected function set_response($message, $type = 'internal') |
|
| 27 | - { |
|
| 28 | - switch($type) |
|
| 29 | - { |
|
| 30 | - case 'internal' : |
|
| 31 | - $this->response['internal'] = $message; |
|
| 32 | - break; |
|
| 33 | - case 'error' : |
|
| 34 | - $this->response['error'] = $message; |
|
| 35 | - default : |
|
| 36 | - $this->response[$type] = $message; |
|
| 37 | - break; |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - protected function fail_response($message) |
|
| 42 | - { |
|
| 43 | - $this->set_response($message, 'error'); |
|
| 44 | - return false; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - protected function eject($message) |
|
| 48 | - { |
|
| 49 | - $this->fail_response($message); |
|
| 50 | - echo $this->response_as_json(); |
|
| 51 | - exit(); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - private function response_as_json() |
|
| 55 | - { |
|
| 56 | - return json_encode($this->response); |
|
| 57 | - } |
|
| 22 | + $this->set_data(); |
|
| 23 | + echo $this->response_as_json(); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + protected function set_response($message, $type = 'internal') |
|
| 27 | + { |
|
| 28 | + switch($type) |
|
| 29 | + { |
|
| 30 | + case 'internal' : |
|
| 31 | + $this->response['internal'] = $message; |
|
| 32 | + break; |
|
| 33 | + case 'error' : |
|
| 34 | + $this->response['error'] = $message; |
|
| 35 | + default : |
|
| 36 | + $this->response[$type] = $message; |
|
| 37 | + break; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + protected function fail_response($message) |
|
| 42 | + { |
|
| 43 | + $this->set_response($message, 'error'); |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + protected function eject($message) |
|
| 48 | + { |
|
| 49 | + $this->fail_response($message); |
|
| 50 | + echo $this->response_as_json(); |
|
| 51 | + exit(); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + private function response_as_json() |
|
| 55 | + { |
|
| 56 | + return json_encode($this->response); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | 'Header', |
| 5 | 5 | 'Request')); |
| 6 | 6 | |
| 7 | -abstract class AJAXController |
|
| 8 | -{ |
|
| 7 | +abstract class AJAXController |
|
| 8 | +{
|
|
| 9 | 9 | |
| 10 | 10 | private static $RESPONSE_HEADER = 'sendJSON'; |
| 11 | 11 | |
@@ -13,18 +13,20 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | abstract protected function set_data(); |
| 15 | 15 | |
| 16 | - function __construct() {} |
|
| 16 | + function __construct() |
|
| 17 | + {
|
|
| 18 | +} |
|
| 17 | 19 | |
| 18 | - public function activate() |
|
| 19 | - { |
|
| 20 | + public function activate() |
|
| 21 | + {
|
|
| 20 | 22 | call_user_func(array('Header', self::$RESPONSE_HEADER)); |
| 21 | 23 | |
| 22 | 24 | $this->set_data(); |
| 23 | 25 | echo $this->response_as_json(); |
| 24 | 26 | } |
| 25 | 27 | |
| 26 | - protected function set_response($message, $type = 'internal') |
|
| 27 | - { |
|
| 28 | + protected function set_response($message, $type = 'internal') |
|
| 29 | + {
|
|
| 28 | 30 | switch($type) |
| 29 | 31 | { |
| 30 | 32 | case 'internal' : |
@@ -38,21 +40,21 @@ discard block |
||
| 38 | 40 | } |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | - protected function fail_response($message) |
|
| 42 | - { |
|
| 43 | + protected function fail_response($message) |
|
| 44 | + {
|
|
| 43 | 45 | $this->set_response($message, 'error'); |
| 44 | 46 | return false; |
| 45 | 47 | } |
| 46 | 48 | |
| 47 | - protected function eject($message) |
|
| 48 | - { |
|
| 49 | + protected function eject($message) |
|
| 50 | + {
|
|
| 49 | 51 | $this->fail_response($message); |
| 50 | 52 | echo $this->response_as_json(); |
| 51 | 53 | exit(); |
| 52 | 54 | } |
| 53 | 55 | |
| 54 | - private function response_as_json() |
|
| 55 | - { |
|
| 56 | + private function response_as_json() |
|
| 57 | + {
|
|
| 56 | 58 | return json_encode($this->response); |
| 57 | 59 | } |
| 58 | 60 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $companion_result = CompanionCollector::getCompanionList(); |
| 43 | 43 | $companion_list = array(); |
| 44 | 44 | |
| 45 | - foreach($companion_result as $companion_row) |
|
| 45 | + foreach ($companion_result as $companion_row) |
|
| 46 | 46 | { |
| 47 | 47 | $companion = new stdclass(); |
| 48 | 48 | $companion->name = $companion_row->name; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $period_result = PeriodCollector::getPeriodList(); |
| 56 | 56 | $period_list = array(); |
| 57 | 57 | |
| 58 | - foreach($period_result as $period_row) |
|
| 58 | + foreach ($period_result as $period_row) |
|
| 59 | 59 | { |
| 60 | 60 | $period = new stdclass(); |
| 61 | 61 | $period->name = $period_row->name; |
@@ -1,73 +1,73 @@ |
||
| 1 | 1 | <? |
| 2 | 2 | |
| 3 | 3 | Loader::load('collector', array( |
| 4 | - 'comment/CommentCollector', |
|
| 5 | - 'waterfall/CompanionCollector', |
|
| 6 | - 'waterfall/LogCollector', |
|
| 7 | - 'waterfall/PeriodCollector')); |
|
| 4 | + 'comment/CommentCollector', |
|
| 5 | + 'waterfall/CompanionCollector', |
|
| 6 | + 'waterfall/LogCollector', |
|
| 7 | + 'waterfall/PeriodCollector')); |
|
| 8 | 8 | Loader::load('controller', 'waterfalls/DefaultListController'); |
| 9 | 9 | |
| 10 | 10 | abstract class DefaultLogListController extends DefaultListController |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - private static $ITEM_COUNT_PER_PAGE = 10; |
|
| 13 | + private static $ITEM_COUNT_PER_PAGE = 10; |
|
| 14 | 14 | |
| 15 | - final protected function get_list_view() |
|
| 16 | - { |
|
| 17 | - return 'LogListing'; |
|
| 18 | - } |
|
| 15 | + final protected function get_list_view() |
|
| 16 | + { |
|
| 17 | + return 'LogListing'; |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - final protected function get_item_count_per_page() |
|
| 21 | - { |
|
| 22 | - return self::$ITEM_COUNT_PER_PAGE; |
|
| 23 | - } |
|
| 20 | + final protected function get_item_count_per_page() |
|
| 21 | + { |
|
| 22 | + return self::$ITEM_COUNT_PER_PAGE; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - final protected function format_item($item) |
|
| 26 | - { |
|
| 27 | - $item_array = array(); |
|
| 25 | + final protected function format_item($item) |
|
| 26 | + { |
|
| 27 | + $item_array = array(); |
|
| 28 | 28 | |
| 29 | - $item_array['title'] = $item->title; |
|
| 30 | - $item_array['image'] = $this->get_image_element($item->photo_category, $item->photo, $item->photo_description); |
|
| 31 | - $item_array['waterfall_list'] = LogCollector::getWaterfallListForLog($item->id); |
|
| 32 | - $item_array['introduction'] = $item->introduction; |
|
| 33 | - $item_array['path'] = "/journal/{$item->alias}/"; |
|
| 34 | - $item_array['comment_count'] = CommentCollector::getCommentCountForURL(self::$WATERFALL_SITE_ID, $item->alias); |
|
| 35 | - $item_array['date'] = $this->get_parsed_date($item->date); |
|
| 29 | + $item_array['title'] = $item->title; |
|
| 30 | + $item_array['image'] = $this->get_image_element($item->photo_category, $item->photo, $item->photo_description); |
|
| 31 | + $item_array['waterfall_list'] = LogCollector::getWaterfallListForLog($item->id); |
|
| 32 | + $item_array['introduction'] = $item->introduction; |
|
| 33 | + $item_array['path'] = "/journal/{$item->alias}/"; |
|
| 34 | + $item_array['comment_count'] = CommentCollector::getCommentCountForURL(self::$WATERFALL_SITE_ID, $item->alias); |
|
| 35 | + $item_array['date'] = $this->get_parsed_date($item->date); |
|
| 36 | 36 | |
| 37 | - return $item_array; |
|
| 38 | - } |
|
| 37 | + return $item_array; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - final protected function get_sidebar() |
|
| 41 | - { |
|
| 42 | - $companion_result = CompanionCollector::getCompanionList(); |
|
| 43 | - $companion_list = array(); |
|
| 40 | + final protected function get_sidebar() |
|
| 41 | + { |
|
| 42 | + $companion_result = CompanionCollector::getCompanionList(); |
|
| 43 | + $companion_list = array(); |
|
| 44 | 44 | |
| 45 | - foreach($companion_result as $companion_row) |
|
| 46 | - { |
|
| 47 | - $companion = new stdclass(); |
|
| 48 | - $companion->name = $companion_row->name; |
|
| 49 | - $companion->uri = "/companion/{$companion_row->alias}/"; |
|
| 50 | - $companion->count = $companion_row->count; |
|
| 45 | + foreach($companion_result as $companion_row) |
|
| 46 | + { |
|
| 47 | + $companion = new stdclass(); |
|
| 48 | + $companion->name = $companion_row->name; |
|
| 49 | + $companion->uri = "/companion/{$companion_row->alias}/"; |
|
| 50 | + $companion->count = $companion_row->count; |
|
| 51 | 51 | |
| 52 | - $companion_list[] = $companion; |
|
| 53 | - } |
|
| 52 | + $companion_list[] = $companion; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - $period_result = PeriodCollector::getPeriodList(); |
|
| 56 | - $period_list = array(); |
|
| 55 | + $period_result = PeriodCollector::getPeriodList(); |
|
| 56 | + $period_list = array(); |
|
| 57 | 57 | |
| 58 | - foreach($period_result as $period_row) |
|
| 59 | - { |
|
| 60 | - $period = new stdclass(); |
|
| 61 | - $period->name = $period_row->name; |
|
| 62 | - $period->uri = "/period/{$period_row->alias}/"; |
|
| 63 | - $period->count = $period_row->count; |
|
| 58 | + foreach($period_result as $period_row) |
|
| 59 | + { |
|
| 60 | + $period = new stdclass(); |
|
| 61 | + $period->name = $period_row->name; |
|
| 62 | + $period->uri = "/period/{$period_row->alias}/"; |
|
| 63 | + $period->count = $period_row->count; |
|
| 64 | 64 | |
| 65 | - $period_list[] = $period; |
|
| 66 | - } |
|
| 65 | + $period_list[] = $period; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - return array( |
|
| 69 | - 'companion_list' => $companion_list, |
|
| 70 | - 'period_list' => $period_list); |
|
| 71 | - } |
|
| 68 | + return array( |
|
| 69 | + 'companion_list' => $companion_list, |
|
| 70 | + 'period_list' => $period_list); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | \ No newline at end of file |
@@ -7,23 +7,23 @@ discard block |
||
| 7 | 7 | 'waterfall/PeriodCollector')); |
| 8 | 8 | Loader::load('controller', 'waterfalls/DefaultListController'); |
| 9 | 9 | |
| 10 | -abstract class DefaultLogListController extends DefaultListController |
|
| 11 | -{ |
|
| 10 | +abstract class DefaultLogListController extends DefaultListController |
|
| 11 | +{
|
|
| 12 | 12 | |
| 13 | 13 | private static $ITEM_COUNT_PER_PAGE = 10; |
| 14 | 14 | |
| 15 | - final protected function get_list_view() |
|
| 16 | - { |
|
| 15 | + final protected function get_list_view() |
|
| 16 | + {
|
|
| 17 | 17 | return 'LogListing'; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - final protected function get_item_count_per_page() |
|
| 21 | - { |
|
| 20 | + final protected function get_item_count_per_page() |
|
| 21 | + {
|
|
| 22 | 22 | return self::$ITEM_COUNT_PER_PAGE; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - final protected function format_item($item) |
|
| 26 | - { |
|
| 25 | + final protected function format_item($item) |
|
| 26 | + {
|
|
| 27 | 27 | $item_array = array(); |
| 28 | 28 | |
| 29 | 29 | $item_array['title'] = $item->title; |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | return $item_array; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - final protected function get_sidebar() |
|
| 41 | - { |
|
| 40 | + final protected function get_sidebar() |
|
| 41 | + {
|
|
| 42 | 42 | $companion_result = CompanionCollector::getCompanionList(); |
| 43 | 43 | $companion_list = array(); |
| 44 | 44 | |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | protected function get_page_number() |
| 28 | 28 | { |
| 29 | 29 | $page = URLDecode::getPiece(2); |
| 30 | - if(isset($page) && is_numeric($page)) |
|
| 30 | + if (isset($page) && is_numeric($page)) |
|
| 31 | 31 | return $page; |
| 32 | 32 | return 1; |
| 33 | 33 | } |
@@ -5,62 +5,62 @@ |
||
| 5 | 5 | final class SearchListController extends DefaultListController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $TITLE = 'Search Listing'; |
|
| 9 | - private static $DESCRIPTION = ''; |
|
| 8 | + private static $TITLE = 'Search Listing'; |
|
| 9 | + private static $DESCRIPTION = ''; |
|
| 10 | 10 | |
| 11 | - private static $KEYWORD_ARRAY = array(); |
|
| 11 | + private static $KEYWORD_ARRAY = array(); |
|
| 12 | 12 | |
| 13 | - protected function set_head_data() |
|
| 14 | - { |
|
| 15 | - parent::set_head_data(); |
|
| 13 | + protected function set_head_data() |
|
| 14 | + { |
|
| 15 | + parent::set_head_data(); |
|
| 16 | 16 | |
| 17 | - $this->set_title(self::$TITLE); |
|
| 18 | - $this->set_description(self::$DESCRIPTION); |
|
| 19 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 20 | - } |
|
| 17 | + $this->set_title(self::$TITLE); |
|
| 18 | + $this->set_description(self::$DESCRIPTION); |
|
| 19 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - protected function get_introduction() |
|
| 23 | - { |
|
| 24 | - return; |
|
| 25 | - } |
|
| 22 | + protected function get_introduction() |
|
| 23 | + { |
|
| 24 | + return; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - protected function get_page_number() |
|
| 28 | - { |
|
| 29 | - $page = URLDecode::getPiece(2); |
|
| 30 | - if(isset($page) && is_numeric($page)) |
|
| 31 | - return $page; |
|
| 32 | - return 1; |
|
| 33 | - } |
|
| 27 | + protected function get_page_number() |
|
| 28 | + { |
|
| 29 | + $page = URLDecode::getPiece(2); |
|
| 30 | + if(isset($page) && is_numeric($page)) |
|
| 31 | + return $page; |
|
| 32 | + return 1; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - protected function get_items() |
|
| 36 | - { |
|
| 37 | - return array(); |
|
| 38 | - } |
|
| 35 | + protected function get_items() |
|
| 36 | + { |
|
| 37 | + return array(); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - protected function get_list_description() |
|
| 41 | - { |
|
| 42 | - return 'yay cloud'; |
|
| 43 | - } |
|
| 40 | + protected function get_list_description() |
|
| 41 | + { |
|
| 42 | + return 'yay cloud'; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - protected function get_list_next_link() |
|
| 46 | - { |
|
| 47 | - return '/'; |
|
| 48 | - } |
|
| 45 | + protected function get_list_next_link() |
|
| 46 | + { |
|
| 47 | + return '/'; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - protected function get_list_prev_link() |
|
| 51 | - { |
|
| 52 | - return '/'; |
|
| 53 | - } |
|
| 50 | + protected function get_list_prev_link() |
|
| 51 | + { |
|
| 52 | + return '/'; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - private $total_post_count; |
|
| 56 | - protected function get_item_count() |
|
| 57 | - { |
|
| 58 | - return 20; |
|
| 59 | - } |
|
| 55 | + private $total_post_count; |
|
| 56 | + protected function get_item_count() |
|
| 57 | + { |
|
| 58 | + return 20; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - protected function get_item_count_per_page() |
|
| 62 | - { |
|
| 63 | - return 20; |
|
| 64 | - } |
|
| 61 | + protected function get_item_count_per_page() |
|
| 62 | + { |
|
| 63 | + return 20; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | \ No newline at end of file |
@@ -2,16 +2,16 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('controller', 'waterfalls/DefaultListController'); |
| 4 | 4 | |
| 5 | -final class SearchListController extends DefaultListController |
|
| 6 | -{ |
|
| 5 | +final class SearchListController extends DefaultListController |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $TITLE = 'Search Listing'; |
| 9 | 9 | private static $DESCRIPTION = ''; |
| 10 | 10 | |
| 11 | 11 | private static $KEYWORD_ARRAY = array(); |
| 12 | 12 | |
| 13 | - protected function set_head_data() |
|
| 14 | - { |
|
| 13 | + protected function set_head_data() |
|
| 14 | + {
|
|
| 15 | 15 | parent::set_head_data(); |
| 16 | 16 | |
| 17 | 17 | $this->set_title(self::$TITLE); |
@@ -19,47 +19,48 @@ discard block |
||
| 19 | 19 | $this->set_keywords(self::$KEYWORD_ARRAY); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - protected function get_introduction() |
|
| 23 | - { |
|
| 22 | + protected function get_introduction() |
|
| 23 | + {
|
|
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - protected function get_page_number() |
|
| 28 | - { |
|
| 27 | + protected function get_page_number() |
|
| 28 | + {
|
|
| 29 | 29 | $page = URLDecode::getPiece(2); |
| 30 | - if(isset($page) && is_numeric($page)) |
|
| 31 | - return $page; |
|
| 30 | + if(isset($page) && is_numeric($page)) {
|
|
| 31 | + return $page; |
|
| 32 | + } |
|
| 32 | 33 | return 1; |
| 33 | 34 | } |
| 34 | 35 | |
| 35 | - protected function get_items() |
|
| 36 | - { |
|
| 36 | + protected function get_items() |
|
| 37 | + {
|
|
| 37 | 38 | return array(); |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | - protected function get_list_description() |
|
| 41 | - { |
|
| 41 | + protected function get_list_description() |
|
| 42 | + {
|
|
| 42 | 43 | return 'yay cloud'; |
| 43 | 44 | } |
| 44 | 45 | |
| 45 | - protected function get_list_next_link() |
|
| 46 | - { |
|
| 46 | + protected function get_list_next_link() |
|
| 47 | + {
|
|
| 47 | 48 | return '/'; |
| 48 | 49 | } |
| 49 | 50 | |
| 50 | - protected function get_list_prev_link() |
|
| 51 | - { |
|
| 51 | + protected function get_list_prev_link() |
|
| 52 | + {
|
|
| 52 | 53 | return '/'; |
| 53 | 54 | } |
| 54 | 55 | |
| 55 | 56 | private $total_post_count; |
| 56 | - protected function get_item_count() |
|
| 57 | - { |
|
| 57 | + protected function get_item_count() |
|
| 58 | + {
|
|
| 58 | 59 | return 20; |
| 59 | 60 | } |
| 60 | 61 | |
| 61 | - protected function get_item_count_per_page() |
|
| 62 | - { |
|
| 62 | + protected function get_item_count_per_page() |
|
| 63 | + {
|
|
| 63 | 64 | return 20; |
| 64 | 65 | } |
| 65 | 66 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $county_result = CountyCollector::getCountyList(); |
| 42 | 42 | $county_list = array(); |
| 43 | 43 | |
| 44 | - foreach($county_result as $county_row) |
|
| 44 | + foreach ($county_result as $county_row) |
|
| 45 | 45 | { |
| 46 | 46 | $county = new stdclass(); |
| 47 | 47 | $county->name = $county_row->name; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $watercourse_result = WatercourseCollector::getWatercourseList(); |
| 55 | 55 | $watercourse_list = array(); |
| 56 | 56 | |
| 57 | - foreach($watercourse_result as $watercourse_row) |
|
| 57 | + foreach ($watercourse_result as $watercourse_row) |
|
| 58 | 58 | { |
| 59 | 59 | $watercourse = new stdclass(); |
| 60 | 60 | $watercourse->name = $watercourse_row->name; |
@@ -1,72 +1,72 @@ |
||
| 1 | 1 | <? |
| 2 | 2 | |
| 3 | 3 | Loader::load('collector', array( |
| 4 | - 'comment/CommentCollector', |
|
| 5 | - 'waterfall/CountyCollector', |
|
| 6 | - 'waterfall/WatercourseCollector', |
|
| 7 | - 'waterfall/WaterfallCollector')); |
|
| 4 | + 'comment/CommentCollector', |
|
| 5 | + 'waterfall/CountyCollector', |
|
| 6 | + 'waterfall/WatercourseCollector', |
|
| 7 | + 'waterfall/WaterfallCollector')); |
|
| 8 | 8 | Loader::load('controller', 'waterfalls/DefaultListController'); |
| 9 | 9 | |
| 10 | 10 | abstract class DefaultWaterfallListController extends DefaultListController |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - protected static $ITEM_COUNT_PER_PAGE = 24; |
|
| 13 | + protected static $ITEM_COUNT_PER_PAGE = 24; |
|
| 14 | 14 | |
| 15 | - final protected function get_list_view() |
|
| 16 | - { |
|
| 17 | - return 'FallListing'; |
|
| 18 | - } |
|
| 15 | + final protected function get_list_view() |
|
| 16 | + { |
|
| 17 | + return 'FallListing'; |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - protected function get_item_count_per_page() |
|
| 21 | - { |
|
| 22 | - return self::$ITEM_COUNT_PER_PAGE; |
|
| 23 | - } |
|
| 20 | + protected function get_item_count_per_page() |
|
| 21 | + { |
|
| 22 | + return self::$ITEM_COUNT_PER_PAGE; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - final protected function format_item($item) |
|
| 26 | - { |
|
| 27 | - $item_array = array(); |
|
| 25 | + final protected function format_item($item) |
|
| 26 | + { |
|
| 27 | + $item_array = array(); |
|
| 28 | 28 | |
| 29 | - $item_array['name'] = $item->name; |
|
| 30 | - $item_array['watercourse'] = $item->watercourse; |
|
| 31 | - $item_array['county'] = $item->county; |
|
| 32 | - $item_array['image'] = $this->get_image_element($item->photo_category, $item->photo, $item->photo_description, 'medium'); |
|
| 33 | - $item_array['path'] = "/{$item->watercourse_alias}/{$item->waterfall_alias}/"; |
|
| 34 | - $item_array['comment_count'] = CommentCollector::getCommentCountForURL(self::$WATERFALL_SITE_ID, "/{$item->watercourse_alias}/{$item->waterfall_alias}/"); |
|
| 29 | + $item_array['name'] = $item->name; |
|
| 30 | + $item_array['watercourse'] = $item->watercourse; |
|
| 31 | + $item_array['county'] = $item->county; |
|
| 32 | + $item_array['image'] = $this->get_image_element($item->photo_category, $item->photo, $item->photo_description, 'medium'); |
|
| 33 | + $item_array['path'] = "/{$item->watercourse_alias}/{$item->waterfall_alias}/"; |
|
| 34 | + $item_array['comment_count'] = CommentCollector::getCommentCountForURL(self::$WATERFALL_SITE_ID, "/{$item->watercourse_alias}/{$item->waterfall_alias}/"); |
|
| 35 | 35 | |
| 36 | - return $item_array; |
|
| 37 | - } |
|
| 36 | + return $item_array; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - final protected function get_sidebar() |
|
| 40 | - { |
|
| 41 | - $county_result = CountyCollector::getCountyList(); |
|
| 42 | - $county_list = array(); |
|
| 39 | + final protected function get_sidebar() |
|
| 40 | + { |
|
| 41 | + $county_result = CountyCollector::getCountyList(); |
|
| 42 | + $county_list = array(); |
|
| 43 | 43 | |
| 44 | - foreach($county_result as $county_row) |
|
| 45 | - { |
|
| 46 | - $county = new stdclass(); |
|
| 47 | - $county->name = $county_row->name; |
|
| 48 | - $county->uri = "/{$county_row->alias}/"; |
|
| 49 | - $county->count = $county_row->count; |
|
| 44 | + foreach($county_result as $county_row) |
|
| 45 | + { |
|
| 46 | + $county = new stdclass(); |
|
| 47 | + $county->name = $county_row->name; |
|
| 48 | + $county->uri = "/{$county_row->alias}/"; |
|
| 49 | + $county->count = $county_row->count; |
|
| 50 | 50 | |
| 51 | - $county_list[] = $county; |
|
| 52 | - } |
|
| 51 | + $county_list[] = $county; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - $watercourse_result = WatercourseCollector::getWatercourseList(); |
|
| 55 | - $watercourse_list = array(); |
|
| 54 | + $watercourse_result = WatercourseCollector::getWatercourseList(); |
|
| 55 | + $watercourse_list = array(); |
|
| 56 | 56 | |
| 57 | - foreach($watercourse_result as $watercourse_row) |
|
| 58 | - { |
|
| 59 | - $watercourse = new stdclass(); |
|
| 60 | - $watercourse->name = $watercourse_row->name; |
|
| 61 | - $watercourse->uri = "/{$watercourse_row->alias}/"; |
|
| 62 | - $watercourse->count = $watercourse_row->count; |
|
| 57 | + foreach($watercourse_result as $watercourse_row) |
|
| 58 | + { |
|
| 59 | + $watercourse = new stdclass(); |
|
| 60 | + $watercourse->name = $watercourse_row->name; |
|
| 61 | + $watercourse->uri = "/{$watercourse_row->alias}/"; |
|
| 62 | + $watercourse->count = $watercourse_row->count; |
|
| 63 | 63 | |
| 64 | - $watercourse_list[] = $watercourse; |
|
| 65 | - } |
|
| 64 | + $watercourse_list[] = $watercourse; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return array( |
|
| 68 | - 'county_list' => $county_list, |
|
| 69 | - 'watercourse_list' => $watercourse_list); |
|
| 70 | - } |
|
| 67 | + return array( |
|
| 68 | + 'county_list' => $county_list, |
|
| 69 | + 'watercourse_list' => $watercourse_list); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | } |
| 73 | 73 | \ No newline at end of file |
@@ -7,23 +7,23 @@ discard block |
||
| 7 | 7 | 'waterfall/WaterfallCollector')); |
| 8 | 8 | Loader::load('controller', 'waterfalls/DefaultListController'); |
| 9 | 9 | |
| 10 | -abstract class DefaultWaterfallListController extends DefaultListController |
|
| 11 | -{ |
|
| 10 | +abstract class DefaultWaterfallListController extends DefaultListController |
|
| 11 | +{
|
|
| 12 | 12 | |
| 13 | 13 | protected static $ITEM_COUNT_PER_PAGE = 24; |
| 14 | 14 | |
| 15 | - final protected function get_list_view() |
|
| 16 | - { |
|
| 15 | + final protected function get_list_view() |
|
| 16 | + {
|
|
| 17 | 17 | return 'FallListing'; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - protected function get_item_count_per_page() |
|
| 21 | - { |
|
| 20 | + protected function get_item_count_per_page() |
|
| 21 | + {
|
|
| 22 | 22 | return self::$ITEM_COUNT_PER_PAGE; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - final protected function format_item($item) |
|
| 26 | - { |
|
| 25 | + final protected function format_item($item) |
|
| 26 | + {
|
|
| 27 | 27 | $item_array = array(); |
| 28 | 28 | |
| 29 | 29 | $item_array['name'] = $item->name; |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | return $item_array; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - final protected function get_sidebar() |
|
| 40 | - { |
|
| 39 | + final protected function get_sidebar() |
|
| 40 | + {
|
|
| 41 | 41 | $county_result = CountyCollector::getCountyList(); |
| 42 | 42 | $county_list = array(); |
| 43 | 43 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | Loader::load('collector', 'blog/IntroductionCollector'); |
| 37 | 37 | $introduction_result = IntroductionCollector::getRow('about'); |
| 38 | 38 | |
| 39 | - if($introduction_result !== null) |
|
| 39 | + if ($introduction_result !== null) |
|
| 40 | 40 | { |
| 41 | 41 | $introduction = array(); |
| 42 | 42 | $introduction['title'] = $introduction_result->title; |
@@ -5,47 +5,47 @@ |
||
| 5 | 5 | final class AboutController extends DefaultPageController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $TITLE = 'About the Blog | Jacob Emerick'; |
|
| 9 | - private static $DESCRIPTION = "A little bit about the awesomeness on Jacob Emerick's Blog, diving into the topics covered, technology used, and methodology of writing new posts."; |
|
| 10 | - |
|
| 11 | - private static $KEYWORD_ARRAY = array( |
|
| 12 | - 'about', |
|
| 13 | - 'technologies', |
|
| 14 | - 'background', |
|
| 15 | - 'blog', |
|
| 16 | - 'Jacob Emerick'); |
|
| 17 | - |
|
| 18 | - protected function set_head_data() |
|
| 19 | - { |
|
| 20 | - $this->set_title(self::$TITLE); |
|
| 21 | - $this->set_description(self::$DESCRIPTION); |
|
| 22 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 8 | + private static $TITLE = 'About the Blog | Jacob Emerick'; |
|
| 9 | + private static $DESCRIPTION = "A little bit about the awesomeness on Jacob Emerick's Blog, diving into the topics covered, technology used, and methodology of writing new posts."; |
|
| 10 | + |
|
| 11 | + private static $KEYWORD_ARRAY = array( |
|
| 12 | + 'about', |
|
| 13 | + 'technologies', |
|
| 14 | + 'background', |
|
| 15 | + 'blog', |
|
| 16 | + 'Jacob Emerick'); |
|
| 17 | + |
|
| 18 | + protected function set_head_data() |
|
| 19 | + { |
|
| 20 | + $this->set_title(self::$TITLE); |
|
| 21 | + $this->set_description(self::$DESCRIPTION); |
|
| 22 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 23 | 23 | |
| 24 | - parent::set_head_data(); |
|
| 25 | - } |
|
| 24 | + parent::set_head_data(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - protected function set_body_data() |
|
| 28 | - { |
|
| 29 | - $this->set_body('view', 'About'); |
|
| 27 | + protected function set_body_data() |
|
| 28 | + { |
|
| 29 | + $this->set_body('view', 'About'); |
|
| 30 | 30 | |
| 31 | - parent::set_body_data(); |
|
| 32 | - } |
|
| 31 | + parent::set_body_data(); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - protected function get_introduction() |
|
| 35 | - { |
|
| 34 | + protected function get_introduction() |
|
| 35 | + { |
|
| 36 | 36 | global $container; |
| 37 | 37 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
| 38 | 38 | $introduction_result = $repository->findByType('about'); |
| 39 | 39 | |
| 40 | - if($introduction_result !== null) |
|
| 41 | - { |
|
| 42 | - $introduction = array(); |
|
| 43 | - $introduction['title'] = $introduction_result['title']; |
|
| 44 | - $introduction['content'] = $introduction_result['content']; |
|
| 45 | - $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
| 40 | + if($introduction_result !== null) |
|
| 41 | + { |
|
| 42 | + $introduction = array(); |
|
| 43 | + $introduction['title'] = $introduction_result['title']; |
|
| 44 | + $introduction['content'] = $introduction_result['content']; |
|
| 45 | + $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
| 46 | 46 | |
| 47 | - return $introduction; |
|
| 48 | - } |
|
| 49 | - } |
|
| 47 | + return $introduction; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | } |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('controller', 'blog/DefaultPageController'); |
| 4 | 4 | |
| 5 | -final class AboutController extends DefaultPageController |
|
| 6 | -{ |
|
| 5 | +final class AboutController extends DefaultPageController |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $TITLE = 'About the Blog | Jacob Emerick'; |
| 9 | 9 | private static $DESCRIPTION = "A little bit about the awesomeness on Jacob Emerick's Blog, diving into the topics covered, technology used, and methodology of writing new posts."; |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | 'blog', |
| 16 | 16 | 'Jacob Emerick'); |
| 17 | 17 | |
| 18 | - protected function set_head_data() |
|
| 19 | - { |
|
| 18 | + protected function set_head_data() |
|
| 19 | + {
|
|
| 20 | 20 | $this->set_title(self::$TITLE); |
| 21 | 21 | $this->set_description(self::$DESCRIPTION); |
| 22 | 22 | $this->set_keywords(self::$KEYWORD_ARRAY); |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | parent::set_head_data(); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - protected function set_body_data() |
|
| 28 | - { |
|
| 27 | + protected function set_body_data() |
|
| 28 | + {
|
|
| 29 | 29 | $this->set_body('view', 'About'); |
| 30 | 30 | |
| 31 | 31 | parent::set_body_data(); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - protected function get_introduction() |
|
| 35 | - { |
|
| 34 | + protected function get_introduction() |
|
| 35 | + {
|
|
| 36 | 36 | global $container; |
| 37 | 37 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
| 38 | 38 | $introduction_result = $repository->findByType('about'); |