added pool & pool_by_name search metatags

This commit is contained in:
Daku 2014-01-14 06:12:34 +00:00
parent ae4da2b410
commit ce256f5bf4
2 changed files with 25 additions and 4 deletions

View file

@ -121,8 +121,8 @@
* <li>Notes * <li>Notes
* <ul> * <ul>
* <li>notes (=, &lt;, &gt;, &lt;=, &gt;=) number -- search by the number of notes an image has * <li>notes (=, &lt;, &gt;, &lt;=, &gt;=) number -- search by the number of notes an image has
* <li>notes_by=Username -- search for a notes created by username * <li>notes_by=Username -- search for images contains notes created by username
* <li>notes_by_userno=UserID -- search for a notes created by userID * <li>notes_by_userno=UserID -- search for images contains notes created by userID
* </ul> * </ul>
* <li>Artists * <li>Artists
* <ul> * <ul>
@ -131,8 +131,13 @@
* <li>Image Comments * <li>Image Comments
* <ul> * <ul>
* <li>comments (=, &lt;, &gt;, &lt;=, &gt;=) number -- search for images by number of comments * <li>comments (=, &lt;, &gt;, &lt;=, &gt;=) number -- search for images by number of comments
* <li>commented_by=Username -- search for a user's comments by username * <li>commented_by=Username -- search for images contains user's comments by username
* <li>commented_by_userno=UserID -- search for a user's comments by userID * <li>commented_by_userno=UserID -- search for images contains user's comments by userID
* </ul>
* <li>Pools
* <ul>
* <li>pool=PoolID -- search for images in a pool by PoolID
* <li>pool_by_name=PoolName -- search for images in a pool by PoolName. underscores are replaced with spaces
* </ul> * </ul>
* </ul> * </ul>
*/ */

View file

@ -293,6 +293,22 @@ class Pools extends Extension {
} }
} }
public function onSearchTermParse(SearchTermParseEvent $event) {
$matches = array();
if(preg_match("/^pool[=|:]([0-9]+)$/", $event->term, $matches)) {
$poolID = $matches[1];
$event->add_querylet(new Querylet("images.id IN (SELECT DISTINCT image_id FROM pool_images WHERE pool_id = $poolID)"));
}
else if(preg_match("/^pool_by_name[=|:](.*)$/", $event->term, $matches)) {
$poolTitle = str_replace("_", " ", $matches[1]);
$pool = $this->get_single_pool_from_title($poolTitle);
$poolID = 0;
if ($pool){ $poolID = $pool['id']; }
$event->add_querylet(new Querylet("images.id IN (SELECT DISTINCT image_id FROM pool_images WHERE pool_id = $poolID)"));
}
}
public function add_post_from_tag(/*str*/ $poolTag, /*int*/ $imageID){ public function add_post_from_tag(/*str*/ $poolTag, /*int*/ $imageID){
$poolTag = str_replace("_", " ", $poolTag); $poolTag = str_replace("_", " ", $poolTag);
//First check if pool tag is a title //First check if pool tag is a title