Wikka Documentation : ActionInfo

HomePage :: Index :: RecentChanges :: Search :: Login/Register
[2374] Latest edit on 2014-12-25 20:00:51 by BrianKoontz [more notes]


Additions:
since 1.3.6
There are two types of actions: Those that act on the wiki page prior to the markup being processed ("traditional" actions, designated by {{...}}), and the new post-formatter actions (designated by {{{...}}}). The main difference between the two is that the new post-formatter action can access the contents of the wiki page it's invoked in after the markup has been processed into HTML. For instance, the new {{{toc}}} post-formatter action will generate a table of contents for all headings on a wiki page, and uses the id generated for each heading by the Wikka formatter. Since this can't happen prior to the page being rendered by the formatter, {{{toc}}} must be implemented as a post-formatter action. The formatted text is made available to the action using $this->config['text'].
If this made no sense to you, don't worry! Almost always you will want to create a "traditional" action using the {{...}} syntax.

Deletions:
since 1.3.6
There are two types of actions: Those that act on the wiki page prior to the markup being processed ("traditional" actions, designated by {{...}}), and the new post-formatter actions (designated by {{{...}}}). The main difference between the two is that the new post-formatter action can access the contents of the wiki page it's invoked in after the markup has been processed into HTML. For instance, the new {{{toc}}} post-formatter action will generate a table of contents for all headings on a wiki page, and uses the id generated for each heading by the Wikka formatter. Since this can't happen prior to the page being rendered by the formatter, {{{toc}}} must be implemented as a post-formatter action.



[2373] Edited on 2014-12-25 19:58:55 by BrianKoontz [typo]


Additions:
since 1.3.6
There are two types of actions: Those that act on the wiki page prior to the markup being processed ("traditional" actions, designated by {{...}}), and the new post-formatter actions (designated by {{{...}}}). The main difference between the two is that the new post-formatter action can access the contents of the wiki page it's invoked in after the markup has been processed into HTML. For instance, the new {{{toc}}} post-formatter action will generate a table of contents for all headings on a wiki page, and uses the id generated for each heading by the Wikka formatter. Since this can't happen prior to the page being rendered by the formatter, {{{toc}}} must be implemented as a post-formatter action.

Deletions:
since 1.3.6
There are two types of actions: Those that act on the wiki page prior to the markup being processed ("traditional" actions, designated by {{...}}), and the new post-formatter actions (designated by {{{...}}}). The main difference between the two is that the new post-formatter action can access the contents of the wiki page it's invoked in after the markup has been processed into HTML. For instance, the new ""{{{toc}}}"" post-formatter action will generate a table of contents for all headings on a wiki page, and uses the id generated for each heading by the Wikka formatter. Since this can't happen prior to the page being rendered by the formatter, {{{toc}}} must be implemented as a post-formatter action.



[2372] Edited on 2014-12-25 19:58:26 by BrianKoontz [added notes about post-formatter actions]


Additions:
Two types of actions
since 1.3.6
There are two types of actions: Those that act on the wiki page prior to the markup being processed ("traditional" actions, designated by {{...}}), and the new post-formatter actions (designated by {{{...}}}). The main difference between the two is that the new post-formatter action can access the contents of the wiki page it's invoked in after the markup has been processed into HTML. For instance, the new ""{{{toc}}}"" post-formatter action will generate a table of contents for all headings on a wiki page, and uses the id generated for each heading by the Wikka formatter. Since this can't happen prior to the page being rendered by the formatter, {{{toc}}} must be implemented as a post-formatter action.
%%(php)
# action called as Unknown action "example/example.php" will create a variable $vars
foreach ($vars as $parm => $value) {
$value = $this->htmlspecialchars_ent($value) # Sanitize your input!
your code here.

Deletions:
%%(php)# action called as Unknown action "example/example.php" will create a variable $vars
foreach ($vars as $parm => $value)
your code here.



[1858] Edited on 2009-01-31 02:04:48 by DarTar [Removed carriage return]


No Differences


[1309] Edited on 2008-11-01 23:23:06 by DarTar [Removed HomePage link]


Deletions:
HomePage


[945] Edited on 2008-03-09 18:30:20 by DarTar [quickly edited, needs more work]


Additions:
When you start working on a new action, announce this at PluginsInDevelopment, someone else may be willing to help. The community mailing list and IRC channel are also a good place to find help and support from other Wikka users and contributors.
Deletions:
When you start working on a new action, announce this at PluginsInDevelopment, someone else may be willing to help. The community mailing list and IRC channel are also a good place to find help and support from other Wikka users and contributors.


[944] Edited on 2008-03-09 18:29:45 by DarTar [quickly edited, needs more work]


Additions:
As you know from this tutorial, to use an action in a page you simply put the name of an action (and parameters if necessary) between double braces ({{action_name [parameter1="A"][ parameter2="B"]}}). The Wikka formatter then sends the text between the two brackets to the Action() core method . Everything after the first word is treated as a parameter of the action. If the corresponding action-file is found in the action directory, parameters are passed to it in the form of an array.
Deletions:
As you know from this tutorial, to use an action in a page you simply put the name of an action (and parameters if necessary) between double braces ({{action_name [parameter1="A"][ parameter2="B"]}}). The Wikka formatter then sends the text between the two brackets to the Action() core method . Everything after the first word is treated as a parameter of the action. If the corresponding action-file is found in the action directory, parameters are passed to it in the form of an array.


[943] Edited on 2008-03-09 18:29:25 by DarTar [quickly edited, needs more work]


Additions:
See also
Coding Guidelines for Wikka contributors
Technically, "actions" are nothing else than PHP files, which are included and run by the Wikka engine.
As you know from this tutorial, to use an action in a page you simply put the name of an action (and parameters if necessary) between double braces ({{action_name [parameter1="A"][ parameter2="B"]}}). The Wikka formatter then sends the text between the two brackets to the Action()
core method . Everything after the first word is treated as a parameter of the action. If the corresponding action-file is found in the action directory, parameters are passed to it in the form of an array.
You can easily extend Wikka's functionality by writing your own actions and saving them in the actions directory. This page will give you some examples and hints on custom action creation.
The first step before writing an action is to understand what the goal of the action is and whether writing an action is the best choice for this goal.
Often you will have to decide whether your code must be written as an action or a handler. The simplest way to decide between these two option is the following question:
Do you wish to add something to a page, or to do something with the page?
  1. for code that adds content or a service to a page (e.g. a google search form, a weather forecast, a table etc.), an action is probably your best choice.
  2. for code that does something to a page (like cloning, deleting, editing...), you would probably use a handler
Don't reinvent the wheel
There are many PHP developers out there, so chances are someone has already written the code you need. You are probably familiar with the official feature list but the (unofficial) code contributions directory and the User Contributions category could be a good place to start from. Many existing PHP scripts can easily be adapted to be plugged into Wikka as actions.
Find someone to help
When you start working on a new action, announce this at PluginsInDevelopment, someone else may be willing to help. The community mailing list and IRC channel are also a good place to find help and support from other Wikka users and contributors.
You should always keep in mind that any user with [ACLInfo write-access]] to your wiki will be able to use an action by default. This means if you want your action to be limited to administrators or registered users, you have to take care of it in the action itself.
As said above, parameters are passed as an array to the action. A special name, $vars, is reserved for this array. You can use the following code to get the values of an action's parameters:
A string representation of all specified parameters is also available through the special variable, $vars['wikka_vars']. It is supported for backward compatibility, and is documented here to help you understand at a glance some actions like {{rss}}, but it's not recommended for use it in your action scripts.
Using $this as a reference in your actions you can invoke any of Wikka's core methods. Every methods and members defined in the Wakka.class.php can be called by your actions.
Defining a function inside an action
Because an action can be called more than once, all the code that is inside it can be executed twice or more. The following is the general rule to be followed to avoid errors due to redeclarations:

Deletions:
See also
Technically, actions are nothing else then normal php-files, which are included through the wikka-engine:
As you know from Using actions in Wikka pages, you simply put the name of an action (and parameters if necessary) between {{ and }}. The wikka-formatter then sends the text between the two brackets to the function Action($action, $forceLinkTracking = 0) in the wikka.php . If you take a closer look at it, you will see that everything after the first word is treated as a parameter of the action. If the action-file is found, the parameters are given to it in form of an array.
You can easily extend wikka's functionality by writing your own actions and saving them under a name in the actions directory. This page intends to give you some help with it.
At first, you should think about what you want to do and if an action is the best choice for it.
Mostly you will have to choose between action and handler. You can easily seperate them with the following question:
Do you add something to a page, or do you want to do something with the page?
  1. for an addition to a page (the google-form, a weather-forecast, a table), an action should be your choice.
  2. for doing something to a page (like cloning, deleting, editing...), use a handler
Let others do your work... ;-)
Since there are many people working with php, it is highly possible that someone has already written the code you need. You surely have looked at the (offical) WikkaFeatures and the Development-Category, but have you also seen the (unoffical) CodeContributions and the UserContributions-category?
It may take you some time to search all this places, but it is better than doing the same work twice.
... or at least help you
When you have started working on your action, announce this at PluginsInDevelopment, perhaps someone else wants to help you working on it.
You should always keep in mind that every user, who has write-access to your pages, can use an action by default. That means if you want your action being limited to administrators or registered users, you have to take care of it in the action itself, because Wikka won't!
As said above, parameters are given as an array to the action. A special name, $vars, is reserved for this array. You can use the following code to get their values:
A string representation of all the parameters given is also available through the special variable, $vars['wikka_vars']. It is supported for backward compatibility, and is documented here to help you understand at a glance some actions like {{rss}}, but it's not recommended to use it in your action scripts.
On the example above, you've seen the syntax $this. It refers to the main Wakka class, just as if your action were a method of this class. Thus, you have every methods and members defined for this class available for you.
define and function inside an action
Because an action can be called more than once, all the code that is inside it can be executed twice or more. The general rule you must take care of is:



[641] Edited on 2008-02-08 10:03:40 by DarTar [minor]


Additions:

How actions work and how to write your own


Deletions:

How actions work and why it is easy to write your own




[639] Edited on 2008-02-08 08:19:11 by DotMG [codes for securing actions, description of $vars, warning about define and function declared twice.]


Additions:

2. Security

You should always keep in mind that every user, who has write-access to your pages, can use an action by default. That means if you want your action being limited to administrators or registered users, you have to take care of it in the action itself, because Wikka won't!
# Put this as the very first line of code inside your action
# The action won't work for non-administrator users.
if (!$this->IsAdmin())
{
    return;
}

As said above, parameters are given as an array to the action. A special name, $vars, is reserved for this array. You can use the following code to get their values:
# action called as {{example parameter="thevalue"}} will create a variable $vars
# defined like this: $vars = array('parameter' => 'thevalue');
if (is_array($vars))
{
    foreach ($vars as $parm => $value)
    {
        // your code here.
    }
}

A string representation of all the parameters given is also available through the special variable, $vars['wikka_vars']. It is supported for backward compatibility, and is documented here to help you understand at a glance some actions like {{rss}}, but it's not recommended to use it in your action scripts.
Global methods and members
On the example above, you've seen the syntax $this. It refers to the main Wakka class, just as if your action were a method of this class. Thus, you have every methods and members defined for this class available for you.
define and function inside an action
Because an action can be called more than once, all the code that is inside it can be executed twice or more. The general rule you must take care of is:
if (!defined('D_ACTION_MYACTION_LOGSIZE')) define ('D_ACTION_MYACTION_LOGSIZE', 60);
if (!function_exists('f_action_myfunction_get_default_logsize'))
{
    function f_action_myfunction_get_default_logsize()
    {
        return D_ACTION_MYACTION_LOGSIZE;
    }
}

to be continued

Deletions:

2.Security

You should always keep in mind that every user, who has write-access to your pages, can use an action by default. That means if you want your action beeing limited to admins or registered users, you have to take care of it in the action itself, because wikka won't!
code for restricting access
As said above, paramters are given as an array to the action. You can use the following code to get their values:
code for getting params
will be continued



[387] Edited on 2006-12-27 21:54:58 by YanB [still needs reviewing]


Additions:
HomePage
Deletions:
Wikka Documentation


[386] Edited on 2006-12-27 21:54:42 by YanB [updated links; other minor corrections; needs reviewing]


Additions:
As you know from Using actions in Wikka pages, you simply put the name of an action (and parameters if necessary) between {{ and }}. The wikka-formatter then sends the text between the two brackets to the function Action($action, $forceLinkTracking = 0) in the wikka.php . If you take a closer look at it, you will see that everything after the first word is treated as a parameter of the action. If the action-file is found, the parameters are given to it in form of an array.
You can easily extend wikka's functionality by writing your own actions and saving them under a name in the actions directory. This page intends to give you some help with it.
  1. for an addition to a page (the google-form, a weather-forecast, a table), an action should be your choice.
  2. for doing something to a page (like cloning, deleting, editing...), use a handler
Since there are many people working with php, it is highly possible that someone has already written the code you need. You surely have looked at the (offical) WikkaFeatures and the Development-Category, but have you also seen the (unoffical) CodeContributions and the UserContributions-category?
When you have started working on your action, announce this at PluginsInDevelopment, perhaps someone else wants to help you working on it.
CategoryEN - CategoryReview

Deletions:
This Page is also avaible in German
As you know from Using actions in Wikka pages, you simply put the name of an action (and parameters if necessary) between {{ and }}. The wikka-formatter then sends the text between the two brackets to the function Action($action, $forceLinkTracking = 0) in the wikka.php . If you take a closer look at it, you will see that everything after the first word is treated as a parameter of the action. If the action-file is found, the parameters are given to it in form of an array.
You can easily extend wikkas functionality by writing your own actions and saving them under a name in the actions directory. This page intends to give you some help with it.
  1. for an addition to a page (the google-form, a weather-forecast, a table), an action should be your choise
  2. for doing something to a page (like cloning, deleting, editing...), use a handler
Since there are many people working with php, it is highly possible that someone has already written the code you need. You surely have looked at the (offical) WikkaFeatures and the Development-Category, but have you also seen the (unoffical) CodeContributions and the UserContributions-category?
When you have started working on your action, announce this at PluginsInDevelopment, perhaps someone else wants to help you working on it.
CategoryDocumentation



[177] The oldest known version of this page was created on 2006-07-13 03:27:38 by DarTar [reverting]

History of recent changes for ActionInfo
Wikka Documentation

How actions work and why it is easy to write your own


See also
Using actions in Wikka pages
This Page is also avaible in German

Technically, actions are nothing else then normal php-files, which are included through the wikka-engine:

As you know from Using actions in Wikka pages, you simply put the name of an action (and parameters if necessary) between {{ and }}. The wikka-formatter then sends the text between the two brackets to the function Action($action, $forceLinkTracking = 0) in the wikka.php . If you take a closer look at it, you will see that everything after the first word is treated as a parameter of the action. If the action-file is found, the parameters are given to it in form of an array.

You can easily extend wikkas functionality by writing your own actions and saving them under a name in the actions directory. This page intends to give you some help with it.


1. Planning

At first, you should think about what you want to do and if an action is the best choice for it.

Action vs. Handler
Mostly you will have to choose between action and handler. You can easily seperate them with the following question:
Do you add something to a page, or do you want to do something with the page?

  1. for an addition to a page (the google-form, a weather-forecast, a table), an action should be your choise
  2. for doing something to a page (like cloning, deleting, editing...), use a handler

Let others do your work... ;-)
Since there are many people working with php, it is highly possible that someone has already written the code you need. You surely have looked at the (offical) WikkaFeatures and the Development-Category, but have you also seen the (unoffical) CodeContributions and the UserContributions-category?

It may take you some time to search all this places, but it is better than doing the same work twice.

... or at least help you
When you have started working on your action, announce this at PluginsInDevelopment, perhaps someone else wants to help you working on it.


2.Security

You should always keep in mind that every user, who has write-access to your pages, can use an action by default. That means if you want your action beeing limited to admins or registered users, you have to take care of it in the action itself, because wikka won't!

code for restricting access

Parameters
As said above, paramters are given as an array to the action. You can use the following code to get their values:

code for getting params

will be continued

CategoryDocumentation
Creative Common Attribution-ShareAlike License
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0458 seconds