2012-12-23 11:29:16 +00:00
|
|
|
<?php
|
2017-05-23 18:16:30 +00:00
|
|
|
abstract class Plugin {
|
2013-04-19 13:26:22 +00:00
|
|
|
const API_VERSION_COMPAT = 1;
|
|
|
|
|
2021-03-02 09:15:42 +00:00
|
|
|
/** @var PDO $pdo */
|
2017-12-02 21:18:08 +00:00
|
|
|
protected $pdo;
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/**
|
|
|
|
* @param PluginHost $host
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* */
|
2021-11-13 16:36:24 +00:00
|
|
|
abstract function init($host);
|
2012-12-25 06:02:08 +00:00
|
|
|
|
2021-11-13 16:52:47 +00:00
|
|
|
/** @return array<null|float|string|bool> */
|
2021-11-13 16:36:24 +00:00
|
|
|
abstract function about();
|
2017-05-23 18:16:30 +00:00
|
|
|
// return array(1.0, "plugin", "No description", "No author", false);
|
2012-12-25 06:02:08 +00:00
|
|
|
|
2017-12-03 06:43:18 +00:00
|
|
|
function __construct() {
|
|
|
|
$this->pdo = Db::pdo();
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:55:30 +00:00
|
|
|
/** @return array<string,bool> */
|
2021-11-13 16:36:24 +00:00
|
|
|
function flags() {
|
2016-01-26 08:45:47 +00:00
|
|
|
/* associative array, possible keys:
|
|
|
|
needs_curl = boolean
|
|
|
|
*/
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/**
|
|
|
|
* @param string $method
|
|
|
|
*
|
|
|
|
* @return bool */
|
2021-11-13 16:36:24 +00:00
|
|
|
function is_public_method($method) {
|
2017-02-10 13:04:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/**
|
|
|
|
* @param string $method
|
|
|
|
*
|
|
|
|
* @return bool */
|
2021-11-13 16:36:24 +00:00
|
|
|
function csrf_ignore($method) {
|
2021-03-02 09:15:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/** @return string */
|
2021-11-13 16:36:24 +00:00
|
|
|
function get_js() {
|
2012-12-25 06:02:08 +00:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:52:47 +00:00
|
|
|
/** @return string */
|
|
|
|
function get_css() {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/** @return string */
|
2021-11-13 16:36:24 +00:00
|
|
|
function get_prefs_js() {
|
2012-12-25 06:02:08 +00:00
|
|
|
return "";
|
|
|
|
}
|
2013-04-19 13:26:22 +00:00
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/** @return int */
|
2021-11-13 16:36:24 +00:00
|
|
|
function api_version() {
|
2013-04-19 13:26:22 +00:00
|
|
|
return Plugin::API_VERSION_COMPAT;
|
|
|
|
}
|
2019-03-05 07:26:23 +00:00
|
|
|
|
|
|
|
/* gettext-related helpers */
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/**
|
|
|
|
* @param string $msgid
|
|
|
|
*
|
|
|
|
* @return string */
|
2021-11-13 16:36:24 +00:00
|
|
|
function __($msgid) {
|
2021-11-13 15:26:11 +00:00
|
|
|
/** @var Plugin $this -- this is a strictly template-related hack */
|
2019-03-05 07:26:23 +00:00
|
|
|
return _dgettext(PluginHost::object_to_domain($this), $msgid);
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/**
|
|
|
|
* @param string $singular
|
|
|
|
* @param string $plural
|
|
|
|
* @param int $number
|
|
|
|
*
|
|
|
|
* @return string */
|
2021-11-13 16:36:24 +00:00
|
|
|
function _ngettext($singular, $plural, $number) {
|
2021-11-13 15:26:11 +00:00
|
|
|
/** @var Plugin $this -- this is a strictly template-related hack */
|
2019-03-05 07:26:23 +00:00
|
|
|
return _dngettext(PluginHost::object_to_domain($this), $singular, $plural, $number);
|
|
|
|
}
|
|
|
|
|
2021-11-13 16:41:50 +00:00
|
|
|
/** @return string */
|
2021-11-13 16:36:24 +00:00
|
|
|
function T_sprintf() {
|
2019-03-05 07:26:23 +00:00
|
|
|
$args = func_get_args();
|
|
|
|
$msgid = array_shift($args);
|
|
|
|
|
|
|
|
return vsprintf($this->__($msgid), $args);
|
|
|
|
}
|
2021-11-13 17:03:28 +00:00
|
|
|
|
|
|
|
/* plugin hook methods */
|
|
|
|
|
2021-11-16 13:31:40 +00:00
|
|
|
/* GLOBAL hooks are invoked in global context, only available to system plugins (loaded via .env for all users) */
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Adds buttons for article (on the right) - e.g. mail, share, add note.
|
2021-11-13 17:07:13 +00:00
|
|
|
* @param array<string,mixed> $line
|
|
|
|
* @return string
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_ARTICLE_BUTTON
|
2021-11-17 12:56:58 +00:00
|
|
|
* @see Plugin::hook_article_left_button()
|
2021-11-13 17:07:13 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_article_button($line) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:07:47 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allows plugins to alter article data as gathered from feed XML, i.e. embed images, get full text content, etc.
|
2021-11-13 17:07:13 +00:00
|
|
|
* @param array<string,mixed> $article
|
|
|
|
* @return array<string,mixed>
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_ARTICLE_FILTER
|
2021-11-13 17:07:13 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_article_filter($article) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:07:47 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allow adding new UI elements (e.g. accordion panes) to (top) tab contents in Preferences
|
2021-11-13 17:07:13 +00:00
|
|
|
* @param string $tab
|
|
|
|
* @return void
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_PREFS_TAB
|
2021-11-13 17:07:13 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_prefs_tab($tab) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allow adding new content to various sections of preferences UI (i.e. OPML import/export pane)
|
2021-11-13 17:07:13 +00:00
|
|
|
* @param string $section
|
|
|
|
* @return void
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_PREFS_TAB_SECTION
|
2021-11-13 17:07:13 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_prefs_tab_section($section) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allows adding new (top) tabs in preferences UI
|
|
|
|
* @return void
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_PREFS_TABS
|
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_prefs_tabs() {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Invoked when feed XML is processed by FeedParser class
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param FeedParser $parser
|
|
|
|
* @param int $feed_id
|
|
|
|
* @return void
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_FEED_PARSED
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_feed_parsed($parser, $feed_id) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** GLOBAL: Invoked when a feed update task finishes
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param array<string,string> $cli_options
|
|
|
|
* @return void
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_UPDATE_TASK
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_update_task($cli_options) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** This is a pluginhost compatibility wrapper that invokes $this->authenticate(...$args) (Auth_Base)
|
2021-11-14 08:11:49 +00:00
|
|
|
* @param string $login
|
|
|
|
* @param string $password
|
|
|
|
* @param string $service
|
2021-11-14 07:48:32 +00:00
|
|
|
* @return int|false user_id
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_AUTH_USER
|
2021-11-14 07:48:32 +00:00
|
|
|
*/
|
2021-11-14 08:11:49 +00:00
|
|
|
function hook_auth_user($login, $password, $service = '') {
|
2021-11-13 17:03:28 +00:00
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 07:48:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IAuthModule only
|
|
|
|
* @param string $login
|
|
|
|
* @param string $password
|
2021-11-14 08:11:49 +00:00
|
|
|
* @param string $service
|
2021-11-14 07:48:32 +00:00
|
|
|
* @return int|false user_id
|
|
|
|
*/
|
2021-11-14 08:11:49 +00:00
|
|
|
function authenticate($login, $password, $service = '') {
|
2021-11-14 07:48:32 +00:00
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
return false;
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allows plugins to modify global hotkey map (hotkey sequence -> action)
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param array<string, string> $hotkeys
|
|
|
|
* @return array<string, string>
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_HOTKEY_MAP
|
2021-11-17 12:56:58 +00:00
|
|
|
* @see Plugin::hook_hotkey_info()
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_hotkey_map($hotkeys) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:07:47 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Invoked when article is rendered by backend (before it gets passed to frontent JS code) - three panel mode
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param array<string, mixed> $article
|
|
|
|
* @return array<string, mixed>
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_RENDER_ARTICLE
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_render_article($article) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Invoked when article is rendered by backend (before it gets passed to frontent JS code) - combined mode
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param array<string, mixed> $article
|
|
|
|
* @return array<string, mixed>
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_RENDER_ARTICLE_CDM
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_render_article_cdm($article) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Invoked when raw feed XML data has been successfully downloaded (but not parsed yet)
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param string $feed_data
|
|
|
|
* @param string $fetch_url
|
|
|
|
* @param int $owner_uid
|
|
|
|
* @param int $feed
|
|
|
|
* @return string
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_FEED_FETCHED
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_feed_fetched($feed_data, $fetch_url, $owner_uid, $feed) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Invoked on article content when it is sanitized (i.e. potentially harmful tags removed)
|
2021-11-14 14:19:35 +00:00
|
|
|
* @param DOMDocument $doc
|
|
|
|
* @param string $site_url
|
|
|
|
* @param array<string> $allowed_elements
|
|
|
|
* @param array<string> $disallowed_attributes
|
|
|
|
* @param int $article_id
|
2021-11-14 17:19:12 +00:00
|
|
|
* @return DOMDocument|array<int,DOMDocument|array<string>>
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_SANITIZE
|
2021-11-14 14:19:35 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:19:35 +00:00
|
|
|
|
|
|
|
return $doc;
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Invoked when article is rendered by backend (before it gets passed to frontent JS code) - exclusive to API clients
|
2021-11-14 15:05:31 +00:00
|
|
|
* @param array{'article': array<string,mixed>|null, 'headline': array<string,mixed>|null} $params
|
2021-11-14 13:49:10 +00:00
|
|
|
* @return array<string, string>
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_RENDER_ARTICLE_API
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_render_article_api($params) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Allows adding new UI elements to tt-rss main toolbar (to the right, before Actions... dropdown)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @return string
|
|
|
|
* @see PluginHost::HOOK_TOOLBAR_BUTTON
|
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_toolbar_button() {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allows adding new items to tt-rss main Actions... dropdown menu
|
2021-11-16 13:31:40 +00:00
|
|
|
* @return string
|
|
|
|
* @see PluginHost::HOOK_ACTION_ITEM
|
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_action_item() {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allows adding new UI elements to the toolbar area related to currently loaded feed headlines
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param int $feed_id
|
|
|
|
* @param bool $is_cat
|
|
|
|
* @return string
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_headline_toolbar_button($feed_id, $is_cat) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allows adding new hotkey action names and descriptions
|
2021-11-14 22:16:16 +00:00
|
|
|
* @param array<string, array<string, string>> $hotkeys
|
2021-11-14 22:11:27 +00:00
|
|
|
* @return array<string, array<string, string>>
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_HOTKEY_INFO
|
2021-11-17 12:56:58 +00:00
|
|
|
* @see Plugin::hook_hotkey_map()
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_hotkey_info($hotkeys) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Adds per-article buttons on the left side
|
2021-11-14 14:07:47 +00:00
|
|
|
* @param array<string,mixed> $row
|
|
|
|
* @return string
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_ARTICLE_LEFT_BUTTON
|
2021-11-17 12:56:58 +00:00
|
|
|
* @see Plugin::hook_article_button()
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_article_left_button($row) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:07:47 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allows adding new UI elements to the "Plugins" tab of the feed editor UI
|
2021-11-14 14:07:47 +00:00
|
|
|
* @param int $feed_id
|
|
|
|
* @return void
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_PREFS_EDIT_FEED
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_prefs_edit_feed($feed_id) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Invoked when data is saved in the feed editor
|
2021-11-14 14:07:47 +00:00
|
|
|
* @param int $feed_id
|
|
|
|
* @return void
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_PREFS_SAVE_FEED
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_prefs_save_feed($feed_id) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allows overriding built-in fetching mechanism for feeds, substituting received data if necessary
|
|
|
|
* (i.e. origin site doesn't actually provide any RSS feeds), or XML is invalid
|
2021-11-14 14:19:35 +00:00
|
|
|
* @param string $feed_data
|
|
|
|
* @param string $fetch_url
|
|
|
|
* @param int $owner_uid
|
|
|
|
* @param int $feed
|
|
|
|
* @param int $last_article_timestamp
|
|
|
|
* @param string $auth_login
|
|
|
|
* @param string $auth_pass
|
|
|
|
* @return string (possibly mangled feed data)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_FETCH_FEED
|
2021-11-14 14:19:35 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:19:35 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Invoked when headlines data ($row) has been retrieved from the database
|
2021-11-14 14:07:47 +00:00
|
|
|
* @param array<string,mixed> $row
|
|
|
|
* @param int $excerpt_length
|
|
|
|
* @return array<string,mixed>
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_QUERY_HEADLINES
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
|
|
|
function hook_query_headlines($row, $excerpt_length) {
|
2021-11-13 17:03:28 +00:00
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:07:47 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 16:54:42 +00:00
|
|
|
/** This is run periodically by the update daemon when idle (available both to user and system plugins)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @return void
|
|
|
|
* @see PluginHost::HOOK_HOUSE_KEEPING */
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_house_keeping() {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
}
|
|
|
|
|
2021-11-17 12:56:58 +00:00
|
|
|
/** Allows overriding built-in article search
|
2021-11-14 14:07:47 +00:00
|
|
|
* @param string $query
|
2021-11-17 12:56:58 +00:00
|
|
|
* @return array<int, string|array<string>> - list(SQL search query, highlight keywords)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_SEARCH
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_search($query) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:07:47 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked when enclosures are rendered to HTML (when article itself is rendered)
|
2021-11-14 14:19:35 +00:00
|
|
|
* @param string $enclosures_formatted
|
|
|
|
* @param array<int, array<string, mixed>> $enclosures
|
|
|
|
* @param int $article_id
|
|
|
|
* @param bool $always_display_enclosures
|
|
|
|
* @param string $article_content
|
|
|
|
* @param bool $hide_images
|
|
|
|
* @return string|array<string,array<int, array<string, mixed>>> ($enclosures_formatted, $enclosures)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_FORMAT_ENCLOSURES
|
2021-11-14 14:19:35 +00:00
|
|
|
*/
|
|
|
|
function hook_format_enclosures($enclosures_formatted, $enclosures, $article_id, $always_display_enclosures, $article_content, $hide_images) {
|
2021-11-13 17:03:28 +00:00
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:19:35 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked during feed subscription (after data has been fetched)
|
2021-11-14 14:07:47 +00:00
|
|
|
* @param string $contents
|
|
|
|
* @param string $url
|
|
|
|
* @param string $auth_login
|
|
|
|
* @param string $auth_pass
|
|
|
|
* @return string (possibly mangled feed data)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_SUBSCRIBE_FEED
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:19:35 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-14 14:07:47 +00:00
|
|
|
/**
|
|
|
|
* @param int $feed
|
|
|
|
* @param bool $is_cat
|
|
|
|
* @param array<string,mixed> $qfh_ret (headlines object)
|
|
|
|
* @return string
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_HEADLINES_BEFORE
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_headlines_before($feed, $is_cat, $qfh_ret) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:07:47 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-14 14:07:47 +00:00
|
|
|
/**
|
|
|
|
* @param array<string,mixed> $entry
|
|
|
|
* @param int $article_id
|
|
|
|
* @param array<string,mixed> $rv
|
|
|
|
* @return string
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_RENDER_ENCLOSURE
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
|
|
|
function hook_render_enclosure($entry, $article_id, $rv) {
|
2021-11-13 17:03:28 +00:00
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:19:35 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-14 14:19:35 +00:00
|
|
|
/**
|
|
|
|
* @param array<string,mixed> $article
|
|
|
|
* @param string $action
|
|
|
|
* @return array<string,mixed> ($article)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_ARTICLE_FILTER_ACTION
|
2021-11-14 14:19:35 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_article_filter_action($article, $action) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:19:35 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-14 14:07:47 +00:00
|
|
|
/**
|
|
|
|
* @param array<string,mixed> $line
|
|
|
|
* @param int $feed
|
|
|
|
* @param bool $is_cat
|
|
|
|
* @param int $owner_uid
|
|
|
|
* @return array<string,mixed> ($line)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_ARTICLE_EXPORT_FEED
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_article_export_feed($line, $feed, $is_cat, $owner_uid) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:07:47 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Allows adding custom buttons to tt-rss main toolbar (left side)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @return void
|
|
|
|
* @see PluginHost::HOOK_MAIN_TOOLBAR_BUTTON
|
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_main_toolbar_button() {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked for every enclosure entry as article is being rendered
|
2021-11-14 08:11:49 +00:00
|
|
|
* @param array<string,string> $entry
|
|
|
|
* @param int $id
|
|
|
|
* @param array{'formatted': string, 'entries': array<int, array<string, mixed>>} $rv
|
2021-11-14 14:07:47 +00:00
|
|
|
* @return array<string,string> ($entry)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_ENCLOSURE_ENTRY
|
2021-11-14 08:11:49 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_enclosure_entry($entry, $id, $rv) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:07:47 +00:00
|
|
|
|
|
|
|
return [];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Share plugins run this when article is being rendered as HTML for sharing
|
2021-11-14 14:07:47 +00:00
|
|
|
* @param string $html
|
|
|
|
* @param array<string,mixed> $row
|
|
|
|
* @return string ($html)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_FORMAT_ARTICLE
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_format_article($html, $row) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:19:35 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked when basic feed information (title, site_url) is being collected, useful to override default if feed doesn't provide anything (or feed itself is synthesized)
|
2021-11-14 15:00:03 +00:00
|
|
|
* @param array{"title": string, "site_url": string} $basic_info
|
|
|
|
* @param string $fetch_url
|
|
|
|
* @param int $owner_uid
|
|
|
|
* @param int $feed_id
|
|
|
|
* @param string $auth_login
|
|
|
|
* @param string $auth_pass
|
|
|
|
* @return array{"title": string, "site_url": string}
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_FEED_BASIC_INFO
|
2021-11-14 15:00:03 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_feed_basic_info($basic_info, $fetch_url, $owner_uid, $feed_id, $auth_login, $auth_pass) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 15:00:03 +00:00
|
|
|
|
|
|
|
return $basic_info;
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked when file (e.g. cache entry, static data) is being sent to client, may override default mechanism
|
|
|
|
* using faster httpd-specific implementation (see nginx_xaccel)
|
2021-11-14 15:00:03 +00:00
|
|
|
* @param string $filename
|
|
|
|
* @return bool
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_SEND_LOCAL_FILE
|
2021-11-14 15:00:03 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_send_local_file($filename) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 15:00:03 +00:00
|
|
|
|
|
|
|
return false;
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked when user tries to unsubscribe from a feed, returning true would prevent any further default actions
|
2021-11-14 15:00:03 +00:00
|
|
|
* @param int $feed_id
|
|
|
|
* @param int $owner_uid
|
|
|
|
* @return bool
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_UNSUBSCRIBE_FEED
|
2021-11-14 15:00:03 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_unsubscribe_feed($feed_id, $owner_uid) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 15:00:03 +00:00
|
|
|
|
|
|
|
return false;
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked when mail is being sent (if no hooks are registered, tt-rss uses PHP mail() as a fallback)
|
2021-11-14 14:07:47 +00:00
|
|
|
* @param Mailer $mailer
|
|
|
|
* @param array<string,mixed> $params
|
|
|
|
* @return int
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_SEND_MAIL
|
2021-11-14 14:07:47 +00:00
|
|
|
*/
|
|
|
|
function hook_send_mail($mailer, $params) {
|
2021-11-13 17:03:28 +00:00
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 14:07:47 +00:00
|
|
|
|
|
|
|
return -1;
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked when filter is triggered on an article, may be used to implement logging for filters
|
|
|
|
* NOTE: $article_filters should be renamed $filter_actions because that's what this is
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param int $feed_id
|
|
|
|
* @param int $owner_uid
|
|
|
|
* @param array<string,mixed> $article
|
|
|
|
* @param array<string,mixed> $matched_filters
|
|
|
|
* @param array<string,string|bool|int> $matched_rules
|
|
|
|
* @param array<string,string> $article_filters
|
|
|
|
* @return void
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_FILTER_TRIGGERED
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_filter_triggered($feed_id, $owner_uid, $article, $matched_filters, $matched_rules, $article_filters) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Plugins may provide this to allow getting full article text (af_readbility implements this)
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param string $url
|
2021-11-14 17:19:12 +00:00
|
|
|
* @return string|false
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_GET_FULL_TEXT
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_get_full_text($url) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked when article flavor image is being determined, allows overriding default selection logic
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param array<string,string> $enclosures
|
|
|
|
* @param string $content
|
|
|
|
* @param string $site_url
|
|
|
|
* @param array<string,mixed> $article
|
2021-11-14 15:05:31 +00:00
|
|
|
* @return string|array<int,string>
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_ARTICLE_IMAGE
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-14 08:11:49 +00:00
|
|
|
function hook_article_image($enclosures, $content, $site_url, $article) {
|
2021-11-13 17:03:28 +00:00
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Allows adding arbitrary elements before feed tree
|
|
|
|
* @return string HTML
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_FEED_TREE
|
|
|
|
* */
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_feed_tree() {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked for every iframe to determine if it is allowed to be displayed
|
2021-11-14 13:49:10 +00:00
|
|
|
* @param string $url
|
|
|
|
* @return bool
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_IFRAME_WHITELISTED
|
2021-11-14 13:49:10 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_iframe_whitelisted($url) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 13:49:10 +00:00
|
|
|
|
|
|
|
return false;
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-14 15:00:03 +00:00
|
|
|
/**
|
2021-11-14 20:03:25 +00:00
|
|
|
* @param object $enclosure
|
2021-11-14 15:00:03 +00:00
|
|
|
* @param int $feed
|
2021-11-14 20:03:25 +00:00
|
|
|
* @return object ($enclosure)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_ENCLOSURE_IMPORTED
|
2021-11-14 15:00:03 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_enclosure_imported($enclosure, $feed) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 15:00:03 +00:00
|
|
|
|
|
|
|
return $enclosure;
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Allows adding custom elements to headline sort dropdown (name -> caption)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @return array<string,string>
|
|
|
|
* @see PluginHost::HOOK_HEADLINES_CUSTOM_SORT_MAP
|
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_headlines_custom_sort_map() {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 15:00:03 +00:00
|
|
|
|
|
|
|
return ["" => ""];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Allows overriding headline sorting (or provide custom sort methods)
|
2021-11-14 15:00:03 +00:00
|
|
|
* @param string $order
|
2021-11-17 15:30:32 +00:00
|
|
|
* @return array<int, string|bool> -- (query, skip_first_id)
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE
|
2021-11-14 15:00:03 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_headlines_custom_sort_override($order) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 15:00:03 +00:00
|
|
|
|
|
|
|
return ["", false];
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Allows adding custom elements to headlines Select... dropdown
|
2021-11-14 15:00:03 +00:00
|
|
|
* @param int $feed_id
|
|
|
|
* @param int $is_cat
|
|
|
|
* @return string
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM
|
2021-11-14 15:00:03 +00:00
|
|
|
*/
|
2021-11-13 17:03:28 +00:00
|
|
|
function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) {
|
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 15:00:03 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-17 15:30:32 +00:00
|
|
|
/** Invoked when user tries to subscribe to feed, may override information (i.e. feed URL) used afterwards
|
2021-11-14 15:00:03 +00:00
|
|
|
* @param string $url
|
|
|
|
* @param string $auth_login
|
|
|
|
* @param string $auth_pass
|
|
|
|
* @return bool
|
2021-11-16 13:31:40 +00:00
|
|
|
* @see PluginHost::HOOK_PRE_SUBSCRIBE
|
2021-11-14 15:00:03 +00:00
|
|
|
*/
|
2021-11-14 08:11:49 +00:00
|
|
|
function hook_pre_subscribe(&$url, $auth_login, $auth_pass) {
|
2021-11-13 17:03:28 +00:00
|
|
|
user_error("Dummy method invoked.", E_USER_ERROR);
|
2021-11-14 15:00:03 +00:00
|
|
|
|
|
|
|
return false;
|
2021-11-13 17:03:28 +00:00
|
|
|
}
|
2021-12-06 10:20:18 +00:00
|
|
|
|
|
|
|
/** Invoked after user logout, may override built-in behavior (redirect back to login page)
|
|
|
|
* @param string $login
|
|
|
|
* @param int $user_id
|
|
|
|
* @return array<mixed> - [0] - if set, url to redirect to
|
|
|
|
*/
|
|
|
|
function hook_post_logout($login, $user_id) {
|
|
|
|
return [""];
|
|
|
|
}
|
2019-03-05 07:26:23 +00:00
|
|
|
}
|