# HG changeset patch # User ymh # Date 1320683139 -3600 # Node ID 7496254cfead550d419f8fc3e2a95ac77abd723a # Parent 85c7e5e965e244cbd06088d1de3d6c20b64d5bc6 correct add tag diff -r 85c7e5e965e2 -r 7496254cfead Controller/WikiTagController.php --- a/Controller/WikiTagController.php Sun Nov 06 23:45:50 2011 +0100 +++ b/Controller/WikiTagController.php Mon Nov 07 17:25:39 2011 +0100 @@ -134,7 +134,7 @@ /** * Modify the tag in the context of a tag list for one document - * + * */ public function modifyDocumentTagAction() { @@ -190,13 +190,13 @@ /** * - * @Route("/wtrtd") * TODO : Enter description here ... * TODO : implement */ public function reorderTagDocumentAction() { $id_Doc = $this->getRequest()->request->get('wikitag_document_id'); + $res = $this->getDoctrine()->getRepository('WikiTagBundle:Document')->search(null,'test', null); return $this->renderDocTags($id_doc); } @@ -482,7 +482,7 @@ /** * * Resemantize the tag with its original label. Kind of undo if we changed the tag's label. - * + * */ public function resetWpInfoAction() { diff -r 85c7e5e965e2 -r 7496254cfead Entity/DocumentRepository.php --- a/Entity/DocumentRepository.php Sun Nov 06 23:45:50 2011 +0100 +++ b/Entity/DocumentRepository.php Mon Nov 07 17:25:39 2011 +0100 @@ -4,7 +4,7 @@ use Doctrine\ORM\EntityRepository; use IRI\Bundle\WikiTagBundle\Entity\Document; - +use Doctrine\ORM\Query\ResultSetMapping; use \ReflectionClass; /** @@ -206,5 +206,42 @@ $document->setTagsStr(implode(",",$tagstr)); $this->getEntityManager()->persist($document); } + + /** + * + * Enter description here ... + * @param array $values : key: the fields to search into, value array('value'=>value, 'weight'=>weight) + * @param unknown_type $conditions + */ + function search(array $values, array $conditions=NULL) + { +/* $em = $this->getEntityManager(); + + $rsm = new ResultSetMapping(); + $rsm->addEntityResult("IRI/Bundle/WikiTagBundle/Entity/Document", "d"); + $rsm->addFieldResult("d", "id", "id"); + $rsm->addFieldResult("d", "external_id", "externalId"); + $rsm->addScalarResult("d", "score"); + + $score = ""; + foreach ($values as $fielddef) { + + $columns = $fielddef["columns"]; + $value = $fielddef["value"]; + $value = isset($fielddef["weight"])?$fielddef["weight"]:1.0; + + $score = "(MATCH($columns) AGAINST (:value))*:weight"; + $parameters[] = + } + + + $query = $em->createNativeQuery("SELECT d.id, d.external_id, MATCH(title) AGAINST('$value') FROM wikitag_document d WHERE MATCH(title) AGAINST('$value') > 0", $rsm); + + $res = $query->getScalarResult(); + + return $res;*/ + + + } } \ No newline at end of file diff -r 85c7e5e965e2 -r 7496254cfead Listener/DocumentListener.php --- a/Listener/DocumentListener.php Sun Nov 06 23:45:50 2011 +0100 +++ b/Listener/DocumentListener.php Mon Nov 07 17:25:39 2011 +0100 @@ -115,9 +115,13 @@ } elseif (is_a($entity, "IRI\Bundle\WikiTagBundle\Model\TagInterface")) { - foreach($entity->getDocuments() as $doctag) + $documents = $entity->getDocuments(); + if(!is_null($documents)) { - $this->getContainer()->get('doctrine')->getRepository("WikiTagBundle:Document")->updateTagsStr($doctag->getDocument()); + foreach($documents as $doctag) + { + $this->getContainer()->get('doctrine')->getRepository("WikiTagBundle:Document")->updateTagsStr($doctag->getDocument()); + } } }