aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/context/channel/help.html24
-rw-r--r--doc/context/cloud/help.html22
-rw-r--r--doc/context/en/admin/security/help.html (renamed from doc/context/admin/security/help.html)0
-rw-r--r--doc/context/en/channel/help.html8
-rw-r--r--doc/context/en/cloud/help.html6
-rw-r--r--doc/context/en/mail/help.html (renamed from doc/context/mail/help.html)0
-rw-r--r--doc/context/en/network/help.html (renamed from doc/context/network/help.html)20
-rw-r--r--doc/context/en/photos/help.html6
-rw-r--r--doc/context/en/profile/help.html6
-rw-r--r--doc/context/photos/help.html22
-rw-r--r--doc/context/profile/help.html22
-rw-r--r--doc/hooklist.bb35
-rw-r--r--doc/plugins.bb92
13 files changed, 132 insertions, 131 deletions
diff --git a/doc/context/channel/help.html b/doc/context/channel/help.html
deleted file mode 100644
index 810913ff3..000000000
--- a/doc/context/channel/help.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<script>
- var contextualHelp1 = function (target, openSidePanel) {
- $("#help-content").removeClass('help-content-open'); // Close the help panel
- $("#navbar-collapse-1").removeClass('in'); // Collapse the navbar for small screens
- if (openSidePanel) {
- $("main").addClass('region_1-on'); // Open the side panel to highlight element
- } else {
- $("main").removeClass('region_1-on');
- }
- // Animate the page scroll to the element and then pulse the element to direct attention
- $('html,body').animate({scrollTop: $(target).offset().top - $('#navbar-collapse-1').height() - 20}, 'slow');
- for (i = 0; i < 3; i++) {
- $(target).fadeTo('slow', 0.1).fadeTo('slow', 1.0);
- }
- }
-</script>
-<dl class="dl-horizontal">
- <dt>General</dt>
- <dd>This is the home page of a channel. It is similar to someone's profile "wall" in a social network context. Posts created by the channel are displayed according to the observer's viewing permissions.</dd>
- <dt>Create a Post</dt>
- <dd>If you have permission to create posts on the channel page, then you will see the post editor at the top.</dd>
- <dt><a href='#' onclick='contextualHelp1("#tabs-collapse-1", 0); return false;' title="Click to highlight element...">Channel Content Tabs</a></dt>
- <dd>The channel content tabs are links to other content published by the channel. The <b>About</b> tab links to the channel profile. The <b>Photos</b> tab links to the channel photo galleries. The <b>Files</b> tab links to the general shared files published by the channel.</dd>
-</dl> \ No newline at end of file
diff --git a/doc/context/cloud/help.html b/doc/context/cloud/help.html
deleted file mode 100644
index 105947517..000000000
--- a/doc/context/cloud/help.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<script>
- var contextualHelp1 = function (target, openSidePanel) {
- $("#help-content").removeClass('help-content-open'); // Close the help panel
- $("#navbar-collapse-1").removeClass('in'); // Collapse the navbar for small screens
- if (openSidePanel) {
- $("main").addClass('region_1-on'); // Open the side panel to highlight element
- } else {
- $("main").removeClass('region_1-on');
- }
- // Animate the page scroll to the element and then pulse the element to direct attention
- $('html,body').animate({scrollTop: $(target).offset().top - $('#navbar-collapse-1').height() - 20}, 'slow');
- for (i = 0; i < 3; i++) {
- $(target).fadeTo('slow', 0.1).fadeTo('slow', 1.0);
- }
- }
-</script>
-<dl class="dl-horizontal">
- <dt>General</dt>
- <dd>This page displays a channel's "cloud" files. The files visible to the observer depend on the individual file permissions set by the channel owner. If you have permission to create/upload files you will see control buttons above the file list.</dd>
- <dt><a href='#' onclick='contextualHelp1("#tabs-collapse-1", 0); return false;' title="Click to highlight element...">Channel Content Tabs</a></dt>
- <dd>The channel content tabs are links to other content published by the channel. The <b>About</b> tab links to the channel profile. The <b>Photos</b> tab links to the channel photo galleries. The <b>Files</b> tab links to the general shared files published by the channel.</dd>
-</dl> \ No newline at end of file
diff --git a/doc/context/admin/security/help.html b/doc/context/en/admin/security/help.html
index e9a741a5e..e9a741a5e 100644
--- a/doc/context/admin/security/help.html
+++ b/doc/context/en/admin/security/help.html
diff --git a/doc/context/en/channel/help.html b/doc/context/en/channel/help.html
new file mode 100644
index 000000000..6e3181cbf
--- /dev/null
+++ b/doc/context/en/channel/help.html
@@ -0,0 +1,8 @@
+<dl class="dl-horizontal">
+ <dt>General</dt>
+ <dd>This is the home page of a channel. It is similar to someone's profile "wall" in a social network context. Posts created by the channel are displayed according to the observer's viewing permissions.</dd>
+ <dt>Create a Post</dt>
+ <dd>If you have permission to create posts on the channel page, then you will see the post editor at the top.</dd>
+ <dt><a href='#' onclick='contextualHelpFocus("#tabs-collapse-1", 0); return false;' title="Click to highlight element...">Channel Content Tabs</a></dt>
+ <dd>The channel content tabs are links to other content published by the channel. The <b>About</b> tab links to the channel profile. The <b>Photos</b> tab links to the channel photo galleries. The <b>Files</b> tab links to the general shared files published by the channel.</dd>
+</dl> \ No newline at end of file
diff --git a/doc/context/en/cloud/help.html b/doc/context/en/cloud/help.html
new file mode 100644
index 000000000..a8f193223
--- /dev/null
+++ b/doc/context/en/cloud/help.html
@@ -0,0 +1,6 @@
+<dl class="dl-horizontal">
+ <dt>General</dt>
+ <dd>This page displays a channel's "cloud" files. The files visible to the observer depend on the individual file permissions set by the channel owner. If you have permission to create/upload files you will see control buttons above the file list.</dd>
+ <dt><a href='#' onclick='contextualHelpFocus("#tabs-collapse-1", 0); return false;' title="Click to highlight element...">Channel Content Tabs</a></dt>
+ <dd>The channel content tabs are links to other content published by the channel. The <b>About</b> tab links to the channel profile. The <b>Photos</b> tab links to the channel photo galleries. The <b>Files</b> tab links to the general shared files published by the channel.</dd>
+</dl> \ No newline at end of file
diff --git a/doc/context/mail/help.html b/doc/context/en/mail/help.html
index a2361a135..a2361a135 100644
--- a/doc/context/mail/help.html
+++ b/doc/context/en/mail/help.html
diff --git a/doc/context/network/help.html b/doc/context/en/network/help.html
index 956af7380..53e993b69 100644
--- a/doc/context/network/help.html
+++ b/doc/context/en/network/help.html
@@ -1,25 +1,9 @@
-<script>
- var contextualHelp1 = function (target, openSidePanel) {
- $("#help-content").removeClass('help-content-open'); // Close the help panel
- $("#navbar-collapse-1").removeClass('in'); // Collapse the navbar for small screens
- if (openSidePanel) {
- $("main").addClass('region_1-on'); // Open the side panel to highlight element
- } else {
- $("main").removeClass('region_1-on');
- }
- // Animate the page scroll to the element and then pulse the element to direct attention
- $('html,body').animate({scrollTop: $(target).offset().top - $('#navbar-collapse-1').height() - 20}, 'slow');
- for (i = 0; i < 3; i++) {
- $(target).fadeTo('slow', 0.1).fadeTo('slow', 1.0);
- }
- }
-</script>
<dl class="dl-horizontal">
<dt>General</dt>
<dd>The network page displays a stream of posts and conversations, typically ordered by the most recently updated. This page is highly customizable.</dd>
- <dt><a href='#' onclick='contextualHelp1("#profile-jot-wrapper", 0); return false;' title="Click to highlight element...">Create a Post</a></dt>
+ <dt><a href='#' onclick='contextualHelpFocus("#profile-jot-wrapper", 0); return false;' title="Click to highlight element...">Create a Post</a></dt>
<dd>At the top of the page there is a text box that says "Share". Clicking this box opens a new post editor. The post editor is customizable, but the basic editor provides fields for a post body and an optional post <b>Title</b>. Buttons below the text area to the left provide shortcuts to text formatting and inserting links, images, and other data into the post. The buttons to the right provide a post preview, the post permissions setting, and a <b>Submit</b> button to send the post.</dd>
- <dt><a href='#' onclick='contextualHelp1("#group-sidebar", 1); return false;' title="Click to highlight element...">Privacy Groups</a></dt>
+ <dt><a href='#' onclick='contextualHelpFocus("#group-sidebar", 1); return false;' title="Click to highlight element...">Privacy Groups</a></dt>
<dd>The privacy groups you have created are displayed in the side panel. Selecting them filters posts to those created by channels in the chosen group.</dd>
<dt><a href='#' onclick='$("#dbtn-acl").click(); return false;' title="Click to highlight element...">Post Permissions</a></dt>
<dd>The access control list (ACL) is what you use to set who can see your new post. Pressing the ACL button beside the Submit button will display a dialog in which you can select what channels and/or privacy groups can see the post. You can also select who is explicitly denied access. For example, say you are planning a surprise party for a friend. You can send an invitation post to everyone in your <b>Friends</b> group <i>except</i> the friend you are surprising. In this case you "show" the <b>Friends</b> group but "don't show" that one person.</dd>
diff --git a/doc/context/en/photos/help.html b/doc/context/en/photos/help.html
new file mode 100644
index 000000000..78b442bb4
--- /dev/null
+++ b/doc/context/en/photos/help.html
@@ -0,0 +1,6 @@
+<dl class="dl-horizontal">
+ <dt>General</dt>
+ <dd>This page displays a channel's photo albums. The images visible to the observer depend on the individual image permissions.</dd>
+ <dt><a href='#' onclick='contextualHelpFocus("#tabs-collapse-1", 0); return false;' title="Click to highlight element...">Channel Content Tabs</a></dt>
+ <dd>The channel content tabs are links to other content published by the channel. The <b>About</b> tab links to the channel profile. The <b>Photos</b> tab links to the channel photo galleries. The <b>Files</b> tab links to the general shared files published by the channel.</dd>
+</dl> \ No newline at end of file
diff --git a/doc/context/en/profile/help.html b/doc/context/en/profile/help.html
new file mode 100644
index 000000000..563e0df99
--- /dev/null
+++ b/doc/context/en/profile/help.html
@@ -0,0 +1,6 @@
+<dl class="dl-horizontal">
+ <dt>General</dt>
+ <dd>This is the profile page of a channel. It typically displays information describing the channel. If the channel represents a person in a social network, for example, then the profile might provide contact information and other personal details about the person. Channels can have multiple profiles, where the displayed profile depends on the observer.</dd>
+ <dt><a href='#' onclick='contextualHelpFocus("#tabs-collapse-1", 0); return false;' title="Click to highlight element...">Channel Content Tabs</a></dt>
+ <dd>The channel content tabs are links to other content published by the channel. The <b>About</b> tab links to the channel profile. The <b>Photos</b> tab links to the channel photo galleries. The <b>Files</b> tab links to the general shared files published by the channel.</dd>
+</dl> \ No newline at end of file
diff --git a/doc/context/photos/help.html b/doc/context/photos/help.html
deleted file mode 100644
index f41611f8d..000000000
--- a/doc/context/photos/help.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<script>
- var contextualHelp1 = function (target, openSidePanel) {
- $("#help-content").removeClass('help-content-open'); // Close the help panel
- $("#navbar-collapse-1").removeClass('in'); // Collapse the navbar for small screens
- if (openSidePanel) {
- $("main").addClass('region_1-on'); // Open the side panel to highlight element
- } else {
- $("main").removeClass('region_1-on');
- }
- // Animate the page scroll to the element and then pulse the element to direct attention
- $('html,body').animate({scrollTop: $(target).offset().top - $('#navbar-collapse-1').height() - 20}, 'slow');
- for (i = 0; i < 3; i++) {
- $(target).fadeTo('slow', 0.1).fadeTo('slow', 1.0);
- }
- }
-</script>
-<dl class="dl-horizontal">
- <dt>General</dt>
- <dd>This page displays a channel's photo albums. The images visible to the observer depend on the individual image permissions.</dd>
- <dt><a href='#' onclick='contextualHelp1("#tabs-collapse-1", 0); return false;' title="Click to highlight element...">Channel Content Tabs</a></dt>
- <dd>The channel content tabs are links to other content published by the channel. The <b>About</b> tab links to the channel profile. The <b>Photos</b> tab links to the channel photo galleries. The <b>Files</b> tab links to the general shared files published by the channel.</dd>
-</dl> \ No newline at end of file
diff --git a/doc/context/profile/help.html b/doc/context/profile/help.html
deleted file mode 100644
index 0d4abb8cb..000000000
--- a/doc/context/profile/help.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<script>
- var contextualHelp1 = function (target, openSidePanel) {
- $("#help-content").removeClass('help-content-open'); // Close the help panel
- $("#navbar-collapse-1").removeClass('in'); // Collapse the navbar for small screens
- if (openSidePanel) {
- $("main").addClass('region_1-on'); // Open the side panel to highlight element
- } else {
- $("main").removeClass('region_1-on');
- }
- // Animate the page scroll to the element and then pulse the element to direct attention
- $('html,body').animate({scrollTop: $(target).offset().top - $('#navbar-collapse-1').height() - 20}, 'slow');
- for (i = 0; i < 3; i++) {
- $(target).fadeTo('slow', 0.1).fadeTo('slow', 1.0);
- }
- }
-</script>
-<dl class="dl-horizontal">
- <dt>General</dt>
- <dd>This is the profile page of a channel. It typically displays information describing the channel. If the channel represents a person in a social network, for example, then the profile might provide contact information and other personal details about the person. Channels can have multiple profiles, where the displayed profile depends on the observer.</dd>
- <dt><a href='#' onclick='contextualHelp1("#tabs-collapse-1", 0); return false;' title="Click to highlight element...">Channel Content Tabs</a></dt>
- <dd>The channel content tabs are links to other content published by the channel. The <b>About</b> tab links to the channel profile. The <b>Photos</b> tab links to the channel photo galleries. The <b>Files</b> tab links to the general shared files published by the channel.</dd>
-</dl> \ No newline at end of file
diff --git a/doc/hooklist.bb b/doc/hooklist.bb
index bae641585..994d0dbb2 100644
--- a/doc/hooklist.bb
+++ b/doc/hooklist.bb
@@ -34,12 +34,18 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/activity_received]activity_received[/zrl]
Called when an activity (post, comment, like, etc.) has been received from a zot source
+[zrl=[baseurl]/help/hook/admin_aside]admin_aside[/zrl]
+ Called when generating the admin page sidebar widget
+
[zrl=[baseurl]/help/hook/affinity_labels]affinity_labels[/zrl]
Used to generate alternate labels for the affinity slider.
[zrl=[baseurl]/help/hook/api_perm_is_allowed]api_perm_is_allowed[/zrl]
Called when perm_is_allowed() is executed from an API call.
+[zrl=[baseurl]/help/hook/app_menu]app_menu[/zrl]
+ Called when generating the app_menu dropdown (may be obsolete)
+
[zrl=[baseurl]/help/hook/atom_author]atom_author[/zrl]
Called when generating an author or owner element for an Atom ActivityStream feed
@@ -88,6 +94,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/check_siteallowed]check_siteallowed[/zrl]
Used to over-ride or bypass the site black/white block lists
+[zrl=[baseurl]/help/hook/comment_buttons]comment_buttons[/zrl]
+ Called when rendering the edit buttons for comments
+
[zrl=[baseurl]/help/hook/connect_premium]connect_premium[/zrl]
Called when connecting to a premium channel
@@ -112,6 +121,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/conversation_start]conversation_start[/zrl]
Called in the beginning of rendering a conversation (message or message collection or stream)
+[zrl=[baseurl]/help/hook/cover_photo_content_end]cover_photo_content_end[/zrl]
+ Called after a cover photo has been uplaoded
+
[zrl=[baseurl]/help/hook/create_identity]create_identity[/zrl]
Called when creating a channel
@@ -184,6 +196,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/follow]follow[/zrl]
called when a follow operation takes place
+[zrl=[baseurl]/help/hook/follow_from_feed]follow_from_feed[/zrl]
+ called when a follow operation takes place on an RSS feed
+
[zrl=[baseurl]/help/hook/follow_allow]follow_allow[/zrl]
called before storing the results of a follow operation
@@ -206,6 +221,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/get_all_perms]get_all_perms[/zrl]
called when get_all_perms() is used
+[zrl=[baseurl]/help/hook/get_best_language]get_best_language[/zrl]
+ called when choosing the preferred language for the page
+
[zrl=[baseurl]/help/hook/get_features]get_features[/zrl]
Called when get_features() is called
@@ -266,6 +284,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/local_dir_update]local_dir_update[/zrl]
Called when processing a directory update from a channel on the directory server
+[zrl=[baseurl]/help/hook/location_move]location_move[/zrl]
+ Called when a new location has been provided to a UNO channel (indicating a move rather than a clone)
+
[zrl=[baseurl]/help/hook/logged_in]logged_in[/zrl]
Called when authentication by any means has succeeeded
@@ -281,6 +302,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/magic_auth]magic_auth[/zrl]
Called when processing a magic-auth sequence
+[zrl=[baseurl]/help/hook/match_webfinger_location]match_webfinger_location[/zrl]
+ Called when processing webfinger requests
+
[zrl=[baseurl]/help/hook/magic_auth_openid_success]magic_auth_openid_success[/zrl]
Called when a magic-auth was successful due to openid credentials
@@ -324,7 +348,10 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
Called when a hub is delivered
[zrl=[baseurl]/help/hook/notifier_normal]notifier_normal[/zrl]
- Called when the notofoer is invoked for a 'normal' delivery
+ Called when the notifier is invoked for a 'normal' delivery
+
+[zrl=[baseurl]/help/hook/notifier_process]notifier_process[/zrl]
+ Called when the notifier is processing a message/event
[zrl=[baseurl]/help/hook/obj_verbs]obj_verbs[/zrl]
Called when creating the list of verbs available for profile "things".
@@ -445,6 +472,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/profile_tabs]profile_tabs[/zrl]
Called when generating the tabs for channel related pages (channel,profile,files,etc.)
+
+[zrl=[baseurl]/help/hook/queue_deliver]queue_deliver[/zrl]
+ Called when delivering a queued message
[zrl=[baseurl]/help/hook/register_account]register_account[/zrl]
Called when an account has been created
@@ -458,6 +488,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/reverse_magic_auth]reverse_magic_auth[/zrl]
Called before invoking reverse magic auth to send you to your own site to authenticate on this site
+[zrl=[baseurl]/help/hook/settings_account]settings_account[/zrl]
+ Called when generating the account settings form
+
[zrl=[baseurl]/help/hook/settings_form]settings_form[/zrl]
Called when generating the channel settings form
diff --git a/doc/plugins.bb b/doc/plugins.bb
index f74276038..f2f0b04e8 100644
--- a/doc/plugins.bb
+++ b/doc/plugins.bb
@@ -1,6 +1,6 @@
[b]Plugins[/b]
-So you want to make the $Projectname do something it doesn't already do. There are lots of ways. But let's learn how to write a plugin or addon.
+So you want to make $Projectname do something it doesn't already do. There are lots of ways. But let's learn how to write a plugin or addon.
In your $Projectname folder/directory, you will probably see a sub-directory called 'addon'. If you don't have one already, go ahead and create it.
@@ -45,16 +45,16 @@ In our case, we'll call them randplace_load() and randplace_unload(), as that is
pluginname_uninstall()
[/code]
-Next we'll talk about **hooks**. Hooks are places in the $Projectname code where we allow plugins to do stuff. There are a [lot of these](help/Hooks), and they each have a name. What we normally do is use the pluginname_load() function to register a &quot;handler function&quot; for any hooks you are interested in. Then when any of these hooks are triggered, your code will be called.
+Next we'll talk about [b]hooks[/b]. Hooks are places in the $Projectname code where we allow plugins to do stuff. There are a [url=[baseurl]/help/hooklist]lot of these[/url], and they each have a name. What we normally do is use the pluginname_load() function to register a &quot;handler function&quot; for any hooks you are interested in. Then when any of these hooks are triggered, your code will be called.
-We register hook handlers with the 'register_hook()' function. It takes 3 arguments. The first is the hook we wish to catch, the second is the filename of the file to find our handler function (relative to the base of your $Projectname installation), and the third is the function name of your handler function. So let's create our randplace_load() function right now.
+We register hook handlers with the 'Zotlabs\Extend\Hook::register()' function. It typically takes 3 arguments. The first is the hook we wish to catch, the second is the filename of the file to find our handler function (relative to the base of your $Projectname installation), and the third is the function name of your handler function. So let's create our randplace_load() function right now.
[code]
function randplace_load() {
- register_hook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook');
+ Zotlabs\Extend\Hook::register('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook');
- register_hook('feature_settings', 'addon/randplace/randplace.php', 'randplace_settings');
- register_hook('feature_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
+ Zotlabs\Extend\Hook::register('feature_settings', 'addon/randplace/randplace.php', 'randplace_settings');
+ Zotlabs\Extend\Hook::register('feature_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
}
[/code]
@@ -64,21 +64,18 @@ So we're going to catch three events, 'post_local' which is triggered when a pos
Next we'll create an unload function. This is easy, as it just unregisters our hooks. It takes exactly the same arguments.
[code]
function randplace_unload() {
- unregister_hook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook');
-
- unregister_hook('feature_settings', 'addon/randplace/randplace.php', 'randplace_settings');
- unregister_hook('feature_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
+ Zotlabs\Extend\Hook::unregister('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook');
+ Zotlabs\Extend\Hook::unregister('feature_settings', 'addon/randplace/randplace.php', 'randplace_settings');
+ Zotlabs\Extend\Hook::unregister('feature_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
}
[/code]
-Hooks are called with two arguments. The first is always $a, which is our global App structure and contains a huge amount of information about the state of the web request we are processing; as well as who the viewer is, and what our login state is, and the current contents of the web page we're probably constructing.
-
-The second argument is specific to the hook you're calling. It contains information relevant to that particular place in the program, and often allows you to look at, and even change it. In order to change it, you need to add '&amp;' to the variable name so it is passed to your function by reference. Otherwise it will create a copy and any changes you make will be lost when the hook process returns. Usually (but not always) the second argument is a named array of data structures. Please see the &quot;hook reference&quot; (not yet written as of this date) for details on any specific hook. Occasionally you may need to view the program source to see precisely how a given hook is called and how the results are processed.
+Hooks are always called with one argument which is specific to the hook you're calling. It contains information relevant to that particular place in the program, and often allows you to look at, and even change it. In order to change it, you need to add '&amp;' to the variable name so it is passed to your function by reference. Otherwise it will create a copy and any changes you make will be lost when the hook process returns. Usually (but not always) the passed data is a named array of data structures. Please see the &quot;hook reference&quot; (not yet written as of this date) for details on any specific hook. Occasionally you may need to view the program source to see precisely how a given hook is called and how the results are processed.
Let's go ahead and add some code to implement our post_local hook handler.
[code]
- function randplace_post_hook($a, &amp;$item) {
+ function randplace_post_hook(&amp;$item) {
/**
*
@@ -145,7 +142,7 @@ Now let's add our functions to create and store preference settings.
*
*/
- function randplace_settings_post($a,$post) {
+ function randplace_settings_post($post) {
if(! local_channel())
return;
if($_POST['randplace-submit'])
@@ -171,7 +168,7 @@ Now let's add our functions to create and store preference settings.
- function randplace_settings(&amp;$a,&amp;$s) {
+ function randplace_settings(&amp;$s) {
if(! local_channel())
return;
@@ -205,19 +202,46 @@ Now let's add our functions to create and store preference settings.
-***Advanced Plugins***
+[h2]Advanced Plugins[/h2]
Sometimes your plugins want to provide a range of new functionality which isn't provided at all or is clumsy to provide using hooks. In this case your plugin can also act as a 'module'. A module in our case refers to a structured webpage handler which responds to a given URL. Then anything which accesses that URL will be handled completely by your plugin.
-The key to this is to create a simple function named pluginname_module() which does nothing.
+There are two ways to accomplish this. To create a module object use the following model:
+[code]
+<?php /* file: addon/randplace/Mod_Randplace.php */
+namespace Zotlabs\Module;
+
+ // Your module will consist of the name of your addon with an uppercase first character, within the Zotlabs\Module namespace
+ // To avoid namespace conflicts with your plugin, the convention we're using is to name the module file Mod_Addonname.php
+ // In this case 'Mod_Randplace.php' and then include it from within your main plugin file 'randplace.php' with the line:
+ //
+ // require_once('addon/randplace/Mod_Randplace.php');
+
+ class Randplace extends \Zotlabs\Web\Controller {
+ function init() {
+ // init method is always called first if it exists
+ }
+ function post() {
+ // the post method is only called if there are $_POST variables present (e.g. the page request method is "post")
+ }
+ function get() {
+ // The get method is used to display normal content on the page
+ // whatever this function returns will be displayed in the page body
+ }
+ }
+[/code]
+
+The other option is to use a procedural interface. The $a argument to these function is obsolete, but must be present.
+The key to this is to create a simple function named pluginname_module() which does nothing. These lines and this interface
+can be used inside your addon file without causing a namespace conflict, as the object method will.
+
[code]
function randplace_module() { return; }
[/code]
-Once this function exists, the URL #^[url=https://yoursite/randplace]https://yoursite/randplace[/url] will access your plugin as a module. Then you can define functions which are called at various points to build a webpage just like the modules in the mod/ directory. The typical functions and the order which they are called is
+Once this function exists, the URL #^[url=https://yoursite/randplace]https://yoursite/randplace[/url] will access your plugin as a module. Then you can define functions which are called at various points to return or process a structured webpage just like system modules. The typical functions and the order which they are called is
[code]
modulename_init($a) // (e.g. randplace_init($a);) called first - if you wish to emit json or xml,
// you should do it here, followed by killme() which will avoid the default action of building a webpage
- modulename_aside($a) // Often used to create sidebar content
modulename_post($a) // Called whenever the page is accessed via the &quot;post&quot; method
modulename_content($a) // called to generate the central page content. This function should return a string
// consisting of the central page content.
@@ -228,7 +252,7 @@ Your module functions have access to the URL path as if they were standalone pro
[/code]
we will create an argc/argv list for use by your module functions
[code]
- $x = argc(); $x will be 4, the number of path arguments after the sitename
+ $x = argc(); // $x will be 4, the number of path arguments after the sitename
for($x = 0; $x &lt; argc(); $x ++)
echo $x . ' ' . argv($x);
@@ -240,6 +264,30 @@ we will create an argc/argv list for use by your module functions
3 whatever
[/code]
+[h3]Using class methods as hook handler functions[/h3]
+
+To register a hook using a class method as a callback, a couple of things need to be considered. The first is that the functions need to be declared static public so that they are available from all contexts, and they need to have a namespace attached because they can be called from within multiple namespaces. You can then register them as strings or arrays (using the PHP internal calling method).
+
+[code]
+<?php
+/*
+ * plugin info block goes here
+ */
+
+function myplugin_load() {
+ Zotlabs\Extend\Hook::register('hook_name','addon/myplugin/myplugin.php','\\Myplugin::foo');
+[b]or[/b]
+ Zotlabs\Extend\Hook::register('hook_name','addon/myplugin/myplugin.php',array('\\Myplugin','foo'));
+}
+
+class Myplugin {
+
+ public static function foo($params) {
+ // handler for 'hook_name'
+ }
+}
+[/code]
+
If you want to keep your plugin hidden from the siteinfo page, simply create a file called '.hidden' in your addon directory
[code]
touch addon/<addon name>/.hidden
@@ -259,6 +307,6 @@ The $Projectname has _install and _uninstall functions but these are used differ
[li] Friendica's &quot;plugin_settings_post&quot; hook is called &quot;feature_settings_post&quot;[/li]
-Changing these will often allow your plugin to function, but please double check all your permission and identity code because the concepts behind it are completely different in the $Projectname. Many structured data names (especially DB schema columns) are also quite different.
+Changing these will often allow your plugin to function, but please double check all your permission and identity code because the concepts behind it are completely different in $Projectname. Many structured data names (especially DB schema columns) are also quite different.
#include doc/macros/main_footer.bb;