Controller/WikiTagController.php
changeset 7 7a877de630fd
parent 5 45378793512a
child 8 7d2fb5d7c9ff
equal deleted inserted replaced
6:2dcfef6e75c3 7:7a877de630fd
    44         $cats = $this->getDoctrine()->getRepository('WikiTagBundle:Category')->findOrderedCategories();
    44         $cats = $this->getDoctrine()->getRepository('WikiTagBundle:Category')->findOrderedCategories();
    45         // $cats is {"Label":"Créateur"},{"Label":"Datation"},...
    45         // $cats is {"Label":"Créateur"},{"Label":"Datation"},...
    46         $nbCats = count($cats);
    46         $nbCats = count($cats);
    47         $ar = array('' => '');
    47         $ar = array('' => '');
    48         for($i=0;$i<$nbCats;$i++){
    48         for($i=0;$i<$nbCats;$i++){
    49             $temp = array($cats[$i]["Label"] => $cats[$i]["Label"]);
    49             $temp = array($cats[$i]["label"] => $cats[$i]["label"]);
    50             $ar = array_merge($ar, $temp);
    50             $ar = array_merge($ar, $temp);
    51         }
    51         }
    52         // ... so we create is json like {"":""},{"Créateur":"Créateur"},{"Datation":"Datation"},...
    52         // ... so we create is json like {"":""},{"Créateur":"Créateur"},{"Datation":"Datation"},...
    53         $categories = json_encode($ar);
    53         $categories = json_encode($ar);
    54         return $this->render('WikiTagBundle:WikiTag:javascript.html.twig', array('categories' => $categories));
    54         return $this->render('WikiTagBundle:WikiTag:javascript.html.twig', array('categories' => $categories));
    55     }
       
    56 
       
    57     /**
       
    58      * List all tags for doc
       
    59      * TODO: doc_id as parameter
       
    60      * TODO: Is this controller usefull ?
       
    61      */
       
    62     public function allTagsAction()
       
    63     {
       
    64         $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findAll();
       
    65         return $this->render('WikiTagBundle:WikiTag:documentTags.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => 1));
       
    66     }
    55     }
    67 
    56 
    68     /**
    57     /**
    69      * Display a list of ordered tag for a document
    58      * Display a list of ordered tag for a document
    70      * @param integer $id_doc
    59      * @param integer $id_doc
   188         return $this->renderDocTags($id_doc);
   177         return $this->renderDocTags($id_doc);
   189     }
   178     }
   190 
   179 
   191     /**
   180     /**
   192      *
   181      *
   193      * TODO: Enter description here ...
   182      * @Route("/wtrtd")
   194      */
       
   195     public function resetWpInfoAction()
       
   196     {
       
   197         $id_doc = $this->getRequest()->request->get('wikitag_document_id');
       
   198         return $this->renderDocTags($id_doc);
       
   199     }
       
   200 
       
   201     /**
       
   202      *
       
   203      * TODO : Enter description here ...
   183      * TODO : Enter description here ...
       
   184      * TODO : implement
   204      */
   185      */
   205     public function reorderTagDocumentAction()
   186     public function reorderTagDocumentAction()
   206     {
   187     {
   207         $id_Doc = $this->getRequest()->request->get('wikitag_document_id');
   188         $id_Doc = $this->getRequest()->request->get('wikitag_document_id');
   208         return $this->renderDocTags($id_doc);
   189         return $this->renderDocTags($id_doc);
   303     }
   284     }
   304 
   285 
   305 
   286 
   306     /**
   287     /**
   307      *
   288      *
   308      * TODO : Enter description here ...
       
   309      * TODO : implement
       
   310      * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
       
   311      */
       
   312     public function updateTagAliasAction()
       
   313     {
       
   314         $id_doc = $this->getRequest()->request->get('wikitag_document_id');
       
   315         return $this->renderDocTags($id_doc);
       
   316     }
       
   317 
       
   318 
       
   319     /**
       
   320      *
       
   321      * TODO: Enter description here ...
   289      * TODO: Enter description here ...
   322      */
   290      */
   323     public function updateTagCategoryAction()
   291     public function updateTagCategoryAction()
   324     {
   292     {
   325         $id_doc = $this->getRequest()->request->get('wikitag_document_id');
   293         $id_doc = $this->getRequest()->request->get('wikitag_document_id');
   350     public function renderDocTags($id_doc)
   318     public function renderDocTags($id_doc)
   351     {
   319     {
   352         $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc);
   320         $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc);
   353         return $this->render('WikiTagBundle:WikiTag:tagTable.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc));
   321         return $this->render('WikiTagBundle:WikiTag:tagTable.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc));
   354     }
   322     }
       
   323     
       
   324     /**
       
   325      * 
       
   326      * @Route("/wtrwi")
       
   327      * TODO: Enter description here ...
       
   328      * TODO : implement
       
   329      */
       
   330     public function resetWpInfoAction()
       
   331     {
       
   332         $id_doc = $this->getRequest()->request->get('wikitag_document_id');
       
   333         return $this->renderDocTags($id_doc);
       
   334     }
       
   335 
       
   336 
       
   337     /**
       
   338      *
       
   339      * TODO : Enter description here ...
       
   340      * TODO : implement
       
   341      * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
       
   342      */
       
   343     public function updateTagAliasAction()
       
   344     {
       
   345         $id_doc = $this->getRequest()->request->get('wikitag_document_id');
       
   346         return $this->renderDocTags($id_doc);
       
   347     }
       
   348     
       
   349     /**
       
   350      * List of all tags
       
   351      * TODO: Enter description here ...
       
   352      */
       
   353     public function allTagsAction()
       
   354     {
       
   355         $tags = $this->getDoctrine()->getRepository('WikiTagBundle:WikiTagTag')->findAll();
       
   356         // $this->getRequest()->query->get('foo') does not work "because" we are a second controller. So we have to use $_GET.
       
   357         $toto = null;
       
   358         if(array_key_exists('toto', $_GET)){
       
   359             $toto = $_GET['toto'];
       
   360         }
       
   361         return $this->render('WikiTagBundle:WikiTag:TagList.html.twig', array('tags' => $tags, 'toto' => $toto));
       
   362     }
   355 
   363 
   356 
   364 
   357 }
   365 }