have Tag::resolve_list always take an array
This commit is contained in:
parent
9c70d1bd3f
commit
7e89481105
@ -460,6 +460,8 @@ class Image {
|
||||
public function set_tags($tags) {
|
||||
global $database;
|
||||
|
||||
assert(is_array($tags));
|
||||
|
||||
$tags = Tag::resolve_list($tags);
|
||||
|
||||
assert(is_array($tags));
|
||||
@ -965,11 +967,11 @@ class Tag {
|
||||
/**
|
||||
* Turn any string or array into a valid tag array
|
||||
*/
|
||||
public static function explode($tags) {
|
||||
public static function explode($tags, $tagme=true) {
|
||||
assert(is_string($tags) || is_array($tags));
|
||||
|
||||
if(is_string($tags)) {
|
||||
$tags = explode(' ', $tags);
|
||||
$tags = explode(' ', trim($tags));
|
||||
}
|
||||
//else if(is_array($tags)) {
|
||||
// do nothing
|
||||
@ -983,7 +985,7 @@ class Tag {
|
||||
}
|
||||
}
|
||||
|
||||
if(count($tag_array) == 0) {
|
||||
if(count($tag_array) == 0 && $tagme) {
|
||||
$tag_array = array("tagme");
|
||||
}
|
||||
|
||||
@ -1053,8 +1055,8 @@ class Tag {
|
||||
* @return Array of tags
|
||||
*/
|
||||
public static function resolve_list($tags) {
|
||||
$tags = Tag::explode($tags);
|
||||
reset($tags); // rewind array to the first element.
|
||||
assert(is_array($tags));
|
||||
|
||||
$new = array();
|
||||
foreach($tags as $tag) {
|
||||
$new_set = explode(' ', Tag::resolve_alias($tag));
|
||||
@ -1062,6 +1064,7 @@ class Tag {
|
||||
$new[] = $new_one;
|
||||
}
|
||||
}
|
||||
|
||||
$new = array_map(array('Tag', 'sanitise'), $new);
|
||||
$new = array_iunique($new); // remove any duplicate tags
|
||||
return $new;
|
||||
|
@ -147,7 +147,7 @@ class Index extends Extension {
|
||||
global $config, $database, $page, $user;
|
||||
if($event->page_matches("post/list")) {
|
||||
if(isset($_GET['search'])) {
|
||||
$search = url_escape(implode(" ", Tag::resolve_list(trim($_GET['search']))));
|
||||
$search = url_escape(Tag::implode(Tag::resolve_list(Tag::explode($_GET['search'], false))));
|
||||
if(empty($search)) {
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/list/1"));
|
||||
|
@ -42,13 +42,13 @@ class MassTagger extends Extension {
|
||||
$_POST['setadd'] == 'set')
|
||||
{
|
||||
foreach($images as $image) {
|
||||
$image->set_tags($tag);
|
||||
$image->set_tags(Tag::explode($tag));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($images as $image) {
|
||||
$image->set_tags($tag . " " . $image->get_tag_list());
|
||||
$image->set_tags(Tag::explode($tag . " " . $image->get_tag_list()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user