--- a/Controller/WikiTagController.php Tue Oct 25 12:20:47 2011 +0200
+++ b/Controller/WikiTagController.php Wed Oct 26 15:38:05 2011 +0200
@@ -473,7 +473,8 @@
*/
public function renderAllTags($num_page=NULL, $nb_by_page=NULL, $sort=NULL, $searched=NULL)
{
- // We get the needed datas in an array($tags, $num_page, $nb_by_page, $searched, $sort, $reverse_sort, $pagerfanta);
+
+ //We get the needed datas in an array($tags, $num_page, $nb_by_page, $searched, $sort, $reverse_sort, $pagerfanta);
$ar = $this->getAllTags($num_page, $nb_by_page, $sort, $searched);
$tags = $ar[0];
$num_page = $ar[1];
@@ -484,6 +485,8 @@
return $this->render('WikiTagBundle:WikiTag:TagListTable.html.twig',
array('tags' => $tags, 'searched' => $searched, 'nb_by_page' => $nb_by_page, 'sort' => $sort, 'num_page' => $num_page, 'reverse_sort' => $reverse_sort));
+
+ return $this->getAllTags();
}
@@ -508,12 +511,17 @@
// We build the query.
$qb = $this->getDoctrine()->getEntityManager()->createQueryBuilder();
- $qb->select('t')->from('WikiTagBundle:Tag','t');
+ $qb->select('t', 'COUNT( dt.id ) AS nb_docs');
+ $qb->from('WikiTagBundle:Tag','t');
+ $qb->leftJoin('t.documents', 'dt', 'WITH', 't = dt.tag');
+ $qb->addGroupBy('t.id');
+
// We add the search string if necessary ('* bugs)
if($searched!="" && $searched!="'*"){
// We replace "*" by "%".
$qb->where($qb->expr()->orx($qb->expr()->like('t.normalizedLabel', "'".str_replace("*", "%", $searched)."'")));
}
+
// We add the sorting criteria
if($sort==NULL){
$sort = "popd"; // sort by descendent popularity by default.
@@ -549,12 +557,10 @@
$adapter = new DoctrineORMAdapter($qb);
$pagerfanta = new Pagerfanta($adapter);
$pagerfanta->setMaxPerPage($nb_by_page); // 10 by default
- //$last_page = $pagerfanta->getNbPages();
$pagerfanta->setCurrentPage($num_page); // 1 by default
$nb_total = $pagerfanta->getNbResults();
$tags = $pagerfanta->getCurrentPageResults();
$pagerfanta->haveToPaginate(); // whether the number of results if higher than the max per page
-
return array($tags, $num_page, $nb_by_page, $searched, $sort, $reverse_sort, $pagerfanta);
}