diff options
Diffstat (limited to 'classes/plugin.php')
-rw-r--r-- | classes/plugin.php | 85 |
1 files changed, 70 insertions, 15 deletions
diff --git a/classes/plugin.php b/classes/plugin.php index 16e9791eb..afa9d7a78 100644 --- a/classes/plugin.php +++ b/classes/plugin.php @@ -1,11 +1,4 @@ <?php -/* TODO: I haven't yet decided if we're keeping hook prototypes which did grow (with additional params) over time and breaking all plugins - with legacy function definitions, or commenting base definitions out for the time being -fox - - (It's a shame that PHP doesn't support argument overloading) - - Stuff like hook_enclosure_entry() etc. -*/ abstract class Plugin { const API_VERSION_COMPAT = 1; @@ -103,9 +96,12 @@ abstract class Plugin { /* plugin hook methods */ + /* GLOBAL hooks are invoked in global context, only available to system plugins (loaded via .env for all users) */ + /** * @param array<string,mixed> $line * @return string + * @see PluginHost::HOOK_ARTICLE_BUTTON */ function hook_article_button($line) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -116,6 +112,7 @@ abstract class Plugin { /** * @param array<string,mixed> $article * @return array<string,mixed> + * @see PluginHost::HOOK_ARTICLE_FILTER */ function hook_article_filter($article) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -126,6 +123,7 @@ abstract class Plugin { /** * @param string $tab * @return void + * @see PluginHost::HOOK_PREFS_TAB */ function hook_prefs_tab($tab) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -134,12 +132,15 @@ abstract class Plugin { /** * @param string $section * @return void + * @see PluginHost::HOOK_PREFS_TAB_SECTION */ function hook_prefs_tab_section($section) { user_error("Dummy method invoked.", E_USER_ERROR); } - /** @return void */ + /** @return void + * @see PluginHost::HOOK_PREFS_TABS + */ function hook_prefs_tabs() { user_error("Dummy method invoked.", E_USER_ERROR); } @@ -148,14 +149,16 @@ abstract class Plugin { * @param FeedParser $parser * @param int $feed_id * @return void + * @see PluginHost::HOOK_FEED_PARSED */ function hook_feed_parsed($parser, $feed_id) { user_error("Dummy method invoked.", E_USER_ERROR); } - /** + /** GLOBAL * @param array<string,string> $cli_options * @return void + * @see PluginHost::HOOK_UPDATE_TASK */ function hook_update_task($cli_options) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -166,6 +169,7 @@ abstract class Plugin { * @param string $password * @param string $service * @return int|false user_id + * @see PluginHost::HOOK_AUTH_USER */ function hook_auth_user($login, $password, $service = '') { user_error("Dummy method invoked.", E_USER_ERROR); @@ -186,6 +190,7 @@ abstract class Plugin { /** * @param array<string, string> $hotkeys * @return array<string, string> + * @see PluginHost::HOOK_HOTKEY_MAP */ function hook_hotkey_map($hotkeys) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -196,6 +201,7 @@ abstract class Plugin { /** * @param array<string, mixed> $article * @return array<string, mixed> + * @see PluginHost::HOOK_RENDER_ARTICLE */ function hook_render_article($article) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -206,6 +212,7 @@ abstract class Plugin { /** * @param array<string, mixed> $article * @return array<string, mixed> + * @see PluginHost::HOOK_RENDER_ARTICLE_CDM */ function hook_render_article_cdm($article) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -219,6 +226,7 @@ abstract class Plugin { * @param int $owner_uid * @param int $feed * @return string + * @see PluginHost::HOOK_FEED_FETCHED */ function hook_feed_fetched($feed_data, $fetch_url, $owner_uid, $feed) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -233,6 +241,7 @@ abstract class Plugin { * @param array<string> $disallowed_attributes * @param int $article_id * @return DOMDocument|array<int,DOMDocument|array<string>> + * @see PluginHost::HOOK_SANITIZE */ function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -243,6 +252,7 @@ abstract class Plugin { /** * @param array{'article': array<string,mixed>|null, 'headline': array<string,mixed>|null} $params * @return array<string, string> + * @see PluginHost::HOOK_RENDER_ARTICLE_API */ function hook_render_article_api($params) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -250,14 +260,20 @@ abstract class Plugin { return []; } - /** @return string */ + /** + * @return string + * @see PluginHost::HOOK_TOOLBAR_BUTTON + */ function hook_toolbar_button() { user_error("Dummy method invoked.", E_USER_ERROR); return ""; } - /** @return string */ + /** + * @return string + * @see PluginHost::HOOK_ACTION_ITEM + */ function hook_action_item() { user_error("Dummy method invoked.", E_USER_ERROR); @@ -268,6 +284,7 @@ abstract class Plugin { * @param int $feed_id * @param bool $is_cat * @return string + * @see PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON */ function hook_headline_toolbar_button($feed_id, $is_cat) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -278,6 +295,7 @@ abstract class Plugin { /** * @param array<string, array<string, string>> $hotkeys * @return array<string, array<string, string>> + * @see PluginHost::HOOK_HOTKEY_INFO */ function hook_hotkey_info($hotkeys) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -288,6 +306,7 @@ abstract class Plugin { /** * @param array<string,mixed> $row * @return string + * @see PluginHost::HOOK_ARTICLE_LEFT_BUTTON */ function hook_article_left_button($row) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -298,6 +317,7 @@ abstract class Plugin { /** * @param int $feed_id * @return void + * @see PluginHost::HOOK_PREFS_EDIT_FEED */ function hook_prefs_edit_feed($feed_id) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -306,6 +326,7 @@ abstract class Plugin { /** * @param int $feed_id * @return void + * @see PluginHost::HOOK_PREFS_SAVE_FEED */ function hook_prefs_save_feed($feed_id) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -320,6 +341,7 @@ abstract class Plugin { * @param string $auth_login * @param string $auth_pass * @return string (possibly mangled feed data) + * @see PluginHost::HOOK_FETCH_FEED */ 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); @@ -331,6 +353,7 @@ abstract class Plugin { * @param array<string,mixed> $row * @param int $excerpt_length * @return array<string,mixed> + * @see PluginHost::HOOK_QUERY_HEADLINES */ function hook_query_headlines($row, $excerpt_length) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -338,7 +361,9 @@ abstract class Plugin { return []; } - /** @return void */ + /** GLOBAL + * @return void + * @see PluginHost::HOOK_HOUSE_KEEPING */ function hook_house_keeping() { user_error("Dummy method invoked.", E_USER_ERROR); } @@ -346,6 +371,7 @@ abstract class Plugin { /** * @param string $query * @return array<int, string|array<string>> + * @see PluginHost::HOOK_SEARCH */ function hook_search($query) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -361,6 +387,7 @@ abstract class Plugin { * @param string $article_content * @param bool $hide_images * @return string|array<string,array<int, array<string, mixed>>> ($enclosures_formatted, $enclosures) + * @see PluginHost::HOOK_FORMAT_ENCLOSURES */ function hook_format_enclosures($enclosures_formatted, $enclosures, $article_id, $always_display_enclosures, $article_content, $hide_images) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -374,6 +401,7 @@ abstract class Plugin { * @param string $auth_login * @param string $auth_pass * @return string (possibly mangled feed data) + * @see PluginHost::HOOK_SUBSCRIBE_FEED */ function hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -386,6 +414,7 @@ abstract class Plugin { * @param bool $is_cat * @param array<string,mixed> $qfh_ret (headlines object) * @return string + * @see PluginHost::HOOK_HEADLINES_BEFORE */ function hook_headlines_before($feed, $is_cat, $qfh_ret) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -398,6 +427,7 @@ abstract class Plugin { * @param int $article_id * @param array<string,mixed> $rv * @return string + * @see PluginHost::HOOK_RENDER_ENCLOSURE */ function hook_render_enclosure($entry, $article_id, $rv) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -409,6 +439,7 @@ abstract class Plugin { * @param array<string,mixed> $article * @param string $action * @return array<string,mixed> ($article) + * @see PluginHost::HOOK_ARTICLE_FILTER_ACTION */ function hook_article_filter_action($article, $action) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -422,6 +453,7 @@ abstract class Plugin { * @param bool $is_cat * @param int $owner_uid * @return array<string,mixed> ($line) + * @see PluginHost::HOOK_ARTICLE_EXPORT_FEED */ function hook_article_export_feed($line, $feed, $is_cat, $owner_uid) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -429,7 +461,10 @@ abstract class Plugin { return []; } - /** @return void */ + /** + * @return void + * @see PluginHost::HOOK_MAIN_TOOLBAR_BUTTON + */ function hook_main_toolbar_button() { user_error("Dummy method invoked.", E_USER_ERROR); } @@ -439,6 +474,7 @@ abstract class Plugin { * @param int $id * @param array{'formatted': string, 'entries': array<int, array<string, mixed>>} $rv * @return array<string,string> ($entry) + * @see PluginHost::HOOK_ENCLOSURE_ENTRY */ function hook_enclosure_entry($entry, $id, $rv) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -450,6 +486,7 @@ abstract class Plugin { * @param string $html * @param array<string,mixed> $row * @return string ($html) + * @see PluginHost::HOOK_FORMAT_ARTICLE */ function hook_format_article($html, $row) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -465,6 +502,7 @@ abstract class Plugin { * @param string $auth_login * @param string $auth_pass * @return array{"title": string, "site_url": string} + * @see PluginHost::HOOK_FEED_BASIC_INFO */ 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); @@ -475,6 +513,7 @@ abstract class Plugin { /** * @param string $filename * @return bool + * @see PluginHost::HOOK_SEND_LOCAL_FILE */ function hook_send_local_file($filename) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -486,6 +525,7 @@ abstract class Plugin { * @param int $feed_id * @param int $owner_uid * @return bool + * @see PluginHost::HOOK_UNSUBSCRIBE_FEED */ function hook_unsubscribe_feed($feed_id, $owner_uid) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -497,6 +537,7 @@ abstract class Plugin { * @param Mailer $mailer * @param array<string,mixed> $params * @return int + * @see PluginHost::HOOK_SEND_MAIL */ function hook_send_mail($mailer, $params) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -512,6 +553,7 @@ abstract class Plugin { * @param array<string,string|bool|int> $matched_rules * @param array<string,string> $article_filters * @return void + * @see PluginHost::HOOK_FILTER_TRIGGERED */ function hook_filter_triggered($feed_id, $owner_uid, $article, $matched_filters, $matched_rules, $article_filters) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -520,6 +562,7 @@ abstract class Plugin { /** * @param string $url * @return string|false + * @see PluginHost::HOOK_GET_FULL_TEXT */ function hook_get_full_text($url) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -533,6 +576,7 @@ abstract class Plugin { * @param string $site_url * @param array<string,mixed> $article * @return string|array<int,string> + * @see PluginHost::HOOK_ARTICLE_IMAGE */ function hook_article_image($enclosures, $content, $site_url, $article) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -540,7 +584,10 @@ abstract class Plugin { return ""; } - /** @return string */ + /** + * @return string + * @see PluginHost::HOOK_FEED_TREE + * */ function hook_feed_tree() { user_error("Dummy method invoked.", E_USER_ERROR); @@ -550,6 +597,7 @@ abstract class Plugin { /** * @param string $url * @return bool + * @see PluginHost::HOOK_IFRAME_WHITELISTED */ function hook_iframe_whitelisted($url) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -561,6 +609,7 @@ abstract class Plugin { * @param object $enclosure * @param int $feed * @return object ($enclosure) + * @see PluginHost::HOOK_ENCLOSURE_IMPORTED */ function hook_enclosure_imported($enclosure, $feed) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -568,7 +617,10 @@ abstract class Plugin { return $enclosure; } - /** @return array<string,string> */ + /** + * @return array<string,string> + * @see PluginHost::HOOK_HEADLINES_CUSTOM_SORT_MAP + */ function hook_headlines_custom_sort_map() { user_error("Dummy method invoked.", E_USER_ERROR); @@ -578,6 +630,7 @@ abstract class Plugin { /** * @param string $order * @return array<int, string|bool> -- query, skip_first_id + * @see PluginHost::HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE */ function hook_headlines_custom_sort_override($order) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -589,6 +642,7 @@ abstract class Plugin { * @param int $feed_id * @param int $is_cat * @return string + * @see PluginHost::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM */ function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) { user_error("Dummy method invoked.", E_USER_ERROR); @@ -601,6 +655,7 @@ abstract class Plugin { * @param string $auth_login * @param string $auth_pass * @return bool + * @see PluginHost::HOOK_PRE_SUBSCRIBE */ function hook_pre_subscribe(&$url, $auth_login, $auth_pass) { user_error("Dummy method invoked.", E_USER_ERROR); |