Controller/WikiTagController.php
changeset 42 0e57c730bb18
parent 37 9ba15af20acc
child 43 54f204bceb28
--- a/Controller/WikiTagController.php	Fri Nov 18 17:54:30 2011 +0100
+++ b/Controller/WikiTagController.php	Fri Nov 25 18:55:42 2011 +0100
@@ -96,7 +96,8 @@
 
     /**
      *
-     * TODO : Enter description here ...
+     * The action called when a tag is moved in a document tag list.
+     *
      * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
      */
     public function tagUpDownAction()
@@ -185,7 +186,7 @@
                 return new Response(json_encode(array('error' => 'duplicate_tag', 'message' => sprintf("Le tag %s existe déjà pour cette fiche.", $tag_label))),400);
             }
             // We create the new tag or get the already existing tag. $tag, $revision_id, $created
-            $ar = WikiTagUtils::getOrCreateTag($tag_label, $this->getDoctrine());
+            $ar = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->getOrCreateTag($tag_label);
             $tag = $ar[0];
             $revision_id = $ar[1];
             $created = $ar[2];
@@ -220,9 +221,8 @@
     }
 
     /**
-     *
-     * TODO : Enter description here ...
-     * TODO : implement
+     * The action called to reorder the the tags of a document. The tags are reordered according to the indexation score of the tag label on the document.
+     * The fields taken into account for calculating the score are defined in the wikitag configuration.
      */
     public function reorderTagDocumentAction()
     {
@@ -243,8 +243,7 @@
     }
 
     /**
-     *
-     * TODO: Enter description here ...
+     * The action called to add a new tag (especially from the completion box)
      */
     public function addTagAction()
     {
@@ -269,7 +268,7 @@
             return new Response(json_encode(array('error' => 'duplicate_tag', 'message' => sprintf("Le tag %s existe déjà pour cette fiche.", $tag_label))),400);
         }
         // returns array($tag, $revision_id, $created)
-        $ar = WikiTagUtils::getOrCreateTag($tag_label, $this->getDoctrine());// tag, revision_id, created = get_or_create_tag(tag_label)
+        $ar = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->getOrCreateTag($tag_label);// tag, revision_id, created = get_or_create_tag(tag_label)
         $tag = $ar[0];
         $revision_id = $ar[1];
         $created = $ar[2];
@@ -551,22 +550,9 @@
                 // We get the Wikipedia informations for the sent label
                 $tag_label_normalized = WikiTagUtils::normalizeTag($label);
                 $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized);
-                $new_label = $wp_response['new_label'];
-                $status = $wp_response['status'];
-                $url = $wp_response['wikipedia_url'];
-                $pageid = $wp_response['pageid'];
-                $dbpedia_uri = $wp_response["dbpedia_uri"];
-                $wikipedia_revision_id = $wp_response['revision_id'];
-                // We save the datas : we DO NOT create a new tag, we change the current tag's informations
-                if($new_label!=null){
-                    $tag->setLabel($new_label);
-                }
-                if($status!=null){
-                    $tag->setUrlStatus($status);
-                }
-                $tag->setWikipediaUrl($url);
-                $tag->setWikipediaPageId($pageid);
-                $tag->setDbpediaUri($dbpedia_uri);
+                
+                $tag->setWikipediaInfo($wp_response);
+
                 // Save datas.
                 $em = $this->getDoctrine()->getEntityManager();
                 $em->persist($tag);