--- a/Controller/WikiTagController.php Mon Nov 28 10:34:24 2011 +0100
+++ b/Controller/WikiTagController.php Mon Nov 28 12:19:56 2011 +0100
@@ -45,15 +45,17 @@
/**
* Renders the little html to add the javascript
- * TODO: review why this injection in javascript, t10n?
+ *
+ * @param unknown_type $tags_list
+ * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
*/
- public function addJavascriptAction($tags_list=FALSE)
+ public function addJavascriptAction($tags_list=false)
{
$cats = $this->getDoctrine()->getRepository('WikiTagBundle:Category')->findOrderedCategories();
// $cats is {"Label":"Créateur"},{"Label":"Datation"},...
$nbCats = count($cats);
$ar = array('' => '');
- for($i=0;$i<$nbCats;$i++){
+ for($i=0;$i<$nbCats;$i++) {
$temp = array($cats[$i]["label"] => $cats[$i]["label"]);
$ar = array_merge($ar, $temp);
}
@@ -103,7 +105,8 @@
/**
*
- * TODO : Enter description here ...
+ * The action called when a tag is moved in a document tag list.
+ *
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response
*/
public function tagUpDownAction()
@@ -144,8 +147,7 @@
}
/**
- *
- * TODO: Enter description here ...
+ * Action to remove a tag from a document tag list
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response
*/
public function removeTagFromListAction()
@@ -154,7 +156,6 @@
$id_tag = $this->getRequest()->request->get('tag_id');
// We get the DocumentTag meant to be deleted, and remove it.
$em = $this->getDoctrine()->getEntityManager();
- //TODO: use external id
$dt = $this->getDoctrine()->getRepository('WikiTagBundle:DocumentTag')->findOneByDocumentExternalId($id_doc, array('tag' => $id_tag));
$em->remove($dt);
@@ -192,7 +193,7 @@
return new Response(json_encode(array('error' => 'duplicate_tag', 'message' => sprintf("Le tag %s existe déjà pour cette fiche.", $tag_label))),400);
}
// We create the new tag or get the already existing tag. $tag, $revision_id, $created
- $ar = WikiTagUtils::getOrCreateTag($tag_label, $this->getDoctrine());
+ $ar = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->getOrCreateTag($tag_label);
$tag = $ar[0];
$revision_id = $ar[1];
$created = $ar[2];
@@ -227,9 +228,8 @@
}
/**
- *
- * TODO : Enter description here ...
- * TODO : implement
+ * The action called to reorder the the tags of a document. The tags are reordered according to the indexation score of the tag label on the document.
+ * The fields taken into account for calculating the score are defined in the wikitag configuration.
*/
public function reorderTagDocumentAction()
{
@@ -250,8 +250,7 @@
}
/**
- *
- * TODO: Enter description here ...
+ * The action called to add a new tag (especially from the completion box)
*/
public function addTagAction()
{
@@ -276,7 +275,7 @@
return new Response(json_encode(array('error' => 'duplicate_tag', 'message' => sprintf("Le tag %s existe déjà pour cette fiche.", $tag_label))),400);
}
// returns array($tag, $revision_id, $created)
- $ar = WikiTagUtils::getOrCreateTag($tag_label, $this->getDoctrine());// tag, revision_id, created = get_or_create_tag(tag_label)
+ $ar = $this->getDoctrine()->getRepository('WikiTagBundle:Tag')->getOrCreateTag($tag_label);// tag, revision_id, created = get_or_create_tag(tag_label)
$tag = $ar[0];
$revision_id = $ar[1];
$created = $ar[2];
@@ -289,7 +288,6 @@
// The result is a double array. And reset(reset($newOrderAr)) is not allowed. And a string is returned.
$a1 = reset($new_order_ar);
$new_order = intval(reset($a1)) + 1;
- // TODO: use a factory that returns an DocumentTagInterface
$new_DT = new DocumentTag();
$new_DT->setDocument($this->getDoctrine()->getRepository('WikiTagBundle:Document')->findOneByExternalId($id_doc));
$new_DT->setTag($tag);
@@ -305,8 +303,8 @@
/**
+ * Action to remove the wikipedia link form a tag. This action create a copy of the original tag with all the link to wikipedia set to null.
*
- * TODO: Enter description here ...
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response
*/
public function removeWpLinkAction()
@@ -321,19 +319,21 @@
$un_tag_created = FALSE;
if(!$un_tag){
// Create another tag almost identical, without the W info
- // TODO: use a factory that return a TagInterface
$un_tag = new Tag();
$un_tag->setLabel($tag->getLabel());
$un_tag->setOriginalLabel($tag->getOriginalLabel());
$un_tag->setUrlStatus(Tag::$TAG_URL_STATUS_DICT['null_result']);
$un_tag->setWikipediaUrl(null);
$un_tag->setWikipediaPageId(null);
+ $un_tag->setAlternativeWikipediaUrl(null);
+ $un_tag->setAlternativeWikipediaPageId(null);
+ $un_tag->setAlternativeLabel(null);
$un_tag->setDbpediaUri(null);
$un_tag->setCategory($tag->getCategory());
$un_tag->setAlias($tag->getAlias());
$un_tag->setPopularity($tag->getPopularity());
$em->persist($un_tag);
- $un_tag_created = TRUE;
+ $un_tag_created = true;
}
if($id_doc && $id_doc!=""){
@@ -362,8 +362,8 @@
/**
- *
- * TODO: Enter description here ...
+ * Action to update a tag category.
+ * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
*/
public function updateTagCategoryAction()
{
@@ -409,9 +409,8 @@
/**
- *
- * TODO : Enter description here ...
- * TODO : implement
+ * Action to update the tag alias.
+ *
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response
*/
public function updateTagAliasAction()
@@ -440,8 +439,9 @@
}
/**
- * List of all tags
- * TODO: Enter description here ...
+ * List all tags, with pagination and search.
+ *
+ * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
*/
public function allTagsAction()
{
@@ -558,29 +558,7 @@
// We get the Wikipedia informations for the sent label
$tag_label_normalized = WikiTagUtils::normalizeTag($label);
$wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized);
- //return new Response(var_dump($wp_response));
- $new_label = $tag_label_normalized;
- $status = $wp_response['status'];
- $url = $wp_response['wikipedia_url'];
- $pageid = $wp_response['pageid'];
- $dbpedia_uri = $wp_response["dbpedia_uri"];
- $wikipedia_revision_id = $wp_response['revision_id'];
- // We save the datas : we DO NOT create a new tag, we change the current tag's informations
- if($new_label!=null){
- $tag->setLabel($new_label);
- }
- else{
- $tag->setLabel($tag_label_normalized);
- }
- if(!is_null($status)){
- $tag->setUrlStatus($status);
- }
- else{
- $tag->setUrlStatus(Tag::$TAG_URL_STATUS_DICT['null_result']);
- }
- $tag->setWikipediaUrl($url);
- $tag->setWikipediaPageId($pageid);
- $tag->setDbpediaUri($dbpedia_uri);
+ $tag->setWikipediaInfo($wp_response);
// Save datas.
$em = $this->getDoctrine()->getEntityManager();
$em->persist($tag);