public function removeTag()
{
global $injector, $registry;
$gallery = $this->vars->gallery;
$tags = $this->vars->tags;
$image = $this->vars->image;
if ($image) {
$id = $image;
$type = 'image';
} else {
$id = $gallery;
$type = 'gallery';
}
if (!is_numeric($id)) {
throw new Ansel_Exception(_("Invalid input %s"), $id);
}
$storage = $injector->getInstance('Ansel_Storage');
if ($type == 'gallery') {
$resource = $storage->getGallery($id);
$parent = $resource;
} else {
$resource = $storage->getImage($id);
$parent = $storage->getGallery($resource->gallery);
}
$tagger = $injector->getInstance('Ansel_Tagger');
$tagger->untag($resource->id, (int) $tags, $type);
$currentTags = $tagger->getTags($resource->id, $type);
if (count($currentTags)) {
$newTags = $tagger->getTagInfo(array_keys($currentTags));
} else {
$newTags = array();
}
$links = Ansel::getTagLinks($newTags, 'add');
foreach ($newTags as &$tag_info) {
$tag_info['link'] = strval($links[$tag_info['tag_id']]);
}
return $newTags;
}