Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docs:addons [2020-09-27 14:07] – Admin Istrator | docs:addons [2022-06-25 10:10] (current) – [Templates] Tobias | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | + | ====== Friendica Addon development ====== |
- | Friendica Addon development | + | Please see the sample addon ‘randplace’ for a working example of using some of these features. Addons work by intercepting event hooks - which must be registered. Modules work by intercepting specific page requests (by URL path). |
- | ============== | + | |
- | * [Home](help) | + | ===== Naming ===== |
- | Please see the sample addon ' | + | Addon names are used in file paths and functions names, and as such: - Can’t contain spaces or punctuation. - Can’t start with a number. |
- | Addons work by intercepting event hooks - which must be registered. | + | |
- | Modules work by intercepting specific page requests (by URL path). | + | |
- | ## Naming | + | ===== Metadata |
- | + | ||
- | Addon names are used in file paths and functions names, and as such: | + | |
- | - Can't contain spaces or punctuation. | + | |
- | - Can't start with a number. | + | |
- | + | ||
- | ## Metadata | + | |
You can provide human-readable information about your addon in the first multi-line comment of your addon file. | You can provide human-readable information about your addon in the first multi-line comment of your addon file. | ||
- | Here's the structure: | + | Here’s the structure: |
- | ```php | + | < |
/** | /** | ||
* Name: {Human-readable name} | * Name: {Human-readable name} | ||
Line 33: | Line 24: | ||
* Status: {Unsupported|Arbitrary status} | * Status: {Unsupported|Arbitrary status} | ||
*/ | */ | ||
- | ``` | + | </ |
- | + | You can also provide a longer documentation in a '' | |
- | You can also provide a longer documentation in a `README` or `README.md` file. | + | |
- | The latter will be converted from Markdown to HTML in the addon detail page. | + | |
- | ## Install/ | + | ===== Install/ |
- | If your addon uses hooks, they have to be registered in a `< | + | If your addon uses hooks, they have to be registered in a '' |
- | This function also allows to perform arbitrary actions your addon needs to function properly. | + | |
- | Uninstalling an addon automatically unregisters any hook it registered, but if you need to provide specific uninstallation steps, you can add them in a `< | + | Uninstalling an addon automatically unregisters any hook it registered, but if you need to provide specific uninstallation steps, you can add them in a '' |
- | The install and uninstall functions will be called (i.e. re-installed) if the addon changes after installation. | + | The install and uninstall functions will be called (i.e. re-installed) if the addon changes after installation. Therefore your uninstall should not destroy data and install should consider that data may already exist. Future extensions may provide for “setup” amd “remove”. |
- | Therefore your uninstall should not destroy data and install should consider that data may already exist. | + | |
- | Future extensions may provide for "setup" | + | |
- | ## PHP addon hooks | + | ===== PHP addon hooks ===== |
Register your addon hooks during installation. | Register your addon hooks during installation. | ||
- | | + | < |
+ | \Friendica\Core\Hook:: | ||
+ | </ | ||
+ | '' | ||
- | `$hookname` | + | '' |
- | `$file` is a pathname relative to the top-level Friendica directory. | + | '' |
- | This *should* | + | |
- | `$function` is a string and is the name of the function which will be executed when the hook is called. | + | ==== Arguments ==== |
- | ### Arguments | ||
Your hook callback functions will be called with at least one and possibly two arguments | Your hook callback functions will be called with at least one and possibly two arguments | ||
- | | + | < |
+ | function < | ||
- | | + | } |
+ | </ | ||
+ | If you wish to make changes to the calling data, you must declare them as reference variables (with '' | ||
- | If you wish to make changes to the calling data, you must declare them as reference variables (with `&`) during function declaration. | + | === $a === |
- | #### $a | + | $a is the Friendica |
- | $a is the Friendica | + | |
- | It contains a wealth of information about the current state of Friendica: | + | |
- | * which module has been called, | + | |
- | * configuration information, | + | * configuration information, |
- | * the page contents at the point the hook was invoked, | + | * the page contents at the point the hook was invoked, |
- | * profile and user information, | + | * profile and user information, |
- | It is recommeded you call this `$a` to match its usage elsewhere. | + | It is recommeded you call this '' |
- | #### $b | + | === $b === |
- | $b can be called anything you like. | + | |
- | This is information specific to the hook currently being processed, and generally contains information that is being immediately processed or acted on that you can use, display, or alter. | + | |
- | Remember to declare it with `&` if you wish to alter it. | + | |
- | ## Admin settings | + | $b can be called anything you like. This is information specific to the hook currently being processed, and generally contains information that is being immediately processed or acted on that you can use, display, or alter. Remember to declare it with '' |
- | Your addon can provide user-specific | + | ===== Admin settings |
- | Simply declare a `<addon> | + | Your addon can provide user-specific settings via the '' |
- | ## Global stylesheets | + | Simply declare a '' |
+ | |||
+ | ===== Global stylesheets | ||
If your addon requires adding a stylesheet on all pages of Friendica, add the following hook: | If your addon requires adding a stylesheet on all pages of Friendica, add the following hook: | ||
- | ```php | + | < |
function < | function < | ||
{ | { | ||
- | \Friendica\Core\Hook:: | + | |
- | ... | + | ... |
} | } | ||
Line 107: | Line 94: | ||
function < | function < | ||
{ | { | ||
- | \Friendica\DI:: | + | |
} | } | ||
- | ``` | + | </ |
+ | '' | ||
- | `__DIR__` is the folder path of your addon. | + | ===== JavaScript ===== |
- | ## JavaScript | + | ==== Global scripts |
- | + | ||
- | ### Global scripts | + | |
If your addon requires adding a script on all pages of Friendica, add the following hook: | If your addon requires adding a script on all pages of Friendica, add the following hook: | ||
- | + | < | |
- | ```php | + | |
function < | function < | ||
{ | { | ||
- | \Friendica\Core\Hook:: | + | |
- | ... | + | ... |
} | } | ||
function < | function < | ||
{ | { | ||
- | \Friendica\DI:: | + | |
} | } | ||
- | ``` | + | </ |
+ | '' | ||
- | `__DIR__` is the folder path of your addon. | + | ==== JavaScript hooks ==== |
- | ### JavaScript | + | The main Friendica script provides |
- | The main Friendica script provides hooks via events dispatched on the `document` property. | + | < |
- | In your Javascript file included as described above, add your event listener like this: | + | |
- | + | ||
- | ```js | + | |
document.addEventListener(name, | document.addEventListener(name, | ||
- | ``` | + | </ |
- | + | * //name// is the name of the hook and corresponds to a known Friendica JavaScript hook. | |
- | - *name* is the name of the hook and corresponds to a known Friendica JavaScript hook. | + | * //callback// is a JavaScript anonymous function to execute. |
- | - *callback* is a JavaScript anonymous function to execute. | + | |
- | More info about Javascript event listeners: https:// | + | More info about Javascript event listeners: https:%%//%%developer.mozilla.org/ |
- | #### Current JavaScript hooks | + | === Current JavaScript hooks === |
- | ##### postprocess_liveupdate | + | == postprocess_liveupdate |
- | Called at the end of the live update process (XmlHttpRequest) and on a post preview. | + | |
- | No additional data is provided. | + | |
- | ## Modules | + | Called at the end of the live update process (XmlHttpRequest) and on a post preview. No additional data is provided. |
- | Addons may also act as " | + | ===== Modules ===== |
- | In order for a addon to act as a module it needs to declare an empty function `< | + | |
- | If this function exists, you will now receive | + | Addons may also act as “modules” and intercept |
- | These are parsed into an array $a->argv, with a corresponding $a->argc indicating the number of URL components. | + | |
- | So `https:// | + | |
- | This will include: | + | |
- | ```php | + | If this function exists, you will now receive all page requests for '' |
- | $a->argc = 3 | + | |
- | $a->argv = array(0 => 'addon', 1 => 'arg1', 2 => ' | + | |
- | ``` | + | |
- | To display a module page, you need to declare the function | + | <code php> |
- | They may also contain | + | DI:: |
- | You may also have `< | + | DI:: |
+ | DI:: | ||
+ | DI:: | ||
+ | </ | ||
+ | To display a module page, you need to declare the function | ||
- | ## Templates | + | ===== Templates |
- | If your addon needs some template, you can use the Friendica template system. | + | If your addon needs some template, you can use the Friendica template system. Friendica uses [[http:// |
- | Friendica uses [smarty3](http:// | + | |
- | Put your tpl files in the *templates/* subfolder of your addon. | + | Put your tpl files in the //templates/// subfolder of your addon. |
In your code, like in the function addon_name_content(), | In your code, like in the function addon_name_content(), | ||
- | ```php | + | < |
use Friendica\Core\Renderer; | use Friendica\Core\Renderer; | ||
Line 193: | Line 169: | ||
# second an array of ' | # second an array of ' | ||
$output = Renderer:: | $output = Renderer:: | ||
- | ' | + | |
)); | )); | ||
- | ``` | + | </ |
+ | See also the wiki page [[docs: | ||
- | See also the wiki page [Quick Template Guide](https:// | + | ===== Current PHP hooks ===== |
- | ## Current PHP hooks | + | ==== authenticate ==== |
- | ### authenticate | + | Called when a user attempts to login. |
- | Called when a user attempts to login. | + | |
- | `$b` is an array containing: | + | |
- | - **username**: | + | * **username**: |
- | - **password**: | + | |
- | - **authenticated**: | + | |
- | - **user_record**: | + | |
- | ### logged_in | + | ==== logged_in |
- | Called after a user has successfully logged in. | + | |
- | `$b` contains the `$a-> | + | |
- | ### display_item | + | Called |
- | Called | + | |
- | $b is an array: | + | |
- | - **item**: The item (array) details pulled from the database | + | ==== display_item ==== |
- | - **output**: the (string) HTML representation of this item prior to adding it to the page | + | |
- | ### post_local | + | Called when formatting |
- | Called when a status | + | |
- | `$b` is the item array of the information to be stored in the database. | + | |
- | Please note: body contents are bbcode - not HTML. | + | |
- | ### post_local_end | + | * **item**: The item (array) details pulled from the database |
- | Called when a local status post or comment has been stored on the local system. | + | * **output**: the (string) |
- | `$b` is the item array of the information which has just been stored in the database. | + | |
- | Please note: body contents are bbcode - not HTML | + | |
- | ### post_remote | + | ==== post_local ==== |
- | Called when receiving a post from another source. This may also be used to post local activity or system generated messages. | + | |
- | `$b` is the item array of information to be stored in the database and the item body is bbcode. | + | |
- | ### settings_form | + | Called when a status post or comment is entered on the local system. '' |
- | Called when generating | + | |
- | `$b` is the HTML string | + | |
- | ### settings_post | + | ==== post_local_end ==== |
- | Called when the Settings pages are submitted. | + | |
- | `$b` is the $_POST array. | + | |
- | ### addon_settings | + | Called when a local status post or comment has been stored on the local system. '' |
- | Called when generating | + | |
- | `$b` is the (string) HTML of the addon settings page before | + | |
- | ### addon_settings_post | + | ==== post_remote ==== |
- | Called when the Addon Settings pages are submitted. | + | |
- | `$b` is the $_POST array. | + | |
- | ### profile_post | + | Called when receiving |
- | Called when posting | + | |
- | `$b` is the $_POST | + | |
- | ### profile_edit | + | ==== addon_settings ==== |
- | Called prior to output of profile edit page. | + | |
- | `$b` is an array containing: | + | |
- | - **profile**: | + | Called when generating |
- | - **entry**: the (string) | + | |
- | ### profile_advanced | + | * **addon** (output): Required. The addon folder name. |
- | Called when the HTML is generated for the Advanced profile, corresponding to the Profile tab within | + | * **title** (output): Required. The addon settings panel title. |
- | `$b` is the HTML string representation | + | * **href** (output): Optional. If set, will reduce |
- | The profile array details are in `$a-> | + | * **html** (output): Optional. Raw HTML of the addon form elements. Both the '' |
+ | * **submit** (output): Optional. If unset, | ||
+ | * **string**: The label to replace the default one. | ||
+ | * **associative array**: A list of submit button, the key is the value of the '' | ||
- | ### directory_item | + | === Examples === |
- | Called from the Directory page when formatting an item for display. | + | |
- | `$b` is an array: | + | |
- | - **contact**: | + | == With link == |
- | - **entry**: the HTML string of the generated entry | + | |
- | ### profile_sidebar_enter | + | <code php> |
- | Called prior to generating the sidebar " | + | $data = [ |
- | `$b` is the person's profile array | + | |
+ | ' | ||
+ | ' | ||
+ | ]; | ||
+ | </ | ||
+ | == With default submit button == | ||
- | ### profile_sidebar | + | <code php> |
- | Called when generating the sidebar " | + | $data = [ |
- | `$b` is an array: | + | ' |
+ | ' | ||
+ | ' | ||
+ | ]; | ||
+ | </ | ||
+ | == With no HTML, just a submit button == | ||
- | - **profile**: | + | <code php> |
- | - **entry**: the HTML string of the generated entry | + | $data = [ |
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ]; | ||
+ | </ | ||
+ | == With multiple submit buttons == | ||
- | ### contact_block_end | + | <code php> |
- | Called when formatting the block of contacts/ | + | $data = [ |
- | `$b` is an array: | + | ' |
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ], | ||
+ | ]; | ||
+ | </ | ||
+ | ==== addon_settings_post ==== | ||
- | - **contacts**: | + | Called when the Addon Settings pages are submitted. '' |
- | - **output**: | + | |
- | ### bbcode | + | ==== connector_settings ==== |
- | Called after conversion of bbcode to HTML. | + | |
- | `$b` is an HTML string converted text. | + | |
- | ### html2bbcode | + | Called |
- | Called | + | |
- | `$b` is a string converted text | + | |
- | ### head | + | * **connector** (output): Required. The addon folder name. |
- | Called when building | + | * **title** (output): Required. The addon settings panel title. |
- | Stylesheets should | + | * **image** (output): Required. The relative path of the logo image of the platform/ |
- | `$b` is an HTML string | + | * **enabled** (output): Optional. If set to a falsy value, the connector image will be dimmed. |
+ | * **html** (output): Optional. Raw HTML of the addon form elements. Both the '' | ||
+ | * **submit** (output): Optional. If unset, a default submit button with '' | ||
+ | * **string**: The label to replace the default one. | ||
+ | * **associative array**: A list of submit button, the key is the value of the '' | ||
- | ### page_header | + | === Examples === |
- | Called after building the page navigation section. | + | |
- | `$b` is a string HTML of nav region. | + | |
- | ### personal_xrd | + | == With default submit button == |
- | Called prior to output of personal XRD file. | + | |
- | `$b` is an array: | + | |
- | - **user**: the user record array for the person | + | <code php> |
- | - **xml**: the complete XML string to be output | + | $data = [ |
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ]; | ||
+ | </ | ||
+ | == With custom submit button label and no logo dim == | ||
- | ### home_content | + | <code php> |
- | Called prior to output home page content, shown to unlogged users. | + | $data = [ |
- | `$b` is the HTML sring of section region. | + | ' |
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ]; | ||
+ | </ | ||
+ | == With conditional submit buttons == | ||
- | ### contact_edit | + | <code php> |
- | Called when editing contact details on an individual from the Contacts page. | + | $submit = [' |
- | $b is an array: | + | if ($oauth_token && $oauth_token_secret) { |
+ | $submit[' | ||
+ | } | ||
- | - **contact**: contact record | + | $data = [ |
- | - **output**: the (string) generated HTML of the contact edit page | + | ' |
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ]; | ||
+ | </ | ||
+ | ==== profile_post ==== | ||
- | ### contact_edit_post | + | Called when posting |
- | Called when posting | + | |
- | `$b` is the `$_POST` array | + | |
- | ### init_1 | + | ==== profile_edit ==== |
- | Called just after DB has been opened and before session start. | + | |
- | No hook data. | + | |
- | ### page_end | + | Called |
- | Called | + | |
- | `$b` is (string) HTML of content div. | + | |
- | ### footer | + | * **profile**: |
- | Called after HTML content functions have completed. | + | * **entry**: the (string) HTML of the generated entry |
- | Deferred Javascript files should be registered using this hook. | + | |
- | `$b` is (string) HTML of footer div/ | + | |
- | ### avatar_lookup | + | ==== profile_advanced ==== |
- | Called when looking up the avatar. `$b` is an array: | + | |
- | - **size**: | + | Called when the HTML is generated for the Advanced profile, corresponding |
- | - **email**: email to look up the avatar for | + | |
- | - **url**: | + | |
- | ### emailer_send_prepare | + | ==== directory_item ==== |
- | Called from `Emailer:: | + | |
- | `$b` is an array of params to `Emailer:: | + | |
- | - **fromName**: | + | Called from the Directory page when formatting an item for display. '' |
- | - **fromEmail**: email fo the sender | + | |
- | - **replyTo**: | + | |
- | - **toEmail**: | + | |
- | - **messageSubject**: | + | |
- | - **htmlVersion**: | + | |
- | - **textVersion**: | + | |
- | - **additionalMailHeader**: | + | |
- | - **sent**: default false, if set to true in the hook, the default mailer will be skipped. | + | |
- | ### emailer_send | + | * **contact**: |
- | Called before calling PHP's `mail()`. | + | * **entry**: the HTML string |
- | `$b` is an array of params to `mail()`. | + | |
- | - **to** | + | ==== profile_sidebar_enter ==== |
- | - **subject** | + | |
- | - **body** | + | |
- | - **headers** | + | |
- | - **sent**: default false, if set to true in the hook, the default mailer will be skipped. | + | |
- | ### load_config | + | Called |
- | Called | + | |
- | ### nav_info | + | ==== profile_sidebar ==== |
- | Called after the navigational menu is build in `include/ | + | |
- | `$b` is an array containing `$nav` from `include/ | + | |
- | ### template_vars | + | Called |
- | Called | + | |
- | The registered function can add,change or remove variables passed to template. | + | |
- | `$b` is an array with: | + | |
- | - **template**: filename of template | + | |
- | - **vars**: array of vars passed to the template | + | * **entry**: the HTML string |
- | ### acl_lookup_end | + | ==== contact_block_end ==== |
- | Called after the other queries have passed. | + | |
- | The registered function can add, change or remove the `acl_lookup()` variables. | + | |
- | - **results**: | + | Called when formatting |
- | ### prepare_body_init | + | * **contacts**: |
- | Called at the start of prepare_body | + | * **output**: the generated HTML string of the contact block |
- | Hook data: | + | |
- | - **item** (input/ | + | ==== bbcode ==== |
- | ### prepare_body_content_filter | + | Called |
- | Called | + | |
- | just add the reason to the filter_reasons element of the hook data. | + | |
- | Hook data: | + | |
- | - **item**: item array (input) | + | ==== html2bbcode ==== |
- | - **filter_reasons** (input/ | + | |
- | ### prepare_body | + | Called after tag conversion |
- | Called after the HTML conversion | + | |
- | Hook data: | + | |
- | - **item** (input): item array | + | ==== head ==== |
- | - **html** (input/ | + | |
- | - **is_preview** (input): post preview flag | + | |
- | - **filter_reasons** (input): reasons array | + | |
- | ### prepare_body_final | + | Called |
- | Called | + | |
- | Hook data: | + | |
- | - **item**: item array (input) | + | ==== page_header ==== |
- | - **html**: converted item body (input/ | + | |
- | ### put_item_in_cache | + | Called after building the page navigation section. '' |
- | Called after `prepare_text()` in `put_item_in_cache()`. | + | |
- | Hook data: | + | |
- | - **item** (input): item array | + | ==== personal_xrd ==== |
- | - **rendered-html** (input/ | + | |
- | - **rendered-hash** (input/ | + | |
- | ### magic_auth_success | + | Called |
- | Called | + | |
- | Hook data: | + | |
- | visitor => array with the contact | + | * **user**: |
- | url => the query string | + | * **xml**: |
- | ### jot_networks | + | ==== home_content ==== |
- | Called when displaying the post permission screen. | + | |
- | Hook data is a list of form fields that need to be displayed along the ACL. | + | |
- | Form field array structure is: | + | |
- | - **type**: `checkbox` or `select`. | + | Called prior to output home page content, shown to unlogged users. '' |
- | - **field**: Standard field data structure | + | |
- | For `checkbox`, **field** is: | + | ==== contact_edit ==== |
- | - [0] (String): Form field name; Mandatory. | + | |
- | - [1]: (String): Form field label; Optional, default is none. | + | |
- | - [2]: (Boolean): Whether the checkbox should be checked by default; Optional, default is false. | + | |
- | - [3]: (String): Additional help text; Optional, default is none. | + | |
- | - [4]: (String): Additional HTML attributes; Optional, default is none. | + | |
- | For `select`, **field** is: | + | Called when editing contact details on an individual from the Contacts page. $b is an array: |
- | - [0] (String): Form field name; Mandatory. | + | |
- | - [1] (String): Form field label; Optional, default | + | |
- | - [2] (Boolean): Default value to be selected by default; Optional, default is none. | + | |
- | - [3] (String): Additional help text; Optional, default is none. | + | |
- | - [4] (Array): Associative array of options. Item key is option value, item value is option label; Mandatory. | + | |
- | ### route_collection | + | * **contact**: |
- | Called just before dispatching | + | * **output**: |
- | Hook data is a `\FastRoute\RouterCollector` object that should be used to add addon routes pointing to classes. | + | |
- | **Notice**: The class whose name is provided in the route handler must be reachable via auto-loader. | + | ==== contact_edit_post ==== |
- | ### probe_detect | + | Called when posting the contact edit page. '' |
- | Called before trying to detect the target network of a URL. | + | ==== init_1 ==== |
- | If any registered hook function sets the `result` key of the hook data array, it will be returned immediately. | + | |
- | Hook functions should also return immediately if the hook data contains an existing result. | + | |
- | Hook data: | + | Called just after DB has been opened and before session start. No hook data. |
- | - **uri** (input): the profile URI. | + | ==== page_end ==== |
- | - **network** (input): the target network (can be empty for auto-detection). | + | |
- | - **uid** (input): the user to return the contact data for (can be empty for public contacts). | + | |
- | - **result** (output): Set by the hook function to indicate a successful detection. | + | |
- | ## Complete list of hook callbacks | + | Called after HTML content functions have completed. '' |
- | Here is a complete list of all hook callbacks with file locations (as of 24-Sep-2018). Please see the source for details of any hooks not documented above. | + | ==== footer ==== |
- | ### index.php | + | Called after HTML content functions have completed. Deferred Javascript files should be registered using this hook. '' |
- | Hook:: | + | ==== avatar_lookup ==== |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | ### include/api.php | + | Called when looking up the avatar. '' |
- | Hook:: | + | * **size**: the size of the avatar that will be looked up |
- | Hook:: | + | * **email**: email to look up the avatar for |
- | Hook::callAll(' | + | * **url**: the (string) generated URL of the avatar |
- | ### include/ | + | ==== emailer_send_prepare ==== |
- | Hook:: | + | Called from '' |
- | Hook::callAll('enotify_store', $datarray); | + | |
- | Hook:: | + | |
- | Hook::callAll('check_item_notification', $notification_data); | + | |
- | ### include/ | + | * **fromName**: |
+ | * **fromEmail**: | ||
+ | * **replyTo**: | ||
+ | * **toEmail**: | ||
+ | * **messageSubject**: | ||
+ | * **htmlVersion**: | ||
+ | * **textVersion**: | ||
+ | * **additionalMailHeader**: | ||
+ | * **sent**: default false, if set to true in the hook, the default mailer will be skipped. | ||
- | Hook:: | + | ==== emailer_send ==== |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | ### mod/ | + | Called before calling PHP’s '' |
- | Hook:: | + | * **to** |
+ | * **subject** | ||
+ | * **body** | ||
+ | * **headers** | ||
+ | * **sent**: default false, if set to true in the hook, the default mailer will be skipped. | ||
- | ### mod/xrd.php | + | ==== load_config ==== |
- | Hook::callAll('personal_xrd', $arr); | + | Called during '' |
- | ### mod/ | + | ==== nav_info ==== |
- | Hook:: | + | Called after the navigational menu is build in '' |
- | ### mod/ | + | ==== template_vars ==== |
- | Hook:: | + | Called before vars are passed to the template engine to render the page. The registered function can add,change or remove variables passed to template. '' |
- | ### src/ | + | * **template**: |
+ | * **vars**: array of vars passed to the template | ||
- | Hook:: | + | ==== acl_lookup_end ==== |
- | ### mod/acl.php | + | Called after the other queries have passed. The registered function can add, change or remove the '' |
- | Hook::callAll(' | + | * **results**: array of the acl_lookup() vars |
- | ### mod/ | + | ==== prepare_body_init ==== |
- | | + | Called at the start of prepare_body |
- | Hook:: | + | |
- | ### mod/friendica.php | + | * **item** (input/output): item array |
- | Hook:: | + | ==== prepare_body_content_filter ==== |
- | ### mod/ | + | Called before the HTML conversion in prepare_body. If the item matches a content filter rule set by an addon, it should just add the reason to the filter_reasons element of the hook data. Hook data: |
- | Hook::callAll(' | + | * **item**: item array (input) |
+ | * **filter_reasons** (input/ | ||
- | ### mod/ | + | ==== prepare_body ==== |
- | Hook:: | + | Called after the HTML conversion in '' |
- | | + | |
- | ### mod/settings.php | + | * **item** (input): item array |
+ | * **html** (input/output): converted item body | ||
+ | * **is_preview** (input): post preview flag | ||
+ | * **filter_reasons** (input): reasons array | ||
- | Hook:: | + | ==== prepare_body_final ==== |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | ### mod/photos.php | + | Called at the end of '' |
- | Hook::callAll(' | + | * **item**: item array (input) |
- | | + | * **html**: converted item body (input/ |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook::callAll(' | + | |
- | ### mod/ | + | ==== put_item_in_cache ==== |
- | Hook:: | + | Called after '' |
- | ### mod/home.php | + | * **item** (input): item array |
+ | * **rendered-html** (input/output): final item body HTML | ||
+ | * **rendered-hash** (input/ | ||
- | Hook:: | + | ==== magic_auth_success ==== |
- | Hook:: | + | |
- | ### mod/poke.php | + | Called when a magic-auth was successful. Hook data: |
- | Hook:: | + | < |
+ | visitor => array with the contact record of the visitor | ||
+ | url => the query string | ||
+ | </ | ||
+ | ==== jot_networks ==== | ||
- | ### mod/ | + | Called when displaying the post permission screen. Hook data is a list of form fields that need to be displayed along the ACL. Form field array structure is: |
- | Hook::callAll('contact_edit_post', $_POST); | + | * **type**: '' |
- | Hook::callAll('contact_edit', $arr); | + | * **field**: Standard field data structure to be used by '' |
- | ### mod/tagger.php | + | For '' |
- | Hook::callAll(' | + | For '' |
- | ### mod/ | + | ==== route_collection ==== |
- | | + | Called just before dispatching the router. |
- | ### mod/ | + | **Notice**: The class whose name is provided in the route handler must be reachable via auto-loader. |
- | Hook:: | + | ==== probe_detect ==== |
- | Hook:: | + | |
- | ### mod/item.php | + | Called before trying to detect the target network of a URL. If any registered hook function sets the '' |
- | | + | Hook data: |
- | Hook:: | + | |
- | Hook:: | + | |
- | ### mod/ | + | * **uri** (input): the profile URI. |
+ | * **network** (input): the target network (can be empty for auto-detection). | ||
+ | * **uid** (input): the user to return the contact data for (can be empty for public contacts). | ||
+ | * **result** (output): Leave null if address isn’t relevant to the connector, set to contact array if probe is successful, false otherwise. | ||
- | Hook:: | + | ==== item_by_link ==== |
- | ### src/ | + | Called when trying to probe an item from a given URI. If any registered hook function sets the '' |
- | | + | Hook data: - **uri** |
- | ### src/ | + | ==== support_follow ==== |
- | Hook:: | + | Called to assert whether a connector addon provides follow capabilities. |
- | ### src/App.php | + | Hook data: - **protocol** (input): shorthand for the protocol. List of values is available in '' |
+ | |||
+ | ==== support_revoke_follow ==== | ||
+ | |||
+ | Called to assert whether a connector addon provides follow revocation capabilities. | ||
+ | |||
+ | Hook data: - **protocol** (input): shorthand for the protocol. List of values is available in '' | ||
+ | |||
+ | ==== follow ==== | ||
+ | |||
+ | Called before adding a new contact for a user to handle non-native network remote contact (like Twitter). | ||
+ | |||
+ | Hook data: | ||
+ | |||
+ | * **url** (input): URL of the remote contact. | ||
+ | * **contact** (output): should be filled with the contact (with uid = user creating the contact) array if follow was successful. | ||
+ | |||
+ | ==== unfollow ==== | ||
+ | |||
+ | Called when unfollowing a remote contact on a non-native network (like Twitter) | ||
+ | |||
+ | Hook data: - **contact** (input): the target public contact (uid = 0) array. - **uid** (input): the id of the source local user. - **result** (output): wether the unfollowing is successful or not. | ||
+ | |||
+ | ==== revoke_follow ==== | ||
+ | |||
+ | Called when making a remote contact on a non-native network (like Twitter) unfollow you. | ||
+ | |||
+ | Hook data: - **contact** (input): the target public contact (uid = 0) array. - **uid** (input): the id of the source local user. - **result** (output): a boolean value indicating wether the operation was successful or not. | ||
+ | |||
+ | ==== block ==== | ||
+ | |||
+ | Called when blocking a remote contact on a non-native network (like Twitter). | ||
+ | |||
+ | Hook data: - **contact** (input): the remote contact (uid = 0) array. - **uid** (input): the user id to issue the block for. - **result** (output): a boolean value indicating wether the operation was successful or not. | ||
+ | |||
+ | ==== unblock ==== | ||
+ | |||
+ | Called when unblocking a remote contact on a non-native network (like Twitter). | ||
+ | |||
+ | Hook data: - **contact** (input): the remote contact (uid = 0) array. - **uid** (input): the user id to revoke the block for. - **result** (output): a boolean value indicating wether the operation was successful or not. | ||
+ | |||
+ | ==== storage_instance ==== | ||
+ | |||
+ | Called when a custom storage is used (e.g. webdav_storage) | ||
+ | |||
+ | Hook data: - **name** (input): the name of the used storage backend - **data[‘storage’]** (output): the storage instance to use (**must** implement '' | ||
+ | |||
+ | ==== storage_config ==== | ||
+ | |||
+ | Called when the admin of the node wants to configure a custom storage (e.g. webdav_storage) | ||
+ | |||
+ | Hook data: - **name** (input): the name of the used storage backend - **data[‘storage_config’]** (output): the storage configuration instance to use (**must** implement '' | ||
+ | |||
+ | ===== Complete list of hook callbacks ===== | ||
+ | |||
+ | Here is a complete list of all hook callbacks with file locations (as of 24-Sep-2018). Please see the source for details of any hooks not documented above. | ||
- | Hook:: | + | ==== index.php ==== |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | ### src/Model/Item.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </code> | ||
+ | ==== include/api.php ==== | ||
- | Hook:: | + | < |
- | Hook:: | + | Hook:: |
- | Hook:: | + | Hook:: |
- | Hook:: | + | Hook:: |
- | | + | </ |
- | | + | ==== include/ |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | Hook:: | + | |
- | ### src/Model/Contact.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Content/Conversation.php ==== | ||
- | | + | < |
- | Hook:: | + | Hook:: |
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== mod/ | ||
- | ### src/Model/Profile.php | + | < |
+ | Hook:: | ||
+ | </code> | ||
+ | ==== mod/xrd.php ==== | ||
- | Hook:: | + | < |
- | Hook:: | + | Hook:: |
- | | + | </ |
- | | + | ==== mod/ |
- | Hook:: | + | |
- | ### src/Model/Event.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Module/Delegation.php ==== | ||
- | | + | < |
- | | + | Hook:: |
+ | </ | ||
+ | ==== mod/acl.php ==== | ||
- | ### src/Model/User.php | + | < |
+ | Hook:: | ||
+ | </code> | ||
+ | ==== mod/network.php ==== | ||
- | | + | < |
- | Hook:: | + | Hook:: |
+ | Hook:: | ||
+ | </ | ||
+ | ==== mod/ | ||
- | ### src/Module/PermissionTooltip.php | + | < |
+ | Hook:: | ||
+ | </code> | ||
+ | ==== mod/profiles.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== mod/ | ||
- | ### src/Content/ContactBlock.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </code> | ||
+ | ==== mod/photos.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== mod/ | ||
- | ### src/Content/Text/BBCode.php | + | < |
+ | Hook:: | ||
+ | </code> | ||
+ | ==== mod/home.php ==== | ||
- | | + | < |
- | Hook:: | + | Hook:: |
+ | Hook:: | ||
+ | </ | ||
+ | ==== mod/ | ||
- | ### src/Content/Text/HTML.php | + | < |
+ | Hook:: | ||
+ | </code> | ||
+ | ==== mod/contacts.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== mod/ | ||
- | ### src/Content/Smilies.php | + | < |
+ | Hook:: | ||
+ | </code> | ||
+ | ==== mod/uexport.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== mod/ | ||
- | ### src/Content/Feature.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </code> | ||
+ | ==== mod/item.php ==== | ||
- | | + | < |
- | Hook:: | + | Hook:: |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== mod/ | ||
- | ### src/Content/ContactSelector.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Render/FriendicaSmartyEngine.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/App.php ==== | ||
- | ### src/Content/OEmbed.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Model/Item.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Content/Nav.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Model/Profile.php ==== | ||
- | | + | < |
- | Hook:: | + | Hook:: |
+ | Hook::callAll(' | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Core/Authentication.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Model/Register.php ==== | ||
- | | + | < |
- | + | Hook:: | |
- | ### src/Core/StorageManager | + | </ |
+ | ==== src/Model/User.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Worker/Directory.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Module/PermissionTooltip.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Worker/Notifier.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Module/ | ||
- | | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Module/Login.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Security/ExAuth.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Module/Logout.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Content/ | ||
- | | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Object/Post.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Content/Smilies.php ==== | ||
- | | + | < |
- | | + | Hook:: |
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Core/ACL.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Content/ContactSelector.php ==== | ||
- | Hook:: | + | <code> |
- | Hook:: | + | Hook:: |
- | Hook:: | + | </code> |
- | | + | ==== src/ |
- | | + | |
- | Hook:: | + | |
- | ### src/Core/Authentication.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Content/Nav.php ==== | ||
- | | + | < |
- | Hook:: | + | Hook:: |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Core/Hook.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Core/Protocol.php ==== | ||
- | self::callSingle(self::getApp(), 'hook_fork', $fork_hook, $hookdata); | + | < |
+ | Hook::callAll(' | ||
+ | Hook::callAll(' | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Core/L10n/L10n.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </code> | ||
+ | ==== src/Worker/Directory.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Core/Worker.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Module/Login.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Util/Emailer.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Object/Post.php ==== | ||
- | | + | < |
- | Hook:: | + | Hook:: |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Util/Map.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Core/Authentication.php ==== | ||
- | | + | < |
- | Hook:: | + | Hook:: |
- | Hook:: | + | Hook:: |
+ | </ | ||
+ | ==== src/Core/Hook.php ==== | ||
- | ### src/Util/Network.php | + | < |
+ | self:: | ||
+ | </ | ||
+ | ==== src/Core/L10n/L10n.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Util/ParseUrl.php | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Util/Emailer.php ==== | ||
- | | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### src/Protocol/DFRN.php | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/Util/Network.php ==== | ||
- | | + | < |
- | | + | Hook:: |
+ | </ | ||
+ | ==== src/ | ||
- | ### src/ | + | < |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | | + | < |
- | Hook:: | + | Hook:: |
+ | Hook:: | ||
+ | </ | ||
+ | ==== src/ | ||
- | ### view/ | + | < |
+ | Hook:: | ||
+ | Hook:: | ||
+ | </ | ||
+ | ==== view/ | ||
- | | + | < |
- | </markdown> | + | document.dispatchEvent(new Event(' |
+ | </code> | ||
+ | > | ||