diff --git a/src/Controllers/TagController.php b/src/Controllers/TagController.php index 2ed137b2..930d9884 100644 --- a/src/Controllers/TagController.php +++ b/src/Controllers/TagController.php @@ -12,12 +12,12 @@ class TagController PrivilegesHelper::confirmWithException(Privilege::ListTags); $suppliedFilter = InputHelper::get('filter'); - $tags = Model_Tag::getEntities($suppliedFilter, null, null); + $tags = Model_Tag::getEntitiesRows($suppliedFilter, null, null); $this->context->transport->tags = $tags; if ($this->context->json) $this->context->transport->tags = array_values(array_map(function($tag) { - return ['name' => $tag->name, 'count' => $tag->getPostCount()]; + return ['name' => $tag['name'], 'count' => $tag['post_count']]; }, $this->context->transport->tags)); } diff --git a/src/Models/Model_Tag.php b/src/Models/Model_Tag.php index d16b69c3..24986d63 100644 --- a/src/Models/Model_Tag.php +++ b/src/Models/Model_Tag.php @@ -83,21 +83,4 @@ class Model_Tag extends AbstractModel { return 'Model_Tag_Querybuilder'; } - - public static function getEntities($query, $perPage = null, $page = 1) - { - $table = static::getTableName(); - $rows = self::getEntitiesRows($query, $perPage, $page); - $entities = R::convertToBeans($table, $rows); - - $rowMap = []; - foreach ($rows as &$row) - $rowMap[$row['id']] = $row; - unset ($row); - - foreach ($entities as $entity) - $entity->setMeta('post_count', $rowMap[$entity->id]['count']); - - return $entities; - } } diff --git a/src/Models/Model_Tag_QueryBuilder.php b/src/Models/Model_Tag_QueryBuilder.php index 111debd2..3344f608 100644 --- a/src/Models/Model_Tag_QueryBuilder.php +++ b/src/Models/Model_Tag_QueryBuilder.php @@ -7,7 +7,7 @@ class model_Tag_QueryBuilder implements AbstractQueryBuilder $limitQuery = false; $dbQuery ->addSql(', COUNT(post_tag.post_id)') - ->as('count') + ->as('post_count') ->from('tag') ->innerJoin('post_tag') ->on('tag.id = post_tag.tag_id') diff --git a/src/Views/tag-list.phtml b/src/Views/tag-list.phtml index c144c6cf..0880821a 100644 --- a/src/Views/tag-list.phtml +++ b/src/Views/tag-list.phtml @@ -1,12 +1,12 @@ -getPostCount(); }, $this->context->transport->tags)); ?> +context->transport->tags)); ?> '{query}']) ?>