@@ -5,7 +5,7 @@ |
||
| 5 | 5 | interface PostRepository |
| 6 | 6 | { |
| 7 | 7 | public function findPostByPath($category, $path); |
| 8 | - public function getActivePosts($limit = null, $offset= 0); |
|
| 8 | + public function getActivePosts($limit = null, $offset = 0); |
|
| 9 | 9 | public function getActivePostsCount(); |
| 10 | 10 | public function getActivePostsByTag($tag, $limit = null, $offset = 0); |
| 11 | 11 | public function getActivePostsCountByTag($tag); |
@@ -4,12 +4,12 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface PostRepositoryInterface |
| 6 | 6 | { |
| 7 | - public function findPostByPath($path); |
|
| 8 | - public function getActivePosts($limit = null, $offset= 0); |
|
| 9 | - public function getActivePostsCount(); |
|
| 10 | - public function getActivePostsByTag($tag, $limit = null, $offset = 0); |
|
| 11 | - public function getActivePostsCountByTag($tag); |
|
| 12 | - public function getActivePostsByCategory($category, $limit = null, $offset = 0); |
|
| 13 | - public function getActivePostsCountByCategory($category); |
|
| 14 | - public function getActivePostsByRelatedTags($post, $limit = 4); |
|
| 7 | + public function findPostByPath($path); |
|
| 8 | + public function getActivePosts($limit = null, $offset= 0); |
|
| 9 | + public function getActivePostsCount(); |
|
| 10 | + public function getActivePostsByTag($tag, $limit = null, $offset = 0); |
|
| 11 | + public function getActivePostsCountByTag($tag); |
|
| 12 | + public function getActivePostsByCategory($category, $limit = null, $offset = 0); |
|
| 13 | + public function getActivePostsCountByCategory($category); |
|
| 14 | + public function getActivePostsByRelatedTags($post, $limit = 4); |
|
| 15 | 15 | } |
@@ -7,25 +7,25 @@ discard block |
||
| 7 | 7 | class MysqlSeriesRepository implements SeriesRepository |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | - protected $connections; |
|
| 10 | + /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | + protected $connections; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param Aura\Sql\ConnectionLocator |
|
| 15 | - */ |
|
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 18 | - $this->connections = $connections; |
|
| 19 | - } |
|
| 13 | + /** |
|
| 14 | + * @param Aura\Sql\ConnectionLocator |
|
| 15 | + */ |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + { |
|
| 18 | + $this->connections = $connections; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param integer $post |
|
| 23 | - * |
|
| 24 | - * @return array|false |
|
| 25 | - */ |
|
| 26 | - public function getSeriesForPost($post) |
|
| 27 | - { |
|
| 28 | - $query = " |
|
| 21 | + /** |
|
| 22 | + * @param integer $post |
|
| 23 | + * |
|
| 24 | + * @return array|false |
|
| 25 | + */ |
|
| 26 | + public function getSeriesForPost($post) |
|
| 27 | + { |
|
| 28 | + $query = " |
|
| 29 | 29 | SELECT `series`.`title` AS `series_title`, `series`.`description` AS `series_descriptions`, |
| 30 | 30 | `post.id` AS `post`, `post`.`title`, `post`.`category`, `post`.`path` |
| 31 | 31 | FROM `jpemeric_blog`.`series` |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | WHERE `post` = :lookup_post |
| 39 | 39 | LIMIT 1) |
| 40 | 40 | ORDER BY `series_post`.`order`"; |
| 41 | - $bindings = [ |
|
| 42 | - 'is_active' => 1, |
|
| 43 | - 'lookup_post' => $post, |
|
| 44 | - ]; |
|
| 41 | + $bindings = [ |
|
| 42 | + 'is_active' => 1, |
|
| 43 | + 'lookup_post' => $post, |
|
| 44 | + ]; |
|
| 45 | 45 | |
| 46 | - return $this |
|
| 47 | - ->connections |
|
| 48 | - ->getRead() |
|
| 49 | - ->fetchAll($query, $bindings); |
|
| 50 | - } |
|
| 46 | + return $this |
|
| 47 | + ->connections |
|
| 48 | + ->getRead() |
|
| 49 | + ->fetchAll($query, $bindings); |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -4,5 +4,5 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface SeriesRepository |
| 6 | 6 | { |
| 7 | - public function getSeriesForPost($post); |
|
| 7 | + public function getSeriesForPost($post); |
|
| 8 | 8 | } |
@@ -7,85 +7,85 @@ |
||
| 7 | 7 | class MysqlTagRepository implements TagRepository |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | - protected $connections; |
|
| 10 | + /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | + protected $connections; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param Aura\Sql\ConnectionLocator |
|
| 15 | - */ |
|
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 18 | - $this->connections = $connections; |
|
| 19 | - } |
|
| 13 | + /** |
|
| 14 | + * @param Aura\Sql\ConnectionLocator |
|
| 15 | + */ |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + { |
|
| 18 | + $this->connections = $connections; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $title |
|
| 23 | - * |
|
| 24 | - * @return array|false |
|
| 25 | - */ |
|
| 26 | - public function findTagByTitle($title) |
|
| 27 | - { |
|
| 28 | - $query = " |
|
| 21 | + /** |
|
| 22 | + * @param string $title |
|
| 23 | + * |
|
| 24 | + * @return array|false |
|
| 25 | + */ |
|
| 26 | + public function findTagByTitle($title) |
|
| 27 | + { |
|
| 28 | + $query = " |
|
| 29 | 29 | SELECT * |
| 30 | 30 | FROM `jpemeric_blog`.`tag` |
| 31 | 31 | WHERE `tag` = :title |
| 32 | 32 | LIMIT 1"; |
| 33 | - $bindings = [ |
|
| 34 | - 'title' => $title, |
|
| 35 | - ]; |
|
| 33 | + $bindings = [ |
|
| 34 | + 'title' => $title, |
|
| 35 | + ]; |
|
| 36 | 36 | |
| 37 | - return $this |
|
| 38 | - ->connections |
|
| 39 | - ->getRead() |
|
| 40 | - ->fetchOne($query, $bindings); |
|
| 41 | - } |
|
| 37 | + return $this |
|
| 38 | + ->connections |
|
| 39 | + ->getRead() |
|
| 40 | + ->fetchOne($query, $bindings); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function getAllTags() |
|
| 44 | - { |
|
| 45 | - $query = " |
|
| 43 | + public function getAllTags() |
|
| 44 | + { |
|
| 45 | + $query = " |
|
| 46 | 46 | SELECT * |
| 47 | 47 | FROM `jpemeric_blog`.`tag` |
| 48 | 48 | ORDER BY `tag`"; |
| 49 | 49 | |
| 50 | - return $this |
|
| 51 | - ->connections |
|
| 52 | - ->getRead() |
|
| 53 | - ->fetchAll($query); |
|
| 54 | - } |
|
| 50 | + return $this |
|
| 51 | + ->connections |
|
| 52 | + ->getRead() |
|
| 53 | + ->fetchAll($query); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - public function getTagCloud() |
|
| 57 | - { |
|
| 58 | - $query = " |
|
| 56 | + public function getTagCloud() |
|
| 57 | + { |
|
| 58 | + $query = " |
|
| 59 | 59 | SELECT COUNT(1) AS `count`, `tag` |
| 60 | 60 | FROM `jpemeric_blog`.`tag` |
| 61 | 61 | INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`tag_id` = `tag`.`id` |
| 62 | 62 | INNER JOIN `jpemeric_blog`.`post` ON `post`.`id` = `ptlink`.`post_id` AND |
| 63 | 63 | `post`.`display` = :is_active |
| 64 | 64 | GROUP BY `tag`"; |
| 65 | - $bindings = [ |
|
| 66 | - 'is_active' => 1, |
|
| 67 | - ]; |
|
| 65 | + $bindings = [ |
|
| 66 | + 'is_active' => 1, |
|
| 67 | + ]; |
|
| 68 | 68 | |
| 69 | - return $this |
|
| 70 | - ->connections |
|
| 71 | - ->getRead() |
|
| 72 | - ->fetchAll($query, $bindings); |
|
| 73 | - } |
|
| 69 | + return $this |
|
| 70 | + ->connections |
|
| 71 | + ->getRead() |
|
| 72 | + ->fetchAll($query, $bindings); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public function getTagsForPost($post) |
|
| 76 | - { |
|
| 77 | - $query = " |
|
| 75 | + public function getTagsForPost($post) |
|
| 76 | + { |
|
| 77 | + $query = " |
|
| 78 | 78 | SELECT `tag`.* |
| 79 | 79 | FROM `jpemeric_blog`.`tag` |
| 80 | 80 | INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`tag_id` AND `post_id` = :post |
| 81 | 81 | ORDER BY `tag`"; |
| 82 | - $bindings = [ |
|
| 83 | - 'post' => $post, |
|
| 84 | - ]; |
|
| 82 | + $bindings = [ |
|
| 83 | + 'post' => $post, |
|
| 84 | + ]; |
|
| 85 | 85 | |
| 86 | - return $this |
|
| 87 | - ->connections |
|
| 88 | - ->getRead() |
|
| 89 | - ->fetchAll($query, $bindings); |
|
| 90 | - } |
|
| 86 | + return $this |
|
| 87 | + ->connections |
|
| 88 | + ->getRead() |
|
| 89 | + ->fetchAll($query, $bindings); |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface TagRepository |
| 6 | 6 | { |
| 7 | - public function findTagByTitle($title); |
|
| 8 | - public function getAllTags(); |
|
| 9 | - public function getTagCloud(); |
|
| 10 | - public function getTagsForPost($post); |
|
| 7 | + public function findTagByTitle($title); |
|
| 8 | + public function getAllTags(); |
|
| 9 | + public function getTagCloud(); |
|
| 10 | + public function getTagsForPost($post); |
|
| 11 | 11 | } |
@@ -4,5 +4,5 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface IntroductionRepository |
| 6 | 6 | { |
| 7 | - public function findByType($type, $value = ''); |
|
| 7 | + public function findByType($type, $value = ''); |
|
| 8 | 8 | } |
@@ -7,38 +7,38 @@ |
||
| 7 | 7 | class MysqlIntroductionRepository implements IntroductionRepository |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | - protected $connections; |
|
| 10 | + /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | + protected $connections; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param Aura\Sql\ConnectionLocator |
|
| 15 | - */ |
|
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 18 | - $this->connections = $connections; |
|
| 19 | - } |
|
| 13 | + /** |
|
| 14 | + * @param Aura\Sql\ConnectionLocator |
|
| 15 | + */ |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + { |
|
| 18 | + $this->connections = $connections; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $type |
|
| 23 | - * @param string $value |
|
| 24 | - * |
|
| 25 | - * @return array|false |
|
| 26 | - */ |
|
| 27 | - public function findByType($type, $value = '') |
|
| 28 | - { |
|
| 29 | - $query = " |
|
| 21 | + /** |
|
| 22 | + * @param string $type |
|
| 23 | + * @param string $value |
|
| 24 | + * |
|
| 25 | + * @return array|false |
|
| 26 | + */ |
|
| 27 | + public function findByType($type, $value = '') |
|
| 28 | + { |
|
| 29 | + $query = " |
|
| 30 | 30 | SELECT `title`, `content`, `image` |
| 31 | 31 | FROM `jpemeric_blog`.`introduction` |
| 32 | 32 | WHERE `type` = :type AND `value` = :value |
| 33 | 33 | LIMIT 1"; |
| 34 | - $bindings = [ |
|
| 35 | - 'type' => $type, |
|
| 36 | - 'value' => $value, |
|
| 37 | - ]; |
|
| 34 | + $bindings = [ |
|
| 35 | + 'type' => $type, |
|
| 36 | + 'value' => $value, |
|
| 37 | + ]; |
|
| 38 | 38 | |
| 39 | - return $this |
|
| 40 | - ->connections |
|
| 41 | - ->getRead() |
|
| 42 | - ->fetchOne($query, $bindings); |
|
| 43 | - } |
|
| 39 | + return $this |
|
| 40 | + ->connections |
|
| 41 | + ->getRead() |
|
| 42 | + ->fetchOne($query, $bindings); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -43,9 +43,9 @@ |
||
| 43 | 43 | |
| 44 | 44 | private function get_recent_posts() |
| 45 | 45 | { |
| 46 | - global $container; |
|
| 47 | - $postRepository = new MysqlPostRepository($container['db_connection_locator']); |
|
| 48 | - $recentPosts = $postRepository->getActivePosts(3); |
|
| 46 | + global $container; |
|
| 47 | + $postRepository = new MysqlPostRepository($container['db_connection_locator']); |
|
| 48 | + $recentPosts = $postRepository->getActivePosts(3); |
|
| 49 | 49 | |
| 50 | 50 | $recent_post_array = array(); |
| 51 | 51 | foreach($recentPosts as $postResult) |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | $recentPosts = $postRepository->getActivePosts(3); |
| 49 | 49 | |
| 50 | 50 | $recent_post_array = array(); |
| 51 | - foreach($recentPosts as $postResult) |
|
| 51 | + foreach ($recentPosts as $postResult) |
|
| 52 | 52 | { |
| 53 | 53 | $post = new stdclass(); |
| 54 | 54 | $post->title = $postResult['title']; |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | Loader::load('collector', array( |
| 4 | - 'waterfall/LogCollector', |
|
| 5 | - 'waterfall/WaterfallCollector')); |
|
| 4 | + 'waterfall/LogCollector', |
|
| 5 | + 'waterfall/WaterfallCollector')); |
|
| 6 | 6 | Loader::load('router', 'Router'); |
| 7 | 7 | |
| 8 | 8 | class WaterfallRouter extends Router |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | (object) array( |
| 27 | 27 | 'pattern' => '@^/falls/results(/?)$@', |
| 28 | 28 | 'replace' => '/falls/'), |
| 29 | - (object) array( |
|
| 30 | - 'pattern' => '@^/log(/?)$@', |
|
| 31 | - 'replace' => '/journal/'), |
|
| 32 | - (object) array( |
|
| 33 | - 'pattern' => '@^/log/(\d+)(/?)$@', |
|
| 34 | - 'replace' => '/journal/$1'), |
|
| 35 | - (object) array( |
|
| 36 | - 'pattern' => '@^/map/([^/]+)(/?)$@', |
|
| 37 | - 'replace' => '/map/'), |
|
| 29 | + (object) array( |
|
| 30 | + 'pattern' => '@^/log(/?)$@', |
|
| 31 | + 'replace' => '/journal/'), |
|
| 32 | + (object) array( |
|
| 33 | + 'pattern' => '@^/log/(\d+)(/?)$@', |
|
| 34 | + 'replace' => '/journal/$1'), |
|
| 35 | + (object) array( |
|
| 36 | + 'pattern' => '@^/map/([^/]+)(/?)$@', |
|
| 37 | + 'replace' => '/map/'), |
|
| 38 | 38 | (object) array( |
| 39 | 39 | 'pattern' => '@^/about/([a-z]*)(/?)$@', |
| 40 | 40 | 'replace' => '/about/'), |
@@ -73,57 +73,57 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | protected function check_for_special_redirect($uri) |
| 75 | 75 | { |
| 76 | - if (preg_match('@^/falls/([a-z\'-]+)(/?)$@', $uri, $matches)) { |
|
| 77 | - $alias = $matches[1]; |
|
| 78 | - $alias = str_replace("'", '', $alias); |
|
| 79 | - $alias .= '-falls'; |
|
| 80 | - $result = WaterfallCollector::getByOldAlias($alias); |
|
| 81 | - if ($result !== null) { |
|
| 82 | - return "/{$result->watercourse_alias}/{$result->alias}/"; |
|
| 83 | - } else { |
|
| 84 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 85 | - } |
|
| 86 | - } |
|
| 76 | + if (preg_match('@^/falls/([a-z\'-]+)(/?)$@', $uri, $matches)) { |
|
| 77 | + $alias = $matches[1]; |
|
| 78 | + $alias = str_replace("'", '', $alias); |
|
| 79 | + $alias .= '-falls'; |
|
| 80 | + $result = WaterfallCollector::getByOldAlias($alias); |
|
| 81 | + if ($result !== null) { |
|
| 82 | + return "/{$result->watercourse_alias}/{$result->alias}/"; |
|
| 83 | + } else { |
|
| 84 | + Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - if (preg_match('@^/photos/([a-z\'-]+)-([^/]+)(/?)$@', $uri, $matches)) { |
|
| 89 | - $alias = $matches[1]; |
|
| 90 | - $alias = explode('-', $alias); |
|
| 91 | - array_pop($alias); |
|
| 92 | - $alias = implode('-', $alias); |
|
| 93 | - $alias = str_replace("'", '', $alias); |
|
| 94 | - $alias .= '-falls'; |
|
| 95 | - $result = WaterfallCollector::getByOldAlias($alias); |
|
| 96 | - if ($result !== null) { |
|
| 97 | - return "/{$result->watercourse_alias}/{$result->alias}/"; |
|
| 98 | - } else { |
|
| 99 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 100 | - } |
|
| 101 | - } |
|
| 88 | + if (preg_match('@^/photos/([a-z\'-]+)-([^/]+)(/?)$@', $uri, $matches)) { |
|
| 89 | + $alias = $matches[1]; |
|
| 90 | + $alias = explode('-', $alias); |
|
| 91 | + array_pop($alias); |
|
| 92 | + $alias = implode('-', $alias); |
|
| 93 | + $alias = str_replace("'", '', $alias); |
|
| 94 | + $alias .= '-falls'; |
|
| 95 | + $result = WaterfallCollector::getByOldAlias($alias); |
|
| 96 | + if ($result !== null) { |
|
| 97 | + return "/{$result->watercourse_alias}/{$result->alias}/"; |
|
| 98 | + } else { |
|
| 99 | + Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - if (preg_match('@/log/([a-z]+-\d{2}-\d{4})(/?)$@', $uri, $matches)) { |
|
| 104 | - $date = $matches[1]; |
|
| 105 | - $date = explode('-', $date); |
|
| 106 | - $date = mktime(0, 0, 0, date('n', strtotime($date[0])), $date[1], $date[2]); |
|
| 107 | - $date = date('Y-m-d', $date); |
|
| 108 | - $result = LogCollector::getByDate($date); |
|
| 109 | - if ($result !== null) { |
|
| 110 | - return "/journal/{$result->alias}/"; |
|
| 111 | - } else { |
|
| 112 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 113 | - } |
|
| 114 | - } |
|
| 103 | + if (preg_match('@/log/([a-z]+-\d{2}-\d{4})(/?)$@', $uri, $matches)) { |
|
| 104 | + $date = $matches[1]; |
|
| 105 | + $date = explode('-', $date); |
|
| 106 | + $date = mktime(0, 0, 0, date('n', strtotime($date[0])), $date[1], $date[2]); |
|
| 107 | + $date = date('Y-m-d', $date); |
|
| 108 | + $result = LogCollector::getByDate($date); |
|
| 109 | + if ($result !== null) { |
|
| 110 | + return "/journal/{$result->alias}/"; |
|
| 111 | + } else { |
|
| 112 | + Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - if (preg_match('@/map/([a-z\'-]+)(/?)$@', $uri, $matches)) { |
|
| 117 | - $alias = $matches[1]; |
|
| 118 | - $alias = str_replace("'", '', $alias); |
|
| 119 | - $alias .= '-falls'; |
|
| 120 | - $result = WaterfallCollector::getByOldAlias($alias); |
|
| 121 | - if ($result !== null) { |
|
| 122 | - return "/map/#{$result->watercourse_alias}/{$result->alias}"; |
|
| 123 | - } else { |
|
| 124 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 125 | - } |
|
| 126 | - } |
|
| 116 | + if (preg_match('@/map/([a-z\'-]+)(/?)$@', $uri, $matches)) { |
|
| 117 | + $alias = $matches[1]; |
|
| 118 | + $alias = str_replace("'", '', $alias); |
|
| 119 | + $alias .= '-falls'; |
|
| 120 | + $result = WaterfallCollector::getByOldAlias($alias); |
|
| 121 | + if ($result !== null) { |
|
| 122 | + return "/map/#{$result->watercourse_alias}/{$result->alias}"; |
|
| 123 | + } else { |
|
| 124 | + Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | return $uri; |
| 129 | 129 | } |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | (object) array( |
| 165 | 165 | 'match' => '/map/', |
| 166 | 166 | 'controller' => 'MapController'), |
| 167 | - (object) array( |
|
| 168 | - 'match' => '/map/#[a-z-/]+', |
|
| 169 | - 'controller' => 'MapController'), |
|
| 167 | + (object) array( |
|
| 168 | + 'match' => '/map/#[a-z-/]+', |
|
| 169 | + 'controller' => 'MapController'), |
|
| 170 | 170 | (object) array( |
| 171 | 171 | 'match' => '/journal/', |
| 172 | 172 | 'controller' => 'LogListController'), |