@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $namespace = 'portfolio'; |
| 4 | -require_once __DIR__ . '/../../bootstrap.php'; |
|
| 4 | +require_once __DIR__.'/../../bootstrap.php'; |
|
| 5 | 5 | |
| 6 | 6 | // route |
| 7 | 7 | Loader::loadInstance('router', 'Router'); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $namespace = 'portfolio'; |
| 4 | -require_once __DIR__ . '/../../bootstrap.php'; |
|
| 4 | +require_once __DIR__.'/../../bootstrap.php'; |
|
| 5 | 5 | |
| 6 | 6 | // route |
| 7 | 7 | Loader::loadInstance('router', 'Router'); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $namespace = 'portfolio'; |
| 4 | -require_once __DIR__ . '/../../bootstrap.php'; |
|
| 4 | +require_once __DIR__.'/../../bootstrap.php'; |
|
| 5 | 5 | |
| 6 | 6 | // route |
| 7 | 7 | Loader::loadInstance('router', 'Router'); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $namespace = 'portfolio'; |
| 4 | -require_once __DIR__ . '/../../bootstrap.php'; |
|
| 4 | +require_once __DIR__.'/../../bootstrap.php'; |
|
| 5 | 5 | |
| 6 | 6 | // route |
| 7 | 7 | Loader::loadInstance('router', 'Router'); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $namespace = 'portfolio'; |
| 4 | -require_once __DIR__ . '/../../bootstrap.php'; |
|
| 4 | +require_once __DIR__.'/../../bootstrap.php'; |
|
| 5 | 5 | |
| 6 | 6 | // route |
| 7 | 7 | Loader::loadInstance('router', 'Router'); |
@@ -5,13 +5,13 @@ discard block |
||
| 5 | 5 | ini_set('display_errors', 0); |
| 6 | 6 | |
| 7 | 7 | |
| 8 | -require_once __DIR__ . '/vendor/autoload.php'; |
|
| 8 | +require_once __DIR__.'/vendor/autoload.php'; |
|
| 9 | 9 | |
| 10 | 10 | $container = new Pimple\Container(); |
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | // load the config for the application |
| 14 | -$config_path = __DIR__ . '/config.json'; |
|
| 14 | +$config_path = __DIR__.'/config.json'; |
|
| 15 | 15 | |
| 16 | 16 | $handle = @fopen($config_path, 'r'); |
| 17 | 17 | if ($handle === false) { |
@@ -29,14 +29,14 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | // timezones are fun |
| 31 | 31 | date_default_timezone_set('America/Phoenix'); // todo - belongs in configuration |
| 32 | -$container['default_timezone'] = function ($c) { |
|
| 32 | +$container['default_timezone'] = function($c) { |
|
| 33 | 33 | return new DateTimeZone('America/Phoenix'); |
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | // configure the db connections holder |
| 38 | 38 | $db_connections = new Aura\Sql\ConnectionLocator(); |
| 39 | -$db_connections->setDefault(function () use ($config) { |
|
| 39 | +$db_connections->setDefault(function() use ($config) { |
|
| 40 | 40 | $connection = $config->database->slave; |
| 41 | 41 | return new Aura\Sql\ExtendedPdo( |
| 42 | 42 | "mysql:host={$connection->host}", |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $connection->password |
| 45 | 45 | ); |
| 46 | 46 | }); |
| 47 | -$db_connections->setWrite('master', function () use ($config) { |
|
| 47 | +$db_connections->setWrite('master', function() use ($config) { |
|
| 48 | 48 | $connection = $config->database->master; |
| 49 | 49 | return new Aura\Sql\ExtendedPdo( |
| 50 | 50 | "mysql:host={$connection->host}", |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $connection->password |
| 53 | 53 | ); |
| 54 | 54 | }); |
| 55 | -$db_connections->setRead('slave', function () use ($config) { |
|
| 55 | +$db_connections->setRead('slave', function() use ($config) { |
|
| 56 | 56 | $connection = $config->database->slave; |
| 57 | 57 | $pdo = new Aura\Sql\ExtendedPdo( |
| 58 | 58 | "mysql:host={$connection->host}", |
@@ -70,16 +70,16 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | // setup mail handler |
| 73 | -$container['mail'] = $container->factory(function ($c) { |
|
| 73 | +$container['mail'] = $container->factory(function($c) { |
|
| 74 | 74 | return (new Jacobemerick\Archangel\Archangel())->setLogger($c['logger']); |
| 75 | 75 | }); |
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | // setup the logger |
| 79 | -$container['setup_logger'] = $container->protect(function ($name) use ($container) { |
|
| 79 | +$container['setup_logger'] = $container->protect(function($name) use ($container) { |
|
| 80 | 80 | $logger = new Monolog\Logger($name); |
| 81 | 81 | |
| 82 | - $logPath = __DIR__ . "/logs/{$name}.log"; |
|
| 82 | + $logPath = __DIR__."/logs/{$name}.log"; |
|
| 83 | 83 | $streamHandler = new Monolog\Handler\StreamHandler($logPath, Monolog\Logger::INFO); |
| 84 | 84 | $streamHandler->setFormatter( |
| 85 | 85 | new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n") |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | // sets up shutdown function to display profiler |
| 110 | -register_shutdown_function(function () use ($container) { |
|
| 110 | +register_shutdown_function(function() use ($container) { |
|
| 111 | 111 | if ( |
| 112 | 112 | !isset($_COOKIE['debugger']) || |
| 113 | 113 | $_COOKIE['debugger'] != 'display' |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | ->getRead() |
| 120 | 120 | ->getProfiler() |
| 121 | 121 | ->getProfiles(); |
| 122 | - $dbProfiles = array_filter($dbProfiles, function ($profile) { |
|
| 122 | + $dbProfiles = array_filter($dbProfiles, function($profile) { |
|
| 123 | 123 | return $profile['function'] == 'perform'; |
| 124 | 124 | }); |
| 125 | - $dbProfiles = array_map(function ($profile) { |
|
| 125 | + $dbProfiles = array_map(function($profile) { |
|
| 126 | 126 | return [ |
| 127 | 127 | 'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])), |
| 128 | 128 | 'parameters' => $profile['bind_values'], |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 28 | 28 | $this->post = $repository->findPostByPath(URLDecode::getPiece(2)); |
| 29 | 29 | |
| 30 | - if($this->post == null) |
|
| 30 | + if ($this->post == null) |
|
| 31 | 31 | $this->eject(); |
| 32 | 32 | |
| 33 | 33 | $this->handle_comment_submit( |
| 34 | 34 | self::$BLOG_SITE_ID, |
| 35 | 35 | $this->post['path'], |
| 36 | - Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/', |
|
| 36 | + Loader::getRootUrl('blog').$this->post['category'].'/'.$this->post['path'].'/', |
|
| 37 | 37 | $this->post['title']); |
| 38 | 38 | |
| 39 | 39 | global $container; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $log_id = self::$DEPRECATED_BLOGS[$this->post['id']]; |
| 59 | 59 | $log = LogCollector::getById($log_id); |
| 60 | 60 | if (!empty($log)) { |
| 61 | - $log_url = Loader::getRootUrl('waterfalls') . "journal/{$log->alias}/"; |
|
| 61 | + $log_url = Loader::getRootUrl('waterfalls')."journal/{$log->alias}/"; |
|
| 62 | 62 | $this->set_canonical($log_url); |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $keyword_array = array(); |
| 97 | 97 | $keywords = $this->tags; |
| 98 | 98 | |
| 99 | - foreach($keywords as $keyword) |
|
| 99 | + foreach ($keywords as $keyword) |
|
| 100 | 100 | { |
| 101 | 101 | $keyword_array[] = $keyword['tag']; |
| 102 | 102 | } |
@@ -110,16 +110,16 @@ discard block |
||
| 110 | 110 | private function get_series_posts() |
| 111 | 111 | { |
| 112 | 112 | $series_posts = $this->fetch_series_posts(); |
| 113 | - if(count($series_posts) < 1) |
|
| 113 | + if (count($series_posts) < 1) |
|
| 114 | 114 | return array(); |
| 115 | 115 | |
| 116 | 116 | $previous_post = new stdclass(); |
| 117 | 117 | $next_post = new stdclass(); |
| 118 | 118 | |
| 119 | 119 | $found_current_post = false; |
| 120 | - foreach($series_posts as $post_row) |
|
| 120 | + foreach ($series_posts as $post_row) |
|
| 121 | 121 | { |
| 122 | - if($post_row['post'] == $this->post['id']) |
|
| 122 | + if ($post_row['post'] == $this->post['id']) |
|
| 123 | 123 | { |
| 124 | 124 | $found_current_post = true; |
| 125 | 125 | continue; |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | $post->title = $post_row['title']; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
| 151 | + $post->url = Loader::getRootUrl('blog')."{$post_row['category']}/{$post_row['path']}/"; |
|
| 152 | 152 | |
| 153 | - if(!$found_current_post) |
|
| 153 | + if (!$found_current_post) |
|
| 154 | 154 | $previous_post = $post; |
| 155 | 155 | else |
| 156 | 156 | { |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | private $series_posts; |
| 170 | 170 | private function fetch_series_posts() |
| 171 | 171 | { |
| 172 | - if(!isset($this->series_posts)) { |
|
| 172 | + if (!isset($this->series_posts)) { |
|
| 173 | 173 | global $container; |
| 174 | 174 | $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
| 175 | 175 | $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
@@ -180,14 +180,14 @@ discard block |
||
| 180 | 180 | private function get_related_posts() |
| 181 | 181 | { |
| 182 | 182 | $tag_array = array(); |
| 183 | - foreach($this->tags as $tag) |
|
| 183 | + foreach ($this->tags as $tag) |
|
| 184 | 184 | { |
| 185 | 185 | $tag_array[] = $tag['id']; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $series_posts = $this->fetch_series_posts(); |
| 189 | 189 | $exclude_post_array = array(); |
| 190 | - foreach($series_posts as $series_post) |
|
| 190 | + foreach ($series_posts as $series_post) |
|
| 191 | 191 | { |
| 192 | 192 | $exclude_post_array[] = $series_post['post']; |
| 193 | 193 | } |
@@ -198,11 +198,11 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | $post_array = array(); |
| 200 | 200 | |
| 201 | - foreach($post_result as $post_row) |
|
| 201 | + foreach ($post_result as $post_row) |
|
| 202 | 202 | { |
| 203 | 203 | $post = new stdclass(); |
| 204 | 204 | $post->title = $post_row['title']; |
| 205 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
| 205 | + $post->url = Loader::getRootUrl('blog')."{$post_row['category']}/{$post_row['path']}/"; |
|
| 206 | 206 | $post->category = ucwords(str_replace('-', ' ', $post_row['category'])); |
| 207 | 207 | $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate(); |
| 208 | 208 | $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | $container['logger']->info("CommentService | Path | {$elapsed}"); |
| 247 | 247 | |
| 248 | 248 | $array = array(); |
| 249 | - foreach((array) $comment_response as $comment) |
|
| 249 | + foreach ((array) $comment_response as $comment) |
|
| 250 | 250 | { |
| 251 | 251 | $body = $comment->getBody(); |
| 252 | 252 | $body = Content::instance('CleanComment', $body)->activate(); |
@@ -6,191 +6,191 @@ discard block |
||
| 6 | 6 | final class PostController extends DefaultPageController |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - private static $PAGE_DESCRIPTION_LIMIT = 250; |
|
| 9 | + private static $PAGE_DESCRIPTION_LIMIT = 250; |
|
| 10 | 10 | |
| 11 | - private static $TITLE = "%s | Jacob Emerick's Blog"; |
|
| 12 | - private static $AUTHOR = 'Jacob Emerick'; |
|
| 13 | - private static $AUTHOR_URL = 'https://home.jacobemerick.com/'; |
|
| 11 | + private static $TITLE = "%s | Jacob Emerick's Blog"; |
|
| 12 | + private static $AUTHOR = 'Jacob Emerick'; |
|
| 13 | + private static $AUTHOR_URL = 'https://home.jacobemerick.com/'; |
|
| 14 | 14 | |
| 15 | - private static $POST_LENGTH_SHORT = 100; |
|
| 16 | - private static $POST_LENGTH_LONG = 140; |
|
| 15 | + private static $POST_LENGTH_SHORT = 100; |
|
| 16 | + private static $POST_LENGTH_LONG = 140; |
|
| 17 | 17 | |
| 18 | - private $post; |
|
| 19 | - private $tags; |
|
| 20 | - private $comment_errors = array(); |
|
| 18 | + private $post; |
|
| 19 | + private $tags; |
|
| 20 | + private $comment_errors = array(); |
|
| 21 | 21 | |
| 22 | - public function __construct() |
|
| 23 | - { |
|
| 24 | - parent::__construct(); |
|
| 22 | + public function __construct() |
|
| 23 | + { |
|
| 24 | + parent::__construct(); |
|
| 25 | 25 | |
| 26 | 26 | global $container; |
| 27 | 27 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 28 | 28 | $this->post = $repository->findPostByPath(URLDecode::getPiece(2)); |
| 29 | 29 | |
| 30 | - if($this->post == null) |
|
| 31 | - $this->eject(); |
|
| 30 | + if($this->post == null) |
|
| 31 | + $this->eject(); |
|
| 32 | 32 | |
| 33 | - $this->handle_comment_submit( |
|
| 34 | - self::$BLOG_SITE_ID, |
|
| 35 | - $this->post['path'], |
|
| 36 | - Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/', |
|
| 37 | - $this->post['title']); |
|
| 33 | + $this->handle_comment_submit( |
|
| 34 | + self::$BLOG_SITE_ID, |
|
| 35 | + $this->post['path'], |
|
| 36 | + Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/', |
|
| 37 | + $this->post['title']); |
|
| 38 | 38 | |
| 39 | 39 | global $container; |
| 40 | 40 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
| 41 | 41 | $this->tags = $repository->getTagsForPost($this->post['id']); |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - protected function set_head_data() |
|
| 45 | - { |
|
| 46 | - parent::set_head_data(); |
|
| 44 | + protected function set_head_data() |
|
| 45 | + { |
|
| 46 | + parent::set_head_data(); |
|
| 47 | 47 | |
| 48 | - $this->set_title(sprintf(self::$TITLE, $this->post['title'])); |
|
| 49 | - $this->set_description($this->get_post_description()); |
|
| 50 | - $this->set_keywords($this->get_post_keywords()); |
|
| 51 | - $this->set_author(self::$AUTHOR); |
|
| 48 | + $this->set_title(sprintf(self::$TITLE, $this->post['title'])); |
|
| 49 | + $this->set_description($this->get_post_description()); |
|
| 50 | + $this->set_keywords($this->get_post_keywords()); |
|
| 51 | + $this->set_author(self::$AUTHOR); |
|
| 52 | 52 | |
| 53 | 53 | $photo = Content::instance('FetchFirstPhoto', $this->post['body'])->activate(true); |
| 54 | 54 | $photo = preg_match('/^<img src="([a-z-:\.\/]+)" [^>]+>$/', $photo, $matches); |
| 55 | 55 | $this->set_head('thumbnail', $matches[1]); |
| 56 | 56 | |
| 57 | - if (array_key_exists($this->post['id'], self::$DEPRECATED_BLOGS)) { |
|
| 58 | - $log_id = self::$DEPRECATED_BLOGS[$this->post['id']]; |
|
| 59 | - $log = LogCollector::getById($log_id); |
|
| 60 | - if (!empty($log)) { |
|
| 61 | - $log_url = Loader::getRootUrl('waterfalls') . "journal/{$log->alias}/"; |
|
| 62 | - $this->set_canonical($log_url); |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 57 | + if (array_key_exists($this->post['id'], self::$DEPRECATED_BLOGS)) { |
|
| 58 | + $log_id = self::$DEPRECATED_BLOGS[$this->post['id']]; |
|
| 59 | + $log = LogCollector::getById($log_id); |
|
| 60 | + if (!empty($log)) { |
|
| 61 | + $log_url = Loader::getRootUrl('waterfalls') . "journal/{$log->alias}/"; |
|
| 62 | + $this->set_canonical($log_url); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - protected function get_introduction() {} |
|
| 67 | + protected function get_introduction() {} |
|
| 68 | 68 | |
| 69 | - protected function set_body_data() |
|
| 70 | - { |
|
| 71 | - parent::set_body_data(); |
|
| 69 | + protected function set_body_data() |
|
| 70 | + { |
|
| 71 | + parent::set_body_data(); |
|
| 72 | 72 | |
| 73 | - $this->set_body('title', $this->post['title']); |
|
| 74 | - $this->set_body('view', 'Post'); |
|
| 75 | - $this->set_body('data', array( |
|
| 76 | - 'post' => $this->format_post($this->post, false), |
|
| 77 | - 'series_posts' => $this->get_series_posts(), |
|
| 78 | - 'related_posts' => $this->get_related_posts(), |
|
| 79 | - 'author' => self::$AUTHOR, |
|
| 80 | - 'author_url' => self::$AUTHOR_URL, |
|
| 81 | - 'comment_array' => $this->get_comment_array("{$this->post['category']}/{$this->post['path']}"), |
|
| 73 | + $this->set_body('title', $this->post['title']); |
|
| 74 | + $this->set_body('view', 'Post'); |
|
| 75 | + $this->set_body('data', array( |
|
| 76 | + 'post' => $this->format_post($this->post, false), |
|
| 77 | + 'series_posts' => $this->get_series_posts(), |
|
| 78 | + 'related_posts' => $this->get_related_posts(), |
|
| 79 | + 'author' => self::$AUTHOR, |
|
| 80 | + 'author_url' => self::$AUTHOR_URL, |
|
| 81 | + 'comment_array' => $this->get_comment_array("{$this->post['category']}/{$this->post['path']}"), |
|
| 82 | 82 | )); |
| 83 | - } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - protected function get_post_description() |
|
| 86 | - { |
|
| 87 | - $description = $this->post['body']; |
|
| 88 | - $description = strip_tags($description); |
|
| 89 | - $description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT); |
|
| 85 | + protected function get_post_description() |
|
| 86 | + { |
|
| 87 | + $description = $this->post['body']; |
|
| 88 | + $description = strip_tags($description); |
|
| 89 | + $description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT); |
|
| 90 | 90 | |
| 91 | - return $description; |
|
| 92 | - } |
|
| 91 | + return $description; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - protected function get_post_keywords() |
|
| 95 | - { |
|
| 96 | - $keyword_array = array(); |
|
| 97 | - $keywords = $this->tags; |
|
| 94 | + protected function get_post_keywords() |
|
| 95 | + { |
|
| 96 | + $keyword_array = array(); |
|
| 97 | + $keywords = $this->tags; |
|
| 98 | 98 | |
| 99 | - foreach($keywords as $keyword) |
|
| 100 | - { |
|
| 101 | - $keyword_array[] = $keyword['tag']; |
|
| 102 | - } |
|
| 99 | + foreach($keywords as $keyword) |
|
| 100 | + { |
|
| 101 | + $keyword_array[] = $keyword['tag']; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - $keyword_array[] = 'blog'; |
|
| 105 | - $keyword_array[] = 'Jacob Emerick'; |
|
| 104 | + $keyword_array[] = 'blog'; |
|
| 105 | + $keyword_array[] = 'Jacob Emerick'; |
|
| 106 | 106 | |
| 107 | - return $keyword_array; |
|
| 108 | - } |
|
| 107 | + return $keyword_array; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - private function get_series_posts() |
|
| 111 | - { |
|
| 112 | - $series_posts = $this->fetch_series_posts(); |
|
| 113 | - if(count($series_posts) < 1) |
|
| 114 | - return array(); |
|
| 110 | + private function get_series_posts() |
|
| 111 | + { |
|
| 112 | + $series_posts = $this->fetch_series_posts(); |
|
| 113 | + if(count($series_posts) < 1) |
|
| 114 | + return array(); |
|
| 115 | 115 | |
| 116 | - $previous_post = new stdclass(); |
|
| 117 | - $next_post = new stdclass(); |
|
| 116 | + $previous_post = new stdclass(); |
|
| 117 | + $next_post = new stdclass(); |
|
| 118 | 118 | |
| 119 | - $found_current_post = false; |
|
| 120 | - foreach($series_posts as $post_row) |
|
| 121 | - { |
|
| 122 | - if($post_row['post'] == $this->post['id']) |
|
| 123 | - { |
|
| 124 | - $found_current_post = true; |
|
| 125 | - continue; |
|
| 126 | - } |
|
| 119 | + $found_current_post = false; |
|
| 120 | + foreach($series_posts as $post_row) |
|
| 121 | + { |
|
| 122 | + if($post_row['post'] == $this->post['id']) |
|
| 123 | + { |
|
| 124 | + $found_current_post = true; |
|
| 125 | + continue; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - $post = new stdclass(); |
|
| 128 | + $post = new stdclass(); |
|
| 129 | 129 | |
| 130 | - if ( |
|
| 130 | + if ( |
|
| 131 | 131 | strpos($post_row['title'], 'Rainy Supe Loop') === 0 || |
| 132 | 132 | strpos($post_row['title'], 'Malapais Loop') === 0 || |
| 133 | 133 | strpos($post_row['title'], 'Mazatzal Peak Loop') === 0 || |
| 134 | 134 | strpos($post_row['title'], 'Dripping Springs Loop') === 0 |
| 135 | - ) { |
|
| 135 | + ) { |
|
| 136 | 136 | $title = $post_row['title']; |
| 137 | 137 | $title = explode(':', $title); |
| 138 | 138 | $title = array_pop($title); |
| 139 | 139 | $title = trim($title); |
| 140 | 140 | $post->title = $title; |
| 141 | - } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
| 142 | - $title = $post_row['title']; |
|
| 143 | - $title = explode(',', $title); |
|
| 144 | - $title = array_pop($title); |
|
| 145 | - $title = trim($title); |
|
| 146 | - $post->title = $title; |
|
| 147 | - } else { |
|
| 148 | - $post->title = $post_row['title']; |
|
| 149 | - } |
|
| 141 | + } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
| 142 | + $title = $post_row['title']; |
|
| 143 | + $title = explode(',', $title); |
|
| 144 | + $title = array_pop($title); |
|
| 145 | + $title = trim($title); |
|
| 146 | + $post->title = $title; |
|
| 147 | + } else { |
|
| 148 | + $post->title = $post_row['title']; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
| 151 | + $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
| 152 | 152 | |
| 153 | - if(!$found_current_post) |
|
| 154 | - $previous_post = $post; |
|
| 155 | - else |
|
| 156 | - { |
|
| 157 | - $next_post = $post; |
|
| 158 | - break; |
|
| 159 | - } |
|
| 160 | - } |
|
| 153 | + if(!$found_current_post) |
|
| 154 | + $previous_post = $post; |
|
| 155 | + else |
|
| 156 | + { |
|
| 157 | + $next_post = $post; |
|
| 158 | + break; |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - return array( |
|
| 163 | - 'title' => $post_row['series_title'], |
|
| 164 | - 'description' => Content::instance('FixInternalLink', $post_row['series_description'])->activate(), |
|
| 165 | - 'previous' => $previous_post, |
|
| 166 | - 'next' => $next_post); |
|
| 167 | - } |
|
| 162 | + return array( |
|
| 163 | + 'title' => $post_row['series_title'], |
|
| 164 | + 'description' => Content::instance('FixInternalLink', $post_row['series_description'])->activate(), |
|
| 165 | + 'previous' => $previous_post, |
|
| 166 | + 'next' => $next_post); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - private $series_posts; |
|
| 170 | - private function fetch_series_posts() |
|
| 171 | - { |
|
| 172 | - if(!isset($this->series_posts)) { |
|
| 173 | - global $container; |
|
| 174 | - $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
| 175 | - $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
| 176 | - } |
|
| 177 | - return $this->series_posts; |
|
| 178 | - } |
|
| 169 | + private $series_posts; |
|
| 170 | + private function fetch_series_posts() |
|
| 171 | + { |
|
| 172 | + if(!isset($this->series_posts)) { |
|
| 173 | + global $container; |
|
| 174 | + $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
| 175 | + $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
| 176 | + } |
|
| 177 | + return $this->series_posts; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - private function get_related_posts() |
|
| 181 | - { |
|
| 182 | - $tag_array = array(); |
|
| 183 | - foreach($this->tags as $tag) |
|
| 184 | - { |
|
| 185 | - $tag_array[] = $tag['id']; |
|
| 186 | - } |
|
| 180 | + private function get_related_posts() |
|
| 181 | + { |
|
| 182 | + $tag_array = array(); |
|
| 183 | + foreach($this->tags as $tag) |
|
| 184 | + { |
|
| 185 | + $tag_array[] = $tag['id']; |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - $series_posts = $this->fetch_series_posts(); |
|
| 189 | - $exclude_post_array = array(); |
|
| 190 | - foreach($series_posts as $series_post) |
|
| 191 | - { |
|
| 192 | - $exclude_post_array[] = $series_post['post']; |
|
| 193 | - } |
|
| 188 | + $series_posts = $this->fetch_series_posts(); |
|
| 189 | + $exclude_post_array = array(); |
|
| 190 | + foreach($series_posts as $series_post) |
|
| 191 | + { |
|
| 192 | + $exclude_post_array[] = $series_post['post']; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | 195 | global $container; |
| 196 | 196 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -198,20 +198,20 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | $post_array = array(); |
| 200 | 200 | |
| 201 | - foreach($post_result as $post_row) |
|
| 202 | - { |
|
| 203 | - $post = new stdclass(); |
|
| 204 | - $post->title = $post_row['title']; |
|
| 205 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
| 206 | - $post->category = ucwords(str_replace('-', ' ', $post_row['category'])); |
|
| 207 | - $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate(); |
|
| 208 | - $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
|
| 201 | + foreach($post_result as $post_row) |
|
| 202 | + { |
|
| 203 | + $post = new stdclass(); |
|
| 204 | + $post->title = $post_row['title']; |
|
| 205 | + $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
| 206 | + $post->category = ucwords(str_replace('-', ' ', $post_row['category'])); |
|
| 207 | + $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate(); |
|
| 208 | + $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
|
| 209 | 209 | |
| 210 | - $post_array[] = $post; |
|
| 211 | - } |
|
| 210 | + $post_array[] = $post; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - return $post_array; |
|
| 214 | - } |
|
| 213 | + return $post_array; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | protected function get_comment_array($path) |
| 217 | 217 | { |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | Loader::load('collector', 'waterfall/LogCollector'); |
| 4 | 4 | Loader::load('controller', 'blog/DefaultPageController'); |
| 5 | 5 | |
| 6 | -final class PostController extends DefaultPageController |
|
| 7 | -{ |
|
| 6 | +final class PostController extends DefaultPageController |
|
| 7 | +{
|
|
| 8 | 8 | |
| 9 | 9 | private static $PAGE_DESCRIPTION_LIMIT = 250; |
| 10 | 10 | |
@@ -19,16 +19,17 @@ discard block |
||
| 19 | 19 | private $tags; |
| 20 | 20 | private $comment_errors = array(); |
| 21 | 21 | |
| 22 | - public function __construct() |
|
| 23 | - { |
|
| 22 | + public function __construct() |
|
| 23 | + {
|
|
| 24 | 24 | parent::__construct(); |
| 25 | 25 | |
| 26 | 26 | global $container; |
| 27 | 27 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 28 | 28 | $this->post = $repository->findPostByPath(URLDecode::getPiece(2)); |
| 29 | 29 | |
| 30 | - if($this->post == null) |
|
| 31 | - $this->eject(); |
|
| 30 | + if($this->post == null) {
|
|
| 31 | + $this->eject(); |
|
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | $this->handle_comment_submit( |
| 34 | 35 | self::$BLOG_SITE_ID, |
@@ -41,8 +42,8 @@ discard block |
||
| 41 | 42 | $this->tags = $repository->getTagsForPost($this->post['id']); |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | - protected function set_head_data() |
|
| 45 | - { |
|
| 45 | + protected function set_head_data() |
|
| 46 | + {
|
|
| 46 | 47 | parent::set_head_data(); |
| 47 | 48 | |
| 48 | 49 | $this->set_title(sprintf(self::$TITLE, $this->post['title'])); |
@@ -64,10 +65,12 @@ discard block |
||
| 64 | 65 | } |
| 65 | 66 | } |
| 66 | 67 | |
| 67 | - protected function get_introduction() {} |
|
| 68 | + protected function get_introduction() |
|
| 69 | + {
|
|
| 70 | +} |
|
| 68 | 71 | |
| 69 | - protected function set_body_data() |
|
| 70 | - { |
|
| 72 | + protected function set_body_data() |
|
| 73 | + {
|
|
| 71 | 74 | parent::set_body_data(); |
| 72 | 75 | |
| 73 | 76 | $this->set_body('title', $this->post['title']); |
@@ -82,8 +85,8 @@ discard block |
||
| 82 | 85 | )); |
| 83 | 86 | } |
| 84 | 87 | |
| 85 | - protected function get_post_description() |
|
| 86 | - { |
|
| 88 | + protected function get_post_description() |
|
| 89 | + {
|
|
| 87 | 90 | $description = $this->post['body']; |
| 88 | 91 | $description = strip_tags($description); |
| 89 | 92 | $description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT); |
@@ -91,8 +94,8 @@ discard block |
||
| 91 | 94 | return $description; |
| 92 | 95 | } |
| 93 | 96 | |
| 94 | - protected function get_post_keywords() |
|
| 95 | - { |
|
| 97 | + protected function get_post_keywords() |
|
| 98 | + {
|
|
| 96 | 99 | $keyword_array = array(); |
| 97 | 100 | $keywords = $this->tags; |
| 98 | 101 | |
@@ -107,11 +110,12 @@ discard block |
||
| 107 | 110 | return $keyword_array; |
| 108 | 111 | } |
| 109 | 112 | |
| 110 | - private function get_series_posts() |
|
| 111 | - { |
|
| 113 | + private function get_series_posts() |
|
| 114 | + {
|
|
| 112 | 115 | $series_posts = $this->fetch_series_posts(); |
| 113 | - if(count($series_posts) < 1) |
|
| 114 | - return array(); |
|
| 116 | + if(count($series_posts) < 1) {
|
|
| 117 | + return array(); |
|
| 118 | + } |
|
| 115 | 119 | |
| 116 | 120 | $previous_post = new stdclass(); |
| 117 | 121 | $next_post = new stdclass(); |
@@ -150,9 +154,9 @@ discard block |
||
| 150 | 154 | |
| 151 | 155 | $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
| 152 | 156 | |
| 153 | - if(!$found_current_post) |
|
| 154 | - $previous_post = $post; |
|
| 155 | - else |
|
| 157 | + if(!$found_current_post) {
|
|
| 158 | + $previous_post = $post; |
|
| 159 | + } else |
|
| 156 | 160 | { |
| 157 | 161 | $next_post = $post; |
| 158 | 162 | break; |
@@ -167,8 +171,8 @@ discard block |
||
| 167 | 171 | } |
| 168 | 172 | |
| 169 | 173 | private $series_posts; |
| 170 | - private function fetch_series_posts() |
|
| 171 | - { |
|
| 174 | + private function fetch_series_posts() |
|
| 175 | + {
|
|
| 172 | 176 | if(!isset($this->series_posts)) { |
| 173 | 177 | global $container; |
| 174 | 178 | $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
@@ -177,8 +181,8 @@ discard block |
||
| 177 | 181 | return $this->series_posts; |
| 178 | 182 | } |
| 179 | 183 | |
| 180 | - private function get_related_posts() |
|
| 181 | - { |
|
| 184 | + private function get_related_posts() |
|
| 185 | + {
|
|
| 182 | 186 | $tag_array = array(); |
| 183 | 187 | foreach($this->tags as $tag) |
| 184 | 188 | { |
@@ -213,8 +217,8 @@ discard block |
||
| 213 | 217 | return $post_array; |
| 214 | 218 | } |
| 215 | 219 | |
| 216 | - protected function get_comment_array($path) |
|
| 217 | - { |
|
| 220 | + protected function get_comment_array($path) |
|
| 221 | + {
|
|
| 218 | 222 | global $config; |
| 219 | 223 | $configuration = new Jacobemerick\CommentService\Configuration(); |
| 220 | 224 | $configuration->setUsername($config->comments->user); |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Jacobemerick\Web\Domain\Comment\Comment; |
| 4 | 4 | |
| 5 | -interface CommentRepositoryInterface |
|
| 6 | -{ |
|
| 5 | +interface CommentRepositoryInterface |
|
| 6 | +{
|
|
| 7 | 7 | public function createComment(array $comment); |
| 8 | 8 | public function getComment($commentId); |
| 9 | 9 | public function getComments($domain = null, $path = null, $page = null, $perPage = null, $order = null); |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Jacobemerick\Web\Domain\Comment\Commenter; |
| 4 | 4 | |
| 5 | -interface CommenterRepositoryInterface |
|
| 6 | -{ |
|
| 5 | +interface CommenterRepositoryInterface |
|
| 6 | +{
|
|
| 7 | 7 | public function createCommenter(array $commenter); |
| 8 | 8 | public function getCommenter($commenterId); |
| 9 | 9 | public function getCommenters($page = null, $perPage = null); |