@@ -5,47 +5,47 @@ |
||
| 5 | 5 | final class FetchFirstPhotoContent extends Content |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@'; |
|
| 9 | - private static $IMAGE_NODE = '<img src="%sphoto/%s/%s-size-%s.%s" height="%d" width="%d" alt="%s" />'; |
|
| 10 | - private static $DEFAULT_RETURN = ''; |
|
| 11 | - |
|
| 12 | - protected function execute($is_absolute = false, $size = 'thumb') |
|
| 13 | - { |
|
| 14 | - if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
| 15 | - $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
|
| 16 | - else |
|
| 17 | - $this->content = self::$DEFAULT_RETURN; |
|
| 18 | - return; |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - private function get_file_path($category, $photo, $size, $extension) |
|
| 22 | - { |
|
| 23 | - $path = "{$category}/{$photo}-size-{$size}.{$extension}"; |
|
| 24 | - return Loader::getImagePath('photo', $path); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - private function get_thumb($string, $is_absolute, $size) |
|
| 28 | - { |
|
| 29 | - list($category, $file_name) = explode('/', $string); |
|
| 30 | - list($photo, $extension) = explode('.', $file_name); |
|
| 8 | + private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@'; |
|
| 9 | + private static $IMAGE_NODE = '<img src="%sphoto/%s/%s-size-%s.%s" height="%d" width="%d" alt="%s" />'; |
|
| 10 | + private static $DEFAULT_RETURN = ''; |
|
| 11 | + |
|
| 12 | + protected function execute($is_absolute = false, $size = 'thumb') |
|
| 13 | + { |
|
| 14 | + if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
| 15 | + $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
|
| 16 | + else |
|
| 17 | + $this->content = self::$DEFAULT_RETURN; |
|
| 18 | + return; |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + private function get_file_path($category, $photo, $size, $extension) |
|
| 22 | + { |
|
| 23 | + $path = "{$category}/{$photo}-size-{$size}.{$extension}"; |
|
| 24 | + return Loader::getImagePath('photo', $path); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + private function get_thumb($string, $is_absolute, $size) |
|
| 28 | + { |
|
| 29 | + list($category, $file_name) = explode('/', $string); |
|
| 30 | + list($photo, $extension) = explode('.', $file_name); |
|
| 31 | 31 | |
| 32 | - $file_path = $this->get_file_path($category, $photo, $size, $extension); |
|
| 33 | - $file_size = getimagesize($file_path); |
|
| 32 | + $file_path = $this->get_file_path($category, $photo, $size, $extension); |
|
| 33 | + $file_size = getimagesize($file_path); |
|
| 34 | 34 | |
| 35 | - Loader::load('collector', 'image/PhotoCollector'); |
|
| 36 | - $photo_result = PhotoCollector::fetchRow($category, $photo); |
|
| 37 | - if($photo_result == false) |
|
| 38 | - return ''; |
|
| 35 | + Loader::load('collector', 'image/PhotoCollector'); |
|
| 36 | + $photo_result = PhotoCollector::fetchRow($category, $photo); |
|
| 37 | + if($photo_result == false) |
|
| 38 | + return ''; |
|
| 39 | 39 | |
| 40 | - $height = $file_size[1]; |
|
| 41 | - $width = $file_size[0]; |
|
| 42 | - $description = $photo_result->description; |
|
| 40 | + $height = $file_size[1]; |
|
| 41 | + $width = $file_size[0]; |
|
| 42 | + $description = $photo_result->description; |
|
| 43 | 43 | |
| 44 | - $domain = '/'; |
|
| 45 | - if($is_absolute) |
|
| 46 | - $domain = Loader::getRootURL(URLDecode::getSite()); |
|
| 44 | + $domain = '/'; |
|
| 45 | + if($is_absolute) |
|
| 46 | + $domain = Loader::getRootURL(URLDecode::getSite()); |
|
| 47 | 47 | |
| 48 | - return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
|
| 49 | - } |
|
| 48 | + return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | } |
@@ -2,30 +2,31 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', 'Content'); |
| 4 | 4 | |
| 5 | -final class FetchFirstPhotoContent extends Content |
|
| 6 | -{ |
|
| 5 | +final class FetchFirstPhotoContent extends Content |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@'; |
| 9 | 9 | private static $IMAGE_NODE = '<img src="%sphoto/%s/%s-size-%s.%s" height="%d" width="%d" alt="%s" />'; |
| 10 | 10 | private static $DEFAULT_RETURN = ''; |
| 11 | 11 | |
| 12 | - protected function execute($is_absolute = false, $size = 'thumb') |
|
| 13 | - { |
|
| 14 | - if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
| 15 | - $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
|
| 16 | - else |
|
| 17 | - $this->content = self::$DEFAULT_RETURN; |
|
| 12 | + protected function execute($is_absolute = false, $size = 'thumb') |
|
| 13 | + {
|
|
| 14 | + if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) {
|
|
| 15 | + $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
|
| 16 | + } else {
|
|
| 17 | + $this->content = self::$DEFAULT_RETURN; |
|
| 18 | + } |
|
| 18 | 19 | return; |
| 19 | 20 | } |
| 20 | 21 | |
| 21 | - private function get_file_path($category, $photo, $size, $extension) |
|
| 22 | - { |
|
| 22 | + private function get_file_path($category, $photo, $size, $extension) |
|
| 23 | + {
|
|
| 23 | 24 | $path = "{$category}/{$photo}-size-{$size}.{$extension}"; |
| 24 | 25 | return Loader::getImagePath('photo', $path); |
| 25 | 26 | } |
| 26 | 27 | |
| 27 | - private function get_thumb($string, $is_absolute, $size) |
|
| 28 | - { |
|
| 28 | + private function get_thumb($string, $is_absolute, $size) |
|
| 29 | + {
|
|
| 29 | 30 | list($category, $file_name) = explode('/', $string); |
| 30 | 31 | list($photo, $extension) = explode('.', $file_name); |
| 31 | 32 | |
@@ -34,16 +35,18 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | Loader::load('collector', 'image/PhotoCollector'); |
| 36 | 37 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
| 37 | - if($photo_result == false) |
|
| 38 | - return ''; |
|
| 38 | + if($photo_result == false) {
|
|
| 39 | + return ''; |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | $height = $file_size[1]; |
| 41 | 43 | $width = $file_size[0]; |
| 42 | 44 | $description = $photo_result->description; |
| 43 | 45 | |
| 44 | 46 | $domain = '/'; |
| 45 | - if($is_absolute) |
|
| 46 | - $domain = Loader::getRootURL(URLDecode::getSite()); |
|
| 47 | + if($is_absolute) {
|
|
| 48 | + $domain = Loader::getRootURL(URLDecode::getSite()); |
|
| 49 | + } |
|
| 47 | 50 | |
| 48 | 51 | return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
| 49 | 52 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | protected function execute($is_absolute = false, $size = 'thumb') |
| 13 | 13 | { |
| 14 | - if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
| 14 | + if (preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
| 15 | 15 | $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
| 16 | 16 | else |
| 17 | 17 | $this->content = self::$DEFAULT_RETURN; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | Loader::load('collector', 'image/PhotoCollector'); |
| 36 | 36 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
| 37 | - if($photo_result == false) |
|
| 37 | + if ($photo_result == false) |
|
| 38 | 38 | return ''; |
| 39 | 39 | |
| 40 | 40 | $height = $file_size[1]; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $description = $photo_result->description; |
| 43 | 43 | |
| 44 | 44 | $domain = '/'; |
| 45 | - if($is_absolute) |
|
| 45 | + if ($is_absolute) |
|
| 46 | 46 | $domain = Loader::getRootURL(URLDecode::getSite()); |
| 47 | 47 | |
| 48 | 48 | return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
@@ -5,50 +5,50 @@ |
||
| 5 | 5 | final class FixPhotoContent extends Content |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@'; |
|
| 9 | - private static $ERROR_CONTENT = '<div class="photo-holder"><p class="photo-caption">Image (%s) could not be found!</p></div>'; |
|
| 10 | - private static $PHOTO_CONTENT = '<div class="photo-holder"><img src="%sphoto/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" /><p class="photo-caption">%s</p></div>'; |
|
| 8 | + private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@'; |
|
| 9 | + private static $ERROR_CONTENT = '<div class="photo-holder"><p class="photo-caption">Image (%s) could not be found!</p></div>'; |
|
| 10 | + private static $PHOTO_CONTENT = '<div class="photo-holder"><img src="%sphoto/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" /><p class="photo-caption">%s</p></div>'; |
|
| 11 | 11 | |
| 12 | - protected function execute($is_absolute = false, $size = 'medium') |
|
| 13 | - { |
|
| 14 | - preg_match_all(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $matches); |
|
| 15 | - foreach($matches[1] as $key => $match) |
|
| 16 | - { |
|
| 17 | - $photo_content = $this->get_photo_content($match, $size, $is_absolute); |
|
| 18 | - $this->content = str_replace($matches[0][$key], $photo_content, $this->content); |
|
| 19 | - } |
|
| 20 | - return; |
|
| 21 | - } |
|
| 12 | + protected function execute($is_absolute = false, $size = 'medium') |
|
| 13 | + { |
|
| 14 | + preg_match_all(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $matches); |
|
| 15 | + foreach($matches[1] as $key => $match) |
|
| 16 | + { |
|
| 17 | + $photo_content = $this->get_photo_content($match, $size, $is_absolute); |
|
| 18 | + $this->content = str_replace($matches[0][$key], $photo_content, $this->content); |
|
| 19 | + } |
|
| 20 | + return; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - private function get_file_path($category, $photo, $size, $extension) |
|
| 24 | - { |
|
| 25 | - $path = "{$category}/{$photo}-size-{$size}.{$extension}"; |
|
| 26 | - return Loader::getImagePath('photo', $path); |
|
| 27 | - } |
|
| 23 | + private function get_file_path($category, $photo, $size, $extension) |
|
| 24 | + { |
|
| 25 | + $path = "{$category}/{$photo}-size-{$size}.{$extension}"; |
|
| 26 | + return Loader::getImagePath('photo', $path); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - private function get_photo_content($string, $size, $is_absolute) |
|
| 30 | - { |
|
| 31 | - list($category, $file_name) = explode('/', $string); |
|
| 32 | - list($photo, $extension) = explode('.', $file_name); |
|
| 29 | + private function get_photo_content($string, $size, $is_absolute) |
|
| 30 | + { |
|
| 31 | + list($category, $file_name) = explode('/', $string); |
|
| 32 | + list($photo, $extension) = explode('.', $file_name); |
|
| 33 | 33 | |
| 34 | - $file_path = $this->get_file_path($category, $photo, $size, $extension); |
|
| 34 | + $file_path = $this->get_file_path($category, $photo, $size, $extension); |
|
| 35 | 35 | |
| 36 | - $file_size = getimagesize($file_path); |
|
| 36 | + $file_size = getimagesize($file_path); |
|
| 37 | 37 | |
| 38 | - Loader::load('collector', 'image/PhotoCollector'); |
|
| 39 | - $photo_result = PhotoCollector::fetchRow($category, $photo); |
|
| 40 | - if($photo_result == false) |
|
| 41 | - return ''; |
|
| 38 | + Loader::load('collector', 'image/PhotoCollector'); |
|
| 39 | + $photo_result = PhotoCollector::fetchRow($category, $photo); |
|
| 40 | + if($photo_result == false) |
|
| 41 | + return ''; |
|
| 42 | 42 | |
| 43 | - $height = $file_size[1]; |
|
| 44 | - $width = $file_size[0]; |
|
| 45 | - $description = $photo_result->description; |
|
| 43 | + $height = $file_size[1]; |
|
| 44 | + $width = $file_size[0]; |
|
| 45 | + $description = $photo_result->description; |
|
| 46 | 46 | |
| 47 | - $domain = '/'; |
|
| 48 | - if($is_absolute) |
|
| 49 | - $domain = Loader::getRootUrl('blog'); |
|
| 47 | + $domain = '/'; |
|
| 48 | + if($is_absolute) |
|
| 49 | + $domain = Loader::getRootUrl('blog'); |
|
| 50 | 50 | |
| 51 | - return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description); |
|
| 52 | - } |
|
| 51 | + return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | } |
@@ -2,15 +2,15 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', 'Content'); |
| 4 | 4 | |
| 5 | -final class FixPhotoContent extends Content |
|
| 6 | -{ |
|
| 5 | +final class FixPhotoContent extends Content |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@'; |
| 9 | 9 | private static $ERROR_CONTENT = '<div class="photo-holder"><p class="photo-caption">Image (%s) could not be found!</p></div>'; |
| 10 | 10 | private static $PHOTO_CONTENT = '<div class="photo-holder"><img src="%sphoto/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" /><p class="photo-caption">%s</p></div>'; |
| 11 | 11 | |
| 12 | - protected function execute($is_absolute = false, $size = 'medium') |
|
| 13 | - { |
|
| 12 | + protected function execute($is_absolute = false, $size = 'medium') |
|
| 13 | + {
|
|
| 14 | 14 | preg_match_all(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $matches); |
| 15 | 15 | foreach($matches[1] as $key => $match) |
| 16 | 16 | { |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | return; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - private function get_file_path($category, $photo, $size, $extension) |
|
| 24 | - { |
|
| 23 | + private function get_file_path($category, $photo, $size, $extension) |
|
| 24 | + {
|
|
| 25 | 25 | $path = "{$category}/{$photo}-size-{$size}.{$extension}"; |
| 26 | 26 | return Loader::getImagePath('photo', $path); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - private function get_photo_content($string, $size, $is_absolute) |
|
| 30 | - { |
|
| 29 | + private function get_photo_content($string, $size, $is_absolute) |
|
| 30 | + {
|
|
| 31 | 31 | list($category, $file_name) = explode('/', $string); |
| 32 | 32 | list($photo, $extension) = explode('.', $file_name); |
| 33 | 33 | |
@@ -37,16 +37,18 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | Loader::load('collector', 'image/PhotoCollector'); |
| 39 | 39 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
| 40 | - if($photo_result == false) |
|
| 41 | - return ''; |
|
| 40 | + if($photo_result == false) {
|
|
| 41 | + return ''; |
|
| 42 | + } |
|
| 42 | 43 | |
| 43 | 44 | $height = $file_size[1]; |
| 44 | 45 | $width = $file_size[0]; |
| 45 | 46 | $description = $photo_result->description; |
| 46 | 47 | |
| 47 | 48 | $domain = '/'; |
| 48 | - if($is_absolute) |
|
| 49 | - $domain = Loader::getRootUrl('blog'); |
|
| 49 | + if($is_absolute) {
|
|
| 50 | + $domain = Loader::getRootUrl('blog');
|
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description); |
| 52 | 54 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | protected function execute($is_absolute = false, $size = 'medium') |
| 13 | 13 | { |
| 14 | 14 | preg_match_all(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $matches); |
| 15 | - foreach($matches[1] as $key => $match) |
|
| 15 | + foreach ($matches[1] as $key => $match) |
|
| 16 | 16 | { |
| 17 | 17 | $photo_content = $this->get_photo_content($match, $size, $is_absolute); |
| 18 | 18 | $this->content = str_replace($matches[0][$key], $photo_content, $this->content); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | Loader::load('collector', 'image/PhotoCollector'); |
| 39 | 39 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
| 40 | - if($photo_result == false) |
|
| 40 | + if ($photo_result == false) |
|
| 41 | 41 | return ''; |
| 42 | 42 | |
| 43 | 43 | $height = $file_size[1]; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $description = $photo_result->description; |
| 46 | 46 | |
| 47 | 47 | $domain = '/'; |
| 48 | - if($is_absolute) |
|
| 48 | + if ($is_absolute) |
|
| 49 | 49 | $domain = Loader::getRootUrl('blog'); |
| 50 | 50 | |
| 51 | 51 | return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description); |
@@ -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' : |
@@ -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,20 +29,20 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $link = ''; |
| 31 | 31 | |
| 32 | - switch($type) |
|
| 32 | + switch ($type) |
|
| 33 | 33 | { |
| 34 | 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) |
|
| 39 | + if ($post === NULL) |
|
| 40 | 40 | return; |
| 41 | 41 | |
| 42 | 42 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
| 43 | 43 | $link .= "{$post['category']}/{$post['path']}/"; |
| 44 | 44 | |
| 45 | - if($anchor == '') |
|
| 45 | + if ($anchor == '') |
|
| 46 | 46 | $anchor = $post['title']; |
| 47 | 47 | |
| 48 | 48 | break; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
| 51 | 51 | $link .= "tag/{$uri}/"; |
| 52 | 52 | |
| 53 | - if($anchor == '') |
|
| 53 | + if ($anchor == '') |
|
| 54 | 54 | { |
| 55 | 55 | $anchor = $uri; |
| 56 | 56 | $anchor = str_replace('-', ' ', $anchor); |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | Loader::load('collector', 'waterfall/LogCollector'); |
| 63 | 63 | $log = LogCollector::getByAlias($uri); |
| 64 | 64 | |
| 65 | - if($log === NULL) |
|
| 65 | + if ($log === NULL) |
|
| 66 | 66 | return; |
| 67 | 67 | |
| 68 | 68 | $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
| 69 | 69 | $link .= "journal/{$log->alias}/"; |
| 70 | 70 | |
| 71 | - if($anchor == '') |
|
| 71 | + if ($anchor == '') |
|
| 72 | 72 | $anchor = $log->title; |
| 73 | 73 | |
| 74 | 74 | break; |
@@ -3,43 +3,43 @@ |
||
| 3 | 3 | abstract class Content |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - protected $original_content; |
|
| 7 | - protected $content; |
|
| 8 | - |
|
| 9 | - function __construct($content) |
|
| 10 | - { |
|
| 11 | - $this->original_content = $content; |
|
| 12 | - $this->content = $content; |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - public function getOriginal() |
|
| 16 | - { |
|
| 17 | - return $this->original_content; |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - abstract protected function execute(); |
|
| 21 | - |
|
| 22 | - public function activate() |
|
| 23 | - { |
|
| 24 | - $args = func_get_args(); |
|
| 25 | - call_user_func_array(array($this, 'execute'), $args); |
|
| 6 | + protected $original_content; |
|
| 7 | + protected $content; |
|
| 8 | + |
|
| 9 | + function __construct($content) |
|
| 10 | + { |
|
| 11 | + $this->original_content = $content; |
|
| 12 | + $this->content = $content; |
|
| 13 | + } |
|
| 14 | + |
|
| 15 | + public function getOriginal() |
|
| 16 | + { |
|
| 17 | + return $this->original_content; |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + abstract protected function execute(); |
|
| 21 | + |
|
| 22 | + public function activate() |
|
| 23 | + { |
|
| 24 | + $args = func_get_args(); |
|
| 25 | + call_user_func_array(array($this, 'execute'), $args); |
|
| 26 | 26 | |
| 27 | - return $this->content; |
|
| 28 | - } |
|
| 27 | + return $this->content; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function check() |
|
| 31 | - { |
|
| 32 | - $args = func_get_args(); |
|
| 33 | - $return = call_user_func_array(array($this, 'execute'), $args); |
|
| 30 | + public function check() |
|
| 31 | + { |
|
| 32 | + $args = func_get_args(); |
|
| 33 | + $return = call_user_func_array(array($this, 'execute'), $args); |
|
| 34 | 34 | |
| 35 | - return $return; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - public static function instance($class, $content) |
|
| 39 | - { |
|
| 40 | - $class_name = "{$class}Content"; |
|
| 41 | - Loader::load('utility', "content/{$class_name}"); |
|
| 42 | - return new $class_name($content); |
|
| 43 | - } |
|
| 35 | + return $return; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + public static function instance($class, $content) |
|
| 39 | + { |
|
| 40 | + $class_name = "{$class}Content"; |
|
| 41 | + Loader::load('utility', "content/{$class_name}"); |
|
| 42 | + return new $class_name($content); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | } |
@@ -1,42 +1,42 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -abstract class Content |
|
| 4 | -{ |
|
| 3 | +abstract class Content |
|
| 4 | +{
|
|
| 5 | 5 | |
| 6 | 6 | protected $original_content; |
| 7 | 7 | protected $content; |
| 8 | 8 | |
| 9 | - function __construct($content) |
|
| 10 | - { |
|
| 9 | + function __construct($content) |
|
| 10 | + {
|
|
| 11 | 11 | $this->original_content = $content; |
| 12 | 12 | $this->content = $content; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function getOriginal() |
|
| 16 | - { |
|
| 15 | + public function getOriginal() |
|
| 16 | + {
|
|
| 17 | 17 | return $this->original_content; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | abstract protected function execute(); |
| 21 | 21 | |
| 22 | - public function activate() |
|
| 23 | - { |
|
| 22 | + public function activate() |
|
| 23 | + {
|
|
| 24 | 24 | $args = func_get_args(); |
| 25 | 25 | call_user_func_array(array($this, 'execute'), $args); |
| 26 | 26 | |
| 27 | 27 | return $this->content; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function check() |
|
| 31 | - { |
|
| 30 | + public function check() |
|
| 31 | + {
|
|
| 32 | 32 | $args = func_get_args(); |
| 33 | 33 | $return = call_user_func_array(array($this, 'execute'), $args); |
| 34 | 34 | |
| 35 | 35 | return $return; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public static function instance($class, $content) |
|
| 39 | - { |
|
| 38 | + public static function instance($class, $content) |
|
| 39 | + {
|
|
| 40 | 40 | $class_name = "{$class}Content"; |
| 41 | 41 | Loader::load('utility', "content/{$class_name}"); |
| 42 | 42 | return new $class_name($content); |
@@ -5,26 +5,26 @@ |
||
| 5 | 5 | final class HomeRouter extends Router |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - protected function get_redirect_array() |
|
| 9 | - { |
|
| 10 | - return array( |
|
| 11 | - (object) array( |
|
| 12 | - 'pattern' => '@/index.(html|htm|php)$@', |
|
| 13 | - 'replace' => '')); |
|
| 14 | - } |
|
| 8 | + protected function get_redirect_array() |
|
| 9 | + { |
|
| 10 | + return array( |
|
| 11 | + (object) array( |
|
| 12 | + 'pattern' => '@/index.(html|htm|php)$@', |
|
| 13 | + 'replace' => '')); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - protected function get_direct_array() |
|
| 17 | - { |
|
| 18 | - return array( |
|
| 19 | - (object) array( |
|
| 20 | - 'match' => '/', |
|
| 21 | - 'controller' => 'HomeController'), |
|
| 22 | - (object) array( |
|
| 23 | - 'match' => '/about/', |
|
| 24 | - 'controller' => 'AboutController'), |
|
| 25 | - (object) array( |
|
| 26 | - 'match' => '/contact/', |
|
| 27 | - 'controller' => 'ContactController')); |
|
| 28 | - } |
|
| 16 | + protected function get_direct_array() |
|
| 17 | + { |
|
| 18 | + return array( |
|
| 19 | + (object) array( |
|
| 20 | + 'match' => '/', |
|
| 21 | + 'controller' => 'HomeController'), |
|
| 22 | + (object) array( |
|
| 23 | + 'match' => '/about/', |
|
| 24 | + 'controller' => 'AboutController'), |
|
| 25 | + (object) array( |
|
| 26 | + 'match' => '/contact/', |
|
| 27 | + 'controller' => 'ContactController')); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -2,19 +2,19 @@ |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('router', 'Router'); |
| 4 | 4 | |
| 5 | -final class HomeRouter extends Router |
|
| 6 | -{ |
|
| 5 | +final class HomeRouter 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' => '@/index.(html|htm|php)$@', |
| 13 | 13 | 'replace' => '')); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - protected function get_direct_array() |
|
| 17 | - { |
|
| 16 | + protected function get_direct_array() |
|
| 17 | + {
|
|
| 18 | 18 | return array( |
| 19 | 19 | (object) array( |
| 20 | 20 | 'match' => '/', |
@@ -5,29 +5,29 @@ |
||
| 5 | 5 | class SiteRouter extends Router |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - protected function get_redirect_array() |
|
| 9 | - { |
|
| 10 | - return array( |
|
| 11 | - (object) array( |
|
| 12 | - 'pattern' => '@/index.(html|htm|php)$@', |
|
| 13 | - 'replace' => '/')); |
|
| 14 | - } |
|
| 8 | + protected function get_redirect_array() |
|
| 9 | + { |
|
| 10 | + return array( |
|
| 11 | + (object) array( |
|
| 12 | + 'pattern' => '@/index.(html|htm|php)$@', |
|
| 13 | + 'replace' => '/')); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - protected function get_direct_array() |
|
| 17 | - { |
|
| 18 | - return array( |
|
| 19 | - (object) array( |
|
| 20 | - 'match' => '/', |
|
| 21 | - 'controller' => 'HomeController'), |
|
| 22 | - (object) array( |
|
| 23 | - 'match' => '/terms/', |
|
| 24 | - 'controller' => 'TermsController'), |
|
| 25 | - (object) array( |
|
| 26 | - 'match' => '/change-log/', |
|
| 27 | - 'controller' => 'ChangelogController'), |
|
| 28 | - (object) array( |
|
| 29 | - 'match' => '/contact/', |
|
| 30 | - 'controller' => 'ContactController')); |
|
| 31 | - } |
|
| 16 | + protected function get_direct_array() |
|
| 17 | + { |
|
| 18 | + return array( |
|
| 19 | + (object) array( |
|
| 20 | + 'match' => '/', |
|
| 21 | + 'controller' => 'HomeController'), |
|
| 22 | + (object) array( |
|
| 23 | + 'match' => '/terms/', |
|
| 24 | + 'controller' => 'TermsController'), |
|
| 25 | + (object) array( |
|
| 26 | + 'match' => '/change-log/', |
|
| 27 | + 'controller' => 'ChangelogController'), |
|
| 28 | + (object) array( |
|
| 29 | + 'match' => '/contact/', |
|
| 30 | + 'controller' => 'ContactController')); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | } |
| 34 | 34 | \ No newline at end of file |
@@ -2,19 +2,19 @@ |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('router', 'Router'); |
| 4 | 4 | |
| 5 | -class SiteRouter extends Router |
|
| 6 | -{ |
|
| 5 | +class SiteRouter 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' => '@/index.(html|htm|php)$@', |
| 13 | 13 | 'replace' => '/')); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - protected function get_direct_array() |
|
| 17 | - { |
|
| 16 | + protected function get_direct_array() |
|
| 17 | + {
|
|
| 18 | 18 | return array( |
| 19 | 19 | (object) array( |
| 20 | 20 | 'match' => '/', |
@@ -5,54 +5,54 @@ |
||
| 5 | 5 | class LifestreamRouter extends Router |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - protected function get_redirect_array() |
|
| 9 | - { |
|
| 10 | - return array( |
|
| 11 | - (object) array( |
|
| 12 | - 'pattern' => '@/index.(html|htm|php)$@', |
|
| 13 | - 'replace' => '/'), |
|
| 14 | - (object) array( |
|
| 15 | - 'pattern' => '@^/1/$@', |
|
| 16 | - 'replace' => '/'), |
|
| 17 | - (object) array( |
|
| 18 | - 'pattern' => '@/page_([0-9]+)(/?)$@', |
|
| 19 | - 'replace' => '/page/$1/'), |
|
| 20 | - (object) array( |
|
| 21 | - 'pattern' => '@/tag/([a-z]+)/$@', |
|
| 22 | - 'replace' => '/$1/'), |
|
| 23 | - (object) array( |
|
| 24 | - 'pattern' => '@/tag/([a-z]+)/page/([0-9]+)/$@', |
|
| 25 | - 'replace' => '/$1/page/$2/'), |
|
| 26 | - (object) array( |
|
| 27 | - 'pattern' => '@/tag/([a-z-]+)/$@', |
|
| 28 | - 'replace' => '/'), |
|
| 29 | - (object) array( |
|
| 30 | - 'pattern' => '@/tag/([a-z-]+)/page/([0-9]+)/$@', |
|
| 31 | - 'replace' => '/')); |
|
| 32 | - } |
|
| 8 | + protected function get_redirect_array() |
|
| 9 | + { |
|
| 10 | + return array( |
|
| 11 | + (object) array( |
|
| 12 | + 'pattern' => '@/index.(html|htm|php)$@', |
|
| 13 | + 'replace' => '/'), |
|
| 14 | + (object) array( |
|
| 15 | + 'pattern' => '@^/1/$@', |
|
| 16 | + 'replace' => '/'), |
|
| 17 | + (object) array( |
|
| 18 | + 'pattern' => '@/page_([0-9]+)(/?)$@', |
|
| 19 | + 'replace' => '/page/$1/'), |
|
| 20 | + (object) array( |
|
| 21 | + 'pattern' => '@/tag/([a-z]+)/$@', |
|
| 22 | + 'replace' => '/$1/'), |
|
| 23 | + (object) array( |
|
| 24 | + 'pattern' => '@/tag/([a-z]+)/page/([0-9]+)/$@', |
|
| 25 | + 'replace' => '/$1/page/$2/'), |
|
| 26 | + (object) array( |
|
| 27 | + 'pattern' => '@/tag/([a-z-]+)/$@', |
|
| 28 | + 'replace' => '/'), |
|
| 29 | + (object) array( |
|
| 30 | + 'pattern' => '@/tag/([a-z-]+)/page/([0-9]+)/$@', |
|
| 31 | + 'replace' => '/')); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - protected function get_direct_array() |
|
| 35 | - { |
|
| 36 | - return array( |
|
| 37 | - (object) array( |
|
| 38 | - 'match' => '/', |
|
| 39 | - 'controller' => 'HomeController'), |
|
| 40 | - (object) array( |
|
| 41 | - 'match' => '/about/', |
|
| 42 | - 'controller' => 'AboutController'), |
|
| 43 | - (object) array( |
|
| 44 | - 'match' => '/page/([0-9]+)/', |
|
| 45 | - 'controller' => 'HomeController'), |
|
| 46 | - (object) array( |
|
| 47 | - 'match' => '/([a-z]+)/', |
|
| 48 | - 'controller' => 'TagController'), |
|
| 49 | - (object) array( |
|
| 50 | - 'match' => '/([a-z]+)/page/([0-9]+)/', |
|
| 51 | - 'controller' => 'TagController'), |
|
| 52 | - (object) array( |
|
| 53 | - 'match' => '/([a-z]+)/([0-9]+)/', |
|
| 54 | - 'controller' => 'PostController')); |
|
| 55 | - } |
|
| 34 | + protected function get_direct_array() |
|
| 35 | + { |
|
| 36 | + return array( |
|
| 37 | + (object) array( |
|
| 38 | + 'match' => '/', |
|
| 39 | + 'controller' => 'HomeController'), |
|
| 40 | + (object) array( |
|
| 41 | + 'match' => '/about/', |
|
| 42 | + 'controller' => 'AboutController'), |
|
| 43 | + (object) array( |
|
| 44 | + 'match' => '/page/([0-9]+)/', |
|
| 45 | + 'controller' => 'HomeController'), |
|
| 46 | + (object) array( |
|
| 47 | + 'match' => '/([a-z]+)/', |
|
| 48 | + 'controller' => 'TagController'), |
|
| 49 | + (object) array( |
|
| 50 | + 'match' => '/([a-z]+)/page/([0-9]+)/', |
|
| 51 | + 'controller' => 'TagController'), |
|
| 52 | + (object) array( |
|
| 53 | + 'match' => '/([a-z]+)/([0-9]+)/', |
|
| 54 | + 'controller' => 'PostController')); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -2,11 +2,11 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('router', 'Router'); |
| 4 | 4 | |
| 5 | -class LifestreamRouter extends Router |
|
| 6 | -{ |
|
| 5 | +class LifestreamRouter 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' => '@/index.(html|htm|php)$@', |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | 'replace' => '/')); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - protected function get_direct_array() |
|
| 35 | - { |
|
| 34 | + protected function get_direct_array() |
|
| 35 | + {
|
|
| 36 | 36 | return array( |
| 37 | 37 | (object) array( |
| 38 | 38 | 'match' => '/', |
@@ -5,22 +5,22 @@ |
||
| 5 | 5 | class AJAXRouter extends Router |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - protected function get_redirect_array() |
|
| 9 | - { |
|
| 10 | - return array( |
|
| 11 | - (object) array( |
|
| 12 | - 'pattern' => '@^/$@', |
|
| 13 | - 'replace' => 'https://home.jacobemerick.com/')); |
|
| 14 | - } |
|
| 8 | + protected function get_redirect_array() |
|
| 9 | + { |
|
| 10 | + return array( |
|
| 11 | + (object) array( |
|
| 12 | + 'pattern' => '@^/$@', |
|
| 13 | + 'replace' => 'https://home.jacobemerick.com/')); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - protected function get_direct_array() |
|
| 17 | - { |
|
| 18 | - return array( |
|
| 19 | - (object) array( |
|
| 20 | - 'match' => '/get/portfolioImage.json', |
|
| 21 | - 'controller' => 'GetPortfolioImageController'), |
|
| 16 | + protected function get_direct_array() |
|
| 17 | + { |
|
| 18 | + return array( |
|
| 19 | + (object) array( |
|
| 20 | + 'match' => '/get/portfolioImage.json', |
|
| 21 | + 'controller' => 'GetPortfolioImageController'), |
|
| 22 | 22 | ); |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | |
@@ -2,19 +2,19 @@ |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('router', 'Router'); |
| 4 | 4 | |
| 5 | -class AJAXRouter extends Router |
|
| 6 | -{ |
|
| 5 | +class AJAXRouter 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' => '@^/$@', |
| 13 | 13 | 'replace' => 'https://home.jacobemerick.com/')); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - protected function get_direct_array() |
|
| 17 | - { |
|
| 16 | + protected function get_direct_array() |
|
| 17 | + {
|
|
| 18 | 18 | return array( |
| 19 | 19 | (object) array( |
| 20 | 20 | 'match' => '/get/portfolioImage.json', |
@@ -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' => '/', |
@@ -45,13 +45,13 @@ 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 | 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) |
|
| 54 | + if (!$post) |
|
| 55 | 55 | { |
| 56 | 56 | Loader::loadNew('controller', '/Error404Controller') |
| 57 | 57 | ->activate(); |
@@ -63,22 +63,22 @@ discard block |
||
| 63 | 63 | else |
| 64 | 64 | { |
| 65 | 65 | $post_uri = URLDecode::getPiece(1); |
| 66 | - if($post_uri !== null) |
|
| 66 | + if ($post_uri !== null) |
|
| 67 | 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) |
|
| 72 | + if ($post != false) |
|
| 73 | 73 | { |
| 74 | 74 | Loader::load('utility', 'Content'); |
| 75 | 75 | $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | - if($uri == '/search/') |
|
| 79 | + if ($uri == '/search/') |
|
| 80 | 80 | { |
| 81 | - if(Request::getGet('submit') == 'Submit Search' && Request::getGet('search')) |
|
| 81 | + if (Request::getGet('submit') == 'Submit Search' && Request::getGet('search')) |
|
| 82 | 82 | { |
| 83 | 83 | $uri .= Request::getGet('search'); |
| 84 | 84 | $uri .= '/'; |