]> git.mxchange.org Git - friendica.git/blob - addon/README
Added plural string for contact block
[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                 'user_record' => successful authentication must also return a valid user record from the database
56
57
58 'logged_in' - called after a user has successfully logged in.
59         $b contains the $a->user array
60
61
62 'display_item' - called when formatting a post for display.
63         $b is an array
64                 'item' => The item (array) details pulled from the database
65                 'output' => the (string) HTML representation of this item prior to adding it 
66                         to the page  
67
68 'post_local' - called when a status post or comment is entered on the local system
69         $b is the item array of the information to be stored in the database
70                 {Please note: body contents are bbcode - not HTML)
71
72 'post_local_end' - called when a local status post or comment has been stored on the local system
73         $b is the item array of the information which has just been stored in the database
74                 {Please note: body contents are bbcode - not HTML)
75
76
77 'post_remote' - called when receiving a post from another source. This may also be used
78         to post local activity or system generated messages.
79         $b is the item array of information to be stored in the database and the item
80         body is bbcode.
81
82 'settings_form' - called when generating the HTML for the user Settings page
83         $b is the (string) HTML of the settings page before the final '</form>' tag.
84
85 'settings_post' - called when the Settings pages are submitted.
86         $b is the $_POST array
87
88 'plugin_settings' - called when generating the HTML for the addon settings page
89         $b is the (string) HTML of the addon settings page before the final '</form>' tag.
90
91 'plugin_settings_post' - called when the Addon Settings pages are submitted.
92         $b is the $_POST array
93
94 'profile_post' - called when posting a profile page.
95         $b is the $_POST array
96
97 'profile_edit' - called prior to output of profile edit page
98         $b is array
99                 'profile' => profile (array) record from the database
100                 'entry' => the (string) HTML of the generated entry
101
102 'profile_advanced' - called when the HTML is generated for the 'Advanced profile', 
103         corresponding to the 'Profile' tab within a person's profile page.
104         $b is the (string) HTML representation of the generated profile
105
106 'directory_item' - called from the Directory page when formatting an item for display
107         $b is an array
108                 'contact' => contact (array) record for the person from the database
109                 'entry' => the (string) HTML of the generated entry 
110
111 'profile_sidebar_enter' - called prior to generating the sidebar "short" profile for a page
112         $b is (array) the person's profile array
113
114 'profile_sidebar' - called when generating the sidebar "short" profile for a page
115         $b is an array
116                 'profile' => profile (array) record for the person from the database
117                 'entry' => the (string) HTML of the generated entry
118
119 'contact_block_end' - called when formatting the block of contacts/friends on a 
120         profile sidebar has completed
121         $b is an array
122                 'contacts' => contact array of entries
123                 'output' => the (string) generated HTML of the contact block
124
125 'bbcode' - called during conversion of bbcode to html
126         $b is (string) converted text
127
128 'html2bbcode' - called during conversion of html to bbcode (e.g. remote message posting)
129         $b is (string) converted text
130
131
132 'page_header' - called after building the page navigation section
133         $b is (string) HTML of nav region
134
135
136 'personal_xrd' - called prior to output of personal XRD file.
137         $b is an array
138                 'user' => the user record for the person
139                 'xml' => the complete XML to be output
140  
141
142 'home_content' - called prior to output home page content, shown to unlogged users
143         $b is (string) HTML of section region
144
145 'contact_edit' - called when editing contact details on an individual from the Contacts page
146         $b is (array)
147                 'contact' => contact record (array) of target contact
148                 'output' => the (string) generated HTML of the contact edit page
149
150 'contact_edit_post' - called when posting the contact edit page
151         $b is the $_POST array
152
153 'init_1' - called just after DB has been opened and before session start
154         $b is not used or passed
155
156 'page_end' - called after HTML content functions have completed
157     $b is (string) HTML of content div
158
159 'jot_plugin' - add tools to jot toolbar
160   $b is (string) HTML for tool icon
161
162
163 *** = subject to change
164
165
166
167
168
169 Not yet documented:
170
171 'atom_feed' ***
172
173 'atom_feed_end' ***
174
175 'parse_atom' ***
176
177 'atom_author' ***
178
179 'atom_entry' ***
180
181 'parse_link' ***
182
183
184
185
186