@@ -11,7 +11,7 @@ discard block |
||
| 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 | { |
@@ -41,6 +41,9 @@ discard block |
||
| 41 | 41 | ->fetchOne($query, $bindings); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | + /** |
|
| 45 | + * @param integer $limit |
|
| 46 | + */ |
|
| 44 | 47 | public function getActivePosts($limit = null, $offset = 0) |
| 45 | 48 | { |
| 46 | 49 | $query = " |
@@ -79,6 +82,9 @@ discard block |
||
| 79 | 82 | ->fetchValue($query, $bindings); |
| 80 | 83 | } |
| 81 | 84 | |
| 85 | + /** |
|
| 86 | + * @param integer $limit |
|
| 87 | + */ |
|
| 82 | 88 | public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
| 83 | 89 | { |
| 84 | 90 | $query = " |
@@ -122,6 +128,9 @@ discard block |
||
| 122 | 128 | ->fetchValue($query, $bindings); |
| 123 | 129 | } |
| 124 | 130 | |
| 131 | + /** |
|
| 132 | + * @param integer $limit |
|
| 133 | + */ |
|
| 125 | 134 | public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
| 126 | 135 | { |
| 127 | 136 | $query = " |
@@ -7,163 +7,163 @@ discard block |
||
| 7 | 7 | class MysqlPostRepository implements PostRepositoryInterface |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | - protected $connections; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
| 15 | - */ |
|
| 16 | - public function __construct(ConnectionLocator $connections) |
|
| 17 | - { |
|
| 18 | - $this->connections = $connections; |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @param string $path |
|
| 23 | - * |
|
| 24 | - * @return array|false |
|
| 25 | - */ |
|
| 26 | - public function findPostByPath($path) |
|
| 27 | - { |
|
| 28 | - $query = " |
|
| 10 | + /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | + protected $connections; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * @param Aura\Sql\ConnectionLocator $connections |
|
| 15 | + */ |
|
| 16 | + public function __construct(ConnectionLocator $connections) |
|
| 17 | + { |
|
| 18 | + $this->connections = $connections; |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @param string $path |
|
| 23 | + * |
|
| 24 | + * @return array|false |
|
| 25 | + */ |
|
| 26 | + public function findPostByPath($path) |
|
| 27 | + { |
|
| 28 | + $query = " |
|
| 29 | 29 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
| 30 | 30 | FROM `jpemeric_blog`.`post` |
| 31 | 31 | WHERE `path` = :path AND `display` = :is_active |
| 32 | 32 | LIMIT 1"; |
| 33 | - $bindings = [ |
|
| 34 | - 'path' => $path, |
|
| 35 | - 'is_active' => 1, |
|
| 36 | - ]; |
|
| 37 | - |
|
| 38 | - return $this |
|
| 39 | - ->connections |
|
| 40 | - ->getRead() |
|
| 41 | - ->fetchOne($query, $bindings); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - public function getActivePosts($limit = null, $offset = 0) |
|
| 45 | - { |
|
| 46 | - $query = " |
|
| 33 | + $bindings = [ |
|
| 34 | + 'path' => $path, |
|
| 35 | + 'is_active' => 1, |
|
| 36 | + ]; |
|
| 37 | + |
|
| 38 | + return $this |
|
| 39 | + ->connections |
|
| 40 | + ->getRead() |
|
| 41 | + ->fetchOne($query, $bindings); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + public function getActivePosts($limit = null, $offset = 0) |
|
| 45 | + { |
|
| 46 | + $query = " |
|
| 47 | 47 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
| 48 | 48 | FROM `jpemeric_blog`.`post` |
| 49 | 49 | WHERE `display` = :is_active |
| 50 | 50 | ORDER BY `date` DESC"; |
| 51 | - if ($limit != null) { |
|
| 52 | - $query .= " |
|
| 51 | + if ($limit != null) { |
|
| 52 | + $query .= " |
|
| 53 | 53 | LIMIT {$offset}, {$limit}"; |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - $bindings = [ |
|
| 57 | - 'is_active' => 1, |
|
| 58 | - ]; |
|
| 56 | + $bindings = [ |
|
| 57 | + 'is_active' => 1, |
|
| 58 | + ]; |
|
| 59 | 59 | |
| 60 | - return $this |
|
| 61 | - ->connections |
|
| 62 | - ->getRead() |
|
| 63 | - ->fetchAll($query, $bindings); |
|
| 64 | - } |
|
| 60 | + return $this |
|
| 61 | + ->connections |
|
| 62 | + ->getRead() |
|
| 63 | + ->fetchAll($query, $bindings); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function getActivePostsCount() |
|
| 67 | - { |
|
| 68 | - $query = " |
|
| 66 | + public function getActivePostsCount() |
|
| 67 | + { |
|
| 68 | + $query = " |
|
| 69 | 69 | SELECT COUNT(1) AS `count` |
| 70 | 70 | FROM `jpemeric_blog`.`post` |
| 71 | 71 | WHERE `display` = :is_active"; |
| 72 | - $bindings = [ |
|
| 73 | - 'is_active' => 1, |
|
| 74 | - ]; |
|
| 75 | - |
|
| 76 | - return $this |
|
| 77 | - ->connections |
|
| 78 | - ->getRead() |
|
| 79 | - ->fetchValue($query, $bindings); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
|
| 83 | - { |
|
| 84 | - $query = " |
|
| 72 | + $bindings = [ |
|
| 73 | + 'is_active' => 1, |
|
| 74 | + ]; |
|
| 75 | + |
|
| 76 | + return $this |
|
| 77 | + ->connections |
|
| 78 | + ->getRead() |
|
| 79 | + ->fetchValue($query, $bindings); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
|
| 83 | + { |
|
| 84 | + $query = " |
|
| 85 | 85 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
| 86 | 86 | FROM `jpemeric_blog`.`post` |
| 87 | 87 | INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`post_id` = `post`.`id` AND |
| 88 | 88 | `ptlink`.`tag_id` = :tag_id |
| 89 | 89 | WHERE `display` = :is_active"; |
| 90 | - if ($limit != null) { |
|
| 91 | - $query .= " |
|
| 90 | + if ($limit != null) { |
|
| 91 | + $query .= " |
|
| 92 | 92 | LIMIT {$offset}, {$limit}"; |
| 93 | - } |
|
| 94 | - |
|
| 95 | - $bindings = [ |
|
| 96 | - 'tag_id' => $tag, |
|
| 97 | - 'is_active' => 1, |
|
| 98 | - ]; |
|
| 99 | - |
|
| 100 | - return $this |
|
| 101 | - ->connections |
|
| 102 | - ->getRead() |
|
| 103 | - ->fetchAll($query, $bindings); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - public function getActivePostsCountByTag($tag) |
|
| 107 | - { |
|
| 108 | - $query = " |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + $bindings = [ |
|
| 96 | + 'tag_id' => $tag, |
|
| 97 | + 'is_active' => 1, |
|
| 98 | + ]; |
|
| 99 | + |
|
| 100 | + return $this |
|
| 101 | + ->connections |
|
| 102 | + ->getRead() |
|
| 103 | + ->fetchAll($query, $bindings); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + public function getActivePostsCountByTag($tag) |
|
| 107 | + { |
|
| 108 | + $query = " |
|
| 109 | 109 | SELECT COUNT(1) AS `count` |
| 110 | 110 | FROM `jpemeric_blog`.`post` |
| 111 | 111 | INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`post_id` = `post`.`id` AND |
| 112 | 112 | `ptlink`.`tag_id` = :tag_id |
| 113 | 113 | WHERE `display` = :is_active"; |
| 114 | - $bindings = [ |
|
| 115 | - 'tag_id' => $tag, |
|
| 116 | - 'is_active' => 1, |
|
| 117 | - ]; |
|
| 118 | - |
|
| 119 | - return $this |
|
| 120 | - ->connections |
|
| 121 | - ->getRead() |
|
| 122 | - ->fetchValue($query, $bindings); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
|
| 126 | - { |
|
| 127 | - $query = " |
|
| 114 | + $bindings = [ |
|
| 115 | + 'tag_id' => $tag, |
|
| 116 | + 'is_active' => 1, |
|
| 117 | + ]; |
|
| 118 | + |
|
| 119 | + return $this |
|
| 120 | + ->connections |
|
| 121 | + ->getRead() |
|
| 122 | + ->fetchValue($query, $bindings); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
|
| 126 | + { |
|
| 127 | + $query = " |
|
| 128 | 128 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
| 129 | 129 | FROM `jpemeric_blog`.`post` |
| 130 | 130 | WHERE `category` = :category AND `display` = :is_active"; |
| 131 | - if ($limit != null) { |
|
| 132 | - $query .= " |
|
| 131 | + if ($limit != null) { |
|
| 132 | + $query .= " |
|
| 133 | 133 | LIMIT {$offset}, {$limit}"; |
| 134 | - } |
|
| 135 | - |
|
| 136 | - $bindings = [ |
|
| 137 | - 'category' => $category, |
|
| 138 | - 'is_active' => 1, |
|
| 139 | - ]; |
|
| 140 | - |
|
| 141 | - return $this |
|
| 142 | - ->connections |
|
| 143 | - ->getRead() |
|
| 144 | - ->fetchAll($query, $bindings); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - public function getActivePostsCountByCategory($category) |
|
| 148 | - { |
|
| 149 | - $query = " |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + $bindings = [ |
|
| 137 | + 'category' => $category, |
|
| 138 | + 'is_active' => 1, |
|
| 139 | + ]; |
|
| 140 | + |
|
| 141 | + return $this |
|
| 142 | + ->connections |
|
| 143 | + ->getRead() |
|
| 144 | + ->fetchAll($query, $bindings); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + public function getActivePostsCountByCategory($category) |
|
| 148 | + { |
|
| 149 | + $query = " |
|
| 150 | 150 | SELECT COUNT(1) AS `count` |
| 151 | 151 | FROM `jpemeric_blog`.`post` |
| 152 | 152 | WHERE `category` = :category AND `display` = :is_active"; |
| 153 | - $bindings = [ |
|
| 154 | - 'category' => $category, |
|
| 155 | - 'is_active' => 1, |
|
| 156 | - ]; |
|
| 157 | - |
|
| 158 | - return $this |
|
| 159 | - ->connections |
|
| 160 | - ->getRead() |
|
| 161 | - ->fetchValue($query, $bindings); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - public function getActivePostsByRelatedTags($post, $limit = 4) |
|
| 165 | - { |
|
| 166 | - $query = " |
|
| 153 | + $bindings = [ |
|
| 154 | + 'category' => $category, |
|
| 155 | + 'is_active' => 1, |
|
| 156 | + ]; |
|
| 157 | + |
|
| 158 | + return $this |
|
| 159 | + ->connections |
|
| 160 | + ->getRead() |
|
| 161 | + ->fetchValue($query, $bindings); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + public function getActivePostsByRelatedTags($post, $limit = 4) |
|
| 165 | + { |
|
| 166 | + $query = " |
|
| 167 | 167 | SELECT `id`, `title`, `path`, `date`, `body`, `category`, COUNT(1) AS `count` |
| 168 | 168 | FROM `jpemeric_blog`.`post` |
| 169 | 169 | INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`post_id` = `post`.`id` AND |
@@ -183,14 +183,14 @@ discard block |
||
| 183 | 183 | GROUP BY `id` |
| 184 | 184 | ORDER BY `count` DESC |
| 185 | 185 | LIMIT {$limit}"; |
| 186 | - $bindings = [ |
|
| 187 | - 'post' => $post, |
|
| 188 | - 'is_active' => 1, |
|
| 189 | - ]; |
|
| 190 | - |
|
| 191 | - return $this |
|
| 192 | - ->connections |
|
| 193 | - ->getRead() |
|
| 194 | - ->fetchAll($query, $bindings); |
|
| 195 | - } |
|
| 186 | + $bindings = [ |
|
| 187 | + 'post' => $post, |
|
| 188 | + 'is_active' => 1, |
|
| 189 | + ]; |
|
| 190 | + |
|
| 191 | + return $this |
|
| 192 | + ->connections |
|
| 193 | + ->getRead() |
|
| 194 | + ->fetchAll($query, $bindings); |
|
| 195 | + } |
|
| 196 | 196 | } |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches)) |
| 49 | 49 | { |
| 50 | - global $container; |
|
| 51 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 52 | - $post = $repository->findPostByPath($matches[2]); |
|
| 50 | + global $container; |
|
| 51 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 52 | + $post = $repository->findPostByPath($matches[2]); |
|
| 53 | 53 | |
| 54 | 54 | if(!$post) |
| 55 | 55 | { |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | $post_uri = URLDecode::getPiece(1); |
| 66 | 66 | if($post_uri !== null) |
| 67 | 67 | { |
| 68 | - global $container; |
|
| 69 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 70 | - $post = $repository->findPostByPath($post_uri); |
|
| 68 | + global $container; |
|
| 69 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 70 | + $post = $repository->findPostByPath($post_uri); |
|
| 71 | 71 | |
| 72 | 72 | if($post != false) |
| 73 | 73 | { |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | switch($type) |
| 33 | 33 | { |
| 34 | 34 | case 'blog' : |
| 35 | - global $container; |
|
| 36 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 37 | - $post = $repository->findPostByPath($post_uri); |
|
| 35 | + global $container; |
|
| 36 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 37 | + $post = $repository->findPostByPath($post_uri); |
|
| 38 | 38 | |
| 39 | 39 | if($post === NULL) |
| 40 | 40 | return; |
@@ -73,38 +73,38 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | break; |
| 75 | 75 | case 'falls' : |
| 76 | - $pieces = explode('/', $uri); |
|
| 77 | - if (count($pieces) == 1) { |
|
| 78 | - Loader::load('collector', 'waterfall/WatercourseCollector'); |
|
| 79 | - list ($watercourse_alias) = $pieces; |
|
| 80 | - $watercourse = WatercourseCollector::getByAlias($watercourse_alias); |
|
| 76 | + $pieces = explode('/', $uri); |
|
| 77 | + if (count($pieces) == 1) { |
|
| 78 | + Loader::load('collector', 'waterfall/WatercourseCollector'); |
|
| 79 | + list ($watercourse_alias) = $pieces; |
|
| 80 | + $watercourse = WatercourseCollector::getByAlias($watercourse_alias); |
|
| 81 | 81 | |
| 82 | - if ($watercourse == null) { |
|
| 83 | - return; |
|
| 84 | - } |
|
| 82 | + if ($watercourse == null) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
|
| 87 | - $link .= "{$watercourse->alias}/"; |
|
| 86 | + $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
|
| 87 | + $link .= "{$watercourse->alias}/"; |
|
| 88 | 88 | |
| 89 | - if ($anchor == '') { |
|
| 90 | - $anchor = $watercourse->name; |
|
| 91 | - } |
|
| 92 | - } else if (count($pieces) == 2) { |
|
| 93 | - Loader::load('collector', 'waterfall/WaterfallCollector'); |
|
| 94 | - list ($watercourse_alias, $waterfall_alias) = $pieces; |
|
| 95 | - $waterfall = WaterfallCollector::getByAlias($watercourse_alias, $waterfall_alias); |
|
| 89 | + if ($anchor == '') { |
|
| 90 | + $anchor = $watercourse->name; |
|
| 91 | + } |
|
| 92 | + } else if (count($pieces) == 2) { |
|
| 93 | + Loader::load('collector', 'waterfall/WaterfallCollector'); |
|
| 94 | + list ($watercourse_alias, $waterfall_alias) = $pieces; |
|
| 95 | + $waterfall = WaterfallCollector::getByAlias($watercourse_alias, $waterfall_alias); |
|
| 96 | 96 | |
| 97 | - if ($waterfall == null) { |
|
| 98 | - return; |
|
| 99 | - } |
|
| 97 | + if ($waterfall == null) { |
|
| 98 | + return; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
|
| 102 | - $link .= "{$waterfall->watercourse_alias}/{$waterfall->alias}/"; |
|
| 101 | + $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
|
| 102 | + $link .= "{$waterfall->watercourse_alias}/{$waterfall->alias}/"; |
|
| 103 | 103 | |
| 104 | - if ($anchor == '') { |
|
| 105 | - $anchor = $waterfall->name; |
|
| 106 | - } |
|
| 107 | - } |
|
| 104 | + if ($anchor == '') { |
|
| 105 | + $anchor = $waterfall->name; |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | 108 | break; |
| 109 | 109 | default : |
| 110 | 110 | break; |
@@ -14,10 +14,11 @@ discard block |
||
| 14 | 14 | preg_match_all(self::$LINK_PLACEHOLDER_MATCH, $this->content, $matches); |
| 15 | 15 | foreach($matches[1] as $key => $match) |
| 16 | 16 | { |
| 17 | - if(isset($matches[3][$key])) |
|
| 18 | - $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
|
| 19 | - else |
|
| 20 | - $link_content = $this->get_link($match, $is_absolute); |
|
| 17 | + if(isset($matches[3][$key])) {
|
|
| 18 | + $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
|
| 19 | + } else {
|
|
| 20 | + $link_content = $this->get_link($match, $is_absolute); |
|
| 21 | + } |
|
| 21 | 22 | $this->content = str_replace($matches[0][$key], $link_content, $this->content); |
| 22 | 23 | } |
| 23 | 24 | return; |
@@ -36,14 +37,16 @@ discard block |
||
| 36 | 37 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 37 | 38 | $post = $repository->findPostByPath($post_uri); |
| 38 | 39 | |
| 39 | - if($post === NULL) |
|
| 40 | - return; |
|
| 40 | + if($post === NULL) {
|
|
| 41 | + return; |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
| 43 | 45 | $link .= "{$post['category']}/{$post['path']}/"; |
| 44 | 46 | |
| 45 | - if($anchor == '') |
|
| 46 | - $anchor = $post['title']; |
|
| 47 | + if($anchor == '') {
|
|
| 48 | + $anchor = $post['title']; |
|
| 49 | + } |
|
| 47 | 50 | |
| 48 | 51 | break; |
| 49 | 52 | case 'blog-tag' : |
@@ -62,14 +65,16 @@ discard block |
||
| 62 | 65 | Loader::load('collector', 'waterfall/LogCollector'); |
| 63 | 66 | $log = LogCollector::getByAlias($uri); |
| 64 | 67 | |
| 65 | - if($log === NULL) |
|
| 66 | - return; |
|
| 68 | + if($log === NULL) {
|
|
| 69 | + return; |
|
| 70 | + } |
|
| 67 | 71 | |
| 68 | 72 | $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
| 69 | 73 | $link .= "journal/{$log->alias}/"; |
| 70 | 74 | |
| 71 | - if($anchor == '') |
|
| 72 | - $anchor = $log->title; |
|
| 75 | + if($anchor == '') {
|
|
| 76 | + $anchor = $log->title; |
|
| 77 | + } |
|
| 73 | 78 | |
| 74 | 79 | break; |
| 75 | 80 | case 'falls' : |
@@ -39,20 +39,20 @@ discard block |
||
| 39 | 39 | public function perform() |
| 40 | 40 | { |
| 41 | 41 | $weighted_array = array(); |
| 42 | - foreach($this->result as $row) |
|
| 42 | + foreach ($this->result as $row) |
|
| 43 | 43 | { |
| 44 | 44 | $weight = $this->get_search_weight($row); |
| 45 | - if($weight > 0) |
|
| 45 | + if ($weight > 0) |
|
| 46 | 46 | $weighted_array[$row['id']] = $weight; |
| 47 | 47 | } |
| 48 | 48 | arsort($weighted_array); |
| 49 | 49 | |
| 50 | 50 | $final_array = array(); |
| 51 | - foreach($weighted_array as $id => $weight) |
|
| 51 | + foreach ($weighted_array as $id => $weight) |
|
| 52 | 52 | { |
| 53 | - foreach($this->result as $row) |
|
| 53 | + foreach ($this->result as $row) |
|
| 54 | 54 | { |
| 55 | - if($row['id'] == $id) |
|
| 55 | + if ($row['id'] == $id) |
|
| 56 | 56 | $final_array[] = $row; |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | private function get_search_weight($row) |
| 63 | 63 | { |
| 64 | 64 | $weight = 0; |
| 65 | - foreach($this->weight as $weight_array) |
|
| 65 | + foreach ($this->weight as $weight_array) |
|
| 66 | 66 | { |
| 67 | 67 | $text = $row[$weight_array['field']]; |
| 68 | 68 | $weight += $weight_array['weight'] * substr_count(strtolower($text), strtolower($this->query)); |
@@ -42,8 +42,9 @@ discard block |
||
| 42 | 42 | foreach($this->result as $row) |
| 43 | 43 | { |
| 44 | 44 | $weight = $this->get_search_weight($row); |
| 45 | - if($weight > 0) |
|
| 46 | - $weighted_array[$row['id']] = $weight; |
|
| 45 | + if($weight > 0) {
|
|
| 46 | + $weighted_array[$row['id']] = $weight; |
|
| 47 | + } |
|
| 47 | 48 | } |
| 48 | 49 | arsort($weighted_array); |
| 49 | 50 | |
@@ -52,8 +53,9 @@ discard block |
||
| 52 | 53 | { |
| 53 | 54 | foreach($this->result as $row) |
| 54 | 55 | { |
| 55 | - if($row['id'] == $id) |
|
| 56 | - $final_array[] = $row; |
|
| 56 | + if($row['id'] == $id) {
|
|
| 57 | + $final_array[] = $row; |
|
| 58 | + } |
|
| 57 | 59 | } |
| 58 | 60 | } |
| 59 | 61 | return $final_array; |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | parent::__construct(); |
| 25 | 25 | |
| 26 | - global $container; |
|
| 27 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 28 | - $this->post = $repository->findPostByPath(URLDecode::getPiece(2)); |
|
| 26 | + global $container; |
|
| 27 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 28 | + $this->post = $repository->findPostByPath(URLDecode::getPiece(2)); |
|
| 29 | 29 | |
| 30 | 30 | if($this->post == null) |
| 31 | 31 | $this->eject(); |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/', |
| 37 | 37 | $this->post['title']); |
| 38 | 38 | |
| 39 | - global $container; |
|
| 40 | - $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
| 41 | - $this->tags = $repository->getTagsForPost($this->post['id']); |
|
| 39 | + global $container; |
|
| 40 | + $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
| 41 | + $this->tags = $repository->getTagsForPost($this->post['id']); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | protected function set_head_data() |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | $this->set_keywords($this->get_post_keywords()); |
| 51 | 51 | $this->set_author(self::$AUTHOR); |
| 52 | 52 | |
| 53 | - $photo = Content::instance('FetchFirstPhoto', $this->post['body'])->activate(true); |
|
| 54 | - $photo = preg_match('/^<img src="([a-z-:\.\/]+)" [^>]+>$/', $photo, $matches); |
|
| 55 | - $this->set_head('thumbnail', $matches[1]); |
|
| 53 | + $photo = Content::instance('FetchFirstPhoto', $this->post['body'])->activate(true); |
|
| 54 | + $photo = preg_match('/^<img src="([a-z-:\.\/]+)" [^>]+>$/', $photo, $matches); |
|
| 55 | + $this->set_head('thumbnail', $matches[1]); |
|
| 56 | 56 | |
| 57 | 57 | if (array_key_exists($this->post['id'], self::$DEPRECATED_BLOGS)) { |
| 58 | 58 | $log_id = self::$DEPRECATED_BLOGS[$this->post['id']]; |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $post = new stdclass(); |
| 128 | 128 | |
| 129 | - if (strpos($post_row['title'], 'Rainy Supe Loop') === 0) { |
|
| 130 | - $title = $post_row['title']; |
|
| 131 | - $title = explode(':', $title); |
|
| 132 | - $title = array_pop($title); |
|
| 133 | - $title = trim($title); |
|
| 134 | - $post->title = $title; |
|
| 135 | - } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
| 129 | + if (strpos($post_row['title'], 'Rainy Supe Loop') === 0) { |
|
| 130 | + $title = $post_row['title']; |
|
| 131 | + $title = explode(':', $title); |
|
| 132 | + $title = array_pop($title); |
|
| 133 | + $title = trim($title); |
|
| 134 | + $post->title = $title; |
|
| 135 | + } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
| 136 | 136 | $title = $post_row['title']; |
| 137 | 137 | $title = explode(',', $title); |
| 138 | 138 | $title = array_pop($title); |
@@ -163,12 +163,12 @@ discard block |
||
| 163 | 163 | private $series_posts; |
| 164 | 164 | private function fetch_series_posts() |
| 165 | 165 | { |
| 166 | - if(!isset($this->series_posts)) { |
|
| 167 | - global $container; |
|
| 168 | - $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
| 169 | - $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
| 170 | - } |
|
| 171 | - return $this->series_posts; |
|
| 166 | + if(!isset($this->series_posts)) { |
|
| 167 | + global $container; |
|
| 168 | + $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
| 169 | + $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
| 170 | + } |
|
| 171 | + return $this->series_posts; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | private function get_related_posts() |
@@ -186,11 +186,11 @@ discard block |
||
| 186 | 186 | $exclude_post_array[] = $series_post['post']; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - global $container; |
|
| 190 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 191 | - $post_result = $repository->getActivePostsByRelatedTags($this->post['id']); |
|
| 189 | + global $container; |
|
| 190 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 191 | + $post_result = $repository->getActivePostsByRelatedTags($this->post['id']); |
|
| 192 | 192 | |
| 193 | - $post_array = array(); |
|
| 193 | + $post_array = array(); |
|
| 194 | 194 | |
| 195 | 195 | foreach($post_result as $post_row) |
| 196 | 196 | { |
@@ -27,7 +27,7 @@ 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( |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $keyword_array = array(); |
| 96 | 96 | $keywords = $this->tags; |
| 97 | 97 | |
| 98 | - foreach($keywords as $keyword) |
|
| 98 | + foreach ($keywords as $keyword) |
|
| 99 | 99 | { |
| 100 | 100 | $keyword_array[] = $keyword['tag']; |
| 101 | 101 | } |
@@ -109,16 +109,16 @@ discard block |
||
| 109 | 109 | private function get_series_posts() |
| 110 | 110 | { |
| 111 | 111 | $series_posts = $this->fetch_series_posts(); |
| 112 | - if(count($series_posts) < 1) |
|
| 112 | + if (count($series_posts) < 1) |
|
| 113 | 113 | return array(); |
| 114 | 114 | |
| 115 | 115 | $previous_post = new stdclass(); |
| 116 | 116 | $next_post = new stdclass(); |
| 117 | 117 | |
| 118 | 118 | $found_current_post = false; |
| 119 | - foreach($series_posts as $post_row) |
|
| 119 | + foreach ($series_posts as $post_row) |
|
| 120 | 120 | { |
| 121 | - if($post_row['post'] == $this->post['id']) |
|
| 121 | + if ($post_row['post'] == $this->post['id']) |
|
| 122 | 122 | { |
| 123 | 123 | $found_current_post = true; |
| 124 | 124 | continue; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
| 146 | 146 | |
| 147 | - if(!$found_current_post) |
|
| 147 | + if (!$found_current_post) |
|
| 148 | 148 | $previous_post = $post; |
| 149 | 149 | else |
| 150 | 150 | { |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | private $series_posts; |
| 164 | 164 | private function fetch_series_posts() |
| 165 | 165 | { |
| 166 | - if(!isset($this->series_posts)) { |
|
| 166 | + if (!isset($this->series_posts)) { |
|
| 167 | 167 | global $container; |
| 168 | 168 | $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
| 169 | 169 | $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | private function get_related_posts() |
| 175 | 175 | { |
| 176 | 176 | $tag_array = array(); |
| 177 | - foreach($this->tags as $tag) |
|
| 177 | + foreach ($this->tags as $tag) |
|
| 178 | 178 | { |
| 179 | 179 | $tag_array[] = $tag['id']; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $series_posts = $this->fetch_series_posts(); |
| 183 | 183 | $exclude_post_array = array(); |
| 184 | - foreach($series_posts as $series_post) |
|
| 184 | + foreach ($series_posts as $series_post) |
|
| 185 | 185 | { |
| 186 | 186 | $exclude_post_array[] = $series_post['post']; |
| 187 | 187 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $post_array = array(); |
| 194 | 194 | |
| 195 | - foreach($post_result as $post_row) |
|
| 195 | + foreach ($post_result as $post_row) |
|
| 196 | 196 | { |
| 197 | 197 | $post = new stdclass(); |
| 198 | 198 | $post->title = $post_row['title']; |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | if($this->page == 1) |
| 51 | 51 | { |
| 52 | - global $container; |
|
| 53 | - $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
| 54 | - $introduction_result = $repository->findByType('home'); |
|
| 52 | + global $container; |
|
| 53 | + $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
| 54 | + $introduction_result = $repository->findByType('home'); |
|
| 55 | 55 | |
| 56 | 56 | $introduction = array(); |
| 57 | 57 | $introduction['title'] = $introduction_result['title']; |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | protected function get_list_results() |
| 77 | 77 | { |
| 78 | - global $container; |
|
| 79 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 80 | - return $repository->getActivePosts(self::$POSTS_PER_PAGE, $this->offset); |
|
| 78 | + global $container; |
|
| 79 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 80 | + return $repository->getActivePosts(self::$POSTS_PER_PAGE, $this->offset); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | protected function get_list_description() |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | private $total_post_count; |
| 108 | 108 | protected function get_total_post_count() |
| 109 | 109 | { |
| 110 | - if(!isset($this->total_post_count)) { |
|
| 111 | - global $container; |
|
| 112 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 113 | - $this->total_post_count = $repository->getActivePostsCount(); |
|
| 114 | - } |
|
| 110 | + if(!isset($this->total_post_count)) { |
|
| 111 | + global $container; |
|
| 112 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 113 | + $this->total_post_count = $repository->getActivePostsCount(); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | return $this->total_post_count; |
| 117 | 117 | } |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | parent::set_head_data(); |
| 34 | 34 | |
| 35 | - if($this->page == 1) |
|
| 35 | + if ($this->page == 1) |
|
| 36 | 36 | $this->set_title(self::$TITLE_MAIN); |
| 37 | 37 | else |
| 38 | 38 | $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
| 39 | 39 | |
| 40 | - if($this->page == 1) |
|
| 40 | + if ($this->page == 1) |
|
| 41 | 41 | $this->set_description(self::$DESCRIPTION_MAIN); |
| 42 | 42 | else |
| 43 | 43 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | protected function get_introduction() |
| 49 | 49 | { |
| 50 | - if($this->page == 1) |
|
| 50 | + if ($this->page == 1) |
|
| 51 | 51 | { |
| 52 | 52 | global $container; |
| 53 | 53 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | protected function get_page_number() |
| 69 | 69 | { |
| 70 | 70 | $page = URLDecode::getPiece(1); |
| 71 | - if(isset($page) && is_numeric($page)) |
|
| 71 | + if (isset($page) && is_numeric($page)) |
|
| 72 | 72 | return $page; |
| 73 | 73 | return 1; |
| 74 | 74 | } |
@@ -90,16 +90,16 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | protected function get_list_next_link() |
| 92 | 92 | { |
| 93 | - if($this->page == 1) |
|
| 93 | + if ($this->page == 1) |
|
| 94 | 94 | return; |
| 95 | - if($this->page == 2) |
|
| 95 | + if ($this->page == 2) |
|
| 96 | 96 | return '/'; |
| 97 | 97 | return '/' . ($this->page - 1) . '/'; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | protected function get_list_prev_link() |
| 101 | 101 | { |
| 102 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 102 | + if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 103 | 103 | return; |
| 104 | 104 | return '/' . ($this->page + 1) . '/'; |
| 105 | 105 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | private $total_post_count; |
| 108 | 108 | protected function get_total_post_count() |
| 109 | 109 | { |
| 110 | - if(!isset($this->total_post_count)) { |
|
| 110 | + if (!isset($this->total_post_count)) { |
|
| 111 | 111 | global $container; |
| 112 | 112 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 113 | 113 | $this->total_post_count = $repository->getActivePostsCount(); |
@@ -32,15 +32,17 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | parent::set_head_data(); |
| 34 | 34 | |
| 35 | - if($this->page == 1) |
|
| 36 | - $this->set_title(self::$TITLE_MAIN); |
|
| 37 | - else |
|
| 38 | - $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
| 35 | + if($this->page == 1) {
|
|
| 36 | + $this->set_title(self::$TITLE_MAIN); |
|
| 37 | + } else {
|
|
| 38 | + $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
| 39 | + } |
|
| 39 | 40 | |
| 40 | - if($this->page == 1) |
|
| 41 | - $this->set_description(self::$DESCRIPTION_MAIN); |
|
| 42 | - else |
|
| 43 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
| 41 | + if($this->page == 1) {
|
|
| 42 | + $this->set_description(self::$DESCRIPTION_MAIN); |
|
| 43 | + } else {
|
|
| 44 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | $this->set_keywords(self::$KEYWORD_ARRAY); |
| 46 | 48 | } |
@@ -68,8 +70,9 @@ discard block |
||
| 68 | 70 | protected function get_page_number() |
| 69 | 71 | { |
| 70 | 72 | $page = URLDecode::getPiece(1); |
| 71 | - if(isset($page) && is_numeric($page)) |
|
| 72 | - return $page; |
|
| 73 | + if(isset($page) && is_numeric($page)) {
|
|
| 74 | + return $page; |
|
| 75 | + } |
|
| 73 | 76 | return 1; |
| 74 | 77 | } |
| 75 | 78 | |
@@ -90,17 +93,20 @@ discard block |
||
| 90 | 93 | |
| 91 | 94 | protected function get_list_next_link() |
| 92 | 95 | { |
| 93 | - if($this->page == 1) |
|
| 94 | - return; |
|
| 95 | - if($this->page == 2) |
|
| 96 | - return '/'; |
|
| 96 | + if($this->page == 1) {
|
|
| 97 | + return; |
|
| 98 | + } |
|
| 99 | + if($this->page == 2) {
|
|
| 100 | + return '/'; |
|
| 101 | + } |
|
| 97 | 102 | return '/' . ($this->page - 1) . '/'; |
| 98 | 103 | } |
| 99 | 104 | |
| 100 | 105 | protected function get_list_prev_link() |
| 101 | 106 | { |
| 102 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 103 | - return; |
|
| 107 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) {
|
|
| 108 | + return; |
|
| 109 | + } |
|
| 104 | 110 | return '/' . ($this->page + 1) . '/'; |
| 105 | 111 | } |
| 106 | 112 | |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | $tag = URLDecode::getPiece(2); |
| 27 | 27 | $tag = str_replace('-', ' ', $tag); |
| 28 | 28 | |
| 29 | - global $container; |
|
| 30 | - $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
| 31 | - $tag_result = $repository->findTagByTitle($tag); |
|
| 29 | + global $container; |
|
| 30 | + $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
| 31 | + $tag_result = $repository->findTagByTitle($tag); |
|
| 32 | 32 | |
| 33 | 33 | if($tag_result === false) |
| 34 | 34 | $this->eject(); |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if($this->page == 1) |
| 66 | 66 | { |
| 67 | - global $container; |
|
| 68 | - $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
| 69 | - $introduction_result = $repository->findByType('tag', $this->tag['tag']); |
|
| 67 | + global $container; |
|
| 68 | + $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
| 69 | + $introduction_result = $repository->findByType('tag', $this->tag['tag']); |
|
| 70 | 70 | |
| 71 | 71 | if($introduction_result !== false) |
| 72 | 72 | { |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | protected function get_list_results() |
| 98 | 98 | { |
| 99 | - global $container; |
|
| 100 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 101 | - return $repository->getActivePostsByTag($this->tag['id'], self::$POSTS_PER_PAGE, $this->offset); |
|
| 99 | + global $container; |
|
| 100 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 101 | + return $repository->getActivePostsByTag($this->tag['id'], self::$POSTS_PER_PAGE, $this->offset); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | protected function get_list_description() |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | protected function get_total_post_count() |
| 130 | 130 | { |
| 131 | 131 | if(!isset($this->total_post_count)) { |
| 132 | - global $container; |
|
| 133 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 134 | - $this->total_post_count = $repository->getActivePostsCountByTag($this->tag['id']); |
|
| 135 | - } |
|
| 132 | + global $container; |
|
| 133 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 134 | + $this->total_post_count = $repository->getActivePostsCountByTag($this->tag['id']); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | 137 | return $this->total_post_count; |
| 138 | 138 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
| 31 | 31 | $tag_result = $repository->findTagByTitle($tag); |
| 32 | 32 | |
| 33 | - if($tag_result === false) |
|
| 33 | + if ($tag_result === false) |
|
| 34 | 34 | $this->eject(); |
| 35 | 35 | |
| 36 | 36 | $this->tag = $tag_result; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | parent::set_head_data(); |
| 44 | 44 | |
| 45 | - if($this->page == 1) |
|
| 45 | + if ($this->page == 1) |
|
| 46 | 46 | { |
| 47 | 47 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->tag['tag']))); |
| 48 | 48 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->tag['tag']))); |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $tag = ucwords($this->tag['tag']); |
| 64 | 64 | |
| 65 | - if($this->page == 1) |
|
| 65 | + if ($this->page == 1) |
|
| 66 | 66 | { |
| 67 | 67 | global $container; |
| 68 | 68 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
| 69 | 69 | $introduction_result = $repository->findByType('tag', $this->tag['tag']); |
| 70 | 70 | |
| 71 | - if($introduction_result !== false) |
|
| 71 | + if ($introduction_result !== false) |
|
| 72 | 72 | { |
| 73 | 73 | $introduction = array(); |
| 74 | 74 | $introduction['title'] = $introduction_result['title']; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | protected function get_page_number() |
| 90 | 90 | { |
| 91 | 91 | $page = URLDecode::getPiece(3); |
| 92 | - if(isset($page) && is_numeric($page)) |
|
| 92 | + if (isset($page) && is_numeric($page)) |
|
| 93 | 93 | return $page; |
| 94 | 94 | return 1; |
| 95 | 95 | } |
@@ -111,16 +111,16 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | protected function get_list_next_link() |
| 113 | 113 | { |
| 114 | - if($this->page == 1) |
|
| 114 | + if ($this->page == 1) |
|
| 115 | 115 | return; |
| 116 | - if($this->page == 2) |
|
| 116 | + if ($this->page == 2) |
|
| 117 | 117 | return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate(); |
| 118 | 118 | return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page - 1) . '/')->activate(); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | protected function get_list_prev_link() |
| 122 | 122 | { |
| 123 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 123 | + if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 124 | 124 | return; |
| 125 | 125 | return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page + 1) . '/')->activate(); |
| 126 | 126 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | private $total_post_count; |
| 129 | 129 | protected function get_total_post_count() |
| 130 | 130 | { |
| 131 | - if(!isset($this->total_post_count)) { |
|
| 131 | + if (!isset($this->total_post_count)) { |
|
| 132 | 132 | global $container; |
| 133 | 133 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 134 | 134 | $this->total_post_count = $repository->getActivePostsCountByTag($this->tag['id']); |
@@ -30,8 +30,9 @@ discard block |
||
| 30 | 30 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
| 31 | 31 | $tag_result = $repository->findTagByTitle($tag); |
| 32 | 32 | |
| 33 | - if($tag_result === false) |
|
| 34 | - $this->eject(); |
|
| 33 | + if($tag_result === false) {
|
|
| 34 | + $this->eject(); |
|
| 35 | + } |
|
| 35 | 36 | |
| 36 | 37 | $this->tag = $tag_result; |
| 37 | 38 | |
@@ -46,8 +47,7 @@ discard block |
||
| 46 | 47 | { |
| 47 | 48 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->tag['tag']))); |
| 48 | 49 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->tag['tag']))); |
| 49 | - } |
|
| 50 | - else |
|
| 50 | + } else |
|
| 51 | 51 | { |
| 52 | 52 | $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->tag['tag']), $this->page, $this->total_pages)); |
| 53 | 53 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->tag['tag']))); |
@@ -89,8 +89,9 @@ discard block |
||
| 89 | 89 | protected function get_page_number() |
| 90 | 90 | { |
| 91 | 91 | $page = URLDecode::getPiece(3); |
| 92 | - if(isset($page) && is_numeric($page)) |
|
| 93 | - return $page; |
|
| 92 | + if(isset($page) && is_numeric($page)) {
|
|
| 93 | + return $page; |
|
| 94 | + } |
|
| 94 | 95 | return 1; |
| 95 | 96 | } |
| 96 | 97 | |
@@ -111,17 +112,20 @@ discard block |
||
| 111 | 112 | |
| 112 | 113 | protected function get_list_next_link() |
| 113 | 114 | { |
| 114 | - if($this->page == 1) |
|
| 115 | - return; |
|
| 116 | - if($this->page == 2) |
|
| 117 | - return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate(); |
|
| 115 | + if($this->page == 1) {
|
|
| 116 | + return; |
|
| 117 | + } |
|
| 118 | + if($this->page == 2) {
|
|
| 119 | + return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate();
|
|
| 120 | + } |
|
| 118 | 121 | return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page - 1) . '/')->activate(); |
| 119 | 122 | } |
| 120 | 123 | |
| 121 | 124 | protected function get_list_prev_link() |
| 122 | 125 | { |
| 123 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 124 | - return; |
|
| 126 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) {
|
|
| 127 | + return; |
|
| 128 | + } |
|
| 125 | 129 | return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page + 1) . '/')->activate(); |
| 126 | 130 | } |
| 127 | 131 | |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | if($this->page == 1) |
| 117 | 117 | { |
| 118 | - global $container; |
|
| 119 | - $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
| 120 | - $introduction_result = $repository->findByType('category', $this->category->link); |
|
| 118 | + global $container; |
|
| 119 | + $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
| 120 | + $introduction_result = $repository->findByType('category', $this->category->link); |
|
| 121 | 121 | |
| 122 | 122 | $introduction = array(); |
| 123 | 123 | $introduction['title'] = $introduction_result['title']; |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | protected function get_list_results() |
| 143 | 143 | { |
| 144 | - global $container; |
|
| 145 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 146 | - return $repository->getActivePostsByCategory($this->category->link, self::$POSTS_PER_PAGE, $this->offset); |
|
| 144 | + global $container; |
|
| 145 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 146 | + return $repository->getActivePostsByCategory($this->category->link, self::$POSTS_PER_PAGE, $this->offset); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | protected function get_list_description() |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | protected function get_total_post_count() |
| 175 | 175 | { |
| 176 | 176 | if(!isset($this->total_post_count)) { |
| 177 | - global $container; |
|
| 178 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 179 | - $this->total_post_count = $repository->getActivePostsCountByCategory($this->category->link); |
|
| 180 | - } |
|
| 177 | + global $container; |
|
| 178 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 179 | + $this->total_post_count = $repository->getActivePostsCountByCategory($this->category->link); |
|
| 180 | + } |
|
| 181 | 181 | return $this->total_post_count; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | parent::set_head_data(); |
| 69 | 69 | |
| 70 | - switch($this->category->display) |
|
| 70 | + switch ($this->category->display) |
|
| 71 | 71 | { |
| 72 | 72 | case 'Hiking' : |
| 73 | - if($this->page == 1) |
|
| 73 | + if ($this->page == 1) |
|
| 74 | 74 | { |
| 75 | 75 | $this->set_title(self::$TITLE_MAIN_HIKING); |
| 76 | 76 | $this->set_description(self::$DESCRIPTION_MAIN_HIKING); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $this->set_keywords(self::$KEYWORD_ARRAY_HIKING); |
| 84 | 84 | break; |
| 85 | 85 | case 'Personal' : |
| 86 | - if($this->page == 1) |
|
| 86 | + if ($this->page == 1) |
|
| 87 | 87 | { |
| 88 | 88 | $this->set_title(self::$TITLE_MAIN_PERSONAL); |
| 89 | 89 | $this->set_description(self::$DESCRIPTION_MAIN_PERSONAL); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $this->set_keywords(self::$KEYWORD_ARRAY_PERSONAL); |
| 97 | 97 | break; |
| 98 | 98 | case 'Web Development' : |
| 99 | - if($this->page == 1) |
|
| 99 | + if ($this->page == 1) |
|
| 100 | 100 | { |
| 101 | 101 | $this->set_title(self::$TITLE_MAIN_WEBDEVELOPMENT); |
| 102 | 102 | $this->set_description(self::$DESCRIPTION_MAIN_WEBDEVELOPMENT); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | protected function get_introduction() |
| 115 | 115 | { |
| 116 | - if($this->page == 1) |
|
| 116 | + if ($this->page == 1) |
|
| 117 | 117 | { |
| 118 | 118 | global $container; |
| 119 | 119 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | protected function get_page_number() |
| 135 | 135 | { |
| 136 | 136 | $page = URLDecode::getPiece(2); |
| 137 | - if(isset($page) && is_numeric($page)) |
|
| 137 | + if (isset($page) && is_numeric($page)) |
|
| 138 | 138 | return $page; |
| 139 | 139 | return 1; |
| 140 | 140 | } |
@@ -156,16 +156,16 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | protected function get_list_next_link() |
| 158 | 158 | { |
| 159 | - if($this->page == 1) |
|
| 159 | + if ($this->page == 1) |
|
| 160 | 160 | return; |
| 161 | - if($this->page == 2) |
|
| 161 | + if ($this->page == 2) |
|
| 162 | 162 | return Content::instance('URLSafe', "/{$this->category->link}/")->activate(); |
| 163 | 163 | return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page - 1) . '/')->activate(); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | protected function get_list_prev_link() |
| 167 | 167 | { |
| 168 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 168 | + if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 169 | 169 | return; |
| 170 | 170 | return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page + 1) . '/')->activate(); |
| 171 | 171 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | private $total_post_count; |
| 174 | 174 | protected function get_total_post_count() |
| 175 | 175 | { |
| 176 | - if(!isset($this->total_post_count)) { |
|
| 176 | + if (!isset($this->total_post_count)) { |
|
| 177 | 177 | global $container; |
| 178 | 178 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
| 179 | 179 | $this->total_post_count = $repository->getActivePostsCountByCategory($this->category->link); |
@@ -74,8 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $this->set_title(self::$TITLE_MAIN_HIKING); |
| 76 | 76 | $this->set_description(self::$DESCRIPTION_MAIN_HIKING); |
| 77 | - } |
|
| 78 | - else |
|
| 77 | + } else |
|
| 79 | 78 | { |
| 80 | 79 | $this->set_title(sprintf(self::$TITLE_PAGINATED_HIKING, $this->page, $this->total_pages)); |
| 81 | 80 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_HIKING, $this->page, $this->total_pages)); |
@@ -87,8 +86,7 @@ discard block |
||
| 87 | 86 | { |
| 88 | 87 | $this->set_title(self::$TITLE_MAIN_PERSONAL); |
| 89 | 88 | $this->set_description(self::$DESCRIPTION_MAIN_PERSONAL); |
| 90 | - } |
|
| 91 | - else |
|
| 89 | + } else |
|
| 92 | 90 | { |
| 93 | 91 | $this->set_title(sprintf(self::$TITLE_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
| 94 | 92 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
@@ -100,8 +98,7 @@ discard block |
||
| 100 | 98 | { |
| 101 | 99 | $this->set_title(self::$TITLE_MAIN_WEBDEVELOPMENT); |
| 102 | 100 | $this->set_description(self::$DESCRIPTION_MAIN_WEBDEVELOPMENT); |
| 103 | - } |
|
| 104 | - else |
|
| 101 | + } else |
|
| 105 | 102 | { |
| 106 | 103 | $this->set_title(sprintf(self::$TITLE_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
| 107 | 104 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
@@ -134,8 +131,9 @@ discard block |
||
| 134 | 131 | protected function get_page_number() |
| 135 | 132 | { |
| 136 | 133 | $page = URLDecode::getPiece(2); |
| 137 | - if(isset($page) && is_numeric($page)) |
|
| 138 | - return $page; |
|
| 134 | + if(isset($page) && is_numeric($page)) {
|
|
| 135 | + return $page; |
|
| 136 | + } |
|
| 139 | 137 | return 1; |
| 140 | 138 | } |
| 141 | 139 | |
@@ -156,17 +154,20 @@ discard block |
||
| 156 | 154 | |
| 157 | 155 | protected function get_list_next_link() |
| 158 | 156 | { |
| 159 | - if($this->page == 1) |
|
| 160 | - return; |
|
| 161 | - if($this->page == 2) |
|
| 162 | - return Content::instance('URLSafe', "/{$this->category->link}/")->activate(); |
|
| 157 | + if($this->page == 1) {
|
|
| 158 | + return; |
|
| 159 | + } |
|
| 160 | + if($this->page == 2) {
|
|
| 161 | + return Content::instance('URLSafe', "/{$this->category->link}/")->activate();
|
|
| 162 | + } |
|
| 163 | 163 | return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page - 1) . '/')->activate(); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | protected function get_list_prev_link() |
| 167 | 167 | { |
| 168 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 169 | - return; |
|
| 168 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) {
|
|
| 169 | + return; |
|
| 170 | + } |
|
| 170 | 171 | return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page + 1) . '/')->activate(); |
| 171 | 172 | } |
| 172 | 173 | |
@@ -33,9 +33,9 @@ |
||
| 33 | 33 | |
| 34 | 34 | protected function get_introduction() |
| 35 | 35 | { |
| 36 | - global $container; |
|
| 37 | - $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
| 38 | - $introduction_result = $repository->findByType('about'); |
|
| 36 | + global $container; |
|
| 37 | + $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
| 38 | + $introduction_result = $repository->findByType('about'); |
|
| 39 | 39 | |
| 40 | 40 | if($introduction_result !== null) |
| 41 | 41 | { |