equal
deleted
inserted
replaced
26 |
26 |
27 $query = $qb->getQuery(); |
27 $query = $qb->getQuery(); |
28 return $query->getResult(); |
28 return $query->getResult(); |
29 } |
29 } |
30 |
30 |
|
31 /** |
|
32 * returns a list of tags label containing the given seed. |
|
33 * The seed is either at the beggining, the end of the label or at the beggining of a word. |
|
34 * @param string $seed |
|
35 */ |
31 public function getCompletion($seed) |
36 public function getCompletion($seed) |
32 { |
37 { |
33 $qb = $this->getEntityManager()->createQueryBuilder(); |
38 $qb = $this->getEntityManager()->createQueryBuilder(); |
34 $qb->select('DISTINCT t.label'); |
39 $qb->select('DISTINCT t.label'); |
35 $qb->from('WikiTagBundle:Tag','t'); |
40 $qb->from('WikiTagBundle:Tag','t'); |
71 * Get or create tag. Returns an array(tag:WikiTagTag, revision_id=int, created:Boolean) |
76 * Get or create tag. Returns an array(tag:WikiTagTag, revision_id=int, created:Boolean) |
72 * @param $tag_label |
77 * @param $tag_label |
73 * @param $doctrine |
78 * @param $doctrine |
74 * @return multitype:boolean Ambigous <NULL, \IRI\Bundle\WikiTagBundle\Entity\Tag> Ambigous <NULL, unknown, mixed, string> (array(\IRI\Bundle\WikiTagBundle\Model\TagInterface, revision_id=int, created:Boolean)) |
79 * @return multitype:boolean Ambigous <NULL, \IRI\Bundle\WikiTagBundle\Entity\Tag> Ambigous <NULL, unknown, mixed, string> (array(\IRI\Bundle\WikiTagBundle\Model\TagInterface, revision_id=int, created:Boolean)) |
75 */ |
80 */ |
76 public function getOrCreateTag($tag_label, $ignore_wikipedia_info=false) |
81 public function getOrCreateTag($tag_label, $ignore_wikipedia_info=false, $logger=null) |
77 { |
82 { |
78 $tag_label_normalized = WikiTagUtils::normalizeTag($tag_label); |
83 $tag_label_normalized = WikiTagUtils::normalizeTag($tag_label); |
79 // We get the wikipedia references for the tag_label |
84 // We get the wikipedia references for the tag_label |
80 // We get or create the tag object |
85 // We get or create the tag object |
81 $tags = $this->findBy(array('normalizedLabel' => $tag_label_normalized)); |
86 $tags = $this->findBy(array('normalizedLabel' => $tag_label_normalized)); |
101 |
106 |
102 // We request Wikipedia if the tag is created or if this is a null result |
107 // We request Wikipedia if the tag is created or if this is a null result |
103 if($created==true || $tag->getUrlStatus()===Tag::$TAG_URL_STATUS_DICT['null_result']) { |
108 if($created==true || $tag->getUrlStatus()===Tag::$TAG_URL_STATUS_DICT['null_result']) { |
104 |
109 |
105 if($wp_request_done==false) { |
110 if($wp_request_done==false) { |
106 $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized, null, $ignore_wikipedia_info); |
111 $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized, null, $ignore_wikipedia_info, $logger); |
107 } |
112 } |
108 |
113 |
109 $tag->setWikipediaInfo($wp_response); |
114 $tag->setWikipediaInfo($wp_response); |
110 |
115 |
111 // Save datas. |
116 // Save datas. |
114 |
119 |
115 $wikipedia_revision_id = $wp_response['revision_id']; |
120 $wikipedia_revision_id = $wp_response['revision_id']; |
116 |
121 |
117 } |
122 } |
118 elseif($tag!=null && $tag->getWikipediaPageId()!=null) { |
123 elseif($tag!=null && $tag->getWikipediaPageId()!=null) { |
119 $wp_response = WikiTagUtils::getWikipediaInfo(null, $tag->getWikipediaPageId(), $ignore_wikipedia_info); |
124 $wp_response = WikiTagUtils::getWikipediaInfo(null, $tag->getWikipediaPageId(), $ignore_wikipedia_info, $logger); |
120 $wikipedia_revision_id = $wp_response['revision_id']; |
125 $wikipedia_revision_id = $wp_response['revision_id']; |
121 } |
126 } |
122 else { |
127 else { |
123 $wikipedia_revision_id = null; |
128 $wikipedia_revision_id = null; |
124 } |
129 } |