86 |
86 |
87 /** |
87 /** |
88 * Display a list of ordered tag for a document |
88 * Display a list of ordered tag for a document |
89 * @param integer $id_doc |
89 * @param integer $id_doc |
90 */ |
90 */ |
91 public function documentTagsAction($id_doc) |
91 public function documentTagsAction($id_doc, $profile_name="") |
92 { |
92 { |
|
93 // Management of profiles for the list of displayed columns and reorder tag button |
|
94 $profile_array = $this->container->getParameter("wiki_tag.document_list_profile"); |
|
95 $columns_array = null; |
|
96 if($profile_array!=null && $profile_name!=null && $profile_name!=""){ |
|
97 $columns_array = $profile_array[$profile_name]; |
|
98 } |
|
99 |
93 $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); |
100 $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); |
94 return $this->render('WikiTagBundle:WikiTag:documentTags.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc)); |
101 return $this->render('WikiTagBundle:WikiTag:documentTags.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc, 'profile_name' => $profile_name, 'columns' => $columns_array)); |
95 } |
102 } |
96 |
103 |
97 /** |
104 /** |
98 * |
105 * |
99 * TODO : Enter description here ... |
106 * TODO : Enter description here ... |
395 * @param unknown_type $id_doc |
402 * @param unknown_type $id_doc |
396 */ |
403 */ |
397 public function renderDocTags($id_doc) |
404 public function renderDocTags($id_doc) |
398 { |
405 { |
399 $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); |
406 $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); |
400 return $this->render('WikiTagBundle:WikiTag:tagTable.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc)); |
407 return $this->render('WikiTagBundle:WikiTag:tagTable.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc, 'columns' => null)); |
401 } |
408 } |
402 |
409 |
403 |
410 |
404 /** |
411 /** |
405 * |
412 * |
528 public function resetWpInfoAction() |
535 public function resetWpInfoAction() |
529 { |
536 { |
530 $id_moved_tag = $this->getRequest()->request->get('tag_id'); |
537 $id_moved_tag = $this->getRequest()->request->get('tag_id'); |
531 $moved_tag = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->findOneBy(array('id' => $id_moved_tag)); |
538 $moved_tag = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->findOneBy(array('id' => $id_moved_tag)); |
532 // We update the tag label and its wikipedia info with the original label. |
539 // We update the tag label and its wikipedia info with the original label. |
533 $this->updateTagWithNewLabel($moved_tag, $moved_tag->getOriginalLabel()); |
540 return $this->updateTagWithNewLabel($moved_tag, $moved_tag->getOriginalLabel()); |
534 |
541 |
535 // We render the tag list. |
542 // We render the tag list. |
536 $num_page = $this->getRequest()->request->get('num_page'); |
543 $num_page = $this->getRequest()->request->get('num_page'); |
537 $nb_by_page = $this->getRequest()->request->get('nb_by_page'); |
544 $nb_by_page = $this->getRequest()->request->get('nb_by_page'); |
538 $sort = $this->getRequest()->request->get('sort'); |
545 $sort = $this->getRequest()->request->get('sort'); |
549 if($tag!=null && $label!=null){ |
556 if($tag!=null && $label!=null){ |
550 if($label!=$tag->getLabel()){ |
557 if($label!=$tag->getLabel()){ |
551 // We get the Wikipedia informations for the sent label |
558 // We get the Wikipedia informations for the sent label |
552 $tag_label_normalized = WikiTagUtils::normalizeTag($label); |
559 $tag_label_normalized = WikiTagUtils::normalizeTag($label); |
553 $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized); |
560 $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized); |
554 $new_label = $wp_response['new_label']; |
561 //return new Response(var_dump($wp_response)); |
|
562 $new_label = $tag_label_normalized; |
555 $status = $wp_response['status']; |
563 $status = $wp_response['status']; |
556 $url = $wp_response['wikipedia_url']; |
564 $url = $wp_response['wikipedia_url']; |
557 $pageid = $wp_response['pageid']; |
565 $pageid = $wp_response['pageid']; |
558 $dbpedia_uri = $wp_response["dbpedia_uri"]; |
566 $dbpedia_uri = $wp_response["dbpedia_uri"]; |
559 $wikipedia_revision_id = $wp_response['revision_id']; |
567 $wikipedia_revision_id = $wp_response['revision_id']; |
560 // We save the datas : we DO NOT create a new tag, we change the current tag's informations |
568 // We save the datas : we DO NOT create a new tag, we change the current tag's informations |
561 if($new_label!=null){ |
569 if($new_label!=null){ |
562 $tag->setLabel($new_label); |
570 $tag->setLabel($new_label); |
563 } |
571 } |
564 if($status!=null){ |
572 else{ |
|
573 $tag->setLabel($tag_label_normalized); |
|
574 } |
|
575 if(!is_null($status)){ |
565 $tag->setUrlStatus($status); |
576 $tag->setUrlStatus($status); |
|
577 } |
|
578 else{ |
|
579 $tag->setUrlStatus(Tag::$TAG_URL_STATUS_DICT['null_result']); |
566 } |
580 } |
567 $tag->setWikipediaUrl($url); |
581 $tag->setWikipediaUrl($url); |
568 $tag->setWikipediaPageId($pageid); |
582 $tag->setWikipediaPageId($pageid); |
569 $tag->setDbpediaUri($dbpedia_uri); |
583 $tag->setDbpediaUri($dbpedia_uri); |
570 // Save datas. |
584 // Save datas. |
626 $qb->addGroupBy('t.id'); |
640 $qb->addGroupBy('t.id'); |
627 |
641 |
628 // We add the search string if necessary |
642 // We add the search string if necessary |
629 if($searched!=""){ |
643 if($searched!=""){ |
630 // We replace "*" by "%", and doctrine wants ' to be ''. |
644 // We replace "*" by "%", and doctrine wants ' to be ''. |
631 $qb->where($qb->expr()->orx($qb->expr()->like('t.normalizedLabel', "'".str_replace("'", "''", str_replace("*", "%", $searched))."'"))); |
645 $qb->where($qb->expr()->orx($qb->expr()->like('t.normalizedLabel', "'".str_replace("'", "''", str_replace("*", "%", str_replace("+", " ", $searched)))."'"))); |
632 } |
646 } |
633 //return $qb->getDql(); |
647 //return $qb->getDql(); |
634 |
648 |
635 // We add the sorting criteria |
649 // We add the sorting criteria |
636 if($sort==NULL){ |
650 if($sort==NULL){ |