# HG changeset patch # User cavaliet # Date 1390581818 -3600 # Node ID 14653baf4f6bfe9e178b113b7a607436038ead71 # Parent fef492d144f489bae63cc56d4eb5758dd6881df5 first change for wikipedia and dbpedia lang configuration diff -r fef492d144f4 -r 14653baf4f6b Controller/WikiTagController.php --- a/Controller/WikiTagController.php Fri Aug 24 13:16:41 2012 +0200 +++ b/Controller/WikiTagController.php Fri Jan 24 17:43:38 2014 +0100 @@ -69,7 +69,12 @@ $columns_array = $profile_array[$profile_name]; } - return $this->render('WikiTagBundle:WikiTag:javascript.html.twig', array('categories' => $categories, 'tags_list' => $tags_list, 'columns' => $columns_array, 'read_only' => $read_only)); + return $this->render('WikiTagBundle:WikiTag:javascript.html.twig', + array('wikipedia_api_url' => $this->container->getParameter("wiki_tag.url_templates")["wikipedia_api"], + 'categories' => $categories, + 'tags_list' => $tags_list, + 'columns' => $columns_array, + 'read_only' => $read_only)); } /** @@ -109,7 +114,12 @@ $ordered_tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOrderedTagsForDoc($id_doc); //$ordered_tags = null; - return $this->render('WikiTagBundle:WikiTag:documentTags.html.twig', array('ordered_tags' => $ordered_tags, 'doc_id' => $id_doc, 'columns' => $columns_array, 'profile_name' => $profile_name)); + return $this->render('WikiTagBundle:WikiTag:documentTags.html.twig', + array('ordered_tags' => $ordered_tags, + 'doc_id' => $id_doc, + 'columns' => $columns_array, + 'profile_name' => $profile_name, + 'wikipedia_opensearch_url' => $this->container->getParameter("wiki_tag.url_templates")["wikipedia_opensearch"])); } /** @@ -398,7 +408,12 @@ $columns_array = $profile_array[$profile_name]; } $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, 'columns' => $columns_array, 'profile_name' => $profile_name)); + return $this->render('WikiTagBundle:WikiTag:tagTable.html.twig', + array('ordered_tags' => $ordered_tags, + 'doc_id' => $id_doc, + 'columns' => $columns_array, + 'profile_name' => $profile_name, + 'wikipedia_opensearch_url' => $this->container->getParameter("wiki_tag.url_templates")["wikipedia_opensearch"])); } @@ -493,9 +508,21 @@ } return $this->render('WikiTagBundle:WikiTag:TagList.html.twig', - array('tags' => $tags, 'searched' => $searched, 'search_def' => $search_def, 'nb_by_page' => $nb_by_page, 'sort' => $sort, - 'start_index' => $start_index, 'end_index' => $end_index, 'nb_total' => $nb_total, 'num_page' => $num_page, 'last_page' => $last_page, - 'prev_page' => $prev_page, 'next_page' => $next_page, 'reverse_sort' => $reverse_sort, 'route_for_documents_by_tag' => $this->container->getParameter("wiki_tag.route_for_documents_by_tag"))); + array('tags' => $tags, + 'searched' => $searched, + 'search_def' => $search_def, + 'nb_by_page' => $nb_by_page, + 'sort' => $sort, + 'start_index' => $start_index, + 'end_index' => $end_index, + 'nb_total' => $nb_total, + 'num_page' => $num_page, + 'last_page' => $last_page, + 'prev_page' => $prev_page, + 'next_page' => $next_page, + 'reverse_sort' => $reverse_sort, + 'route_for_documents_by_tag' => $this->container->getParameter("wiki_tag.route_for_documents_by_tag"), + 'wikipedia_opensearch_url' => $this->container->getParameter("wiki_tag.url_templates")["wikipedia_opensearch"])); } /** @@ -605,8 +632,14 @@ $reverse_sort = $ar[5]; return $this->render('WikiTagBundle:WikiTag:TagListTable.html.twig', - array('tags' => $tags, 'searched' => $searched, 'nb_by_page' => $nb_by_page, 'sort' => $sort, 'num_page' => $num_page, - 'reverse_sort' => $reverse_sort, 'route_for_documents_by_tag' => $this->container->getParameter("wiki_tag.route_for_documents_by_tag"))); + array('tags' => $tags, + 'searched' => $searched, + 'nb_by_page' => $nb_by_page, + 'sort' => $sort, + 'num_page' => $num_page, + 'reverse_sort' => $reverse_sort, + 'route_for_documents_by_tag' => $this->container->getParameter("wiki_tag.route_for_documents_by_tag"), + 'wikipedia_opensearch_url' => $this->container->getParameter("wiki_tag.url_templates")["wikipedia_opensearch"])); } /** diff -r fef492d144f4 -r 14653baf4f6b DependencyInjection/Configuration.php --- a/DependencyInjection/Configuration.php Fri Aug 24 13:16:41 2012 +0200 +++ b/DependencyInjection/Configuration.php Fri Jan 24 17:43:38 2014 +0100 @@ -61,6 +61,12 @@ ->end() ->end() ->end() + ->arrayNode('url_templates') + ->treatNullLike(array()) + ->useAttributeAsKey('name') + ->prototype('variable') + ->end() + ->end() ->arrayNode('reactive_selectors') ->treatNullLike(array()) ->useAttributeAsKey('name') diff -r fef492d144f4 -r 14653baf4f6b DependencyInjection/WikiTagExtension.php --- a/DependencyInjection/WikiTagExtension.php Fri Aug 24 13:16:41 2012 +0200 +++ b/DependencyInjection/WikiTagExtension.php Fri Jan 24 17:43:38 2014 +0100 @@ -58,6 +58,7 @@ $container->setParameter("wiki_tag.fields", $fields); $fields['tagsStr'] = array("type"=>"text"); $container->setParameter("wiki_tag.fields_all", $fields); + $container->setParameter("wiki_tag.url_templates", $config['url_templates']); $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 fef492d144f4 -r 14653baf4f6b Model/DocumentTag.php --- a/Model/DocumentTag.php Fri Aug 24 13:16:41 2012 +0200 +++ b/Model/DocumentTag.php Fri Jan 24 17:43:38 2014 +0100 @@ -214,16 +214,13 @@ /** - * Get wikipedia_version_permalink + * Get wikipedia_version_permalink : DEPRECATED * * @return string */ public function getWikipediaVersionPermalink() { - $WIKIPEDIA_VERSION_PERMALINK_TEMPLATE = "http://fr.wikipedia.org/w/index.php?oldid="; - return $WIKIPEDIA_VERSION_PERMALINK_TEMPLATE.$this->wikipediaRevisionId; - } - - + return sprintf($GLOBALS["kernel"]->getContainer()->getParameter("wiki_tag.url_templates")["wikipedia_permalink"], $this->wikipediaRevisionId); + } } \ No newline at end of file diff -r fef492d144f4 -r 14653baf4f6b README.md --- a/README.md Fri Aug 24 13:16:41 2012 +0200 +++ b/README.md Fri Jan 24 17:43:38 2014 +0100 @@ -74,6 +74,25 @@ accessor: : the field name in the host app's document class, or the name of the method used to access the field value. If not found it will try ta add 'get' in frint of the name. Default : the field name weight: : the weight used for this field to calculate the score of each tag. default : 1.0 +* We can configure WikiTagBundle for it to works with any wikipedia and dbpedia. Just set up the language you want with the url templates. +There is no default version so this configuration **has** to be set. Here is an example with german (de) endpoints : + + wiki_tag: + [...] + url_templates: + wikipedia_api: 'http://de.wikipedia.org/w/api.php' + wikipedia_permalink: 'http://de.wikipedia.org/w/index.php?oldid=%s' + wikipedia_opensearch: 'http://de.wikipedia.org/w/index.php?search=' + dbpedia: 'http://de.dbpedia.org/resource/%s' + +The 'document_id_column' option is used to indicate the primary key column used by the host app's document class. We are currently limited to non composite primary keys. +A field definition has the following format: +: + type: : field type. default : text + length: : the length of the field. ignored if field type is text + accessor: : the field name in the host app's document class, or the name of the method used to access the field value. If not found it will try ta add 'get' in frint of the name. Default : the field name + weight: : the weight used for this field to calculate the score of each tag. default : 1.0 + * Add the WikiTag routes to your routing.yml : WikiTagBundle: diff -r fef492d144f4 -r 14653baf4f6b Resources/public/js/wikiTag.js --- a/Resources/public/js/wikiTag.js Fri Aug 24 13:16:41 2012 +0200 +++ b/Resources/public/js/wikiTag.js Fri Jan 24 17:43:38 2014 +0100 @@ -70,7 +70,7 @@ autocomplete : { source: function( request, response ) { $.ajax({ - url: "http://fr.wikipedia.org/w/api.php", + url: wikipedia_api_url, dataType: "jsonp", data: { action: "opensearch", @@ -189,7 +189,7 @@ $("#wikitag_wp_search").autocomplete({ source: function( request, response ) { $.ajax({ - url: "http://fr.wikipedia.org/w/api.php", + url: wikipedia_api_url, dataType: "jsonp", data: { action: "opensearch", @@ -293,7 +293,7 @@ $("#wikitag_wp_search_context").autocomplete({ source: function( request, response ) { $.ajax({ - url: "http://fr.wikipedia.org/w/api.php", + url: wikipedia_api_url, dataType: "jsonp", data: { action: "query", diff -r fef492d144f4 -r 14653baf4f6b Resources/views/WikiTag/TagListTable.html.twig --- a/Resources/views/WikiTag/TagListTable.html.twig Fri Aug 24 13:16:41 2012 +0200 +++ b/Resources/views/WikiTag/TagListTable.html.twig Fri Jan 24 17:43:38 2014 +0100 @@ -65,7 +65,7 @@ {% if tag.wikipediaurl and tag.wikipediaurl != "" %} {% else %} - + {% endif %} diff -r fef492d144f4 -r 14653baf4f6b Resources/views/WikiTag/javascript.html.twig --- a/Resources/views/WikiTag/javascript.html.twig Fri Aug 24 13:16:41 2012 +0200 +++ b/Resources/views/WikiTag/javascript.html.twig Fri Jan 24 17:43:38 2014 +0100 @@ -20,7 +20,8 @@