order[=|:]random_#### metatag
possible replacement for random_list ext?
This commit is contained in:
parent
320a92289b
commit
d675827173
@ -129,7 +129,7 @@ class Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$querylet = Image::build_search_querylet($tags);
|
$querylet = Image::build_search_querylet($tags);
|
||||||
$querylet->append(new Querylet(" ORDER BY images.".($order_sql ?: $config->get_string("index_order"))));
|
$querylet->append(new Querylet(" ORDER BY ".($order_sql ?: "images.".$config->get_string("index_order"))));
|
||||||
$querylet->append(new Querylet(" LIMIT :limit OFFSET :offset", array("limit"=>$limit, "offset"=>$start)));
|
$querylet->append(new Querylet(" LIMIT :limit OFFSET :offset", array("limit"=>$limit, "offset"=>$start)));
|
||||||
#var_dump($querylet->sql); var_dump($querylet->variables);
|
#var_dump($querylet->sql); var_dump($querylet->variables);
|
||||||
$result = $database->execute($querylet->sql, $querylet->variables);
|
$result = $database->execute($querylet->sql, $querylet->variables);
|
||||||
|
@ -94,6 +94,10 @@
|
|||||||
* <li>order=width -- find all images sorted from highest > lowest width
|
* <li>order=width -- find all images sorted from highest > lowest width
|
||||||
* <li>order=filesize_asc -- find all images sorted from lowest > highest filesize
|
* <li>order=filesize_asc -- find all images sorted from lowest > highest filesize
|
||||||
* </ul>
|
* </ul>
|
||||||
|
* <li>order=random_####, eg
|
||||||
|
* <ul>
|
||||||
|
* <li>order=random_8547 -- find all images sorted randomly using 8547 as a seed
|
||||||
|
* </ul>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>Search items can be combined to search for images which match both,
|
* <p>Search items can be combined to search for images which match both,
|
||||||
* or you can stick "-" in front of an item to search for things that don't
|
* or you can stick "-" in front of an item to search for things that don't
|
||||||
@ -362,7 +366,15 @@ class Index extends Extension {
|
|||||||
$ord = strtolower($matches[1]);
|
$ord = strtolower($matches[1]);
|
||||||
$default_order_for_column = preg_match("/^(id|filename)$/", $matches[1]) ? "ASC" : "DESC";
|
$default_order_for_column = preg_match("/^(id|filename)$/", $matches[1]) ? "ASC" : "DESC";
|
||||||
$sort = isset($matches[2]) ? strtoupper($matches[2]) : $default_order_for_column;
|
$sort = isset($matches[2]) ? strtoupper($matches[2]) : $default_order_for_column;
|
||||||
$order_sql = "$ord $sort";
|
$order_sql = "images.$ord $sort";
|
||||||
|
$event->add_querylet(new Querylet("1=1")); //small hack to avoid metatag being treated as normal tag
|
||||||
|
}
|
||||||
|
else if(preg_match("/^order[=|:]random[_]([0-9]{1,4})$/i", $event->term, $matches)){
|
||||||
|
global $order_sql;
|
||||||
|
//order[=|:]random requires a seed to avoid duplicates
|
||||||
|
//since the tag can't be changed during the parseevent, we instead generate the seed during submit using js
|
||||||
|
$seed = $matches[1];
|
||||||
|
$order_sql = "RAND($seed)";
|
||||||
$event->add_querylet(new Querylet("1=1")); //small hack to avoid metatag being treated as normal tag
|
$event->add_querylet(new Querylet("1=1")); //small hack to avoid metatag being treated as normal tag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,18 @@ $(function() {
|
|||||||
function() {$('.shm-image-list').show();}
|
function() {$('.shm-image-list').show();}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Generate a random seed when using order:random
|
||||||
|
$('form[action="/shimmie/post/list"]').submit(function(e){
|
||||||
|
var input = $('form[action="/shimmie/post/list"] input[name=search]');
|
||||||
|
var tagArr = input.val().split(" ");
|
||||||
|
|
||||||
|
var rand = (($.inArray("order:random", tagArr) + 1) || ($.inArray("order=random", tagArr) + 1)) - 1;
|
||||||
|
if(rand !== -1){
|
||||||
|
tagArr[rand] = "order:random_"+Math.floor((Math.random()*9999)+1);
|
||||||
|
input.val(tagArr.join(" "));
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function select_blocked_tags() {
|
function select_blocked_tags() {
|
||||||
|
@ -237,7 +237,7 @@ class NumericScore extends Extension {
|
|||||||
global $order_sql;
|
global $order_sql;
|
||||||
$default_order_for_column = "DESC";
|
$default_order_for_column = "DESC";
|
||||||
$sort = isset($matches[3]) ? strtoupper($matches[3]) : $default_order_for_column;
|
$sort = isset($matches[3]) ? strtoupper($matches[3]) : $default_order_for_column;
|
||||||
$order_sql = "numeric_score $sort";
|
$order_sql = "images.numeric_score $sort";
|
||||||
$event->add_querylet(new Querylet("1=1")); //small hack to avoid metatag being treated as normal tag
|
$event->add_querylet(new Querylet("1=1")); //small hack to avoid metatag being treated as normal tag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user