diff -r b910b4f7485f -r 38dcd2db04e4 Utils/WikiTagUtils.php --- a/Utils/WikiTagUtils.php Wed Nov 09 17:33:26 2011 +0100 +++ b/Utils/WikiTagUtils.php Thu Nov 10 12:40:22 2011 +0100 @@ -38,6 +38,7 @@ } } } + $wp_request_done = false; if($tag==null){ $tag = new Tag(); $tag->setLabel($tag_label_normalized); @@ -47,11 +48,35 @@ } else{ $created = false; + $match_exists = false; + // Even if a tag with the normalised label exists, IF this tag is not wikipedia semantised, + // we search if a wikipedia semantised version exists in the base + foreach ($tags as $t){ + if($t->getUrlStatus()==Tag::$TAG_URL_STATUS_DICT['match']){ + $tag = $t; + $match_exists = true; + break; + } + } + if($match_exists==false){ + $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized); + $status = $wp_response['status']; + if($status==Tag::$TAG_URL_STATUS_DICT['match']){ + $tag = new Tag(); + $tag->setLabel($tag_label_normalized); + $tag->setOriginalLabel($tag_label); + $tag->setNormalizedLabel($tag_label_normalized); + $created = true; + $wp_request_done = true; + } + } } // We request Wikipedia if the tag is created if($created==true){ - $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized); + if($wp_request_done==false){ + $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized); + } $new_label = $wp_response['new_label']; $status = $wp_response['status']; $url = $wp_response['wikipedia_url']; @@ -83,7 +108,6 @@ else{ $wikipedia_revision_id = null; } - //return "coucou4"; return array($tag, $wikipedia_revision_id, $created);//, $wpReponse); }