| author | cavaliet |
| Mon, 24 Oct 2011 18:45:34 +0200 | |
| changeset 11 | 5f038a505cd7 |
| parent 10 | a1234ceba912 |
| child 12 | 81cc9274c20a |
| permissions | -rwxr-xr-x |
| 2 | 1 |
<?php |
2 |
/* |
|
3 |
* This file is part of the WikiTagBundle package. |
|
4 |
* |
|
5 |
* (c) IRI <http://www.iri.centrepompidou.fr/> |
|
6 |
* |
|
7 |
* For the full copyright and license information, please view the LICENSE |
|
8 |
* file that was distributed with this source code. |
|
9 |
*/ |
|
10 |
||
11 |
namespace IRI\Bundle\WikiTagBundle\Controller; |
|
12 |
||
|
10
a1234ceba912
add first letter list. It works but searching ' bugs.
cavaliet
parents:
9
diff
changeset
|
13 |
use Doctrine\ORM\Query\ResultSetMapping; |
|
a1234ceba912
add first letter list. It works but searching ' bugs.
cavaliet
parents:
9
diff
changeset
|
14 |
use Doctrine\DBAL\DriverManager; |
|
a1234ceba912
add first letter list. It works but searching ' bugs.
cavaliet
parents:
9
diff
changeset
|
15 |
|
| 2 | 16 |
use IRI\Bundle\WikiTagBundle\Entity\DocumentTag; |
17 |
use IRI\Bundle\WikiTagBundle\Entity\Tag; |
|
18 |
use IRI\Bundle\WikiTagBundle\Utils\WikiTagUtils; |
|
|
9
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
19 |
use Pagerfanta\Pagerfanta; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
20 |
use Pagerfanta\Adapter\ArrayAdapter; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
21 |
use Pagerfanta\Adapter\DoctrineORMAdapter; |
| 2 | 22 |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
23 |
use Symfony\Component\HttpFoundation\Response; |
|
24 |
||
25 |
||
26 |
class WikiTagController extends Controller |
|
27 |
{ |
|
|
10
a1234ceba912
add first letter list. It works but searching ' bugs.
cavaliet
parents:
9
diff
changeset
|
28 |
private static $SEARCH_STAR_CHARACTER = "*"; |
|
a1234ceba912
add first letter list. It works but searching ' bugs.
cavaliet
parents:
9
diff
changeset
|
29 |
|
| 2 | 30 |
/** |
31 |
* Fake index action |
|
32 |
*/ |
|
33 |
public function indexAction() |
|
34 |
{ |
|
35 |
return new Response('<html><body>Nothing to see here.</body></html>'); |
|
36 |
} |
|
37 |
||
38 |
/** |
|
39 |
* Renders the little html to add the css |
|
40 |
*/ |
|
41 |
public function addCssAction() |
|
42 |
{ |
|
43 |
return $this->render('WikiTagBundle:WikiTag:css.html.twig'); |
|
44 |
} |
|
45 |
||
46 |
/** |
|
47 |
* Renders the little html to add the javascript |
|
48 |
* TODO: review why this injection in javascript, t10n? |
|
49 |
*/ |
|
50 |
public function addJavascriptAction() |
|
51 |
{ |
|
52 |
$cats = $this->getDoctrine()->getRepository('WikiTagBundle:Category')->findOrderedCategories(); |
|
53 |
// $cats is {"Label":"Créateur"},{"Label":"Datation"},... |
|
54 |
$nbCats = count($cats); |
|
55 |
$ar = array('' => ''); |
|
56 |
for($i=0;$i<$nbCats;$i++){ |
|
| 7 | 57 |
$temp = array($cats[$i]["label"] => $cats[$i]["label"]); |
| 2 | 58 |
$ar = array_merge($ar, $temp); |
59 |
} |
|
60 |
// ... so we create is json like {"":""},{"Créateur":"Créateur"},{"Datation":"Datation"},... |
|
61 |
$categories = json_encode($ar); |
|
62 |
return $this->render('WikiTagBundle:WikiTag:javascript.html.twig', array('categories' => $categories)); |
|
63 |
} |
|
64 |
||
65 |
/** |
|
66 |
* Display a list of ordered tag for a document |
|
67 |
* @param integer $id_doc |
|
68 |
*/ |
|
69 |
public function documentTagsAction($id_doc) |
|
70 |
{ |
|
71 |
$ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); |
|
72 |
return $this->render('WikiTagBundle:WikiTag:documentTags.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc)); |
|
73 |
} |
|
74 |
||
75 |
/** |
|
76 |
* |
|
77 |
* TODO : Enter description here ... |
|
78 |
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response |
|
79 |
*/ |
|
80 |
public function tagUpDownAction() |
|
81 |
{ |
|
82 |
||
83 |
$req = $this->getRequest()->request; |
|
84 |
$id_doc = $req->get('wikitag_document_id'); |
|
85 |
// post vars new_order and old_order indicate the position (from 1) of the tag in the list. |
|
86 |
// NB : it is different from the DocumentTag.order in the database. |
|
87 |
$new_order = intval($req->get('new_order')) - 1; |
|
88 |
$old_order = intval($req->get('old_order')) - 1; |
|
89 |
// First we get the DocumentTags |
|
90 |
$em = $this->getDoctrine()->getEntityManager(); |
|
91 |
$ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); |
|
92 |
// We change the moved DocumentTag's order |
|
93 |
$new_dt_order = $ordered_tags[$new_order]->getTagOrder(); |
|
94 |
$moved_dt = $ordered_tags[$old_order]; |
|
95 |
$moved_dt->setTagOrder($new_dt_order); |
|
96 |
// We move the TaggedSheets's order |
|
97 |
if($new_order > $old_order){ |
|
98 |
// And we decrease the other ones |
|
99 |
for ($i=($old_order+1); $i <= ($new_order); $i++){ |
|
100 |
$dt = $ordered_tags[$i]; |
|
101 |
$dt->setTagOrder($dt->getTagOrder() - 1); |
|
102 |
} |
|
103 |
} |
|
104 |
else{ |
|
105 |
// And we increase the other ones |
|
106 |
for ($i=$new_order; $i <= ($old_order-1); $i++){ |
|
107 |
$dt = $ordered_tags[$i]; |
|
108 |
$dt->setTagOrder($dt->getTagOrder() + 1); |
|
109 |
} |
|
110 |
} |
|
111 |
// Save datas. |
|
112 |
$em->flush(); |
|
113 |
||
114 |
return $this->renderDocTags($id_doc); |
|
115 |
} |
|
116 |
||
117 |
/** |
|
118 |
* |
|
119 |
* TODO: Enter description here ... |
|
120 |
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response |
|
121 |
*/ |
|
122 |
public function removeTagFromListAction() |
|
123 |
{ |
|
124 |
$id_doc = $this->getRequest()->request->get('wikitag_document_id'); |
|
125 |
$id_tag = $this->getRequest()->request->get('tag_id'); |
|
126 |
// We get the DocumentTag meant to be deleted, and remove it. |
|
127 |
$em = $this->getDoctrine()->getEntityManager(); |
|
128 |
$dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneBy(array('tag' => $id_tag, 'document' => $id_doc)); |
|
129 |
$em->remove($dt); |
|
130 |
$em->flush(); |
|
131 |
||
132 |
return $this->renderDocTags($id_doc); |
|
133 |
} |
|
134 |
||
135 |
/** |
|
136 |
* |
|
137 |
* TODO: Enter description here ... |
|
138 |
*/ |
|
139 |
public function modifyDocumentTagAction() |
|
140 |
{ |
|
141 |
$id_doc = $this->getRequest()->request->get('wikitag_document_id'); |
|
142 |
$tag_label = $this->getRequest()->request->get('value'); |
|
143 |
$id_moved_tag = $this->getRequest()->request->get('id'); |
|
144 |
$moved_tag = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->findOneBy(array('id' => $id_moved_tag)); |
|
|
11
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
145 |
if($tag_label!=$moved_tag->getLabel()){ |
| 2 | 146 |
// We get the DocumentTags |
147 |
$em = $this->getDoctrine()->getEntityManager(); |
|
148 |
$tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findBy(array('document' => $id_doc)); |
|
149 |
$nb_tags = count($tags); |
|
150 |
$found = false; |
|
151 |
$i = 0; |
|
152 |
while($i<$nb_tags && $found==false){ |
|
153 |
$dt = $tags[$i]; |
|
154 |
if(strtolower($dt->getTag()->getLabel())==strtolower($tag_label)){ |
|
155 |
$found = true; |
|
156 |
} |
|
157 |
$i++; |
|
158 |
} |
|
159 |
// If the label was found, we sent a bad request |
|
160 |
if($found==true){ |
|
161 |
return new Response(json_encode(array('error' => 'duplicate_tag', 'message' => sprintf("Le tag %s existe déjà pour cette fiche.", $tag_label))),400); |
|
162 |
} |
|
163 |
// We create the new tag or get the already existing tag. $tag, $revision_id, $created |
|
164 |
$ar = WikiTagUtils::getOrCreateTag($tag_label, $this->getDoctrine());// tag, revision_id, created = get_or_create_tag(tag_label) |
|
165 |
$tag = $ar[0]; |
|
166 |
$revision_id = $ar[1]; |
|
167 |
$created = $ar[2]; |
|
168 |
// We get the DocumentTag and change its tag |
|
|
11
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
169 |
$dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneBy(array('document' => $id_doc, 'tag' => $id_moved_tag)); |
| 2 | 170 |
$dt->setTag($tag); |
171 |
$dt->setWikipediaRevisionId($revision_id); |
|
172 |
// |
|
173 |
// HERE QUERY TO GET A INDEX_NOTE/SCORE for the tag. Here is python code : |
|
174 |
//kwargs = {DJANGO_ID + "__exact": unicode(ds_id)} |
|
175 |
//results = SearchQuerySet().filter(title=tag_label).filter_or(description=tag_label).filter(**kwargs) |
|
176 |
//if len(results) > 0: |
|
177 |
// ts.index_note = results[0].score |
|
178 |
// |
|
179 |
// We save the datas |
|
180 |
$doc = $this->getDoctrine()->getRepository('WikiTagBundle:Document')->findOneBy(array('id' => $id_doc)); |
|
181 |
$doc->setManualOrder(true); |
|
182 |
$em->flush(); |
|
183 |
} |
|
184 |
||
185 |
return $this->renderDocTags($id_doc); |
|
186 |
} |
|
187 |
||
188 |
/** |
|
189 |
* |
|
| 7 | 190 |
* @Route("/wtrtd") |
| 2 | 191 |
* TODO : Enter description here ... |
| 7 | 192 |
* TODO : implement |
| 2 | 193 |
*/ |
194 |
public function reorderTagDocumentAction() |
|
195 |
{ |
|
196 |
$id_Doc = $this->getRequest()->request->get('wikitag_document_id'); |
|
197 |
return $this->renderDocTags($id_doc); |
|
198 |
} |
|
199 |
||
200 |
/** |
|
201 |
* |
|
202 |
* TODO: Enter description here ... |
|
203 |
*/ |
|
204 |
public function addTagAction() |
|
205 |
{ |
|
206 |
$id_doc = $this->getRequest()->request->get('wikitag_document_id'); |
|
207 |
$tag_label = $this->getRequest()->request->get('value'); |
|
208 |
// We get the DocumentTags |
|
209 |
$em = $this->getDoctrine()->getEntityManager(); |
|
|
5
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
210 |
$tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findByDocumentExternalId($id_doc); |
| 2 | 211 |
$nb_tags = count($tags); |
212 |
$found = false; |
|
213 |
$i = 0; |
|
214 |
while($i<$nb_tags && $found==false){ |
|
215 |
$dt = $tags[$i]; |
|
216 |
if(strtolower($dt->getTag()->getLabel())==strtolower($tag_label)){ |
|
217 |
$found = true; |
|
218 |
} |
|
219 |
$i++; |
|
220 |
} |
|
221 |
// If the label was found, we sent a bad request |
|
222 |
if($found==true){ |
|
223 |
//TODO : translation |
|
224 |
return new Response(json_encode(array('error' => 'duplicate_tag', 'message' => sprintf("Le tag %s existe déjà pour cette fiche.", $tag_label))),400); |
|
225 |
} |
|
| 8 | 226 |
// returns array($tag, $revision_id, $created) |
| 2 | 227 |
$ar = WikiTagUtils::getOrCreateTag($tag_label, $this->getDoctrine());// tag, revision_id, created = get_or_create_tag(tag_label) |
228 |
$tag = $ar[0]; |
|
229 |
$revision_id = $ar[1]; |
|
230 |
$created = $ar[2]; |
|
| 8 | 231 |
|
|
5
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
232 |
$tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findByDocumentExternalId($id_doc, array('tag'=>$tag->getId())); |
| 2 | 233 |
$nb_tags = count($tags); |
234 |
||
235 |
if($created==true || $nb_tags==0){ |
|
236 |
$new_order_ar = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->getMaxOrder($id_doc); |
|
237 |
// The result is a double array. And reset(reset($newOrderAr)) is not allowed. And a string is returned. |
|
238 |
$a1 = reset($new_order_ar); |
|
239 |
$new_order = intval(reset($a1)) + 1; |
|
240 |
// TODO: use a factory that returns an DocumentTagInterface |
|
241 |
$new_DT = new DocumentTag(); |
|
|
5
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
242 |
$new_DT->setDocument($this->getDoctrine()->getRepository('WikiTagBundle:Document')->findOneByExternalId($id_doc)); |
| 2 | 243 |
$new_DT->setTag($tag); |
244 |
$new_DT->setOriginalOrder($new_order); |
|
245 |
$new_DT->setTagOrder($new_order); |
|
246 |
$new_DT->setWikipediaRevisionId($revision_id); |
|
247 |
$em->persist($new_DT); |
|
248 |
$em->flush(); |
|
249 |
} |
|
250 |
||
251 |
return $this->renderDocTags($id_doc); |
|
252 |
} |
|
253 |
||
254 |
||
255 |
/** |
|
256 |
* |
|
257 |
* TODO: Enter description here ... |
|
258 |
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response |
|
259 |
*/ |
|
260 |
public function removeWpLinkAction() |
|
261 |
{ |
|
262 |
$id_doc = $this->getRequest()->request->get('wikitag_document_id'); |
|
263 |
$id_tag = $this->getRequest()->request->get('tag_id'); |
|
264 |
$tag = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->find($id_tag); |
|
265 |
//return new Response(var_dump(array($tag))); |
|
266 |
// We search if the unsemantized version of the tag already exist. |
|
267 |
$un_tag = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->findOneBy(array('label'=>$tag->getLabel(), 'urlStatus'=>Tag::$TAG_URL_STATUS_DICT['null_result'])); |
|
268 |
$em = $this->getDoctrine()->getEntityManager(); |
|
269 |
if(!$un_tag){ |
|
270 |
// Create another tag almost identical, without the W info |
|
271 |
// TODO: use a factory that return a TagInterface |
|
272 |
$un_tag = new Tag(); |
|
273 |
$un_tag->setLabel($tag->getLabel()); |
|
274 |
$un_tag->setOriginalLabel($tag->getOriginalLabel()); |
|
275 |
$un_tag->setUrlStatus(Tag::$TAG_URL_STATUS_DICT['null_result']); |
|
276 |
$un_tag->setWikipediaUrl(null); |
|
277 |
$un_tag->setWikipediaPageId(null); |
|
278 |
$un_tag->setDbpediaUri(null); |
|
279 |
$un_tag->setCategory($tag->getCategory()); |
|
280 |
$un_tag->setAlias($tag->getAlias()); |
|
281 |
$un_tag->setPopularity($tag->getPopularity()); |
|
282 |
$em->persist($un_tag); |
|
283 |
} |
|
284 |
// We associate the unsemantized tag to the DocumentTag and save datas |
|
|
5
45378793512a
Correct tag insert + external id on doc
ymh <ymh.work@gmail.com>
parents:
2
diff
changeset
|
285 |
// TODO: do the request on external id of document |
| 8 | 286 |
$dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneBy(array('document' => $id_doc, 'tag' => $id_tag)); |
| 2 | 287 |
$dt->setTag($un_tag); |
288 |
$em->flush(); |
|
289 |
||
290 |
return $this->renderDocTags($id_doc); |
|
291 |
} |
|
292 |
||
293 |
||
294 |
/** |
|
295 |
* |
|
296 |
* TODO: Enter description here ... |
|
297 |
*/ |
|
298 |
public function updateTagCategoryAction() |
|
299 |
{ |
|
300 |
$id_doc = $this->getRequest()->request->get('wikitag_document_id'); |
|
301 |
$id_tag = $this->getRequest()->request->get('id'); |
|
302 |
$cat_label = $this->getRequest()->request->get('value'); |
|
303 |
// We get the Tag and update its category. |
|
304 |
$em = $this->getDoctrine()->getEntityManager(); |
|
305 |
$tag = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->find($id_tag); |
|
306 |
if($cat_label==''){ |
|
307 |
$cat = null; |
|
308 |
$tag->nullCategory(); |
|
309 |
} |
|
310 |
else{ |
|
311 |
$cat = $this->getDoctrine()->getRepository('WikiTagBundle:Category')->findOneBy(array('label' => $cat_label)); |
|
312 |
$tag->setCategory($cat); |
|
313 |
} |
|
314 |
$em->flush(); |
|
315 |
||
|
11
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
316 |
if($id_doc && $id_doc!=""){ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
317 |
return $this->renderDocTags($id_doc); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
318 |
} |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
319 |
else{ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
320 |
$num_page = $this->getRequest()->request->get('num_page'); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
321 |
$nb_by_page = $this->getRequest()->request->get('nb_by_page'); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
322 |
$sort = $this->getRequest()->request->get('sort'); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
323 |
$searched = $this->getRequest()->request->get('searched'); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
324 |
return $this->renderAllTags($num_page, $nb_by_page, $sort, $searched); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
325 |
} |
| 2 | 326 |
} |
327 |
||
328 |
||
329 |
/** |
|
330 |
* |
|
331 |
* Generic render partial template |
|
332 |
* @param unknown_type $id_doc |
|
333 |
*/ |
|
334 |
public function renderDocTags($id_doc) |
|
335 |
{ |
|
336 |
$ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); |
|
337 |
return $this->render('WikiTagBundle:WikiTag:tagTable.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc)); |
|
338 |
} |
|
| 7 | 339 |
|
340 |
/** |
|
341 |
* |
|
342 |
* @Route("/wtrwi") |
|
343 |
* TODO: Enter description here ... |
|
344 |
* TODO : implement |
|
345 |
*/ |
|
346 |
public function resetWpInfoAction() |
|
347 |
{ |
|
348 |
$id_doc = $this->getRequest()->request->get('wikitag_document_id'); |
|
349 |
return $this->renderDocTags($id_doc); |
|
350 |
} |
|
351 |
||
352 |
||
353 |
/** |
|
354 |
* |
|
355 |
* TODO : Enter description here ... |
|
356 |
* TODO : implement |
|
357 |
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response |
|
358 |
*/ |
|
359 |
public function updateTagAliasAction() |
|
360 |
{ |
|
361 |
$id_doc = $this->getRequest()->request->get('wikitag_document_id'); |
|
362 |
return $this->renderDocTags($id_doc); |
|
363 |
} |
|
364 |
||
365 |
/** |
|
366 |
* List of all tags |
|
367 |
* TODO: Enter description here ... |
|
368 |
*/ |
|
369 |
public function allTagsAction() |
|
370 |
{ |
|
371 |
// $this->getRequest()->query->get('foo') does not work "because" we are a second controller. So we have to use $_GET. |
|
|
11
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
372 |
// Searched string |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
373 |
$searched = NULL; |
|
9
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
374 |
if(array_key_exists('searched', $_GET)){ |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
375 |
$searched = $_GET['searched']; |
| 7 | 376 |
} |
|
9
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
377 |
// Number of tags per page |
| 8 | 378 |
$nb_by_page = 50; |
|
9
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
379 |
if(array_key_exists('nb_by_page', $_GET)){ |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
380 |
$nb_by_page = intval($_GET['nb_by_page']); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
381 |
} |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
382 |
// Current page number |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
383 |
$num_page = 1; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
384 |
if(array_key_exists('num_page', $_GET)){ |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
385 |
$num_page = intval($_GET['num_page']); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
386 |
} |
|
11
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
387 |
// Sorting criteria |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
388 |
$sort = NULL; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
389 |
if(array_key_exists('sort', $_GET)){ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
390 |
$sort = $_GET['sort']; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
391 |
} |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
392 |
|
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
393 |
// We get the needed datas in an array($tags, $num_page, $nb_by_page, $searched, $sort, $reverse_sort, $pagerfanta); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
394 |
$ar = $this->getAllTags($num_page, $nb_by_page, $sort, $searched); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
395 |
$tags = $ar[0]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
396 |
$num_page = $ar[1]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
397 |
$nb_by_page = $ar[2]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
398 |
$searched = $ar[3]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
399 |
$sort = $ar[4]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
400 |
$reverse_sort = $ar[5]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
401 |
$pagerfanta = $ar[6]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
402 |
|
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
403 |
// We get the needed vars : number totals of tags, previous and next page number |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
404 |
$last_page = $pagerfanta->getNbPages(); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
405 |
$nb_total = $pagerfanta->getNbResults(); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
406 |
$prev_page = 1; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
407 |
if($pagerfanta->hasPreviousPage()){ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
408 |
$prev_page = $pagerfanta->getPreviousPage(); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
409 |
} |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
410 |
$next_page = $last_page; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
411 |
if($pagerfanta->hasNextPage()){ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
412 |
$next_page = $pagerfanta->getNextPage(); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
413 |
} |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
414 |
// We calculate start_index and end_index (number of tags in the whole list) |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
415 |
$start_index = 1 + (($num_page - 1) * $nb_by_page); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
416 |
$end_index = min($nb_total, $start_index + $nb_by_page - 1); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
417 |
|
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
418 |
// We build the list of tags's first letters to make quick search. |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
419 |
$conn = $this->getDoctrine()->getEntityManager()->getConnection(); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
420 |
$sql = "SELECT UPPER(SUBSTRING(normalized_label,1,1)) as fl FROM wikitag_tag GROUP BY fl ORDER BY fl"; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
421 |
$letters = $conn->query($sql)->fetchAll(); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
422 |
$search_def = array(); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
423 |
foreach ($letters as $l){ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
424 |
$search_def[$l[0]] = $l[0].WikiTagController::$SEARCH_STAR_CHARACTER; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
425 |
} |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
426 |
|
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
427 |
return $this->render('WikiTagBundle:WikiTag:TagList.html.twig', |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
428 |
array('tags' => $tags, 'searched' => $searched, 'search_def' => $search_def, 'nb_by_page' => $nb_by_page, 'sort' => $sort, |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
429 |
'start_index' => $start_index, 'end_index' => $end_index, 'nb_total' => $nb_total, 'num_page' => $num_page, 'last_page' => $last_page, |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
430 |
'prev_page' => $prev_page, 'next_page' => $next_page, 'reverse_sort' => $reverse_sort)); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
431 |
} |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
432 |
|
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
433 |
|
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
434 |
/** |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
435 |
* Generic render partial template for tag list |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
436 |
*/ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
437 |
public function renderAllTags($num_page=NULL, $nb_by_page=NULL, $sort=NULL, $searched=NULL) |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
438 |
{ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
439 |
// We get the needed datas in an array($tags, $num_page, $nb_by_page, $searched, $sort, $reverse_sort, $pagerfanta); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
440 |
$ar = $this->getAllTags($num_page, $nb_by_page, $sort, $searched); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
441 |
$tags = $ar[0]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
442 |
$num_page = $ar[1]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
443 |
$nb_by_page = $ar[2]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
444 |
$searched = $ar[3]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
445 |
$sort = $ar[4]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
446 |
$reverse_sort = $ar[5]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
447 |
//$pagerfanta = $ar[6]; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
448 |
|
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
449 |
return $this->render('WikiTagBundle:WikiTag:TagListTable.html.twig', |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
450 |
array('tags' => $tags, 'searched' => $searched, 'nb_by_page' => $nb_by_page, 'sort' => $sort, 'num_page' => $num_page, 'reverse_sort' => $reverse_sort)); |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
451 |
} |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
452 |
|
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
453 |
|
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
454 |
/** |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
455 |
* Generic to get all tags with the context (pagination number, nb by page, searched string, sort) |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
456 |
*/ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
457 |
private function getAllTags($num_page=NULL, $nb_by_page=NULL, $sort=NULL, $searched=NULL) |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
458 |
{ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
459 |
// We get/set all the parameters for the search and pagination. |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
460 |
// Searched string |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
461 |
if($searched==NULL){ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
462 |
$searched = ""; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
463 |
} |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
464 |
// Number of tags per page |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
465 |
if($nb_by_page==NULL){ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
466 |
$nb_by_page = 50; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
467 |
} |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
468 |
// Current page number |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
469 |
if($num_page==NULL){ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
470 |
$num_page = 1; |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
471 |
} |
|
9
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
472 |
|
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
473 |
// We build the query. |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
474 |
$qb = $this->getDoctrine()->getEntityManager()->createQueryBuilder(); |
|
10
a1234ceba912
add first letter list. It works but searching ' bugs.
cavaliet
parents:
9
diff
changeset
|
475 |
$qb->select('t')->from('WikiTagBundle:Tag','t'); |
|
a1234ceba912
add first letter list. It works but searching ' bugs.
cavaliet
parents:
9
diff
changeset
|
476 |
// We add the search string if necessary ('* bugs) |
|
a1234ceba912
add first letter list. It works but searching ' bugs.
cavaliet
parents:
9
diff
changeset
|
477 |
if($searched!="" && $searched!="'*"){ |
|
9
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
478 |
// We replace "*" by "%". |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
479 |
$qb->where($qb->expr()->orx($qb->expr()->like('t.normalizedLabel', "'".str_replace("*", "%", $searched)."'"))); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
480 |
} |
|
10
a1234ceba912
add first letter list. It works but searching ' bugs.
cavaliet
parents:
9
diff
changeset
|
481 |
// We add the sorting criteria |
|
11
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
482 |
if($sort==NULL){ |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
483 |
$sort = "popd"; // sort by descendent popularity by default. |
|
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
484 |
$reverse_sort = "popa"; |
|
9
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
485 |
} |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
486 |
$sort_query = "t.popularity DESC t.normalizedLabel ASC t.label ASC"; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
487 |
switch($sort){ |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
488 |
case "popd": |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
489 |
$qb->addOrderBy('t.popularity','DESC'); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
490 |
$qb->addOrderBy('t.normalizedLabel','ASC'); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
491 |
$qb->addOrderBy('t.label','ASC'); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
492 |
$reverse_sort = "popa"; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
493 |
break; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
494 |
case "popa": |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
495 |
$qb->addOrderBy('t.popularity','ASC'); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
496 |
$qb->addOrderBy('t.normalizedLabel','ASC'); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
497 |
$qb->addOrderBy('t.label','ASC'); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
498 |
$reverse_sort = "popd"; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
499 |
break; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
500 |
case "labd": |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
501 |
$qb->addOrderBy('t.normalizedLabel','DESC'); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
502 |
$qb->addOrderBy('t.label','DESC'); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
503 |
$reverse_sort = "laba"; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
504 |
break; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
505 |
case "laba": |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
506 |
$qb->addOrderBy('t.normalizedLabel','ASC'); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
507 |
$qb->addOrderBy('t.label','ASC'); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
508 |
$reverse_sort = "labd"; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
509 |
break; |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
510 |
} |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
511 |
|
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
512 |
// We paginate |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
513 |
$adapter = new DoctrineORMAdapter($qb); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
514 |
$pagerfanta = new Pagerfanta($adapter); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
515 |
$pagerfanta->setMaxPerPage($nb_by_page); // 10 by default |
|
11
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
516 |
//$last_page = $pagerfanta->getNbPages(); |
|
9
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
517 |
$pagerfanta->setCurrentPage($num_page); // 1 by default |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
518 |
$nb_total = $pagerfanta->getNbResults(); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
519 |
$tags = $pagerfanta->getCurrentPageResults(); |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
520 |
$pagerfanta->haveToPaginate(); // whether the number of results if higher than the max per page |
|
cc32af725176
first step for tag list and add Pagerfanta for paginator
cavaliet
parents:
8
diff
changeset
|
521 |
|
|
11
5f038a505cd7
Debug Category on tag list and document. Finish pagination for tag list.
cavaliet
parents:
10
diff
changeset
|
522 |
return array($tags, $num_page, $nb_by_page, $searched, $sort, $reverse_sort, $pagerfanta); |
| 7 | 523 |
} |
| 2 | 524 |
|
525 |
||
526 |
} |