@@ -9,14 +9,14 @@ discard block |
||
| 9 | 9 | class MysqlChangelogRepositoryTest extends PHPUnit_Framework_TestCase |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - protected static $connection; |
|
| 12 | + protected static $connection; |
|
| 13 | 13 | |
| 14 | - public static function setUpBeforeClass() |
|
| 15 | - { |
|
| 16 | - $extendedPdo = new ExtendedPdo('sqlite::memory:'); |
|
| 17 | - $extendedPdo->exec("ATTACH DATABASE `jpemeric_stream.db` AS `jpemeric_stream`"); |
|
| 14 | + public static function setUpBeforeClass() |
|
| 15 | + { |
|
| 16 | + $extendedPdo = new ExtendedPdo('sqlite::memory:'); |
|
| 17 | + $extendedPdo->exec("ATTACH DATABASE `jpemeric_stream.db` AS `jpemeric_stream`"); |
|
| 18 | 18 | |
| 19 | - $extendedPdo->exec(" |
|
| 19 | + $extendedPdo->exec(" |
|
| 20 | 20 | CREATE TABLE IF NOT EXISTS `jpemeric_stream`.`changelog` ( |
| 21 | 21 | `id` integer PRIMARY KEY AUTOINCREMENT, |
| 22 | 22 | `hash` char(40) NOT NULL, |
@@ -28,171 +28,171 @@ discard block |
||
| 28 | 28 | `created_at` datetime, |
| 29 | 29 | `updated_at` datetime |
| 30 | 30 | )" |
| 31 | - ); |
|
| 32 | - |
|
| 33 | - self::$connection = new ConnectionLocator(function () use ($extendedPdo) { |
|
| 34 | - return $extendedPdo; |
|
| 35 | - }); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - public function testIsInstanceOfChangelogRepository() |
|
| 39 | - { |
|
| 40 | - $repository = new MysqlChangelogRepository(self::$connection); |
|
| 41 | - |
|
| 42 | - $this->assertInstanceOf( |
|
| 43 | - 'Jacobemerick\Web\Domain\Stream\Changelog\MysqlChangelogRepository', |
|
| 44 | - $repository |
|
| 45 | - ); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - public function testImplementsChangelogInterface() |
|
| 49 | - { |
|
| 50 | - $repository = new MysqlChangelogRepository(self::$connection); |
|
| 51 | - |
|
| 52 | - $this->assertInstanceOf( |
|
| 53 | - 'Jacobemerick\Web\Domain\Stream\Changelog\ChangelogRepositoryInterface', |
|
| 54 | - $repository |
|
| 55 | - ); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - public function testConstructSetsConnections() |
|
| 59 | - { |
|
| 60 | - $respository = new MysqlChangelogRepository(self::$connection); |
|
| 61 | - |
|
| 62 | - $this->assertAttributeSame( |
|
| 63 | - self::$connection, |
|
| 64 | - 'connections', |
|
| 65 | - $respository |
|
| 66 | - ); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - public function testGetChanges() |
|
| 70 | - { |
|
| 71 | - $testData = [ |
|
| 72 | - [ |
|
| 73 | - 'id' => rand(1, 100), |
|
| 74 | - 'message' => 'test one', |
|
| 75 | - ], |
|
| 76 | - [ |
|
| 77 | - 'id' => rand(101, 200), |
|
| 78 | - 'message' => 'test two', |
|
| 79 | - ], |
|
| 80 | - ]; |
|
| 81 | - |
|
| 82 | - array_walk($testData, [$this, 'insertData']); |
|
| 83 | - |
|
| 84 | - $repository = new MysqlChangelogRepository(self::$connection); |
|
| 85 | - $data = $repository->getChanges(); |
|
| 86 | - |
|
| 87 | - $this->assertNotFalse($data); |
|
| 88 | - $this->assertInternalType('array', $data); |
|
| 89 | - foreach ($testData as $key => $testRow) { |
|
| 90 | - $this->assertInternalType('array', $data[$key]); |
|
| 91 | - $this->assertArraySubset($testRow, $data[$key]); |
|
| 92 | - $this->assertArrayHasKey('id', $data[$key]); |
|
| 93 | - $this->assertArrayHasKey('message', $data[$key]); |
|
| 94 | - $this->assertArrayHasKey('message_short', $data[$key]); |
|
| 95 | - $this->assertArrayHasKey('datetime', $data[$key]); |
|
| 96 | - $this->assertArrayHasKey('commit_link', $data[$key]); |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - public function testGetChangesFailure() |
|
| 101 | - { |
|
| 102 | - $repository = new MysqlChangelogRepository(self::$connection); |
|
| 103 | - $data = $repository->getChanges(); |
|
| 104 | - |
|
| 105 | - $this->assertEmpty($data); |
|
| 106 | - $this->assertInternalType('array', $data); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - public function testGetChangesRange() |
|
| 110 | - { |
|
| 111 | - $testData = [ |
|
| 112 | - [ |
|
| 113 | - 'id' => rand(1, 100), |
|
| 114 | - 'message' => 'test one', |
|
| 115 | - ], |
|
| 116 | - [ |
|
| 117 | - 'id' => rand(101, 200), |
|
| 118 | - 'message' => 'test two', |
|
| 119 | - ], |
|
| 120 | - [ |
|
| 121 | - 'id' => rand(201, 300), |
|
| 122 | - 'message' => 'test three', |
|
| 123 | - ], |
|
| 124 | - ]; |
|
| 125 | - |
|
| 126 | - array_walk($testData, [$this, 'insertData']); |
|
| 127 | - |
|
| 128 | - $repository = new MysqlChangelogRepository(self::$connection); |
|
| 129 | - $data = $repository->getChanges(2, 1); |
|
| 130 | - |
|
| 131 | - $this->assertNotFalse($data); |
|
| 132 | - $this->assertInternalType('array', $data); |
|
| 133 | - $this->assertCount(2, $data); |
|
| 134 | - |
|
| 135 | - $testData = array_slice($testData, 1, 2); |
|
| 136 | - |
|
| 137 | - foreach ($testData as $key => $testRow) { |
|
| 138 | - $this->assertInternalType('array', $testRow); |
|
| 139 | - $this->assertArraySubset($testRow, $data[$key]); |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - public function testGetChangesRangeFailure() |
|
| 144 | - { |
|
| 145 | - $testData = [ |
|
| 146 | - [ |
|
| 147 | - 'id' => rand(1, 100), |
|
| 148 | - 'message' => 'test one', |
|
| 149 | - ], |
|
| 150 | - [ |
|
| 151 | - 'id' => rand(101, 200), |
|
| 152 | - 'message' => 'test two', |
|
| 153 | - ], |
|
| 154 | - ]; |
|
| 155 | - |
|
| 156 | - array_walk($testData, [$this, 'insertData']); |
|
| 157 | - |
|
| 158 | - $repository = new MysqlChangelogRepository(self::$connection); |
|
| 159 | - $data = $repository->getChanges(1, 3); |
|
| 160 | - |
|
| 161 | - $this->assertEmpty($data); |
|
| 162 | - $this->assertInternalType('array', $data); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - protected function insertData(array $data) |
|
| 166 | - { |
|
| 167 | - $defaultData = [ |
|
| 168 | - 'id' => null, |
|
| 169 | - 'hash' => '', |
|
| 170 | - 'message' => null, |
|
| 171 | - 'message_short' => null, |
|
| 172 | - 'datetime' => '', |
|
| 173 | - 'author' => '', |
|
| 174 | - 'commit_link' => '', |
|
| 175 | - ]; |
|
| 176 | - |
|
| 177 | - $data = array_merge($defaultData, $data); |
|
| 178 | - |
|
| 179 | - return self::$connection->getDefault()->perform(" |
|
| 31 | + ); |
|
| 32 | + |
|
| 33 | + self::$connection = new ConnectionLocator(function () use ($extendedPdo) { |
|
| 34 | + return $extendedPdo; |
|
| 35 | + }); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + public function testIsInstanceOfChangelogRepository() |
|
| 39 | + { |
|
| 40 | + $repository = new MysqlChangelogRepository(self::$connection); |
|
| 41 | + |
|
| 42 | + $this->assertInstanceOf( |
|
| 43 | + 'Jacobemerick\Web\Domain\Stream\Changelog\MysqlChangelogRepository', |
|
| 44 | + $repository |
|
| 45 | + ); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + public function testImplementsChangelogInterface() |
|
| 49 | + { |
|
| 50 | + $repository = new MysqlChangelogRepository(self::$connection); |
|
| 51 | + |
|
| 52 | + $this->assertInstanceOf( |
|
| 53 | + 'Jacobemerick\Web\Domain\Stream\Changelog\ChangelogRepositoryInterface', |
|
| 54 | + $repository |
|
| 55 | + ); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + public function testConstructSetsConnections() |
|
| 59 | + { |
|
| 60 | + $respository = new MysqlChangelogRepository(self::$connection); |
|
| 61 | + |
|
| 62 | + $this->assertAttributeSame( |
|
| 63 | + self::$connection, |
|
| 64 | + 'connections', |
|
| 65 | + $respository |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + public function testGetChanges() |
|
| 70 | + { |
|
| 71 | + $testData = [ |
|
| 72 | + [ |
|
| 73 | + 'id' => rand(1, 100), |
|
| 74 | + 'message' => 'test one', |
|
| 75 | + ], |
|
| 76 | + [ |
|
| 77 | + 'id' => rand(101, 200), |
|
| 78 | + 'message' => 'test two', |
|
| 79 | + ], |
|
| 80 | + ]; |
|
| 81 | + |
|
| 82 | + array_walk($testData, [$this, 'insertData']); |
|
| 83 | + |
|
| 84 | + $repository = new MysqlChangelogRepository(self::$connection); |
|
| 85 | + $data = $repository->getChanges(); |
|
| 86 | + |
|
| 87 | + $this->assertNotFalse($data); |
|
| 88 | + $this->assertInternalType('array', $data); |
|
| 89 | + foreach ($testData as $key => $testRow) { |
|
| 90 | + $this->assertInternalType('array', $data[$key]); |
|
| 91 | + $this->assertArraySubset($testRow, $data[$key]); |
|
| 92 | + $this->assertArrayHasKey('id', $data[$key]); |
|
| 93 | + $this->assertArrayHasKey('message', $data[$key]); |
|
| 94 | + $this->assertArrayHasKey('message_short', $data[$key]); |
|
| 95 | + $this->assertArrayHasKey('datetime', $data[$key]); |
|
| 96 | + $this->assertArrayHasKey('commit_link', $data[$key]); |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + public function testGetChangesFailure() |
|
| 101 | + { |
|
| 102 | + $repository = new MysqlChangelogRepository(self::$connection); |
|
| 103 | + $data = $repository->getChanges(); |
|
| 104 | + |
|
| 105 | + $this->assertEmpty($data); |
|
| 106 | + $this->assertInternalType('array', $data); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + public function testGetChangesRange() |
|
| 110 | + { |
|
| 111 | + $testData = [ |
|
| 112 | + [ |
|
| 113 | + 'id' => rand(1, 100), |
|
| 114 | + 'message' => 'test one', |
|
| 115 | + ], |
|
| 116 | + [ |
|
| 117 | + 'id' => rand(101, 200), |
|
| 118 | + 'message' => 'test two', |
|
| 119 | + ], |
|
| 120 | + [ |
|
| 121 | + 'id' => rand(201, 300), |
|
| 122 | + 'message' => 'test three', |
|
| 123 | + ], |
|
| 124 | + ]; |
|
| 125 | + |
|
| 126 | + array_walk($testData, [$this, 'insertData']); |
|
| 127 | + |
|
| 128 | + $repository = new MysqlChangelogRepository(self::$connection); |
|
| 129 | + $data = $repository->getChanges(2, 1); |
|
| 130 | + |
|
| 131 | + $this->assertNotFalse($data); |
|
| 132 | + $this->assertInternalType('array', $data); |
|
| 133 | + $this->assertCount(2, $data); |
|
| 134 | + |
|
| 135 | + $testData = array_slice($testData, 1, 2); |
|
| 136 | + |
|
| 137 | + foreach ($testData as $key => $testRow) { |
|
| 138 | + $this->assertInternalType('array', $testRow); |
|
| 139 | + $this->assertArraySubset($testRow, $data[$key]); |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + public function testGetChangesRangeFailure() |
|
| 144 | + { |
|
| 145 | + $testData = [ |
|
| 146 | + [ |
|
| 147 | + 'id' => rand(1, 100), |
|
| 148 | + 'message' => 'test one', |
|
| 149 | + ], |
|
| 150 | + [ |
|
| 151 | + 'id' => rand(101, 200), |
|
| 152 | + 'message' => 'test two', |
|
| 153 | + ], |
|
| 154 | + ]; |
|
| 155 | + |
|
| 156 | + array_walk($testData, [$this, 'insertData']); |
|
| 157 | + |
|
| 158 | + $repository = new MysqlChangelogRepository(self::$connection); |
|
| 159 | + $data = $repository->getChanges(1, 3); |
|
| 160 | + |
|
| 161 | + $this->assertEmpty($data); |
|
| 162 | + $this->assertInternalType('array', $data); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + protected function insertData(array $data) |
|
| 166 | + { |
|
| 167 | + $defaultData = [ |
|
| 168 | + 'id' => null, |
|
| 169 | + 'hash' => '', |
|
| 170 | + 'message' => null, |
|
| 171 | + 'message_short' => null, |
|
| 172 | + 'datetime' => '', |
|
| 173 | + 'author' => '', |
|
| 174 | + 'commit_link' => '', |
|
| 175 | + ]; |
|
| 176 | + |
|
| 177 | + $data = array_merge($defaultData, $data); |
|
| 178 | + |
|
| 179 | + return self::$connection->getDefault()->perform(" |
|
| 180 | 180 | INSERT INTO `jpemeric_stream`.`changelog` |
| 181 | 181 | (id, hash, message, message_short, datetime, author, commit_link) |
| 182 | 182 | VALUES |
| 183 | 183 | (:id, :hash, :message, :message_short, :datetime, :author, :commit_link)", |
| 184 | - $data |
|
| 185 | - ); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - protected function tearDown() |
|
| 189 | - { |
|
| 190 | - self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`changelog`"); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - public static function tearDownAfterClass() |
|
| 194 | - { |
|
| 195 | - self::$connection->getDefault()->disconnect(); |
|
| 196 | - unlink('jpemeric_stream.db'); |
|
| 197 | - } |
|
| 184 | + $data |
|
| 185 | + ); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + protected function tearDown() |
|
| 189 | + { |
|
| 190 | + self::$connection->getDefault()->perform("DELETE FROM `jpemeric_stream`.`changelog`"); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + public static function tearDownAfterClass() |
|
| 194 | + { |
|
| 195 | + self::$connection->getDefault()->disconnect(); |
|
| 196 | + unlink('jpemeric_stream.db'); |
|
| 197 | + } |
|
| 198 | 198 | } |
@@ -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 | { |
@@ -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 | { |
@@ -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 | } |
@@ -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 | } |
@@ -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 | |
@@ -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 | { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $query = URLDecode::getPiece(2); |
| 36 | 36 | $query = urldecode($query); |
| 37 | - $query = str_replace('-', ' ', $query); |
|
| 37 | + $query = str_replace('-', ' ', $query); |
|
| 38 | 38 | |
| 39 | 39 | $this->query = $query; |
| 40 | 40 | |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | if(!isset($this->search_result)) |
| 89 | 89 | { |
| 90 | - global $container; |
|
| 91 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 92 | - $posts = $repository->getActivePosts(); |
|
| 90 | + global $container; |
|
| 91 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
| 92 | + $posts = $repository->getActivePosts(); |
|
| 93 | 93 | |
| 94 | 94 | $this->search_result = Search::instance() |
| 95 | 95 | ->setQuery($this->query) |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | protected function set_head_data() |
| 20 | 20 | { |
| 21 | - $this->set_head('rss_link', [ |
|
| 22 | - 'title' => 'Jacob Emerick Blog Feed', |
|
| 23 | - 'url' => '/rss.xml' |
|
| 24 | - ]); |
|
| 25 | - $this->set_head('rss_comment_link', [ |
|
| 26 | - 'title' => 'Jacob Emerick Blog Comment Feed', |
|
| 27 | - 'url' => '/rss-comments.xml' |
|
| 28 | - ]); |
|
| 21 | + $this->set_head('rss_link', [ |
|
| 22 | + 'title' => 'Jacob Emerick Blog Feed', |
|
| 23 | + 'url' => '/rss.xml' |
|
| 24 | + ]); |
|
| 25 | + $this->set_head('rss_comment_link', [ |
|
| 26 | + 'title' => 'Jacob Emerick Blog Comment Feed', |
|
| 27 | + 'url' => '/rss-comments.xml' |
|
| 28 | + ]); |
|
| 29 | 29 | |
| 30 | 30 | $this->add_css('normalize'); |
| 31 | 31 | $this->add_css('blog'); |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | final private function get_tags_for_post($post) |
| 89 | 89 | { |
| 90 | - global $container; |
|
| 91 | - $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
| 92 | - $tag_result = $repository->getTagsForPost($post['id']); |
|
| 90 | + global $container; |
|
| 91 | + $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
| 92 | + $tag_result = $repository->getTagsForPost($post['id']); |
|
| 93 | 93 | |
| 94 | - $tag_array = array(); |
|
| 94 | + $tag_array = array(); |
|
| 95 | 95 | foreach($tag_result as $tag) |
| 96 | 96 | { |
| 97 | 97 | $tag_object = new stdclass(); |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | final private function get_tag_cloud() |
| 127 | 127 | { |
| 128 | - global $container; |
|
| 129 | - $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
| 130 | - $tag_result = $repository->getTagCloud(); |
|
| 128 | + global $container; |
|
| 129 | + $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
| 130 | + $tag_result = $repository->getTagCloud(); |
|
| 131 | 131 | |
| 132 | 132 | $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
| 133 | 133 | |