mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-14 01:35:54 +00:00
add plugin-based filter actions (see example plugin in attic)
bump schema
This commit is contained in:
@@ -1004,10 +1004,10 @@ class Handler_Public extends Handler {
|
||||
|
||||
print "<h2>Database update required</h2>";
|
||||
|
||||
print "<h3>";
|
||||
printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.",
|
||||
$updater->getSchemaVersion(), SCHEMA_VERSION);
|
||||
print "</h3>";
|
||||
print_notice("<h4>".
|
||||
sprintf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.",
|
||||
$updater->getSchemaVersion(), SCHEMA_VERSION).
|
||||
"</h4>");
|
||||
|
||||
print_warning("Please backup your database before proceeding.");
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ class PluginHost {
|
||||
private $storage = array();
|
||||
private $feeds = array();
|
||||
private $api_methods = array();
|
||||
private $plugin_actions = array();
|
||||
private $owner_uid;
|
||||
private $debug;
|
||||
private $last_registered;
|
||||
@@ -47,6 +48,7 @@ class PluginHost {
|
||||
const HOOK_SUBSCRIBE_FEED = 27;
|
||||
const HOOK_HEADLINES_BEFORE = 28;
|
||||
const HOOK_RENDER_ENCLOSURE = 29;
|
||||
const HOOK_ARTICLE_FILTER_ACTION = 30;
|
||||
|
||||
const KIND_ALL = 1;
|
||||
const KIND_SYSTEM = 2;
|
||||
@@ -98,7 +100,7 @@ class PluginHost {
|
||||
}
|
||||
|
||||
function get_plugin($name) {
|
||||
return $this->plugins[$name];
|
||||
return $this->plugins[strtolower($name)];
|
||||
}
|
||||
|
||||
function run_hooks($type, $method, $args) {
|
||||
@@ -415,5 +417,19 @@ class PluginHost {
|
||||
function get_api_method($name) {
|
||||
return $this->api_methods[$name];
|
||||
}
|
||||
|
||||
function add_filter_action($sender, $action_name, $action_desc) {
|
||||
$sender_class = get_class($sender);
|
||||
|
||||
if (!isset($this->plugin_actions[$sender_class]))
|
||||
$this->plugin_actions[$sender_class] = array();
|
||||
|
||||
array_push($this->plugin_actions[$sender_class],
|
||||
array("action" => $action_name, "description" => $action_desc, "sender" => $sender));
|
||||
}
|
||||
|
||||
function get_filter_actions() {
|
||||
return $this->plugin_actions;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -519,6 +519,21 @@ class Pref_Filters extends Handler_Protected {
|
||||
$action["action_id"] == 7)
|
||||
$title .= ": " . $action["action_param"];
|
||||
|
||||
if ($action["action_id"] == 9) {
|
||||
list ($pfclass, $pfaction) = explode(":", $action["action_param"]);
|
||||
|
||||
$filter_actions = PluginHost::getInstance()->get_filter_actions();
|
||||
|
||||
foreach ($filter_actions as $fclass => $factions) {
|
||||
foreach ($factions as $faction) {
|
||||
if ($pfaction == $faction["action"] && $pfclass == $fclass) {
|
||||
$title .= ": " . $fclass . ": " . $faction["description"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
@@ -989,16 +1004,18 @@ class Pref_Filters extends Handler_Protected {
|
||||
|
||||
print "</select>";
|
||||
|
||||
$param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6) ?
|
||||
$param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6 || $action_id == 9) ?
|
||||
"" : "display : none";
|
||||
|
||||
$param_hidden = ($action_id == 4 || $action_id == 6) ?
|
||||
"" : "display : none";
|
||||
|
||||
$label_param_hidden = ($action_id == 7) ? "" : "display : none";
|
||||
$plugin_param_hidden = ($action_id == 9) ? "" : "display : none";
|
||||
|
||||
print "<span id=\"filterDlg_paramBox\" style=\"$param_box_hidden\">";
|
||||
print " " . __("with parameters:") . " ";
|
||||
print " ";
|
||||
//print " " . __("with parameters:") . " ";
|
||||
print "<input dojoType=\"dijit.form.TextBox\"
|
||||
id=\"filterDlg_actionParam\" style=\"$param_hidden\"
|
||||
name=\"action_param\" value=\"$action_param\">";
|
||||
@@ -1007,6 +1024,22 @@ class Pref_Filters extends Handler_Protected {
|
||||
"id=\"filterDlg_actionParamLabel\" style=\"$label_param_hidden\"
|
||||
dojoType=\"dijit.form.Select\"");
|
||||
|
||||
$filter_actions = PluginHost::getInstance()->get_filter_actions();
|
||||
$filter_action_hash = array();
|
||||
|
||||
foreach ($filter_actions as $fclass => $factions) {
|
||||
foreach ($factions as $faction) {
|
||||
|
||||
$filter_action_hash[$fclass . ":" . $faction["action"]] =
|
||||
$fclass . ": " . $faction["description"];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print_select_hash("filterDlg_actionParamPlugin", $action_param, $filter_action_hash,
|
||||
"style=\"$plugin_param_hidden\" dojoType=\"dijit.form.Select\"",
|
||||
"action_param_plugin");
|
||||
|
||||
print "</span>";
|
||||
|
||||
print " "; // tiny layout hack
|
||||
|
||||
@@ -752,7 +752,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||
foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
|
||||
$about = $plugin->about();
|
||||
|
||||
if ($about[3] && strpos($name, "example") === FALSE) {
|
||||
if ($about[3]) {
|
||||
if (in_array($name, $system_enabled)) {
|
||||
$checked = "checked='1'";
|
||||
} else {
|
||||
@@ -802,7 +802,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||
foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
|
||||
$about = $plugin->about();
|
||||
|
||||
if (!$about[3] && strpos($name, "example") === FALSE) {
|
||||
if (!$about[3]) {
|
||||
|
||||
if (in_array($name, $system_enabled)) {
|
||||
$checked = "checked='1'";
|
||||
|
||||
Reference in New Issue
Block a user