Improved documentation formatting (of Plugins.md)

This commit is contained in:
Andrej Stieben 2016-02-04 19:37:06 +01:00
parent 4d0778bfe1
commit acefb84681
2 changed files with 92 additions and 84 deletions

View file

@ -1,5 +1,7 @@
Friendica Addon/Plugin development
==========================
==============
* [Home](help)
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.
@ -18,7 +20,7 @@ Plugins should contain a comment block with the four following parameters:
/*
* Name: My Great Plugin
* Description: This is what my plugin does. It's really cool
* Description: This is what my plugin does. It's really cool.
* Version: 1.0
* Author: John Q. Public <john@myfriendicasite.com>
*/
@ -45,7 +47,7 @@ Your hook callback functions will be called with at least one and possibly two a
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 'App' class.
It contains a wealth of information about the current state of Friendica:
@ -56,13 +58,13 @@ It contains a wealth of information about the current state of Friendica:
It is recommeded you call this '$a' to match its usage elsewhere.
###$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.
Modules
--------
---
Plugins/addons may also act as "modules" and intercept all page requests for a given URL path.
In order for a plugin to act as a module it needs to define a function "plugin_name_module()" which takes no arguments and needs not do anything.
@ -80,7 +82,7 @@ They may also contain plugin_name_post(&$a) which is called before the _content
You may also have plugin_name_init(&$a) which is called very early on and often does module initialisation.
Templates
----------
---
If your plugin needs some template, you can use the Friendica template system.
Friendica uses [smarty3](http://www.smarty.net/) as a template engine.
@ -463,4 +465,3 @@ mod/cb.php: call_hooks('cb_afterpost');
mod/cb.php: call_hooks('cb_content', $o);
mod/directory.php: call_hooks('directory_item', $arr);

View file

@ -1,4 +1,4 @@
**Friendica Addon/Plugin-Entwicklung**
Friendica Addon/Plugin-Entwicklung
==============
* [Zur Startseite der Hilfe](help)
@ -34,6 +34,9 @@ Das *sollte* "addon/plugin_name/plugin_name.php' sein.
$function ist ein String und der Name der Funktion, die ausgeführt wird, wenn der Hook aufgerufen wird.
Argumente
---
Deine Hook-Callback-Funktion wird mit mindestens einem und bis zu zwei Argumenten aufgerufen
function myhook_function(&$a, &$b) {
@ -50,7 +53,8 @@ Diese Information ist speziell auf den Hook bezogen, der aktuell bearbeitet wird
Achte darauf, diese mit "&" zu deklarieren, wenn du sie bearbeiten willst.
**Module**
Module
---
Plugins/Addons können auch als "Module" agieren und alle Seitenanfragen für eine bestimte URL abfangen.
Um ein Plugin als Modul zu nutzen, ist es nötig, die Funktion "plugin_name_module()" zu definieren, die keine Argumente benötigt und nichts weiter machen muss.
@ -67,7 +71,8 @@ Sie können auch plugin_name_post(&$a) umfassen, welches vor der content-Funktio
Du kannst ebenso plugin_name_init(&$a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert.
**Derzeitige Hooks:**
Derzeitige Hooks
---
**'authenticate'** - wird aufgerufen, wenn sich der User einloggt.
$b ist ein Array
@ -180,6 +185,9 @@ Du kannst ebenso plugin_name_init(&$a) nutzen, was oft frühzeitig aufgerufen wi
- wird aufgerufen nachdem in include/nav,php der Inhalt des Navigations Menüs erzeugt wurde.
- $b ist ein Array, das $nav wiederspiegelt.
Komplette Liste der Hook-Callbacks
---
Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 14-Feb-2012 generiert): Bitte schau in die Quellcodes für Details zu Hooks, die oben nicht dokumentiert sind.
boot.php: call_hooks('login_hook',$o);
@ -359,4 +367,3 @@ mod/cb.php: call_hooks('cb_afterpost');
mod/cb.php: call_hooks('cb_content', $o);
mod/directory.php: call_hooks('directory_item', $arr);