# HG changeset patch # User cavaliet # Date 1322479196 -3600 # Node ID 34718ebfb3c0b4875239f6e27d997eb132134719 # Parent 6f643fc1de26d521dbfea7b2d2b929f480029b83# Parent 54f204bceb28e10bb1f9776e5d6bbde138d6aa35 merge diff -r 54f204bceb28 -r 34718ebfb3c0 .hgtags diff -r 54f204bceb28 -r 34718ebfb3c0 Command/CreateFullTextIndexesCommand.php diff -r 54f204bceb28 -r 34718ebfb3c0 Command/GenerateDocumentClassCommand.php diff -r 54f204bceb28 -r 34718ebfb3c0 Command/PurgeTagsCommand.php diff -r 54f204bceb28 -r 34718ebfb3c0 Command/QueryWikipediaCommand.php diff -r 54f204bceb28 -r 34718ebfb3c0 Command/ReorderTagsCommand.php diff -r 54f204bceb28 -r 34718ebfb3c0 Controller/WikiTagController.php --- a/Controller/WikiTagController.php Sun Nov 27 22:36:21 2011 +0100 +++ b/Controller/WikiTagController.php Mon Nov 28 12:19:56 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(); diff -r 54f204bceb28 -r 34718ebfb3c0 DependencyInjection/Configuration.php --- a/DependencyInjection/Configuration.php Sun Nov 27 22:36:21 2011 +0100 +++ b/DependencyInjection/Configuration.php Mon Nov 28 12:19:56 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; diff -r 54f204bceb28 -r 34718ebfb3c0 DependencyInjection/WikiTagExtension.php --- a/DependencyInjection/WikiTagExtension.php Sun Nov 27 22:36:21 2011 +0100 +++ b/DependencyInjection/WikiTagExtension.php Mon Nov 28 12:19:56 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']); } } diff -r 54f204bceb28 -r 34718ebfb3c0 Event/DocumentTagEvent.php diff -r 54f204bceb28 -r 34718ebfb3c0 Event/WikiTagEvents.php diff -r 54f204bceb28 -r 34718ebfb3c0 Listener/WikiTagDocumentListener.php diff -r 54f204bceb28 -r 34718ebfb3c0 Resources/meta/LICENSE diff -r 54f204bceb28 -r 34718ebfb3c0 Resources/public/css/wikiTag.css --- a/Resources/public/css/wikiTag.css Sun Nov 27 22:36:21 2011 +0100 +++ b/Resources/public/css/wikiTag.css Mon Nov 28 12:19:56 2011 +0100 @@ -94,6 +94,9 @@ float: none; position: absolute; } +.wikitag_context_static { + width: 300px; +} /* These styles can be changed. */ .wikitag_context_change { width: 260px; @@ -103,5 +106,20 @@ .wikitag_context_change input { width: 250px; } +.wikitag_context_result { + width: 500px !important; +} +.wikitag_context_result_item { + text-indent:-5px; +} +.wikitag_context_result_title { + font-weight: bold; +} +.wikitag_context_result_snippet { + font-size: 11.5px; +} +.searchmatch { + color: #0000ff; +} diff -r 54f204bceb28 -r 34718ebfb3c0 Resources/public/js/wikiTag.js --- a/Resources/public/js/wikiTag.js Sun Nov 27 22:36:21 2011 +0100 +++ b/Resources/public/js/wikiTag.js Mon Nov 28 12:19:56 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 }, @@ -216,87 +220,97 @@ function wikitag_init_search_context_events() { - // We implement the behaviour on text select. Kolich is just an object name, it could be anything - if(!window.Kolich){ - Kolich = {}; - } - Kolich.Selector = {}; - Kolich.Selector.getSelected = function(){ - var t = ''; - if(window.getSelection){ - t = window.getSelection(); - }else if(document.getSelection){ - t = document.getSelection(); - }else if(document.selection){ - t = document.selection.createRange().text; - } - return t; - }; - Kolich.Selector.mouseup = function(e){ - var st = Kolich.Selector.getSelected(); - if(st!=''){ - // Behaviour after the text was selected - $("#wikitag_context_div").offset({left:e.pageX+10,top:e.pageY}); - $("#wikitag_context_div").show(); - $("#wikitag_context_div #wikitag_wp_search_context").val(st); - $("#wikitag_context_div #wikitag_wp_search_context").autocomplete("search"); - } - }; - $(document).ready(function(){ - for(c in reactive_selectors){ - $(reactive_selectors[c]).bind("mouseup", Kolich.Selector.mouseup); - } - }); - - // Function to close the context window - $("#wikitag_context_close").click(function(e){ - $("#wikitag_context_div #wikitag_wp_search_context").autocomplete("close"); - $("#wikitag_context_div").offset({left:0,top:0}); - $("#wikitag_context_div").hide(); - }); - - // Wikipedia search management (new tag) - $("#wikitag_wp_search_context").autocomplete({ - source: function( request, response ) { - $.ajax({ - url: "http://fr.wikipedia.org/w/api.php", - dataType: "jsonp", - data: { - action: "opensearch", - limit: "20", - namespace: "0", - format: "json", - search: request.term - }, - success: function( data ) { - response( $.map( data[1], function( item ) { - return { - label: item, - value: item - }; - })); - } - }); - }, - select: function(event, ui) { - // Since the event still did not update wp_search's val, we force it. - $("#wikitag_wp_search_context").val(ui.item.label); - add_tag($("#wikitag_wp_search_context").val()); - $("#wikitag_context_close").click(); - }, - minLength: 2, - open: function() { - $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); - }, - close: function() { - $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); - } - }); - $('#wikitag_wp_search_context').keyup(function(e){ - if((e.keyCode==13) && ($("#wikitag_wp_search_context").val()!="")){ - add_tag($("#wikitag_wp_search_context").val()); - } - }); + // We implement the behaviour on text select. Kolich is just an object name, it could be anything + if(!window.Kolich){ + Kolich = {}; + } + Kolich.Selector = {}; + Kolich.Selector.getSelected = function(){ + var t = ''; + if(window.getSelection){ + t = window.getSelection(); + }else if(document.getSelection){ + t = document.getSelection(); + }else if(document.selection){ + t = document.selection.createRange().text; + } + return t; + }; + Kolich.Selector.mouseup = function(e){ + var st = Kolich.Selector.getSelected(); + if(st!=''){ + // Behaviour after the text was selected + $("#wikitag_context_div").offset({left:e.pageX+10,top:e.pageY}); + $("#wikitag_context_div").show(); + $("#wikitag_context_div #wikitag_wp_search_context").val(st); + $("#wikitag_context_div #wikitag_wp_search_context").autocomplete("search"); + } + }; + $(document).ready(function(){ + for(c in reactive_selectors){ + $(reactive_selectors[c]).bind("mouseup", Kolich.Selector.mouseup); + } + }); + + // Function to close the context window + $("#wikitag_context_close").click(function(e){ + $("#wikitag_context_div #wikitag_wp_search_context").autocomplete("close"); + $("#wikitag_context_div").offset({left:0,top:0}); + $("#wikitag_context_div").hide(); + }); + + // Wikipedia search management (new tag) + $("#wikitag_wp_search_context").autocomplete({ + source: function( request, response ) { + $.ajax({ + url: "http://fr.wikipedia.org/w/api.php", + dataType: "jsonp", + data: { + action: "query", + limit: "20", + list: "search", + format: "json", + srsearch: request.term + }, + success: function( data ) { + response( $.map( data["query"]["search"], function( item ) { + console.log(item); + return { + label: item["title"], + snippet: item["snippet"], + value: item["title"] + }; + })); + } + }); + }, + select: function(event, ui) { + // Since the event still did not update wp_search's val, we force it. + $("#wikitag_wp_search_context").val(ui.item.label); + add_tag($("#wikitag_wp_search_context").val()); + $("#wikitag_context_close").click(); + }, + minLength: 2, + open: function() { + $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); + // We force width to something not too large + $( this ).autocomplete("widget").addClass("wikitag_context_result"); + }, + close: function() { + $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); + } + }); + $("#wikitag_wp_search_context").data("autocomplete")._renderItem = function( ul, item ) { + return $( "
  • " ) + .data( "item.autocomplete", item ) + .append( ''+ item.label + ' : ' + item.snippet + '' ) + .appendTo( ul ); + }; + $('#wikitag_wp_search_context').keyup(function(e){ + if((e.keyCode==13) && ($("#wikitag_wp_search_context").val()!="")){ + add_tag($("#wikitag_wp_search_context").val()); + } + }); } function wikitag_update_tag(btn) @@ -324,6 +338,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), @@ -361,6 +376,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 @@ -383,6 +399,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 @@ -414,7 +431,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); diff -r 54f204bceb28 -r 34718ebfb3c0 Resources/views/WikiTag/contextSearchDiv.html.twig diff -r 54f204bceb28 -r 34718ebfb3c0 Resources/views/WikiTag/documentTags.html.twig --- a/Resources/views/WikiTag/documentTags.html.twig Sun Nov 27 22:36:21 2011 +0100 +++ b/Resources/views/WikiTag/documentTags.html.twig Mon Nov 28 12:19:56 2011 +0100 @@ -6,6 +6,7 @@ Ajouter un tag : OK +
    {% include 'WikiTagBundle:WikiTag:tagTable.html.twig' %} diff -r 54f204bceb28 -r 34718ebfb3c0 Resources/views/WikiTag/tagTable.html.twig --- a/Resources/views/WikiTag/tagTable.html.twig Sun Nov 27 22:36:21 2011 +0100 +++ b/Resources/views/WikiTag/tagTable.html.twig Mon Nov 28 12:19:56 2011 +0100 @@ -1,23 +1,54 @@ {# partial display document's tags (table only) #} + {% if columns is null or "order" in columns %} + {% endif %} + {% if columns is null or "move_up_down" in columns %} + {% endif %} + {% if columns is null or "id" in columns %} + {% endif %} + {% if columns is null or "label" in columns %} + {% endif %} + {% if columns is null or "wikipedia_link" in columns %} + {% endif %} + {% if columns is null or "wikipedia_permalink" in columns %} + {% endif %} + {% if columns is null or "dbpedia_link" in columns %} + {% endif %} + {% if columns is null or "category" in columns %} + {% endif %} + {% if columns is null or "remove_wikipedia_link" in columns %} + {% endif %} + {% if columns is null or "alias" in columns %} + {% endif %} + {% if columns is null or "remove_tag_from_list" in columns %} + {% endif %} {% for t in ordered_tags %} + {% if columns is null or "order" in columns %} + {% endif %} + {% if columns is null or "move_up_down" in columns %} + {% endif %} + {% if columns is null or "id" in columns %} + {% endif %} + {% if columns is null or "label" in columns %} + {% endif %} + {% if columns is null or "wikipedia_link" in columns %} + {% endif %} + {% if columns is null or "wikipedia_permalink" in columns %} + {% endif %} + {% if columns is null or "dbpedia_link" in columns %} + {% endif %} + {% if columns is null or "category" in columns %} + {% endif %} + {% if columns is null or "remove_wikipedia_link" in columns %} + {% endif %} + {% if columns is null or "alias" in columns %} + {% endif %} + {% if columns is null or "remove_tag_from_list" in columns %} + {% endif %} {% endfor %}
    #idlabelLien WpLien WLien DCatégorieSupprimer
    le lien W
    AliasRetirer le tag
    {{loop.index}}updown{{t.tag.id}}{{t.tag.label}} {% if t.tag.wikipediaurl and t.tag.wikipediaurl != "" %} @@ -25,6 +56,8 @@ {% endif %} {% if t.wikipediarevisionid %} @@ -32,6 +65,8 @@   {% endif %} {% if t.tag.dbpediauri and t.tag.dbpediauri != "" %} @@ -39,9 +74,18 @@   {% endif %} {% if t.tag.category %}{{ t.tag.category.label }}{% endif %}{{t.tag.label}}{% if t.tag.alias %}{{t.tag.alias}}{% endif %}{{t.tag.label}}
    diff -r 54f204bceb28 -r 34718ebfb3c0 Search/Search.php diff -r 54f204bceb28 -r 34718ebfb3c0 Tests/Search/SearchServiceTest.php diff -r 54f204bceb28 -r 34718ebfb3c0 Utils/SchemaUtils.php