]> git.mxchange.org Git - friendica.git/blob - addon/README
Merge branch 'master' of git://github.com/friendika/friendika
[friendica.git] / addon / README
1 Friendika Addon/Plugin development
2
3 This is an early specification and hook details may be subject to change.
4
5 Please see the sample addon 'randplace' for a working example of using these features.
6
7
8 You must register plugins with the system in the .htconfig.php file.
9
10 $a->config['system']['addon'] = 'plugin1name, plugin2name, another_name';
11
12 Plugin names cannot contain spaces and are used as filenames.
13
14
15 Register your plugin hooks during installation. 
16
17         register_hook($hookname, $file, $function);
18
19         $hookname is a string and corresponds to a known Friendika hook
20         $file is a pathname relative to the top-level Friendika directory.
21                 This *should* be 'addon/plugin_name/plugin_name.php' in most cases.
22         $function is a string and is the name of the function which will be executed
23                 when the hook is called.
24
25
26 Your hook functions will be called with at least one and possibly two arguments
27
28         function myhook_function(&$a, &$b) {
29
30
31         }
32
33 If you wish to make changes to the calling data, you must declare them as 
34 reference variables (with '&') during function declaration. 
35
36 $a is the Friendika 'App' class - which contains a wealth of information
37 about the current state of Friendika, such as which module has been called,
38 configuration info, the page contents at the point the hook was invoked, profile
39 and user information, etc. It is recommeded you call this '$a' to match its usage 
40 elsewhere.
41
42 $b can be called anything you like. This is information which is specific to the hook 
43 currently being processed, and generally contains information that is being immediately
44 processed or acted on that you can use, display, or alter. Remember to declare it with 
45 '&' if you wish to alter it.
46
47
48 Current hooks:
49
50 'authenticate' - called when a user attempts to login. 
51         $b is an array
52                 'username' => the supplied username
53                 'password' => the supplied password
54                 'authenticated' => set this to non-zero to authenticate the user.
55
56 'logged_in' - called after a user has successfully logged in.
57         $b contains the $a->user array
58
59
60 'display_item' - called when formatting a post for display.
61         $b is an array
62                 'item' => The item (array) details pulled from the database
63                 'output' => the (string) HTML representation of this item prior to adding it 
64                         to the page  
65
66 'post_local' - called when a status post or comment is entered on the local system
67         $b is the item array of the information to be stored in the database
68                 {Please note: body contents are bbcode - not HTML)
69
70 'post_remote' - called when receiving a post from another source. This may also be used
71         to post local activity or system generated messages.
72         $b is the item array of information to be stored in the database and the item
73         body is bbcode.
74
75 'settings_form' - called when generating the HTML for the user Settings page
76         $b is the (string) HTML of the settings page before the final '</form>' tag.
77
78 'plugin_settings' - called when generating the HTML for the addon settings page
79         $b is the (string) HTML of the addon settings page before the final '</form>' tag.
80
81 'settings_post' - called when the Settings and Addon Settings pages are submitted.
82         $b is the $_POST array
83
84 'profile_advanced' - called when the HTML is generated for the 'Advanced profile', 
85         corresponding to the 'Profile' tab within a person's profile page.
86         $b is the (string) HTML representation of the generated profile
87
88 'directory_item' - called from the Directory page when formatting an item for display
89         $b is an array
90                 'contact' => contact (array) record for the person from the database
91                 'entry' => the (string) HTML of the generated entry 
92
93 'profile_sidebar' - called when generating the sidebar "short" profile for a page
94         $b is the (string) generated HTML of the entry
95                 (The profile array details are in $a->profile)
96
97 'contact_block_end' - called when formatting the block of contacts/friends on a 
98         profile sidebar has completed
99         $b is an array
100                 'contacts' => contact array of entries
101                 'output' => the (string) generated HTML of the contact block
102
103
104 *** = subject to change
105
106
107
108
109
110 Not yet documented:
111
112 'atom_feed'
113
114 'atom_feed_end'
115
116 'parse_atom'
117
118 'atom_author'
119
120 'atom_entry'
121
122 'parse_link'
123
124
125
126
127