Controller/WikiTagController.php
changeset 43 54f204bceb28
parent 42 0e57c730bb18
child 47 34718ebfb3c0
--- a/Controller/WikiTagController.php	Fri Nov 25 18:55:42 2011 +0100
+++ b/Controller/WikiTagController.php	Sun Nov 27 22:36:21 2011 +0100
@@ -45,15 +45,17 @@
 
     /**
      * Renders the little html to add the javascript
-     * TODO: review why this injection in javascript, t10n?
+     *
+     * @param unknown_type $tags_list
+     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
      */
-    public function addJavascriptAction($tags_list=FALSE)
+    public function addJavascriptAction($tags_list=false)
     {
         $cats = $this->getDoctrine()->getRepository('WikiTagBundle:Category')->findOrderedCategories();
         // $cats is {"Label":"Créateur"},{"Label":"Datation"},...
         $nbCats = count($cats);
         $ar = array('' => '');
-        for($i=0;$i<$nbCats;$i++){
+        for($i=0;$i<$nbCats;$i++) {
             $temp = array($cats[$i]["label"] => $cats[$i]["label"]);
             $ar = array_merge($ar, $temp);
         }
@@ -138,8 +140,7 @@
     }
 
     /**
-     *
-     * TODO: Enter description here ...
+     * Action to remove a tag from a document tag list
      * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
      */
     public function removeTagFromListAction()
@@ -148,7 +149,6 @@
         $id_tag = $this->getRequest()->request->get('tag_id');
         // We get the DocumentTag meant to be deleted, and remove it.
         $em = $this->getDoctrine()->getEntityManager();
-        //TODO: use external id
         
         $dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneByDocumentExternalId($id_doc, array('tag' => $id_tag));
         $em->remove($dt);
@@ -281,7 +281,6 @@
             // The result is a double array. And reset(reset($newOrderAr)) is not allowed. And a string is returned.
             $a1 = reset($new_order_ar);
             $new_order = intval(reset($a1)) + 1;
-            // TODO: use a factory that returns an DocumentTagInterface
             $new_DT = new DocumentTag();
             $new_DT->setDocument($this->getDoctrine()->getRepository('WikiTagBundle:Document')->findOneByExternalId($id_doc));
             $new_DT->setTag($tag);
@@ -297,8 +296,8 @@
 
 
     /**
+     * Action to remove the wikipedia link form a tag. This action create a copy of the original tag with all the link to wikipedia set to null.
      *
-     * TODO: Enter description here ...
      * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
      */
     public function removeWpLinkAction()
@@ -313,19 +312,21 @@
         $un_tag_created = FALSE;
         if(!$un_tag){
             // Create another tag almost identical, without the W info
-            // TODO: use a factory that return a TagInterface
             $un_tag = new Tag();
             $un_tag->setLabel($tag->getLabel());
             $un_tag->setOriginalLabel($tag->getOriginalLabel());
             $un_tag->setUrlStatus(Tag::$TAG_URL_STATUS_DICT['null_result']);
             $un_tag->setWikipediaUrl(null);
             $un_tag->setWikipediaPageId(null);
+            $un_tag->setAlternativeWikipediaUrl(null);
+            $un_tag->setAlternativeWikipediaPageId(null);
+            $un_tag->setAlternativeLabel(null);
             $un_tag->setDbpediaUri(null);
             $un_tag->setCategory($tag->getCategory());
             $un_tag->setAlias($tag->getAlias());
             $un_tag->setPopularity($tag->getPopularity());
             $em->persist($un_tag);
-            $un_tag_created = TRUE;
+            $un_tag_created = true;
         }
         
         if($id_doc && $id_doc!=""){
@@ -354,8 +355,8 @@
 
 
     /**
-     *
-     * TODO: Enter description here ...
+     * Action to update a tag category.
+     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
      */
     public function updateTagCategoryAction()
     {
@@ -401,9 +402,8 @@
 
 
     /**
-     *
-     * TODO : Enter description here ...
-     * TODO : implement
+     * Action to update the tag alias.
+	 *
      * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
      */
     public function updateTagAliasAction()
@@ -432,8 +432,9 @@
     }
     
     /**
-     * List of all tags
-     * TODO: Enter description here ...
+     * List all tags, with pagination and search.
+     *
+     * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
      */
     public function allTagsAction()
     {