From a6eae9adec28454b1829fe15dc79e1cb8278d5ac Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 14 Jul 2018 04:58:05 -0400 Subject: [PATCH] Add new put_item_in_cache hook in include/text --- doc/Addons.md | 26 +++++++++++++++++--------- doc/de/Addons.md | 9 +++++---- include/text.php | 6 ++++++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/doc/Addons.md b/doc/Addons.md index 710d10cfd0..ae7e1fbbd3 100644 --- a/doc/Addons.md +++ b/doc/Addons.md @@ -357,6 +357,13 @@ Hook data: 'item' => item array (input) 'html' => converted item body (input/output) +### 'put_item_in_cache' +Called after prepare_text in put_item_in_cache(). +Hook data: + 'item' => item array (input) + 'rendered-html' => final item body HTML (input/output) + 'rendered-hash' => original item body hash (input/output) + ### 'magic_auth_success' Called when a magic-auth was successful. Hook data: @@ -386,7 +393,7 @@ Here is a complete list of all hook callbacks with file locations (as of 01-Apr- Addon::callHooks($a->module.'_mod_content', $arr); Addon::callHooks($a->module.'_mod_aftercontent', $arr); Addon::callHooks('page_end', $a->page['content']); - + ### include/api.php Addon::callHooks('logged_in', $a->user); @@ -394,12 +401,12 @@ Here is a complete list of all hook callbacks with file locations (as of 01-Apr- Addon::callHooks('logged_in', $a->user); ### include/enotify.php - + Addon::callHooks('enotify', $h); Addon::callHooks('enotify_store', $datarray); Addon::callHooks('enotify_mail', $datarray); Addon::callHooks('check_item_notification', $notification_data); - + ### include/conversation.php Addon::callHooks('conversation_start', $cb); @@ -417,6 +424,7 @@ Here is a complete list of all hook callbacks with file locations (as of 01-Apr- Addon::callHooks('contact_block_end', $arr); Addon::callHooks('poke_verbs', $arr); + Addon::callHooks('put_item_in_cache', $hook_data); Addon::callHooks('prepare_body_init', $item); Addon::callHooks('prepare_body_content_filter', $hook_data); Addon::callHooks('prepare_body', $hook_data); @@ -458,7 +466,7 @@ Here is a complete list of all hook callbacks with file locations (as of 01-Apr- ### mod/friendica.php Addon::callHooks('about_hook', $o); - + ### mod/subthread.php Addon::callHooks('post_local_end', $arr); @@ -531,7 +539,7 @@ Here is a complete list of all hook callbacks with file locations (as of 01-Apr- Addon::callHooks('post_local', $datarray); Addon::callHooks('post_local_end', $datarray); -### mod/editpost.php +### mod/editpost.php Addon::callHooks('jot_tool', $jotplugins); @@ -600,11 +608,11 @@ Here is a complete list of all hook callbacks with file locations (as of 01-Apr- Addon::callHooks('sexpref_selector', $select); Addon::callHooks('marital_selector', $select); -### src/Content/OEmbed.php +### src/Content/OEmbed.php Addon::callHooks('oembed_fetch_url', $embedurl, $j); -### src/Content/Nav.php +### src/Content/Nav.php Addon::callHooks('page_header', $a->page['nav']); Addon::callHooks('nav_info', $nav); @@ -617,7 +625,7 @@ Here is a complete list of all hook callbacks with file locations (as of 01-Apr- Addon::callHooks('notifier_end', $target_item); -### src/Worker/Queue.php +### src/Worker/Queue.php Addon::callHooks('queue_predeliver', $r); Addon::callHooks('queue_deliver', $params); @@ -627,7 +635,7 @@ Here is a complete list of all hook callbacks with file locations (as of 01-Apr- Addon::callHooks('authenticate', $addon_auth); Addon::callHooks('login_hook', $o); -### src/Module/Logout.php +### src/Module/Logout.php Addon::callHooks("logging_out"); diff --git a/doc/de/Addons.md b/doc/de/Addons.md index 02be19e30b..ce9af37781 100644 --- a/doc/de/Addons.md +++ b/doc/de/Addons.md @@ -203,7 +203,7 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap Addon::callHooks($a->module.'_mod_content', $arr); Addon::callHooks($a->module.'_mod_aftercontent', $arr); Addon::callHooks('page_end', $a->page['content']); - + ### include/api.php Addon::callHooks('logged_in', $a->user); @@ -216,7 +216,7 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap Addon::callHooks('enotify_store', $datarray); Addon::callHooks('enotify_mail', $datarray); Addon::callHooks('check_item_notification', $notification_data); - + ### include/conversation.php Addon::callHooks('conversation_start', $cb); @@ -234,6 +234,7 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap Addon::callHooks('contact_block_end', $arr); Addon::callHooks('poke_verbs', $arr); + Addon::callHooks('put_item_in_cache', $hook_data); Addon::callHooks('prepare_body_init', $item); Addon::callHooks('prepare_body_content_filter', $hook_data); Addon::callHooks('prepare_body', $hook_data); @@ -275,7 +276,7 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap ### mod/friendica.php Addon::callHooks('about_hook', $o); - + ### mod/subthread.php Addon::callHooks('post_local_end', $arr); @@ -322,7 +323,7 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap ### mod/contacts.php - Addon::callHooks('contact_edit_post', $_POST); + Addon::callHooks('contact_edit_post', $_POST); Addon::callHooks('contact_edit', $arr); ### mod/tagger.php diff --git a/include/text.php b/include/text.php index d6b40dcc2e..2ca0e0e517 100644 --- a/include/text.php +++ b/include/text.php @@ -1173,6 +1173,12 @@ function put_item_in_cache(&$item, $update = false) $item["rendered-html"] = prepare_text($item["body"]); $item["rendered-hash"] = hash("md5", $item["body"]); + $hook_data = ['item' => $item, 'rendered-html' => $item['rendered-html'], 'rendered-hash' => $item['rendered-hash']]; + Addon::callHooks('put_item_in_cache', $hook_data); + $item['rendered-html'] = $hook_data['rendered-html']; + $item['rendered-hash'] = $hook_data['rendered-hash']; + unset($hook_data); + // Force an update if the generated values differ from the existing ones if ($rendered_hash != $item["rendered-hash"]) { $update = true; -- 2.39.5