Merge branch 'master' of github.com:shish/shimmie2
This commit is contained in:
commit
61f3a9d372
@ -609,6 +609,9 @@ class Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* WARNING: this description is no longer accurate, though it does get across
|
||||||
|
* the general idea - the actual method has a few extra optimisiations
|
||||||
|
*
|
||||||
* "foo bar -baz user=foo" becomes
|
* "foo bar -baz user=foo" becomes
|
||||||
*
|
*
|
||||||
* SELECT * FROM images WHERE
|
* SELECT * FROM images WHERE
|
||||||
@ -742,32 +745,29 @@ class Image {
|
|||||||
$have_pos = count($positive_tag_id_array) > 0;
|
$have_pos = count($positive_tag_id_array) > 0;
|
||||||
$have_neg = count($negative_tag_id_array) > 0;
|
$have_neg = count($negative_tag_id_array) > 0;
|
||||||
|
|
||||||
$sql = "SELECT images.* FROM images WHERE ";
|
$sql = "SELECT images.* FROM images WHERE images.id IN (";
|
||||||
if($have_pos) {
|
if($have_pos) {
|
||||||
$positive_tag_id_list = join(', ', $positive_tag_id_array);
|
$positive_tag_id_list = join(', ', $positive_tag_id_array);
|
||||||
$sql .= "
|
$sql .= "
|
||||||
images.id IN (
|
|
||||||
SELECT image_id
|
SELECT image_id
|
||||||
FROM image_tags
|
FROM image_tags
|
||||||
WHERE tag_id IN ($positive_tag_id_list)
|
WHERE tag_id IN ($positive_tag_id_list)
|
||||||
GROUP BY image_id
|
GROUP BY image_id
|
||||||
HAVING COUNT(image_id)>=$positive_tag_count
|
HAVING COUNT(image_id)>=$positive_tag_count
|
||||||
)
|
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
if($have_pos && $have_neg) {
|
if($have_pos && $have_neg) {
|
||||||
$sql .= " AND ";
|
$sql .= " EXCEPT ";
|
||||||
}
|
}
|
||||||
if($have_neg) {
|
if($have_neg) {
|
||||||
$negative_tag_id_list = join(', ', $negative_tag_id_array);
|
$negative_tag_id_list = join(', ', $negative_tag_id_array);
|
||||||
$sql .= "
|
$sql .= "
|
||||||
images.id NOT IN (
|
|
||||||
SELECT image_id
|
SELECT image_id
|
||||||
FROM image_tags
|
FROM image_tags
|
||||||
WHERE tag_id IN ($negative_tag_id_list)
|
WHERE tag_id IN ($negative_tag_id_list)
|
||||||
)
|
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
$sql .= ")";
|
||||||
$query = new Querylet($sql);
|
$query = new Querylet($sql);
|
||||||
|
|
||||||
if(strlen($img_search->sql) > 0) {
|
if(strlen($img_search->sql) > 0) {
|
||||||
|
@ -224,7 +224,11 @@ class Index extends Extension {
|
|||||||
}
|
}
|
||||||
else if(preg_match("/^(filename|name)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) {
|
else if(preg_match("/^(filename|name)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) {
|
||||||
$filename = strtolower($matches[2]);
|
$filename = strtolower($matches[2]);
|
||||||
$event->add_querylet(new Querylet('images.filename LIKE "%'.$filename.'%"'));
|
$event->add_querylet(new Querylet('images.filename LIKE :fn', array("fn"=>"%$filename%")));
|
||||||
|
}
|
||||||
|
else if(preg_match("/^(source)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) {
|
||||||
|
$filename = strtolower($matches[2]);
|
||||||
|
$event->add_querylet(new Querylet('images.source LIKE :src', array("src"=>"%$filename%")));
|
||||||
}
|
}
|
||||||
else if(preg_match("/^posted(<|>|<=|>=|=)([0-9-]*)$/", $event->term, $matches)) {
|
else if(preg_match("/^posted(<|>|<=|>=|=)([0-9-]*)$/", $event->term, $matches)) {
|
||||||
$cmp = $matches[1];
|
$cmp = $matches[1];
|
||||||
|
@ -394,6 +394,9 @@ class TagList extends Extension {
|
|||||||
global $database;
|
global $database;
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
$related_tags = $database->cache->get("related_tags:$search");
|
||||||
|
|
||||||
|
if(empty($related_tags)) {
|
||||||
$wild_tags = Tag::explode($search);
|
$wild_tags = Tag::explode($search);
|
||||||
// $search_tags = array();
|
// $search_tags = array();
|
||||||
|
|
||||||
@ -431,11 +434,14 @@ class TagList extends Extension {
|
|||||||
$args = array("limit"=>$config->get_int('tag_list_length'));
|
$args = array("limit"=>$config->get_int('tag_list_length'));
|
||||||
|
|
||||||
$related_tags = $database->get_all($query, $args);
|
$related_tags = $database->get_all($query, $args);
|
||||||
|
$database->cache->set("related_tags:$search", $related_tags, 60*60);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(count($related_tags) > 0) {
|
if(count($related_tags) > 0) {
|
||||||
$this->theme->display_refine_block($page, $related_tags, $wild_tags);
|
$this->theme->display_refine_block($page, $related_tags, $wild_tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// }}}
|
// }}}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user