@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | protected function execute($is_absolute = false, $size = 'medium') |
| 13 | 13 | { |
| 14 | 14 | preg_match_all(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $matches); |
| 15 | - foreach($matches[1] as $key => $match) |
|
| 15 | + foreach ($matches[1] as $key => $match) |
|
| 16 | 16 | { |
| 17 | 17 | $photo_content = $this->get_photo_content($match, $size, $is_absolute); |
| 18 | 18 | $this->content = str_replace($matches[0][$key], $photo_content, $this->content); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | Loader::load('collector', 'image/PhotoCollector'); |
| 39 | 39 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
| 40 | - if($photo_result == false) |
|
| 40 | + if ($photo_result == false) |
|
| 41 | 41 | return ''; |
| 42 | 42 | |
| 43 | 43 | $height = $file_size[1]; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $domain = '/'; |
| 52 | - if($is_absolute) |
|
| 52 | + if ($is_absolute) |
|
| 53 | 53 | $domain = Loader::getRootUrl('blog'); |
| 54 | 54 | |
| 55 | 55 | return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description); |
@@ -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 | } |
@@ -10,61 +10,61 @@ |
||
| 10 | 10 | $previous_time = strtotime($this->content); |
| 11 | 11 | $current_time = time(); |
| 12 | 12 | |
| 13 | - if($current_time <= $previous_time) |
|
| 13 | + if ($current_time <= $previous_time) |
|
| 14 | 14 | $this->content = 'few seconds ago'; |
| 15 | - else if(($current_time - $previous_time) < 30) |
|
| 15 | + else if (($current_time - $previous_time) < 30) |
|
| 16 | 16 | $this->content = 'few seconds ago'; |
| 17 | - else if(($current_time - $previous_time) < 1.5 * 60) |
|
| 17 | + else if (($current_time - $previous_time) < 1.5 * 60) |
|
| 18 | 18 | $this->content = 'a minute ago'; |
| 19 | - else if(($current_time - $previous_time) < 4 * 60) |
|
| 19 | + else if (($current_time - $previous_time) < 4 * 60) |
|
| 20 | 20 | $this->content = 'few minutes ago'; |
| 21 | - else if(($current_time - $previous_time) < 7 * 60) |
|
| 21 | + else if (($current_time - $previous_time) < 7 * 60) |
|
| 22 | 22 | $this->content = 'five minutes ago'; |
| 23 | - else if(($current_time - $previous_time) < 12 * 60) |
|
| 23 | + else if (($current_time - $previous_time) < 12 * 60) |
|
| 24 | 24 | $this->content = 'ten minutes ago'; |
| 25 | - else if(($current_time - $previous_time) < 17 * 60) |
|
| 25 | + else if (($current_time - $previous_time) < 17 * 60) |
|
| 26 | 26 | $this->content = 'fifteen minutes ago'; |
| 27 | - else if(($current_time - $previous_time) < 22 * 60) |
|
| 27 | + else if (($current_time - $previous_time) < 22 * 60) |
|
| 28 | 28 | $this->content = 'twenty minutes ago'; |
| 29 | - else if(($current_time - $previous_time) < 37 * 60) |
|
| 29 | + else if (($current_time - $previous_time) < 37 * 60) |
|
| 30 | 30 | $this->content = 'half hour ago'; |
| 31 | - else if(($current_time - $previous_time) < 52 * 60) |
|
| 31 | + else if (($current_time - $previous_time) < 52 * 60) |
|
| 32 | 32 | $this->content = 'forty-five minutes ago'; |
| 33 | - else if(($current_time - $previous_time) < 1.5 * 60 * 60) |
|
| 33 | + else if (($current_time - $previous_time) < 1.5 * 60 * 60) |
|
| 34 | 34 | $this->content = 'an hour ago'; |
| 35 | - else if(($current_time - $previous_time) < 2.5 * 60 * 60) |
|
| 35 | + else if (($current_time - $previous_time) < 2.5 * 60 * 60) |
|
| 36 | 36 | $this->content = 'two hours ago'; |
| 37 | - else if(($current_time - $previous_time) < 3.5 * 60 * 60) |
|
| 37 | + else if (($current_time - $previous_time) < 3.5 * 60 * 60) |
|
| 38 | 38 | $this->content = 'three hours ago'; |
| 39 | - else if(($current_time - $previous_time) < 4.5 * 60 * 60) |
|
| 39 | + else if (($current_time - $previous_time) < 4.5 * 60 * 60) |
|
| 40 | 40 | $this->content = 'few hours ago'; |
| 41 | - else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') |
|
| 41 | + else if (($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') |
|
| 42 | 42 | $this->content = 'this afternoon'; |
| 43 | - else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') |
|
| 43 | + else if (($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') |
|
| 44 | 44 | $this->content = 'this morning'; |
| 45 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) |
|
| 45 | + else if (($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) |
|
| 46 | 46 | $this->content = 'yesterday evening'; |
| 47 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') |
|
| 47 | + else if (($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') |
|
| 48 | 48 | $this->content = 'yesterday afternoon'; |
| 49 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') |
|
| 49 | + else if (($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') |
|
| 50 | 50 | $this->content = 'yesterday morning'; |
| 51 | - else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) |
|
| 51 | + else if (($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) |
|
| 52 | 52 | $this->content = 'two days ago'; |
| 53 | - else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) |
|
| 53 | + else if (($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) |
|
| 54 | 54 | $this->content = 'three days ago'; |
| 55 | - else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) |
|
| 55 | + else if (($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) |
|
| 56 | 56 | $this->content = 'earlier this week'; |
| 57 | - else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) |
|
| 57 | + else if (($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) |
|
| 58 | 58 | $this->content = 'late last week'; |
| 59 | - else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) |
|
| 59 | + else if (($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) |
|
| 60 | 60 | $this->content = 'early last week'; |
| 61 | - else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) |
|
| 61 | + else if (($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) |
|
| 62 | 62 | $this->content = 'few weeks ago'; |
| 63 | - else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) |
|
| 63 | + else if (($current_time - $previous_time) < 1.25 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) |
|
| 64 | 64 | $this->content = 'earlier this month'; |
| 65 | - else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) |
|
| 65 | + else if (($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) |
|
| 66 | 66 | $this->content = 'last month'; |
| 67 | - else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) |
|
| 67 | + else if (($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) |
|
| 68 | 68 | $this->content = 'several months ago'; |
| 69 | 69 | else |
| 70 | 70 | $this->content = 'long ago'; |
@@ -5,69 +5,69 @@ |
||
| 5 | 5 | final class ElapsedTimeContent extends Content |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - protected function execute() |
|
| 9 | - { |
|
| 10 | - $previous_time = strtotime($this->content); |
|
| 11 | - $current_time = time(); |
|
| 8 | + protected function execute() |
|
| 9 | + { |
|
| 10 | + $previous_time = strtotime($this->content); |
|
| 11 | + $current_time = time(); |
|
| 12 | 12 | |
| 13 | - if($current_time <= $previous_time) |
|
| 14 | - $this->content = 'few seconds ago'; |
|
| 15 | - else if(($current_time - $previous_time) < 30) |
|
| 16 | - $this->content = 'few seconds ago'; |
|
| 17 | - else if(($current_time - $previous_time) < 1.5 * 60) |
|
| 18 | - $this->content = 'a minute ago'; |
|
| 19 | - else if(($current_time - $previous_time) < 4 * 60) |
|
| 20 | - $this->content = 'few minutes ago'; |
|
| 21 | - else if(($current_time - $previous_time) < 7 * 60) |
|
| 22 | - $this->content = 'five minutes ago'; |
|
| 23 | - else if(($current_time - $previous_time) < 12 * 60) |
|
| 24 | - $this->content = 'ten minutes ago'; |
|
| 25 | - else if(($current_time - $previous_time) < 17 * 60) |
|
| 26 | - $this->content = 'fifteen minutes ago'; |
|
| 27 | - else if(($current_time - $previous_time) < 22 * 60) |
|
| 28 | - $this->content = 'twenty minutes ago'; |
|
| 29 | - else if(($current_time - $previous_time) < 37 * 60) |
|
| 30 | - $this->content = 'half hour ago'; |
|
| 31 | - else if(($current_time - $previous_time) < 52 * 60) |
|
| 32 | - $this->content = 'forty-five minutes ago'; |
|
| 33 | - else if(($current_time - $previous_time) < 1.5 * 60 * 60) |
|
| 34 | - $this->content = 'an hour ago'; |
|
| 35 | - else if(($current_time - $previous_time) < 2.5 * 60 * 60) |
|
| 36 | - $this->content = 'two hours ago'; |
|
| 37 | - else if(($current_time - $previous_time) < 3.5 * 60 * 60) |
|
| 38 | - $this->content = 'three hours ago'; |
|
| 39 | - else if(($current_time - $previous_time) < 4.5 * 60 * 60) |
|
| 40 | - $this->content = 'few hours ago'; |
|
| 41 | - else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') |
|
| 42 | - $this->content = 'this afternoon'; |
|
| 43 | - else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') |
|
| 44 | - $this->content = 'this morning'; |
|
| 45 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) |
|
| 46 | - $this->content = 'yesterday evening'; |
|
| 47 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') |
|
| 48 | - $this->content = 'yesterday afternoon'; |
|
| 49 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') |
|
| 50 | - $this->content = 'yesterday morning'; |
|
| 51 | - else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) |
|
| 52 | - $this->content = 'two days ago'; |
|
| 53 | - else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) |
|
| 54 | - $this->content = 'three days ago'; |
|
| 55 | - else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) |
|
| 56 | - $this->content = 'earlier this week'; |
|
| 57 | - else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) |
|
| 58 | - $this->content = 'late last week'; |
|
| 59 | - else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) |
|
| 60 | - $this->content = 'early last week'; |
|
| 61 | - else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) |
|
| 62 | - $this->content = 'few weeks ago'; |
|
| 63 | - else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) |
|
| 64 | - $this->content = 'earlier this month'; |
|
| 65 | - else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) |
|
| 66 | - $this->content = 'last month'; |
|
| 67 | - else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) |
|
| 68 | - $this->content = 'several months ago'; |
|
| 69 | - else |
|
| 70 | - $this->content = 'long ago'; |
|
| 71 | - } |
|
| 13 | + if($current_time <= $previous_time) |
|
| 14 | + $this->content = 'few seconds ago'; |
|
| 15 | + else if(($current_time - $previous_time) < 30) |
|
| 16 | + $this->content = 'few seconds ago'; |
|
| 17 | + else if(($current_time - $previous_time) < 1.5 * 60) |
|
| 18 | + $this->content = 'a minute ago'; |
|
| 19 | + else if(($current_time - $previous_time) < 4 * 60) |
|
| 20 | + $this->content = 'few minutes ago'; |
|
| 21 | + else if(($current_time - $previous_time) < 7 * 60) |
|
| 22 | + $this->content = 'five minutes ago'; |
|
| 23 | + else if(($current_time - $previous_time) < 12 * 60) |
|
| 24 | + $this->content = 'ten minutes ago'; |
|
| 25 | + else if(($current_time - $previous_time) < 17 * 60) |
|
| 26 | + $this->content = 'fifteen minutes ago'; |
|
| 27 | + else if(($current_time - $previous_time) < 22 * 60) |
|
| 28 | + $this->content = 'twenty minutes ago'; |
|
| 29 | + else if(($current_time - $previous_time) < 37 * 60) |
|
| 30 | + $this->content = 'half hour ago'; |
|
| 31 | + else if(($current_time - $previous_time) < 52 * 60) |
|
| 32 | + $this->content = 'forty-five minutes ago'; |
|
| 33 | + else if(($current_time - $previous_time) < 1.5 * 60 * 60) |
|
| 34 | + $this->content = 'an hour ago'; |
|
| 35 | + else if(($current_time - $previous_time) < 2.5 * 60 * 60) |
|
| 36 | + $this->content = 'two hours ago'; |
|
| 37 | + else if(($current_time - $previous_time) < 3.5 * 60 * 60) |
|
| 38 | + $this->content = 'three hours ago'; |
|
| 39 | + else if(($current_time - $previous_time) < 4.5 * 60 * 60) |
|
| 40 | + $this->content = 'few hours ago'; |
|
| 41 | + else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') |
|
| 42 | + $this->content = 'this afternoon'; |
|
| 43 | + else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') |
|
| 44 | + $this->content = 'this morning'; |
|
| 45 | + else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) |
|
| 46 | + $this->content = 'yesterday evening'; |
|
| 47 | + else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') |
|
| 48 | + $this->content = 'yesterday afternoon'; |
|
| 49 | + else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') |
|
| 50 | + $this->content = 'yesterday morning'; |
|
| 51 | + else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) |
|
| 52 | + $this->content = 'two days ago'; |
|
| 53 | + else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) |
|
| 54 | + $this->content = 'three days ago'; |
|
| 55 | + else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) |
|
| 56 | + $this->content = 'earlier this week'; |
|
| 57 | + else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) |
|
| 58 | + $this->content = 'late last week'; |
|
| 59 | + else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) |
|
| 60 | + $this->content = 'early last week'; |
|
| 61 | + else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) |
|
| 62 | + $this->content = 'few weeks ago'; |
|
| 63 | + else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) |
|
| 64 | + $this->content = 'earlier this month'; |
|
| 65 | + else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) |
|
| 66 | + $this->content = 'last month'; |
|
| 67 | + else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) |
|
| 68 | + $this->content = 'several months ago'; |
|
| 69 | + else |
|
| 70 | + $this->content = 'long ago'; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | \ No newline at end of file |
@@ -2,72 +2,73 @@ |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', 'Content'); |
| 4 | 4 | |
| 5 | -final class ElapsedTimeContent extends Content |
|
| 6 | -{ |
|
| 5 | +final class ElapsedTimeContent extends Content |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | - protected function execute() |
|
| 9 | - { |
|
| 8 | + protected function execute() |
|
| 9 | + {
|
|
| 10 | 10 | $previous_time = strtotime($this->content); |
| 11 | 11 | $current_time = time(); |
| 12 | 12 | |
| 13 | - if($current_time <= $previous_time) |
|
| 14 | - $this->content = 'few seconds ago'; |
|
| 15 | - else if(($current_time - $previous_time) < 30) |
|
| 16 | - $this->content = 'few seconds ago'; |
|
| 17 | - else if(($current_time - $previous_time) < 1.5 * 60) |
|
| 18 | - $this->content = 'a minute ago'; |
|
| 19 | - else if(($current_time - $previous_time) < 4 * 60) |
|
| 20 | - $this->content = 'few minutes ago'; |
|
| 21 | - else if(($current_time - $previous_time) < 7 * 60) |
|
| 22 | - $this->content = 'five minutes ago'; |
|
| 23 | - else if(($current_time - $previous_time) < 12 * 60) |
|
| 24 | - $this->content = 'ten minutes ago'; |
|
| 25 | - else if(($current_time - $previous_time) < 17 * 60) |
|
| 26 | - $this->content = 'fifteen minutes ago'; |
|
| 27 | - else if(($current_time - $previous_time) < 22 * 60) |
|
| 28 | - $this->content = 'twenty minutes ago'; |
|
| 29 | - else if(($current_time - $previous_time) < 37 * 60) |
|
| 30 | - $this->content = 'half hour ago'; |
|
| 31 | - else if(($current_time - $previous_time) < 52 * 60) |
|
| 32 | - $this->content = 'forty-five minutes ago'; |
|
| 33 | - else if(($current_time - $previous_time) < 1.5 * 60 * 60) |
|
| 34 | - $this->content = 'an hour ago'; |
|
| 35 | - else if(($current_time - $previous_time) < 2.5 * 60 * 60) |
|
| 36 | - $this->content = 'two hours ago'; |
|
| 37 | - else if(($current_time - $previous_time) < 3.5 * 60 * 60) |
|
| 38 | - $this->content = 'three hours ago'; |
|
| 39 | - else if(($current_time - $previous_time) < 4.5 * 60 * 60) |
|
| 40 | - $this->content = 'few hours ago'; |
|
| 41 | - else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') |
|
| 42 | - $this->content = 'this afternoon'; |
|
| 43 | - else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') |
|
| 44 | - $this->content = 'this morning'; |
|
| 45 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) |
|
| 46 | - $this->content = 'yesterday evening'; |
|
| 47 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') |
|
| 48 | - $this->content = 'yesterday afternoon'; |
|
| 49 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') |
|
| 50 | - $this->content = 'yesterday morning'; |
|
| 51 | - else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) |
|
| 52 | - $this->content = 'two days ago'; |
|
| 53 | - else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) |
|
| 54 | - $this->content = 'three days ago'; |
|
| 55 | - else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) |
|
| 56 | - $this->content = 'earlier this week'; |
|
| 57 | - else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) |
|
| 58 | - $this->content = 'late last week'; |
|
| 59 | - else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) |
|
| 60 | - $this->content = 'early last week'; |
|
| 61 | - else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) |
|
| 62 | - $this->content = 'few weeks ago'; |
|
| 63 | - else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) |
|
| 64 | - $this->content = 'earlier this month'; |
|
| 65 | - else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) |
|
| 66 | - $this->content = 'last month'; |
|
| 67 | - else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) |
|
| 68 | - $this->content = 'several months ago'; |
|
| 69 | - else |
|
| 70 | - $this->content = 'long ago'; |
|
| 13 | + if($current_time <= $previous_time) {
|
|
| 14 | + $this->content = 'few seconds ago'; |
|
| 15 | + } else if(($current_time - $previous_time) < 30) {
|
|
| 16 | + $this->content = 'few seconds ago'; |
|
| 17 | + } else if(($current_time - $previous_time) < 1.5 * 60) {
|
|
| 18 | + $this->content = 'a minute ago'; |
|
| 19 | + } else if(($current_time - $previous_time) < 4 * 60) {
|
|
| 20 | + $this->content = 'few minutes ago'; |
|
| 21 | + } else if(($current_time - $previous_time) < 7 * 60) {
|
|
| 22 | + $this->content = 'five minutes ago'; |
|
| 23 | + } else if(($current_time - $previous_time) < 12 * 60) {
|
|
| 24 | + $this->content = 'ten minutes ago'; |
|
| 25 | + } else if(($current_time - $previous_time) < 17 * 60) {
|
|
| 26 | + $this->content = 'fifteen minutes ago'; |
|
| 27 | + } else if(($current_time - $previous_time) < 22 * 60) {
|
|
| 28 | + $this->content = 'twenty minutes ago'; |
|
| 29 | + } else if(($current_time - $previous_time) < 37 * 60) {
|
|
| 30 | + $this->content = 'half hour ago'; |
|
| 31 | + } else if(($current_time - $previous_time) < 52 * 60) {
|
|
| 32 | + $this->content = 'forty-five minutes ago'; |
|
| 33 | + } else if(($current_time - $previous_time) < 1.5 * 60 * 60) {
|
|
| 34 | + $this->content = 'an hour ago'; |
|
| 35 | + } else if(($current_time - $previous_time) < 2.5 * 60 * 60) {
|
|
| 36 | + $this->content = 'two hours ago'; |
|
| 37 | + } else if(($current_time - $previous_time) < 3.5 * 60 * 60) {
|
|
| 38 | + $this->content = 'three hours ago'; |
|
| 39 | + } else if(($current_time - $previous_time) < 4.5 * 60 * 60) {
|
|
| 40 | + $this->content = 'few hours ago'; |
|
| 41 | + } else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') {
|
|
| 42 | + $this->content = 'this afternoon'; |
|
| 43 | + } else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') {
|
|
| 44 | + $this->content = 'this morning'; |
|
| 45 | + } else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) {
|
|
| 46 | + $this->content = 'yesterday evening'; |
|
| 47 | + } else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') {
|
|
| 48 | + $this->content = 'yesterday afternoon'; |
|
| 49 | + } else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') {
|
|
| 50 | + $this->content = 'yesterday morning'; |
|
| 51 | + } else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) {
|
|
| 52 | + $this->content = 'two days ago'; |
|
| 53 | + } else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) {
|
|
| 54 | + $this->content = 'three days ago'; |
|
| 55 | + } else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) {
|
|
| 56 | + $this->content = 'earlier this week'; |
|
| 57 | + } else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) {
|
|
| 58 | + $this->content = 'late last week'; |
|
| 59 | + } else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) {
|
|
| 60 | + $this->content = 'early last week'; |
|
| 61 | + } else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) {
|
|
| 62 | + $this->content = 'few weeks ago'; |
|
| 63 | + } else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) {
|
|
| 64 | + $this->content = 'earlier this month'; |
|
| 65 | + } else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) {
|
|
| 66 | + $this->content = 'last month'; |
|
| 67 | + } else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) {
|
|
| 68 | + $this->content = 'several months ago'; |
|
| 69 | + } else {
|
|
| 70 | + $this->content = 'long ago'; |
|
| 71 | + } |
|
| 71 | 72 | } |
| 72 | 73 | |
| 73 | 74 | } |
| 74 | 75 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | protected function execute($is_absolute = false, $size = 'thumb') |
| 13 | 13 | { |
| 14 | - if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
| 14 | + if (preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
| 15 | 15 | $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
| 16 | 16 | else |
| 17 | 17 | $this->content = self::$DEFAULT_RETURN; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | Loader::load('collector', 'image/PhotoCollector'); |
| 36 | 36 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
| 37 | - if($photo_result == false) |
|
| 37 | + if ($photo_result == false) |
|
| 38 | 38 | return ''; |
| 39 | 39 | |
| 40 | 40 | $height = $file_size[1]; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $description = $photo_result->description; |
| 43 | 43 | |
| 44 | 44 | $domain = '/'; |
| 45 | - if($is_absolute) |
|
| 45 | + if ($is_absolute) |
|
| 46 | 46 | $domain = Loader::getRootUrl(); |
| 47 | 47 | |
| 48 | 48 | return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
@@ -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 | } |
@@ -56,11 +56,11 @@ |
||
| 56 | 56 | final private function get_list_posts() |
| 57 | 57 | { |
| 58 | 58 | $post_array = array(); |
| 59 | - foreach($this->get_list_results() as $post) |
|
| 59 | + foreach ($this->get_list_results() as $post) |
|
| 60 | 60 | { |
| 61 | 61 | $post_array[] = $this->format_post($post, true); |
| 62 | 62 | } |
| 63 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
| 63 | + if (count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
| 64 | 64 | $this->eject(); |
| 65 | 65 | return $post_array; |
| 66 | 66 | } |
@@ -5,63 +5,63 @@ |
||
| 5 | 5 | abstract class DefaultListController extends DefaultPageController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - protected static $POSTS_PER_PAGE = 15; |
|
| 8 | + protected static $POSTS_PER_PAGE = 15; |
|
| 9 | 9 | |
| 10 | - protected $page; |
|
| 11 | - protected $offset; |
|
| 10 | + protected $page; |
|
| 11 | + protected $offset; |
|
| 12 | 12 | |
| 13 | - public function __construct() |
|
| 14 | - { |
|
| 15 | - parent::__construct(); |
|
| 13 | + public function __construct() |
|
| 14 | + { |
|
| 15 | + parent::__construct(); |
|
| 16 | 16 | |
| 17 | - $this->page = $this->get_page_number(); |
|
| 18 | - $this->offset = ($this->page - 1) * self::$POSTS_PER_PAGE; |
|
| 19 | - } |
|
| 17 | + $this->page = $this->get_page_number(); |
|
| 18 | + $this->offset = ($this->page - 1) * self::$POSTS_PER_PAGE; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - abstract protected function get_page_number(); |
|
| 22 | - abstract protected function get_list_results(); |
|
| 23 | - abstract protected function get_list_description(); |
|
| 24 | - abstract protected function get_list_next_link(); |
|
| 25 | - abstract protected function get_list_prev_link(); |
|
| 26 | - abstract protected function get_total_post_count(); |
|
| 21 | + abstract protected function get_page_number(); |
|
| 22 | + abstract protected function get_list_results(); |
|
| 23 | + abstract protected function get_list_description(); |
|
| 24 | + abstract protected function get_list_next_link(); |
|
| 25 | + abstract protected function get_list_prev_link(); |
|
| 26 | + abstract protected function get_total_post_count(); |
|
| 27 | 27 | |
| 28 | - protected function set_head_data() |
|
| 29 | - { |
|
| 30 | - parent::set_head_data(); |
|
| 28 | + protected function set_head_data() |
|
| 29 | + { |
|
| 30 | + parent::set_head_data(); |
|
| 31 | 31 | |
| 32 | - $this->set_head('next_link', $this->get_list_next_link()); |
|
| 33 | - $this->set_head('previous_link', $this->get_list_prev_link()); |
|
| 34 | - } |
|
| 32 | + $this->set_head('next_link', $this->get_list_next_link()); |
|
| 33 | + $this->set_head('previous_link', $this->get_list_prev_link()); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - protected function set_body_data() |
|
| 37 | - { |
|
| 38 | - parent::set_body_data(); |
|
| 36 | + protected function set_body_data() |
|
| 37 | + { |
|
| 38 | + parent::set_body_data(); |
|
| 39 | 39 | |
| 40 | - $this->set_body('view', 'Listing'); |
|
| 41 | - $this->set_body('data', $this->get_list_body_data()); |
|
| 42 | - } |
|
| 40 | + $this->set_body('view', 'Listing'); |
|
| 41 | + $this->set_body('data', $this->get_list_body_data()); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - final private function get_list_body_data() |
|
| 45 | - { |
|
| 46 | - return array( |
|
| 47 | - 'posts' => $this->get_list_posts(), |
|
| 48 | - 'type' => 'list', |
|
| 49 | - 'pagination' => array( |
|
| 50 | - 'description' => $this->get_list_description(), |
|
| 51 | - 'next' => $this->get_list_next_link(), |
|
| 52 | - 'prev' => $this->get_list_prev_link())); |
|
| 53 | - } |
|
| 44 | + final private function get_list_body_data() |
|
| 45 | + { |
|
| 46 | + return array( |
|
| 47 | + 'posts' => $this->get_list_posts(), |
|
| 48 | + 'type' => 'list', |
|
| 49 | + 'pagination' => array( |
|
| 50 | + 'description' => $this->get_list_description(), |
|
| 51 | + 'next' => $this->get_list_next_link(), |
|
| 52 | + 'prev' => $this->get_list_prev_link())); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - final private function get_list_posts() |
|
| 56 | - { |
|
| 57 | - $post_array = array(); |
|
| 58 | - foreach($this->get_list_results() as $post) |
|
| 59 | - { |
|
| 60 | - $post_array[] = $this->expand_post($post, 'full'); |
|
| 61 | - } |
|
| 62 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
| 63 | - $this->eject(); |
|
| 64 | - return $post_array; |
|
| 65 | - } |
|
| 55 | + final private function get_list_posts() |
|
| 56 | + { |
|
| 57 | + $post_array = array(); |
|
| 58 | + foreach($this->get_list_results() as $post) |
|
| 59 | + { |
|
| 60 | + $post_array[] = $this->expand_post($post, 'full'); |
|
| 61 | + } |
|
| 62 | + if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
| 63 | + $this->eject(); |
|
| 64 | + return $post_array; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | } |
@@ -2,16 +2,16 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('controller', 'lifestream/DefaultPageController'); |
| 4 | 4 | |
| 5 | -abstract class DefaultListController extends DefaultPageController |
|
| 6 | -{ |
|
| 5 | +abstract class DefaultListController extends DefaultPageController |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | protected static $POSTS_PER_PAGE = 15; |
| 9 | 9 | |
| 10 | 10 | protected $page; |
| 11 | 11 | protected $offset; |
| 12 | 12 | |
| 13 | - public function __construct() |
|
| 14 | - { |
|
| 13 | + public function __construct() |
|
| 14 | + {
|
|
| 15 | 15 | parent::__construct(); |
| 16 | 16 | |
| 17 | 17 | $this->page = $this->get_page_number(); |
@@ -25,24 +25,24 @@ discard block |
||
| 25 | 25 | abstract protected function get_list_prev_link(); |
| 26 | 26 | abstract protected function get_total_post_count(); |
| 27 | 27 | |
| 28 | - protected function set_head_data() |
|
| 29 | - { |
|
| 28 | + protected function set_head_data() |
|
| 29 | + {
|
|
| 30 | 30 | parent::set_head_data(); |
| 31 | 31 | |
| 32 | 32 | $this->set_head('next_link', $this->get_list_next_link()); |
| 33 | 33 | $this->set_head('previous_link', $this->get_list_prev_link()); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - protected function set_body_data() |
|
| 37 | - { |
|
| 36 | + protected function set_body_data() |
|
| 37 | + {
|
|
| 38 | 38 | parent::set_body_data(); |
| 39 | 39 | |
| 40 | 40 | $this->set_body('view', 'Listing'); |
| 41 | 41 | $this->set_body('data', $this->get_list_body_data()); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - final private function get_list_body_data() |
|
| 45 | - { |
|
| 44 | + final private function get_list_body_data() |
|
| 45 | + {
|
|
| 46 | 46 | return array( |
| 47 | 47 | 'posts' => $this->get_list_posts(), |
| 48 | 48 | 'type' => 'list', |
@@ -52,15 +52,16 @@ discard block |
||
| 52 | 52 | 'prev' => $this->get_list_prev_link())); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - final private function get_list_posts() |
|
| 56 | - { |
|
| 55 | + final private function get_list_posts() |
|
| 56 | + {
|
|
| 57 | 57 | $post_array = array(); |
| 58 | 58 | foreach($this->get_list_results() as $post) |
| 59 | 59 | { |
| 60 | 60 | $post_array[] = $this->expand_post($post, 'full'); |
| 61 | 61 | } |
| 62 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
| 63 | - $this->eject(); |
|
| 62 | + if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') {
|
|
| 63 | + $this->eject(); |
|
| 64 | + } |
|
| 64 | 65 | return $post_array; |
| 65 | 66 | } |
| 66 | 67 | |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | parent::__construct(); |
| 21 | 21 | |
| 22 | 22 | $id = URLDecode::getPiece(2); |
| 23 | - if(!$id || !is_numeric($id)) |
|
| 23 | + if (!$id || !is_numeric($id)) |
|
| 24 | 24 | $this->eject(); |
| 25 | 25 | |
| 26 | 26 | $post = $this->postRepository->getPostById($id); |
| 27 | - if(!$post) |
|
| 27 | + if (!$post) |
|
| 28 | 28 | $this->eject(); |
| 29 | 29 | |
| 30 | - if(URLDecode::getPiece(1) != $post['type']) |
|
| 30 | + if (URLDecode::getPiece(1) != $post['type']) |
|
| 31 | 31 | $this->eject(); |
| 32 | 32 | |
| 33 | 33 | $this->post = $post; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | private function get_title() |
| 61 | 61 | { |
| 62 | - switch($this->post['type']) |
|
| 62 | + switch ($this->post['type']) |
|
| 63 | 63 | { |
| 64 | 64 | case 'blog' : |
| 65 | 65 | return 'Jacob blogged'; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | private function get_description() |
| 86 | 86 | { |
| 87 | - switch($this->post['type']) |
|
| 87 | + switch ($this->post['type']) |
|
| 88 | 88 | { |
| 89 | 89 | case 'blog' : |
| 90 | 90 | return 'Another awesome blog post from Jacob. Did I mention it was awesome?'; |
@@ -5,112 +5,112 @@ |
||
| 5 | 5 | final class PostController extends DefaultPageController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $TITLE = "Post %d | %s Activity | Jacob Emerick's Lifestream"; |
|
| 9 | - private static $DESCRIPTION = "Post %d of %s activity on Jacob Emerick's Lifestream."; |
|
| 8 | + private static $TITLE = "Post %d | %s Activity | Jacob Emerick's Lifestream"; |
|
| 9 | + private static $DESCRIPTION = "Post %d of %s activity on Jacob Emerick's Lifestream."; |
|
| 10 | 10 | |
| 11 | - private static $KEYWORD_ARRAY = array( |
|
| 12 | - 'lifestream', |
|
| 13 | - 'activity stream', |
|
| 14 | - 'Jacob Emerick'); |
|
| 11 | + private static $KEYWORD_ARRAY = array( |
|
| 12 | + 'lifestream', |
|
| 13 | + 'activity stream', |
|
| 14 | + 'Jacob Emerick'); |
|
| 15 | 15 | |
| 16 | - private $post; |
|
| 16 | + private $post; |
|
| 17 | 17 | |
| 18 | - public function __construct() |
|
| 19 | - { |
|
| 20 | - parent::__construct(); |
|
| 18 | + public function __construct() |
|
| 19 | + { |
|
| 20 | + parent::__construct(); |
|
| 21 | 21 | |
| 22 | - $id = URLDecode::getPiece(2); |
|
| 23 | - if(!$id || !is_numeric($id)) |
|
| 24 | - $this->eject(); |
|
| 22 | + $id = URLDecode::getPiece(2); |
|
| 23 | + if(!$id || !is_numeric($id)) |
|
| 24 | + $this->eject(); |
|
| 25 | 25 | |
| 26 | - $post = $this->activityRepository->getActivityById($id); |
|
| 27 | - if(!$post) |
|
| 28 | - $this->eject(); |
|
| 26 | + $post = $this->activityRepository->getActivityById($id); |
|
| 27 | + if(!$post) |
|
| 28 | + $this->eject(); |
|
| 29 | 29 | |
| 30 | - if(URLDecode::getPiece(1) != $post['type']) |
|
| 31 | - $this->eject(); |
|
| 30 | + if(URLDecode::getPiece(1) != $post['type']) |
|
| 31 | + $this->eject(); |
|
| 32 | 32 | |
| 33 | - $this->post = $post; |
|
| 34 | - } |
|
| 33 | + $this->post = $post; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - protected function set_head_data() |
|
| 37 | - { |
|
| 38 | - $this->set_title(sprintf(self::$TITLE, $this->post['id'], ucwords($this->post['type']))); |
|
| 39 | - $this->set_description(sprintf(self::$DESCRIPTION, $this->post['id'], ucwords($this->post['type']))); |
|
| 36 | + protected function set_head_data() |
|
| 37 | + { |
|
| 38 | + $this->set_title(sprintf(self::$TITLE, $this->post['id'], ucwords($this->post['type']))); |
|
| 39 | + $this->set_description(sprintf(self::$DESCRIPTION, $this->post['id'], ucwords($this->post['type']))); |
|
| 40 | 40 | |
| 41 | - $keyword_array = self::$KEYWORD_ARRAY; |
|
| 42 | - array_unshift($keyword_array, $this->post['type']); |
|
| 43 | - $this->set_keywords($keyword_array); |
|
| 41 | + $keyword_array = self::$KEYWORD_ARRAY; |
|
| 42 | + array_unshift($keyword_array, $this->post['type']); |
|
| 43 | + $this->set_keywords($keyword_array); |
|
| 44 | 44 | |
| 45 | - parent::set_head_data(); |
|
| 46 | - } |
|
| 45 | + parent::set_head_data(); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - protected function set_body_data() |
|
| 49 | - { |
|
| 50 | - $this->set_body('title', $this->get_title()); |
|
| 51 | - $this->set_body('description', $this->get_description()); |
|
| 48 | + protected function set_body_data() |
|
| 49 | + { |
|
| 50 | + $this->set_body('title', $this->get_title()); |
|
| 51 | + $this->set_body('description', $this->get_description()); |
|
| 52 | 52 | |
| 53 | - $this->set_body('post', $this->expand_post($this->post, 'full')); |
|
| 54 | - $this->set_body('type', 'single'); |
|
| 55 | - $this->set_body('view', 'Post'); |
|
| 53 | + $this->set_body('post', $this->expand_post($this->post, 'full')); |
|
| 54 | + $this->set_body('type', 'single'); |
|
| 55 | + $this->set_body('view', 'Post'); |
|
| 56 | 56 | |
| 57 | - parent::set_body_data(); |
|
| 58 | - } |
|
| 57 | + parent::set_body_data(); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - private function get_title() |
|
| 61 | - { |
|
| 62 | - switch($this->post['type']) |
|
| 63 | - { |
|
| 64 | - case 'blog' : |
|
| 65 | - return 'Jacob blogged'; |
|
| 66 | - break; |
|
| 67 | - case 'book' : |
|
| 68 | - return 'Jacob read again'; |
|
| 69 | - break; |
|
| 70 | - case 'distance' : |
|
| 71 | - return 'Jacob ran xor hiked'; |
|
| 72 | - break; |
|
| 73 | - case 'github' : |
|
| 60 | + private function get_title() |
|
| 61 | + { |
|
| 62 | + switch($this->post['type']) |
|
| 63 | + { |
|
| 64 | + case 'blog' : |
|
| 65 | + return 'Jacob blogged'; |
|
| 66 | + break; |
|
| 67 | + case 'book' : |
|
| 68 | + return 'Jacob read again'; |
|
| 69 | + break; |
|
| 70 | + case 'distance' : |
|
| 71 | + return 'Jacob ran xor hiked'; |
|
| 72 | + break; |
|
| 73 | + case 'github' : |
|
| 74 | 74 | return 'Jacob did code'; |
| 75 | - break; |
|
| 76 | - case 'hulu' : |
|
| 77 | - return 'What Jacob watched'; |
|
| 78 | - break; |
|
| 79 | - case 'twitter' : |
|
| 80 | - return 'What Jacob tweeted'; |
|
| 81 | - break; |
|
| 82 | - case 'youtube' : |
|
| 83 | - return 'Jacob Liked a Video'; |
|
| 84 | - break; |
|
| 85 | - } |
|
| 86 | - } |
|
| 75 | + break; |
|
| 76 | + case 'hulu' : |
|
| 77 | + return 'What Jacob watched'; |
|
| 78 | + break; |
|
| 79 | + case 'twitter' : |
|
| 80 | + return 'What Jacob tweeted'; |
|
| 81 | + break; |
|
| 82 | + case 'youtube' : |
|
| 83 | + return 'Jacob Liked a Video'; |
|
| 84 | + break; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - private function get_description() |
|
| 89 | - { |
|
| 90 | - switch($this->post['type']) |
|
| 91 | - { |
|
| 92 | - case 'blog' : |
|
| 93 | - return 'Another awesome blog post from Jacob. Did I mention it was awesome?'; |
|
| 94 | - break; |
|
| 95 | - case 'book' : |
|
| 96 | - return "Yup, Jacob read another book. Don't tell his parents."; |
|
| 97 | - break; |
|
| 98 | - case 'distance' : |
|
| 99 | - return 'Well, it might have been both at the same time if there was a bear.'; |
|
| 100 | - break; |
|
| 101 | - case 'github' : |
|
| 88 | + private function get_description() |
|
| 89 | + { |
|
| 90 | + switch($this->post['type']) |
|
| 91 | + { |
|
| 92 | + case 'blog' : |
|
| 93 | + return 'Another awesome blog post from Jacob. Did I mention it was awesome?'; |
|
| 94 | + break; |
|
| 95 | + case 'book' : |
|
| 96 | + return "Yup, Jacob read another book. Don't tell his parents."; |
|
| 97 | + break; |
|
| 98 | + case 'distance' : |
|
| 99 | + return 'Well, it might have been both at the same time if there was a bear.'; |
|
| 100 | + break; |
|
| 101 | + case 'github' : |
|
| 102 | 102 | return 'An epic code change by Jacob on the Githubs.'; |
| 103 | - break; |
|
| 104 | - case 'hulu' : |
|
| 105 | - return 'It was a cold, dark night, so Jacob watched something on Hulu.'; |
|
| 106 | - break; |
|
| 107 | - case 'twitter' : |
|
| 108 | - return 'Just another awesome insight/thought/RT/random from Jacob.'; |
|
| 109 | - break; |
|
| 110 | - case 'youtube' : |
|
| 111 | - return "This is a video that Jacob liked on Youtube. It's probably awesome. You should check it out."; |
|
| 112 | - break; |
|
| 113 | - } |
|
| 114 | - } |
|
| 103 | + break; |
|
| 104 | + case 'hulu' : |
|
| 105 | + return 'It was a cold, dark night, so Jacob watched something on Hulu.'; |
|
| 106 | + break; |
|
| 107 | + case 'twitter' : |
|
| 108 | + return 'Just another awesome insight/thought/RT/random from Jacob.'; |
|
| 109 | + break; |
|
| 110 | + case 'youtube' : |
|
| 111 | + return "This is a video that Jacob liked on Youtube. It's probably awesome. You should check it out."; |
|
| 112 | + break; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | } |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('controller', 'lifestream/DefaultPageController'); |
| 4 | 4 | |
| 5 | -final class PostController extends DefaultPageController |
|
| 6 | -{ |
|
| 5 | +final class PostController extends DefaultPageController |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $TITLE = "Post %d | %s Activity | Jacob Emerick's Lifestream"; |
| 9 | 9 | private static $DESCRIPTION = "Post %d of %s activity on Jacob Emerick's Lifestream."; |
@@ -15,26 +15,29 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | private $post; |
| 17 | 17 | |
| 18 | - public function __construct() |
|
| 19 | - { |
|
| 18 | + public function __construct() |
|
| 19 | + {
|
|
| 20 | 20 | parent::__construct(); |
| 21 | 21 | |
| 22 | 22 | $id = URLDecode::getPiece(2); |
| 23 | - if(!$id || !is_numeric($id)) |
|
| 24 | - $this->eject(); |
|
| 23 | + if(!$id || !is_numeric($id)) {
|
|
| 24 | + $this->eject(); |
|
| 25 | + } |
|
| 25 | 26 | |
| 26 | 27 | $post = $this->activityRepository->getActivityById($id); |
| 27 | - if(!$post) |
|
| 28 | - $this->eject(); |
|
| 28 | + if(!$post) {
|
|
| 29 | + $this->eject(); |
|
| 30 | + } |
|
| 29 | 31 | |
| 30 | - if(URLDecode::getPiece(1) != $post['type']) |
|
| 31 | - $this->eject(); |
|
| 32 | + if(URLDecode::getPiece(1) != $post['type']) {
|
|
| 33 | + $this->eject(); |
|
| 34 | + } |
|
| 32 | 35 | |
| 33 | 36 | $this->post = $post; |
| 34 | 37 | } |
| 35 | 38 | |
| 36 | - protected function set_head_data() |
|
| 37 | - { |
|
| 39 | + protected function set_head_data() |
|
| 40 | + {
|
|
| 38 | 41 | $this->set_title(sprintf(self::$TITLE, $this->post['id'], ucwords($this->post['type']))); |
| 39 | 42 | $this->set_description(sprintf(self::$DESCRIPTION, $this->post['id'], ucwords($this->post['type']))); |
| 40 | 43 | |
@@ -45,8 +48,8 @@ discard block |
||
| 45 | 48 | parent::set_head_data(); |
| 46 | 49 | } |
| 47 | 50 | |
| 48 | - protected function set_body_data() |
|
| 49 | - { |
|
| 51 | + protected function set_body_data() |
|
| 52 | + {
|
|
| 50 | 53 | $this->set_body('title', $this->get_title()); |
| 51 | 54 | $this->set_body('description', $this->get_description()); |
| 52 | 55 | |
@@ -57,8 +60,8 @@ discard block |
||
| 57 | 60 | parent::set_body_data(); |
| 58 | 61 | } |
| 59 | 62 | |
| 60 | - private function get_title() |
|
| 61 | - { |
|
| 63 | + private function get_title() |
|
| 64 | + {
|
|
| 62 | 65 | switch($this->post['type']) |
| 63 | 66 | { |
| 64 | 67 | case 'blog' : |
@@ -85,8 +88,8 @@ discard block |
||
| 85 | 88 | } |
| 86 | 89 | } |
| 87 | 90 | |
| 88 | - private function get_description() |
|
| 89 | - { |
|
| 91 | + private function get_description() |
|
| 92 | + {
|
|
| 90 | 93 | switch($this->post['type']) |
| 91 | 94 | { |
| 92 | 95 | case 'blog' : |
@@ -131,6 +131,9 @@ |
||
| 131 | 131 | self::send($array); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | + /** |
|
| 135 | + * @param string[] $array |
|
| 136 | + */ |
|
| 134 | 137 | private static function send($array, $gzip = true) |
| 135 | 138 | { |
| 136 | 139 | if($gzip) |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | 'Cache-Control: no-cache', |
| 11 | 11 | 'Content-Language: en', |
| 12 | 12 | 'Content-Type: application/json', |
| 13 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 14 | - 'Last-Modified: ' . self::get_date(), |
|
| 13 | + 'Expires: '.self::get_date(time() - 1), |
|
| 14 | + 'Last-Modified: '.self::get_date(), |
|
| 15 | 15 | 'X-Powered-By: jacobemerick.com'); |
| 16 | 16 | self::send($array); |
| 17 | 17 | } |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | 'Cache-Control: no-cache', |
| 24 | 24 | 'Content-Language: en', |
| 25 | 25 | 'Content-Type: text/html', |
| 26 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 27 | - 'Last-Modified: ' . self::get_date(), |
|
| 26 | + 'Expires: '.self::get_date(time() - 1), |
|
| 27 | + 'Last-Modified: '.self::get_date(), |
|
| 28 | 28 | 'X-Powered-By: jacobemerick.com'); |
| 29 | 29 | self::send($array); |
| 30 | 30 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | 'Cache-Control: no-cache', |
| 43 | 43 | 'Content-Language: en', |
| 44 | 44 | 'Content-Type: text/html', |
| 45 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 46 | - 'Last-Modified: ' . self::get_date(), |
|
| 45 | + 'Expires: '.self::get_date(time() - 1), |
|
| 46 | + 'Last-Modified: '.self::get_date(), |
|
| 47 | 47 | 'X-Powered-By: jacobemerick.com'); |
| 48 | 48 | self::send($array); |
| 49 | 49 | } |
@@ -55,18 +55,18 @@ discard block |
||
| 55 | 55 | 'Cache-Control: no-cache', |
| 56 | 56 | 'Content-Language: en', |
| 57 | 57 | 'Content-Type: text/html', |
| 58 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 59 | - 'Last-Modified: ' . self::get_date(), |
|
| 58 | + 'Expires: '.self::get_date(time() - 1), |
|
| 59 | + 'Last-Modified: '.self::get_date(), |
|
| 60 | 60 | 'X-Powered-By: jacobemerick.com'); |
| 61 | 61 | self::send($array); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | private static function send($array, $gzip = true) |
| 65 | 65 | { |
| 66 | - if($gzip) |
|
| 66 | + if ($gzip) |
|
| 67 | 67 | self::start_gzipping(); |
| 68 | 68 | |
| 69 | - foreach($array as $row) |
|
| 69 | + foreach ($array as $row) |
|
| 70 | 70 | { |
| 71 | 71 | header($row, TRUE); |
| 72 | 72 | } |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | private static function get_date($timestamp = false) |
| 76 | 76 | { |
| 77 | - if($timestamp == 0) |
|
| 77 | + if ($timestamp == 0) |
|
| 78 | 78 | $timestamp = time(); |
| 79 | 79 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | private static function start_gzipping() |
| 83 | 83 | { |
| 84 | - if(!ob_start('ob_gzhandler')) |
|
| 84 | + if (!ob_start('ob_gzhandler')) |
|
| 85 | 85 | ob_start(); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -3,86 +3,86 @@ |
||
| 3 | 3 | final class Header |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - public static function sendJSON() |
|
| 7 | - { |
|
| 8 | - $array = array( |
|
| 9 | - 'HTTP/1.1 200 OK', |
|
| 10 | - 'Cache-Control: no-cache', |
|
| 11 | - 'Content-Language: en', |
|
| 12 | - 'Content-Type: application/json', |
|
| 13 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 14 | - 'Last-Modified: ' . self::get_date(), |
|
| 15 | - 'X-Powered-By: jacobemerick.com'); |
|
| 16 | - self::send($array); |
|
| 17 | - } |
|
| 6 | + public static function sendJSON() |
|
| 7 | + { |
|
| 8 | + $array = array( |
|
| 9 | + 'HTTP/1.1 200 OK', |
|
| 10 | + 'Cache-Control: no-cache', |
|
| 11 | + 'Content-Language: en', |
|
| 12 | + 'Content-Type: application/json', |
|
| 13 | + 'Expires: ' . self::get_date(time() - 1), |
|
| 14 | + 'Last-Modified: ' . self::get_date(), |
|
| 15 | + 'X-Powered-By: jacobemerick.com'); |
|
| 16 | + self::send($array); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public static function sendHTML() |
|
| 20 | - { |
|
| 21 | - $array = array( |
|
| 22 | - 'HTTP/1.1 200 OK', |
|
| 23 | - 'Cache-Control: no-cache', |
|
| 24 | - 'Content-Language: en', |
|
| 25 | - 'Content-Type: text/html', |
|
| 26 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 27 | - 'Last-Modified: ' . self::get_date(), |
|
| 28 | - 'X-Powered-By: jacobemerick.com'); |
|
| 29 | - self::send($array); |
|
| 30 | - } |
|
| 19 | + public static function sendHTML() |
|
| 20 | + { |
|
| 21 | + $array = array( |
|
| 22 | + 'HTTP/1.1 200 OK', |
|
| 23 | + 'Cache-Control: no-cache', |
|
| 24 | + 'Content-Language: en', |
|
| 25 | + 'Content-Type: text/html', |
|
| 26 | + 'Expires: ' . self::get_date(time() - 1), |
|
| 27 | + 'Last-Modified: ' . self::get_date(), |
|
| 28 | + 'X-Powered-By: jacobemerick.com'); |
|
| 29 | + self::send($array); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public static function redirect($location, $method = 301) |
|
| 33 | - { |
|
| 34 | - header("Location: {$location}", TRUE, $method); |
|
| 35 | - exit(); |
|
| 36 | - } |
|
| 32 | + public static function redirect($location, $method = 301) |
|
| 33 | + { |
|
| 34 | + header("Location: {$location}", TRUE, $method); |
|
| 35 | + exit(); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public static function send404() |
|
| 39 | - { |
|
| 40 | - $array = array( |
|
| 41 | - 'HTTP/1.1 404 Not Found', |
|
| 42 | - 'Cache-Control: no-cache', |
|
| 43 | - 'Content-Language: en', |
|
| 44 | - 'Content-Type: text/html', |
|
| 45 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 46 | - 'Last-Modified: ' . self::get_date(), |
|
| 47 | - 'X-Powered-By: jacobemerick.com'); |
|
| 48 | - self::send($array); |
|
| 49 | - } |
|
| 38 | + public static function send404() |
|
| 39 | + { |
|
| 40 | + $array = array( |
|
| 41 | + 'HTTP/1.1 404 Not Found', |
|
| 42 | + 'Cache-Control: no-cache', |
|
| 43 | + 'Content-Language: en', |
|
| 44 | + 'Content-Type: text/html', |
|
| 45 | + 'Expires: ' . self::get_date(time() - 1), |
|
| 46 | + 'Last-Modified: ' . self::get_date(), |
|
| 47 | + 'X-Powered-By: jacobemerick.com'); |
|
| 48 | + self::send($array); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public static function send503() |
|
| 52 | - { |
|
| 53 | - $array = array( |
|
| 54 | - 'HTTP/1.1 503 Service Unavailable', |
|
| 55 | - 'Cache-Control: no-cache', |
|
| 56 | - 'Content-Language: en', |
|
| 57 | - 'Content-Type: text/html', |
|
| 58 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 59 | - 'Last-Modified: ' . self::get_date(), |
|
| 60 | - 'X-Powered-By: jacobemerick.com'); |
|
| 61 | - self::send($array); |
|
| 62 | - } |
|
| 51 | + public static function send503() |
|
| 52 | + { |
|
| 53 | + $array = array( |
|
| 54 | + 'HTTP/1.1 503 Service Unavailable', |
|
| 55 | + 'Cache-Control: no-cache', |
|
| 56 | + 'Content-Language: en', |
|
| 57 | + 'Content-Type: text/html', |
|
| 58 | + 'Expires: ' . self::get_date(time() - 1), |
|
| 59 | + 'Last-Modified: ' . self::get_date(), |
|
| 60 | + 'X-Powered-By: jacobemerick.com'); |
|
| 61 | + self::send($array); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - private static function send($array, $gzip = true) |
|
| 65 | - { |
|
| 66 | - if($gzip) |
|
| 67 | - self::start_gzipping(); |
|
| 64 | + private static function send($array, $gzip = true) |
|
| 65 | + { |
|
| 66 | + if($gzip) |
|
| 67 | + self::start_gzipping(); |
|
| 68 | 68 | |
| 69 | - foreach($array as $row) |
|
| 70 | - { |
|
| 71 | - header($row, TRUE); |
|
| 72 | - } |
|
| 73 | - } |
|
| 69 | + foreach($array as $row) |
|
| 70 | + { |
|
| 71 | + header($row, TRUE); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - private static function get_date($timestamp = false) |
|
| 76 | - { |
|
| 77 | - if($timestamp == 0) |
|
| 78 | - $timestamp = time(); |
|
| 79 | - return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
|
| 80 | - } |
|
| 75 | + private static function get_date($timestamp = false) |
|
| 76 | + { |
|
| 77 | + if($timestamp == 0) |
|
| 78 | + $timestamp = time(); |
|
| 79 | + return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - private static function start_gzipping() |
|
| 83 | - { |
|
| 84 | - if(!ob_start('ob_gzhandler')) |
|
| 82 | + private static function start_gzipping() |
|
| 83 | + { |
|
| 84 | + if(!ob_start('ob_gzhandler')) |
|
| 85 | 85 | ob_start(); |
| 86 | - } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | } |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <? |
| 2 | 2 | |
| 3 | -final class Header |
|
| 4 | -{ |
|
| 3 | +final class Header |
|
| 4 | +{
|
|
| 5 | 5 | |
| 6 | - public static function sendJSON() |
|
| 7 | - { |
|
| 6 | + public static function sendJSON() |
|
| 7 | + {
|
|
| 8 | 8 | $array = array( |
| 9 | 9 | 'HTTP/1.1 200 OK', |
| 10 | 10 | 'Cache-Control: no-cache', |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | self::send($array); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public static function sendHTML() |
|
| 20 | - { |
|
| 19 | + public static function sendHTML() |
|
| 20 | + {
|
|
| 21 | 21 | $array = array( |
| 22 | 22 | 'HTTP/1.1 200 OK', |
| 23 | 23 | 'Cache-Control: no-cache', |
@@ -29,14 +29,14 @@ discard block |
||
| 29 | 29 | self::send($array); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public static function redirect($location, $method = 301) |
|
| 33 | - { |
|
| 32 | + public static function redirect($location, $method = 301) |
|
| 33 | + {
|
|
| 34 | 34 | header("Location: {$location}", TRUE, $method); |
| 35 | 35 | exit(); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public static function send404() |
|
| 39 | - { |
|
| 38 | + public static function send404() |
|
| 39 | + {
|
|
| 40 | 40 | $array = array( |
| 41 | 41 | 'HTTP/1.1 404 Not Found', |
| 42 | 42 | 'Cache-Control: no-cache', |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | self::send($array); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public static function send503() |
|
| 52 | - { |
|
| 51 | + public static function send503() |
|
| 52 | + {
|
|
| 53 | 53 | $array = array( |
| 54 | 54 | 'HTTP/1.1 503 Service Unavailable', |
| 55 | 55 | 'Cache-Control: no-cache', |
@@ -61,10 +61,11 @@ discard block |
||
| 61 | 61 | self::send($array); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - private static function send($array, $gzip = true) |
|
| 65 | - { |
|
| 66 | - if($gzip) |
|
| 67 | - self::start_gzipping(); |
|
| 64 | + private static function send($array, $gzip = true) |
|
| 65 | + {
|
|
| 66 | + if($gzip) {
|
|
| 67 | + self::start_gzipping(); |
|
| 68 | + } |
|
| 68 | 69 | |
| 69 | 70 | foreach($array as $row) |
| 70 | 71 | { |
@@ -72,17 +73,19 @@ discard block |
||
| 72 | 73 | } |
| 73 | 74 | } |
| 74 | 75 | |
| 75 | - private static function get_date($timestamp = false) |
|
| 76 | - { |
|
| 77 | - if($timestamp == 0) |
|
| 78 | - $timestamp = time(); |
|
| 76 | + private static function get_date($timestamp = false) |
|
| 77 | + {
|
|
| 78 | + if($timestamp == 0) {
|
|
| 79 | + $timestamp = time(); |
|
| 80 | + } |
|
| 79 | 81 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
| 80 | 82 | } |
| 81 | 83 | |
| 82 | - private static function start_gzipping() |
|
| 83 | - { |
|
| 84 | - if(!ob_start('ob_gzhandler')) |
|
| 85 | - ob_start(); |
|
| 84 | + private static function start_gzipping() |
|
| 85 | + {
|
|
| 86 | + if(!ob_start('ob_gzhandler')) {
|
|
| 87 | + ob_start(); |
|
| 88 | + } |
|
| 86 | 89 | } |
| 87 | 90 | |
| 88 | 91 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | protected $connections; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
| 14 | + * @param ConnectionLocator $connections |
|
| 15 | 15 | */ |
| 16 | 16 | public function __construct(ConnectionLocator $connections) |
| 17 | 17 | { |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Aura\Sql\ConnectionLocator; |
| 6 | 6 | |
| 7 | -class MysqlWaterfallRepository implements WaterfallRepositoryInterface |
|
| 8 | -{ |
|
| 7 | +class MysqlWaterfallRepository implements WaterfallRepositoryInterface |
|
| 8 | +{
|
|
| 9 | 9 | |
| 10 | 10 | /** @var Aura\Sql\ConnectionLocator */ |
| 11 | 11 | protected $connections; |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @param Aura\Sql\ConnectionLocator $connections |
| 15 | 15 | */ |
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + {
|
|
| 18 | 18 | $this->connections = $connections; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function getWaterfalls($limit = null, $offset = 0) |
|
| 22 | - { |
|
| 21 | + public function getWaterfalls($limit = null, $offset = 0) |
|
| 22 | + {
|
|
| 23 | 23 | $query = " |
| 24 | 24 | SELECT `waterfall`.`id`, `waterfall`.`name`, `waterfall`.`alias`, |
| 25 | 25 | `watercourse`.`name` AS `watercourse`, `watercourse`.`alias` AS `watercourse_alias` |
@@ -4,5 +4,5 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface LogRepositoryInterface |
| 6 | 6 | { |
| 7 | - public function getActiveLogs($limit = null, $offset= 0); |
|
| 7 | + public function getActiveLogs($limit = null, $offset = 0); |
|
| 8 | 8 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Jacobemerick\Web\Domain\Waterfall\Log; |
| 4 | 4 | |
| 5 | -interface LogRepositoryInterface |
|
| 6 | -{ |
|
| 5 | +interface LogRepositoryInterface |
|
| 6 | +{
|
|
| 7 | 7 | public function getActiveLogs($limit = null, $offset= 0); |
| 8 | 8 | } |
@@ -4,5 +4,5 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface WaterfallRepositoryInterface |
| 6 | 6 | { |
| 7 | - public function getWaterfalls($limit = null, $offset= 0); |
|
| 7 | + public function getWaterfalls($limit = null, $offset = 0); |
|
| 8 | 8 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Jacobemerick\Web\Domain\Waterfall\Waterfall; |
| 4 | 4 | |
| 5 | -interface WaterfallRepositoryInterface |
|
| 6 | -{ |
|
| 5 | +interface WaterfallRepositoryInterface |
|
| 6 | +{
|
|
| 7 | 7 | public function getWaterfalls($limit = null, $offset= 0); |
| 8 | 8 | } |