--- 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 %}"><<</a>
+ <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}"><</a>
+ {{ num_page }}/{{ last_page }}
+ <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}">></a>
+ <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}">>></a></p>
+ {% else %}
+ <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, sort=sort %}"><<</a>
+ <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, sort=sort %}"><</a>
+ {{ num_page }}/{{ last_page }}
+ <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, sort=sort %}">></a>
+ <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, sort=sort %}">>></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 %}"><<</a>
+ <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}"><</a>
+ {{ num_page }}/{{ last_page }}
+ <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}">></a>
+ <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, sort=sort, searched=searched %}">>></a></p>
+ {% else %}
+ <a href="{% url hdabo.views.all_tags num_page=1, nb_by_page=nb_by_page, sort=sort %}"><<</a>
+ <a href="{% url hdabo.views.all_tags num_page=prev_page, nb_by_page=nb_by_page, sort=sort %}"><</a>
+ {{ num_page }}/{{ last_page }}
+ <a href="{% url hdabo.views.all_tags num_page=next_page, nb_by_page=nb_by_page, sort=sort %}">></a>
+ <a href="{% url hdabo.views.all_tags num_page=last_page, nb_by_page=nb_by_page, sort=sort %}">>></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;