pluginhost: allow overriding default sort modes via HOOK_HEADLINES_CUSTOM_SORT_MAP etc

This commit is contained in:
Andrew Dolgov 2020-08-13 12:23:27 +03:00
parent dfa65e9374
commit ddf9227dc4
3 changed files with 17 additions and 0 deletions

View File

@ -2352,6 +2352,13 @@ class Feeds extends Handler_Protected {
break; break;
} }
if (!$query) {
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE) as $p) {
list ($query, $skip_first_id) = $p->hook_headlines_custom_sort_override($order);
if ($query) break;
}
}
return [$query, $skip_first_id]; return [$query, $skip_first_id];
} }
} }

View File

@ -66,6 +66,8 @@ class PluginHost {
const HOOK_FEED_TREE = 43; const HOOK_FEED_TREE = 43;
const HOOK_IFRAME_WHITELISTED = 44; const HOOK_IFRAME_WHITELISTED = 44;
const HOOK_ENCLOSURE_IMPORTED = 45; const HOOK_ENCLOSURE_IMPORTED = 45;
const HOOK_HEADLINES_CUSTOM_SORT_MAP = 46;
const HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE = 47;
const KIND_ALL = 1; const KIND_ALL = 1;
const KIND_SYSTEM = 2; const KIND_SYSTEM = 2;

View File

@ -198,6 +198,14 @@
<option value="feed_dates"><?php echo __('Newest first') ?></option> <option value="feed_dates"><?php echo __('Newest first') ?></option>
<option value="date_reverse"><?php echo __('Oldest first') ?></option> <option value="date_reverse"><?php echo __('Oldest first') ?></option>
<option value="title"><?php echo __('Title') ?></option> <option value="title"><?php echo __('Title') ?></option>
<?php foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_CUSTOM_SORT_MAP) as $p) {
$sort_map = $p->hook_headlines_custom_sort_map();
foreach ($sort_map as $sort_value => $sort_title) {
print "<option value=\"" . htmlspecialchars($sort_value) . "\">$sort_title</option>";
}
} ?>
</select> </select>
<div dojoType="fox.form.ComboButton" onclick="Feeds.catchupCurrent()"> <div dojoType="fox.form.ComboButton" onclick="Feeds.catchupCurrent()">