debug addtag for document
authorcavaliet
Thu, 20 Oct 2011 18:35:33 +0200
changeset 8 7d2fb5d7c9ff
parent 7 7a877de630fd
child 9 cc32af725176
debug addtag for document
.buildpath
.hgignore
.project
Command/SyncDocumentsCommand.php
Controller/WikiTagController.php
DependencyInjection/Configuration.php
DependencyInjection/WikiTagExtension.php
Entity/Category.php
Entity/CategoryRepository.php
Entity/Document.php
Entity/DocumentListener.php
Entity/DocumentRepository.php
Entity/DocumentTag.php
Entity/DocumentTagRepository.php
Entity/Tag.php
Entity/TagRepository.php
Model/BaseDocumentInterface.php
Model/Category.php
Model/CategoryInterface.php
Model/Document.php
Model/DocumentInterface.php
Model/DocumentTag.php
Model/DocumentTagInterface.php
Model/Tag.php
Model/TagInterface.php
Resources/config/doctrine/Category.orm.yml
Resources/config/doctrine/Document.orm.yml
Resources/config/doctrine/DocumentTag.orm.yml
Resources/config/doctrine/Tag.orm.yml
Resources/config/routing.yml
Resources/config/services.yml
Resources/doc/index.rst
Resources/public/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
Resources/public/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
Resources/public/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
Resources/public/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
Resources/public/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png
Resources/public/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
Resources/public/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
Resources/public/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
Resources/public/css/smoothness/images/ui-icons_222222_256x240.png
Resources/public/css/smoothness/images/ui-icons_2e83ff_256x240.png
Resources/public/css/smoothness/images/ui-icons_454545_256x240.png
Resources/public/css/smoothness/images/ui-icons_888888_256x240.png
Resources/public/css/smoothness/images/ui-icons_cd0a0a_256x240.png
Resources/public/css/smoothness/jquery-ui-1.8.13.custom.css
Resources/public/css/wikiTag.css
Resources/public/images/arrow_green_right.png
Resources/public/images/arrow_right.png
Resources/public/images/arrow_up_down.png
Resources/public/images/clock_arrow.png
Resources/public/images/indicator.gif
Resources/public/images/red_cross.png
Resources/public/images/sort-asc.png
Resources/public/images/sort-desc.png
Resources/public/images/sort-descending.png
Resources/public/images/tag_remove.png
Resources/public/images/wikipedia_search.png
Resources/public/js/jquery-ui.min.js
Resources/public/js/jquery.jeditable.js
Resources/public/js/jquery.min.js
Resources/public/js/jquery.qtip.min.js
Resources/public/js/jquery.tablednd_0_5.js
Resources/public/js/jquery.textchange.min.js
Resources/public/js/jquery.tools.min.js
Resources/public/js/jquery.validate.js
Resources/public/js/wikiTag.js
Resources/translations/messages.fr.xliff
Resources/views/WikiTag/TagList.html.twig
Resources/views/WikiTag/TagListTable.html.twig
Resources/views/WikiTag/css.html.twig
Resources/views/WikiTag/documentTags.html.twig
Resources/views/WikiTag/javascript.html.twig
Resources/views/WikiTag/tagTable.html.twig
Tests/Controller/DefaultControllerTest.php
Utils/WikiTagUtils.php
WikiTagBundle.php
--- a/Controller/WikiTagController.php	Wed Oct 19 15:44:23 2011 +0200
+++ b/Controller/WikiTagController.php	Thu Oct 20 18:35:33 2011 +0200
@@ -215,13 +215,12 @@
             //TODO : translation
             return new Response(json_encode(array('error' => 'duplicate_tag', 'message' => sprintf("Le tag %s existe déjà pour cette fiche.", $tag_label))),400);
         }
-        // $tag, $revision_id, $created
+        // returns array($tag, $revision_id, $created)
         $ar = WikiTagUtils::getOrCreateTag($tag_label, $this->getDoctrine());// tag, revision_id, created = get_or_create_tag(tag_label)
-
         $tag = $ar[0];
         $revision_id = $ar[1];
         $created = $ar[2];
-
+        
         $tags = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findByDocumentExternalId($id_doc, array('tag'=>$tag->getId()));
         $nb_tags = count($tags);
 
@@ -276,7 +275,7 @@
         }
         // We associate the unsemantized tag to the DocumentTag and save datas
         // TODO: do the request on external id of document
-        $dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneByDocumentExternalId($id_doc, array('tag' => $idTag));
+        $dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneBy(array('document' => $id_doc, 'tag' => $id_tag));
         $dt->setTag($un_tag);
         $em->flush();
         
@@ -352,13 +351,25 @@
      */
     public function allTagsAction()
     {
-        $tags = $this->getDoctrine()->getRepository('WikiTagBundle:WikiTagTag')->findAll();
+        $tags = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->findBy(array('id' => '10'));
         // $this->getRequest()->query->get('foo') does not work "because" we are a second controller. So we have to use $_GET.
         $toto = null;
         if(array_key_exists('toto', $_GET)){
             $toto = $_GET['toto'];
         }
-        return $this->render('WikiTagBundle:WikiTag:TagList.html.twig', array('tags' => $tags, 'toto' => $toto));
+        $searched = "truc";
+        $search_def = array('A', 'B');
+        $nb_by_page = 50;
+        $sort = "p+";
+        $current_page = NULL;// avec start_index et end_index
+        $nb_total = "truc";// nb de pages
+        $num_page = 2;
+        $last_page = 4;
+        $prev_page = 1;
+        $next_page = 3;
+        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, '$current_page' => $current_page,
+            '$nb_total' => $nb_total, '$num_page' => $num_page, '$last_page' => $last_page, '$prev_page' => $prev_page, '$next_page' => $next_page));
     }
 
 
--- a/Entity/DocumentTagRepository.php	Wed Oct 19 15:44:23 2011 +0200
+++ b/Entity/DocumentTagRepository.php	Thu Oct 20 18:35:33 2011 +0200
@@ -56,9 +56,10 @@
         
         if(!is_null($filter_array)) {
             foreach ($filter_array as $key => $value) {
-                $qb = $qb->where("dt.$key = :p_$key");
-                $params["p_$key"] = $value;
+                $qb = $qb->andWhere("dt.$key = :$key");
+                //$params[$key] = $value;
             }
+            $params = array_merge($params, $filter_array);
         }
         
         $qb = $qb->setParameters($params);
--- a/Model/Tag.php	Wed Oct 19 15:44:23 2011 +0200
+++ b/Model/Tag.php	Thu Oct 20 18:35:33 2011 +0200
@@ -9,7 +9,9 @@
  */
  namespace IRI\Bundle\WikiTagBundle\Model;
  
- abstract class Tag implements TagInterface {
+ use IRI\Bundle\WikiTagBundle\Utils\WikiTagUtils;
+
+abstract class Tag implements TagInterface {
     
     public static $TAG_URL_STATUS_DICT = array('null_result'=>0,'redirection'=>1,'homonyme'=>2,'match'=>3);
      
@@ -87,6 +89,7 @@
     public function setLabel($label)
     {
         $this->label = $label;
+        $this->normalizedLabel = WikiTagUtils::normalizeTag($label);
     }
 
     /**
--- a/Resources/config/doctrine/Tag.orm.yml	Wed Oct 19 15:44:23 2011 +0200
+++ b/Resources/config/doctrine/Tag.orm.yml	Thu Oct 20 18:35:33 2011 +0200
@@ -27,16 +27,20 @@
       type: string
       length: '2048'
       column: wikipedia_url
+      nullable: true
     wikipediaPageId:
       type: bigint
       column: normalized_pageid
+      nullable: true
     urlStatus:
       type: smallint
       column: url_status
+      nullable: true
     dbpediaUri:
       type: string
       length: '2048'
       column: dbpedia_uri
+      nullable: true
     popularity:
       type: integer
   manyToOne:
--- a/Resources/views/WikiTag/TagList.html.twig	Wed Oct 19 15:44:23 2011 +0200
+++ b/Resources/views/WikiTag/TagList.html.twig	Thu Oct 20 18:35:33 2011 +0200
@@ -1,4 +1,52 @@
-DUDE 1.
-{% if toto and toto != ""  %}
-toto = {{toto}}
-{% endif %}
\ No newline at end of file
+<form method="GET" action="">
+<p>Chercher : 
+{#{% for s in search_def %}
+<a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, sort=sort, searched=s.1 %}">{{s.0}}</a>
+{% endfor %}#}
+<input type="text" name="searched" value="{#{% if searched %}{{searched}}{% endif %}#}" id="searched" />
+</p>
+<p>Tags {#{{ current_page.start_index }} à {{ current_page.end_index }} sur {{ nb_total }}#}</p>
+<div id="count_nav_top"><p>
+{#
+    {% if searched and searched != "" %}
+        <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, sort=sort, searched=searched %}">&lt;&lt;</a>&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}">&lt;</a>&nbsp;&nbsp;
+        {{ num_page }}/{{ last_page }}&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}">&gt;</a>&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}">&gt;&gt;</a></p>
+    {% else %}
+        <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, sort=sort %}">&lt;&lt;</a>&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, sort=sort %}">&lt;</a>&nbsp;&nbsp;
+        {{ num_page }}/{{ last_page }}&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, sort=sort %}">&gt;</a>&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, sort=sort %}">&gt;&gt;</a>
+    {% endif %}</p>
+#}
+</div>
+{#
+<input type="hidden" name="num_page" value="{{num_page}}" id="num_page" />
+<input type="hidden" name="nb_by_page" value="{{nb_by_page}}" id="nb_by_page" />
+<input type="hidden" name="searched_str" value="{% if searched %}{{searched}}{% endif %}" id="searched_str" />
+<input type="hidden" name="sort" value="{% if sort %}{{sort}}{% endif %}" id="sort" />
+#}
+</form>
+<div id="tag_table_container">
+{% include "WikiTagBundle:WikiTag:TagListTable.html.twig" %}
+</div>
+<div id="count_nav_bottom"><p>
+{#
+    {% if searched and searched != "" %}
+        <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, sort=sort, searched=searched %}">&lt;&lt;</a>&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}">&lt;</a>&nbsp;&nbsp;
+        {{ num_page }}/{{ last_page }}&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}">&gt;</a>&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}">&gt;&gt;</a></p>
+    {% else %}
+        <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, sort=sort %}">&lt;&lt;</a>&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, sort=sort %}">&lt;</a>&nbsp;&nbsp;
+        {{ num_page }}/{{ last_page }}&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, sort=sort %}">&gt;</a>&nbsp;&nbsp;
+        <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, sort=sort %}">&gt;&gt;</a>
+    {% endif %}</p>
+#}
+</div>
\ No newline at end of file
--- a/Resources/views/WikiTag/tagTable.html.twig	Wed Oct 19 15:44:23 2011 +0200
+++ b/Resources/views/WikiTag/tagTable.html.twig	Thu Oct 20 18:35:33 2011 +0200
@@ -16,7 +16,7 @@
         <tr class="imageline {{ cycle(['wikitag_oddline', 'wikitag_evenline'], loop.index) }}" id="{{loop.index}}">
         <td>{{loop.index}}</td>
         <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>
-        <td>T-{{t.tag.id}} - {{t.tagorder}} - DT-{{t.id}}</td>
+        <td>{{t.tag.id}}</td>
         <td class="wikitag_{{t.tag.urlstatustext}} wikipediatag" id="{{t.tag.id}}" >{{t.tag.label}}</td>
         <td class="wikitag_text_centered">
             {% if t.tag.wikipediaurl and t.tag.wikipediaurl != ""  %}
--- a/Utils/WikiTagUtils.php	Wed Oct 19 15:44:23 2011 +0200
+++ b/Utils/WikiTagUtils.php	Thu Oct 20 18:35:33 2011 +0200
@@ -47,7 +47,6 @@
         }
         else{
             $created = false;
-            //$created = true;
         }
         
         // We request Wikipedia if the tag is created
@@ -84,6 +83,7 @@
         else{
             $wikipedia_revision_id = null;
         }
+        //return "coucou4";
         
         return array($tag, $wikipedia_revision_id, $created);//, $wpReponse);
     }
@@ -91,7 +91,7 @@
     /**
      * Cleans the tag label
      */
-    private static function normalizeTag($tag_label)
+    public static function normalizeTag($tag_label)
     {
         if(strlen($tag_label)==0){
             return $tag_label;