Merge
authorcavaliet
Mon, 28 Nov 2011 12:31:32 +0100
changeset 48 16b5fd8d5405
parent 47 34718ebfb3c0 (diff)
parent 45 e25a00a6f9e1 (current diff)
child 49 e854d8cb376c
Merge
Resources/public/js/wikiTag.js
--- a/Controller/WikiTagController.php	Sun Nov 27 23:48:40 2011 +0100
+++ b/Controller/WikiTagController.php	Mon Nov 28 12:31:32 2011 +0100
@@ -90,10 +90,17 @@
      * Display a list of ordered tag for a document
      * @param integer $id_doc
      */
-    public function documentTagsAction($id_doc)
+    public function documentTagsAction($id_doc, $profile_name="")
     {
+        // Management of profiles for the list of displayed columns and reorder tag button
+        $profile_array = $this->container->getParameter("wiki_tag.document_list_profile");
+        $columns_array = null;
+        if($profile_array!=null && $profile_name!=null && $profile_name!=""){
+            $columns_array = $profile_array[$profile_name];
+        }
+        
         $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc);
-        return $this->render('WikiTagBundle:WikiTag:documentTags.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc));
+        return $this->render('WikiTagBundle:WikiTag:documentTags.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc, 'profile_name' => $profile_name, 'columns' => $columns_array));
     }
 
     /**
@@ -397,7 +404,7 @@
     public function renderDocTags($id_doc)
     {
         $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc);
-        return $this->render('WikiTagBundle:WikiTag:tagTable.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc));
+        return $this->render('WikiTagBundle:WikiTag:tagTable.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc, 'columns' => null));
     }
 
 
@@ -530,7 +537,7 @@
         $id_moved_tag = $this->getRequest()->request->get('tag_id');
         $moved_tag = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->findOneBy(array('id' => $id_moved_tag));
         // We update the tag label and its wikipedia info with the original label.
-        $this->updateTagWithNewLabel($moved_tag, $moved_tag->getOriginalLabel());
+        return $this->updateTagWithNewLabel($moved_tag, $moved_tag->getOriginalLabel());
         
         // We render the tag list.
         $num_page = $this->getRequest()->request->get('num_page');
@@ -551,9 +558,7 @@
                 // We get the Wikipedia informations for the sent label
                 $tag_label_normalized = WikiTagUtils::normalizeTag($label);
                 $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized);
-                
                 $tag->setWikipediaInfo($wp_response);
-
                 // Save datas.
                 $em = $this->getDoctrine()->getEntityManager();
                 $em->persist($tag);
@@ -615,7 +620,7 @@
         // We add the search string if necessary
         if($searched!=""){
             // We replace "*" by "%", and doctrine wants ' to be ''.
-            $qb->where($qb->expr()->orx($qb->expr()->like('t.normalizedLabel', "'".str_replace("'", "''", str_replace("*", "%", $searched))."'")));
+            $qb->where($qb->expr()->orx($qb->expr()->like('t.normalizedLabel', "'".str_replace("'", "''", str_replace("*", "%", str_replace("+", " ", $searched)))."'")));
         }
         //return $qb->getDql();
         
--- a/DependencyInjection/Configuration.php	Sun Nov 27 23:48:40 2011 +0100
+++ b/DependencyInjection/Configuration.php	Mon Nov 28 12:31:32 2011 +0100
@@ -58,6 +58,13 @@
                     ->useAttributeAsKey('name')
                     ->prototype('variable')
                     ->end()
+                ->end()
+                ->arrayNode('document_list_profile')
+                    ->treatNullLike(array())
+                    ->useAttributeAsKey('name')
+                    ->prototype('variable')
+                    ->end()
+                ->end()
             ->end();
         
         return $treeBuilder;
--- a/DependencyInjection/WikiTagExtension.php	Sun Nov 27 23:48:40 2011 +0100
+++ b/DependencyInjection/WikiTagExtension.php	Mon Nov 28 12:31:32 2011 +0100
@@ -46,5 +46,6 @@
         $container->setParameter("wiki_tag.fields_all", $fields);
         $container->setParameter("wiki_tag.route_for_documents_by_tag", $config['route_for_documents_by_tag']);
         $container->setParameter("wiki_tag.reactive_selectors", $config['reactive_selectors']);
+        $container->setParameter("wiki_tag.document_list_profile", $config['document_list_profile']);
     }
 }
--- a/Resources/public/js/wikiTag.js	Sun Nov 27 23:48:40 2011 +0100
+++ b/Resources/public/js/wikiTag.js	Mon Nov 28 12:31:32 2011 +0100
@@ -31,8 +31,9 @@
     	tooltip   : "Cliquer pour éditer...",
     	onblur    : "submit",
     	submitdata: {
-            csrfmiddlewaretoken:global_csrf_token, 
+            csrfmiddlewaretoken:global_csrf_token,
             wikitag_document_id:$('#wikitag_document_id').val(),
+            wikitag_document_profile:$('#wikitag_document_profile').val(),
             num_page:(('num_page' in getUrlVars()) ? getUrlVars()['num_page'] : undefined),
             nb_by_page:(('nb_by_page' in getUrlVars()) ? getUrlVars()['nb_by_page'] : undefined),
             sort:((('sort' in getUrlVars()) && (typeof(getUrlVars()['sort'])=="string")) ? getUrlVars()['sort'] : undefined),
@@ -87,8 +88,9 @@
     	tooltip   : "Cliquer pour éditer...",
     	onblur    : "submit",
     	submitdata: {
-            csrfmiddlewaretoken:global_csrf_token, 
+            csrfmiddlewaretoken:global_csrf_token,
             wikitag_document_id:$('#wikitag_document_id').val(),
+            wikitag_document_profile:$('#wikitag_document_profile').val(),
             num_page:(('num_page' in getUrlVars()) ? getUrlVars()['num_page'] : undefined),
             nb_by_page:(('nb_by_page' in getUrlVars()) ? getUrlVars()['nb_by_page'] : undefined),
             sort:((('sort' in getUrlVars()) && (typeof(getUrlVars()['sort'])=="string")) ? getUrlVars()['sort'] : undefined),
@@ -111,6 +113,7 @@
     	submitdata: {
             csrfmiddlewaretoken:global_csrf_token,
             wikitag_document_id:$('#wikitag_document_id').val(),
+            wikitag_document_profile:$('#wikitag_document_profile').val(),
             num_page:(('num_page' in getUrlVars()) ? getUrlVars()['num_page'] : undefined),
             nb_by_page:(('nb_by_page' in getUrlVars()) ? getUrlVars()['nb_by_page'] : undefined),
             sort:((('sort' in getUrlVars()) && (typeof(getUrlVars()['sort'])=="string")) ? getUrlVars()['sort'] : undefined),
@@ -138,6 +141,7 @@
                         type: 'POST',
                         data: {csrfmiddlewaretoken:global_csrf_token, 
                                wikitag_document_id:$('#wikitag_document_id').val(),
+                               wikitag_document_profile:$('#wikitag_document_profile').val(),
                                new_order:new_order,
                                old_order:old_order
                                },
@@ -270,7 +274,6 @@
                 },
                 success: function( data ) {
                     response( $.map( data["query"]["search"], function( item ) {
-                    	console.log(item);
                         return {
                             label: item["title"],
                             snippet: item["snippet"],
@@ -307,7 +310,7 @@
             add_tag($("#wikitag_wp_search_context").val());
         }
     });
-};
+}
 
 function wikitag_update_tag(btn)
 {
@@ -334,6 +337,7 @@
         type: 'POST',
         data: {csrfmiddlewaretoken:global_csrf_token, 
                wikitag_document_id:$('#wikitag_document_id').val(),
+               wikitag_document_profile:$('#wikitag_document_profile').val(),
                num_page:(('num_page' in getUrlVars()) ? getUrlVars()['num_page'] : undefined),
                nb_by_page:(('nb_by_page' in getUrlVars()) ? getUrlVars()['nb_by_page'] : undefined),
                sort:((('sort' in getUrlVars()) && (typeof(getUrlVars()['sort'])=="string")) ? getUrlVars()['sort'] : undefined),
@@ -371,6 +375,7 @@
         type: 'POST',
         data: {csrfmiddlewaretoken:global_csrf_token, 
                wikitag_document_id:$('#wikitag_document_id').val(),
+               wikitag_document_profile:$('#wikitag_document_profile').val(),
                tag_id:id_tag,
                move:mv,
                tag_pos:pos_tag
@@ -393,6 +398,7 @@
         type: 'POST',
         data: {csrfmiddlewaretoken:global_csrf_token,
                wikitag_document_id:$('#wikitag_document_id').val(),
+               wikitag_document_profile:$('#wikitag_document_profile').val(),
                value:tag_label
                },
         // bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType
@@ -424,7 +430,8 @@
 		type: 'POST',
 		data: {
 			csrfmiddlewaretoken:global_csrf_token,
-            wikitag_document_id:$('#wikitag_document_id').val()
+            wikitag_document_id:$('#wikitag_document_id').val(),
+            wikitag_document_profile:$('#wikitag_document_profile').val()
 		},
         success: function(msg, textStatus, XMLHttpRequest) {
             $('#wikitag_table_container').html(msg);
--- a/Resources/views/WikiTag/documentTags.html.twig	Sun Nov 27 23:48:40 2011 +0100
+++ b/Resources/views/WikiTag/documentTags.html.twig	Mon Nov 28 12:31:32 2011 +0100
@@ -6,6 +6,7 @@
       <span>Ajouter un tag : <input type="text" name="wikitag_wp_search" id="wikitag_wp_search" size="35" /> <span id="wikitag_ok_search" class="wikitag_hand_cursor"><b>OK</b></span></span>
     </div>
     <input type="hidden" name="wikitag_document_id" value="{{ doc_id }}" id="wikitag_document_id" />
+    <input type="hidden" name="wikitag_document_profile" value="{{ profile_name }}" id="wikitag_document_profile" />
 </div>
 <div id="wikitag_table_container" style="float:left; width: 100%">
   {% include 'WikiTagBundle:WikiTag:tagTable.html.twig' %}
--- a/Resources/views/WikiTag/tagTable.html.twig	Sun Nov 27 23:48:40 2011 +0100
+++ b/Resources/views/WikiTag/tagTable.html.twig	Mon Nov 28 12:31:32 2011 +0100
@@ -1,23 +1,54 @@
 {# partial display document's tags (table only) #}
   <table id="wikitag_table">
     <tr class="nodrop nodrag">
+  {% if columns is null or "order" in columns %}
     <th>#</th>
+  {% endif %}
+  {% if columns is null or "move_up_down" in columns %}
     <th><img src="{{ asset('bundles/wikitag/images/arrow_up_down.png') }}"/></th>
+  {% endif %}
+  {% if columns is null or "id" in columns %}
     <th>id</th>
+  {% endif %}
+  {% if columns is null or "label" in columns %}
     <th>label</th>
+  {% endif %}
+  {% if columns is null or "wikipedia_link" in columns %}
     <th class="wikitag_text_centered">Lien W</th>
+  {% endif %}
+  {% if columns is null or "wikipedia_permalink" in columns %}
     <th class="wikitag_text_centered">pLien W</th>
+  {% endif %}
+  {% if columns is null or "dbpedia_link" in columns %}
     <th class="wikitag_text_centered">Lien D</th>
+  {% endif %}
+  {% if columns is null or "category" in columns %}
     <th>Catégorie</th>
+  {% endif %}
+  {% if columns is null or "remove_wikipedia_link" in columns %}
     <th class="wikitag_large_25 wikitag_text_centered">Supprimer<br/>le lien W</th>
+  {% endif %}
+  {% if columns is null or "alias" in columns %}
     <th>Alias</th>
+  {% endif %}
+  {% if columns is null or "remove_tag_from_list" in columns %}
     <th class="wikitag_large_25 wikitag_text_centered">Retirer le tag</th></tr>
+  {% endif %}
     {% for t in ordered_tags %}
         <tr class="imageline {{ cycle(['wikitag_oddline', 'wikitag_evenline'], loop.index) }}" id="{{loop.index}}">
+      {% if columns is null or "order" in columns %}
         <td>{{loop.index}}</td>
+      {% endif  %}
+      {% if columns is null or "move_up_down" in columns %}
         <td class="wikitag_updown_td wikitag_text_centered"><img src="{{ asset('bundles/wikitag/images/arrow_up_down.png') }}" class="updown" alt="updown" id={{t.tag.id}} pos="{{loop.index0}}"></td>
+      {% endif  %}
+      {% if columns is null or "id" in columns %}
         <td>{{t.tag.id}}</td>
+      {% endif  %}
+      {% if columns is null or "label" in columns %}
         <td class="wikitag_{{t.tag.urlstatustext}} wikipediatag" id="{{t.tag.id}}" >{{t.tag.label}}</td>
+      {% endif  %}
+      {% if columns is null or "wikipedia_link" in columns %}
         <td class="wikitag_text_centered">
             {% if t.tag.wikipediaurl and t.tag.wikipediaurl != ""  %}
             <a href="{{t.tag.wikipediaurl}}" target="_blank"><img src="{{ asset('bundles/wikitag/images/arrow_right.png') }}" ></a>
@@ -25,6 +56,8 @@
             <a href="http://fr.wikipedia.org/w/index.php?search={{t.tag.label}}" target="_blank"><img src="{{ asset('bundles/wikitag/images/wikipedia_search.png') }}" ></a>
             {% endif %}
         </td>
+      {% endif  %}
+      {% if columns is null or "wikipedia_permalink" in columns %}
         <td class="wikitag_text_centered">
             {% if t.wikipediarevisionid  %}
             <a href="{{t.wikipediaversionpermalink}}" target="_blank"><img src="{{ asset('bundles/wikitag/images/clock_arrow.png') }}" ></a>
@@ -32,6 +65,8 @@
             &nbsp;
             {% endif %}
         </td>
+      {% endif  %}
+      {% if columns is null or "dbpedia_link" in columns %}
         <td class="wikitag_text_centered">
             {% if t.tag.dbpediauri and t.tag.dbpediauri != ""  %}
             <a href="{{t.tag.dbpediauri}}" target="_blank"><img src="{{ asset('bundles/wikitag/images/arrow_green_right.png') }}" ></a>
@@ -39,9 +74,18 @@
             &nbsp;
             {% endif %}
         </td>
+      {% endif  %}
+      {% if columns is null or "category" in columns %}
         <td class="wikitag_category" id="{{t.tag.id}}">{% if t.tag.category %}{{ t.tag.category.label }}{% endif %}</td>
+      {% endif  %}
+      {% if columns is null or "remove_wikipedia_link" in columns %}
         <td class="wikitag_text_centered"><img src="{{ asset('bundles/wikitag/images/red_cross.png') }}" class="wikitag_remove_wp_link" id="{{t.tag.id}}" alt="{{t.tag.label}}" /></td>
+      {% endif  %}
+      {% if columns is null or "alias" in columns %}
         <td>{% if t.tag.alias %}{{t.tag.alias}}{% endif %}</td>
+      {% endif  %}
+      {% if columns is null or "remove_tag_from_list" in columns %}
         <td class="wikitag_text_centered"><img src="{{ asset('bundles/wikitag/images/tag_remove.png') }}" class="wikitag_remove_tag_from_list" id="{{t.tag.id}}" alt="{{t.tag.label}}" /></td></tr>
+      {% endif  %}
     {% endfor %}
   </table>