Controller/WikiTagController.php
changeset 16 876df98c9208
parent 15 ab71cf8bff55
child 21 780ef37e63b9
equal deleted inserted replaced
15:ab71cf8bff55 16:876df98c9208
   428             $sort = $_GET['sort'];
   428             $sort = $_GET['sort'];
   429         }
   429         }
   430         
   430         
   431         // We get the needed datas in an array($tags, $num_page, $nb_by_page, $searched, $sort, $reverse_sort, $pagerfanta);
   431         // We get the needed datas in an array($tags, $num_page, $nb_by_page, $searched, $sort, $reverse_sort, $pagerfanta);
   432         $ar = $this->getAllTags($num_page, $nb_by_page, $sort, $searched);
   432         $ar = $this->getAllTags($num_page, $nb_by_page, $sort, $searched);
       
   433         //return new Response($ar);
   433         $tags = $ar[0];
   434         $tags = $ar[0];
   434         $num_page = $ar[1];
   435         $num_page = $ar[1];
   435         $nb_by_page = $ar[2];
   436         $nb_by_page = $ar[2];
   436         $searched = $ar[3];
   437         $searched = $ar[3];
   437         $sort = $ar[4];
   438         $sort = $ar[4];
   516         $qb->select('t', 'COUNT( dt.id ) AS nb_docs');
   517         $qb->select('t', 'COUNT( dt.id ) AS nb_docs');
   517         $qb->from('WikiTagBundle:Tag','t');
   518         $qb->from('WikiTagBundle:Tag','t');
   518         $qb->leftJoin('t.documents', 'dt', 'WITH', 't = dt.tag');
   519         $qb->leftJoin('t.documents', 'dt', 'WITH', 't = dt.tag');
   519         $qb->addGroupBy('t.id');
   520         $qb->addGroupBy('t.id');
   520         
   521         
   521         // We add the search string if necessary ('* bugs)
   522         // We add the search string if necessary
   522         if($searched!="" && $searched!="'*"){
   523         if($searched!=""){
   523             // We replace "*" by "%".
   524             // We replace "*" by "%", and doctrine wants ' to be ''.
   524             $qb->where($qb->expr()->orx($qb->expr()->like('t.normalizedLabel', "'".str_replace("*", "%", $searched)."'")));
   525             $qb->where($qb->expr()->orx($qb->expr()->like('t.normalizedLabel', "'".str_replace("'", "''", str_replace("*", "%", $searched))."'")));
   525         }
   526         }
       
   527         //return $qb->getDql();
   526         
   528         
   527         // We add the sorting criteria
   529         // We add the sorting criteria
   528         if($sort==NULL){
   530         if($sort==NULL){
   529             $sort = "popd"; // sort by descendent popularity by default.
   531             $sort = "popd"; // sort by descendent popularity by default.
   530             $reverse_sort = "popa";
   532             $reverse_sort = "popa";