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.");
private $storage = array();
private $feeds = array();
private $api_methods = array();
+ private $plugin_actions = array();
private $owner_uid;
private $debug;
private $last_registered;
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;
}
function get_plugin($name) {
- return $this->plugins[$name];
+ return $this->plugins[strtolower($name)];
}
function run_hooks($type, $method, $args) {
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;
+ }
}
?>
$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;
}
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\">";
"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
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 {
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'";
<?php
define('EXPECTED_CONFIG_VERSION', 26);
- define('SCHEMA_VERSION', 128);
+ define('SCHEMA_VERSION', 129);
define('LABEL_BASE_INDEX', -1024);
define('PLUGIN_FEED_BASE_INDEX', -128);
}
}
- function print_select($id, $default, $values, $attributes = "") {
- print "<select name=\"$id\" id=\"$id\" $attributes>";
+ function print_select($id, $default, $values, $attributes = "", $name = "") {
+ if (!$name) $name = $id;
+
+ print "<select name=\"$name\" id=\"$id\" $attributes>";
foreach ($values as $v) {
if ($v == $default)
$sel = "selected=\"1\"";
print "</select>";
}
- function print_select_hash($id, $default, $values, $attributes = "") {
- print "<select name=\"$id\" id='$id' $attributes>";
+ function print_select_hash($id, $default, $values, $attributes = "", $name = "") {
+ if (!$name) $name = $id;
+
+ print "<select name=\"$name\" id='$id' $attributes>";
foreach (array_keys($values) as $v) {
if ($v == $default)
$sel = 'selected="selected"';
}
}
+ /* Collect article tags here so we could filter by them: */
+
+ $article_filters = get_article_filters($filters, $article["title"],
+ $article["content"], $article["link"], 0, $article["author"],
+ $article["tags"]);
+
+ if ($debug_enabled) {
+ _debug("article filters: ", $debug_enabled);
+ if (count($article_filters) != 0) {
+ print_r($article_filters);
+ }
+ }
+
+ $plugin_filter_names = find_article_filters($article_filters, "plugin");
+ $plugin_filter_actions = $pluginhost->get_filter_actions();
+
+ if (count($plugin_filter_names) > 0) {
+ _debug("applying plugin filter actions...", $debug_enabled);
+
+ foreach ($plugin_filter_names as $pfn) {
+ list($pfclass,$pfaction) = explode(":", $pfn["param"]);
+
+ if (isset($plugin_filter_actions[$pfclass])) {
+ $plugin = $pluginhost->get_plugin($pfclass);
+
+ _debug("... $pfclass: $pfaction", $debug_enabled);
+
+ if ($plugin) {
+ $start = microtime(true);
+ $article = $plugin->hook_article_filter_action($article, $pfaction);
+
+ _debug("=== " . sprintf("%.4f (sec)", microtime(true) - $start), $debug_enabled);
+ } else {
+ _debug("??? $pfclass: plugin object not found.");
+ }
+ } else {
+ _debug("??? $pfclass: filter plugin not registered.");
+ }
+ }
+ }
+
$entry_tags = $article["tags"];
$entry_guid = db_escape_string($entry_guid);
$entry_title = db_escape_string($article["title"]);
$dupcheck_qpart = "";
}
- /* Collect article tags here so we could filter by them: */
-
- $article_filters = get_article_filters($filters, $entry_title,
- $entry_content, $entry_link, $entry_timestamp, $entry_author,
- $entry_tags);
-
- if ($debug_enabled) {
- _debug("article filters: ", $debug_enabled);
- if (count($article_filters) != 0) {
- print_r($article_filters);
- }
- }
-
if (find_article_filter($article_filters, "filter")) {
//db_query("COMMIT"); // close transaction in progress
continue;
}
// if selected action supports parameters, enable params field
- if (action == 4 || action == 6 || action == 7) {
+ if (action == 4 || action == 6 || action == 7 || action == 9) {
new Effect.Appear(action_param, {duration : 0.5});
- if (action != 7) {
- Element.show(dijit.byId("filterDlg_actionParam").domNode);
- Element.hide(dijit.byId("filterDlg_actionParamLabel").domNode);
- } else {
+
+ Element.hide(dijit.byId("filterDlg_actionParam").domNode);
+ Element.hide(dijit.byId("filterDlg_actionParamLabel").domNode);
+ Element.hide(dijit.byId("filterDlg_actionParamPlugin").domNode);
+
+ if (action == 7) {
Element.show(dijit.byId("filterDlg_actionParamLabel").domNode);
- Element.hide(dijit.byId("filterDlg_actionParam").domNode);
+ } else if (action == 9) {
+ Element.show(dijit.byId("filterDlg_actionParamPlugin").domNode);
+ } else {
+ Element.show(dijit.byId("filterDlg_actionParam").domNode);
}
+
} else {
Element.hide(action_param);
}
if (form.action_id.value == 7) {
form.action_param.value = form.action_param_label.value;
+ } else if (form.action_id.value == 9) {
+ form.action_param.value = form.action_param_plugin.value;
}
var query = "backend.php?op=pref-filters&method=printactionname&action="+
insert into ttrss_filter_actions (id,name,description) values (8, 'stop',
'Stop / Do nothing');
+insert into ttrss_filter_actions (id,name,description) values (9, 'plugin',
+ 'Invoke plugin');
+
create table ttrss_filters2(id integer primary key auto_increment,
owner_uid integer not null,
match_any_rule boolean not null default false,
create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
-insert into ttrss_version values (127);
+insert into ttrss_version values (129);
create table ttrss_enclosures (id integer primary key auto_increment,
content_url text not null,
insert into ttrss_filter_actions (id,name,description) values (8, 'stop',
'Stop / Do nothing');
+insert into ttrss_filter_actions (id,name,description) values (9, 'plugin',
+ 'Invoke plugin');
+
create table ttrss_filters2(id serial not null primary key,
owner_uid integer not null references ttrss_users(id) on delete cascade,
match_any_rule boolean not null default false,
create table ttrss_version (schema_version int not null);
-insert into ttrss_version values (127);
+insert into ttrss_version values (129);
create table ttrss_enclosures (id serial not null primary key,
content_url text not null,
--- /dev/null
+BEGIN;
+
+insert into ttrss_filter_actions (id,name,description) values (9, 'plugin',
+ 'Invoke plugin');
+
+UPDATE ttrss_version SET schema_version = 129;
+
+COMMIT;
--- /dev/null
+BEGIN;
+
+insert into ttrss_filter_actions (id,name,description) values (9, 'plugin',
+ 'Invoke plugin');
+
+UPDATE ttrss_version SET schema_version = 129;
+
+COMMIT;