2021-01-17 07:47:37 +00:00
|
|
|
<?php
|
|
|
|
class Scored_Oldest_First extends Plugin {
|
|
|
|
|
|
|
|
function init($host) {
|
|
|
|
$host->add_hook($host::HOOK_HEADLINES_CUSTOM_SORT_MAP, $this);
|
|
|
|
$host->add_hook($host::HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE, $this);
|
|
|
|
}
|
|
|
|
|
|
|
|
function hook_headlines_custom_sort_map() {
|
|
|
|
return [
|
2021-01-17 07:50:40 +00:00
|
|
|
"dates_reverse_scored" => "Oldest first (with score)"
|
2021-01-17 07:47:37 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function hook_headlines_custom_sort_override($order) {
|
|
|
|
if ($order == "dates_reverse_scored") {
|
|
|
|
return [ "score DESC, updated", true ];
|
|
|
|
} else {
|
|
|
|
return [ "", false ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function about() {
|
2021-03-01 09:11:42 +00:00
|
|
|
return array(null,
|
2021-01-17 07:47:37 +00:00
|
|
|
"Consider article score while sorting by oldest first",
|
|
|
|
"fox",
|
|
|
|
false,
|
|
|
|
"");
|
|
|
|
}
|
|
|
|
|
|
|
|
function api_version() {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|