What does this do?

This provides Xajax functionality to the frontend.


How is it used?

Copy the file function.xajax_tools.php to your /plugins/ directory.
Make sure you have access to the file directly from the browser.
Example .htaccess file for your plugins directory:

# To deny PHPs
<Files ~ "\.(php|php3|php4|php5|phtml|pl|cgi)$">
	order deny,allow
	deny from all
</Files>

# To allow xajax_tools
<Files "function.xajax_tools.php"> 
	order allow,deny
	allow from all
</Files>

Simply insert {xajax_tools [params]} in the <head> section of your page template.
This prints out all the required xajax javascripts.
Additionally there is a javascript function called xajax_tools() that may process all your ajax requests


Parameters:

    (csv) actions (optional)
        A comma separated list of allowed actions. (module_action, plugin, udt, ... more to come ... )
        If empty all available plugin actions may be called.

    (csv) modules (optional)
        A comma separated list of allowed modules.
        If empty all available modules with frontend actions may be processed.

    (csv) plugins (optional)
        A comma separated list of allowed plugins.
        If empty all available plugins may be processed.
        Make sure you only allow/create plugins that are as secure as possible to be used in frontend!

    (csv) udts (optional)
        A comma separated list of allowed udts.
        Due to security this plugin will not process all available udts but only those where the name of the udt starts with a certain prefix.
        The prefix can be set with the param udt_prefix.
        You must not specify the prefix in the udt list.
        So if empty all available udts with a certain prefix may be processed.
        Make sure you only allow/create udts that are as secure as possible to be used in frontend!

    (string) udt_prefix (optional)
        A prefix for the name of all udts that may be processed via xaxjax requests in frontend.
        Default is 'xajax_tools_'

    (boolean) debug (optional)
        Set to true for debugging


Usage of the javascript function xajax_tools():

xajax_tools(action, params, target_id, target_property, target_value)

    (mixed) action (required)
        This is the serverside action you want to process.
        This can be a string or an array with multiple actions.
        The array may consist of just function names or js objects with individual options for each action.

        Example:

        xajax_tools('module_action', further arguments)
        xajax_tools(['module_action','plugin', ... ], further arguments)
        xajax_tools({action: 'module_action', params: {...} }, further arguments)
        xajax_tools([{action: 'module_action', params: {...} },{action: 'plugin', params: {...} }, ... ], further arguments)

        If you pass an js object as argument it will be handled like an associative array.
        The action object consists of the following options:

        {
        	action: 'The name of the action (string - required)',
        	params: 'The action params (string, array, object - optional but may be required for certain actions)',
        	target_id: 'The id of the html dom element where the result will be displayed (string - optional; if not used no result will be seen)',
        	target_property: 'The property of the html dom element that will be changed (string - optional; default is innerHTML; may be any property of a html dom element)',
        	target_value: 'if specified this will be used instead of the result (not ready yet)'
        }


    (mixed) params (optional)
        The action params (string, array, object - optional but may be required for certain actions).

    (string) target_id (optional)
        The id of the html dom element where the result will be displayed.
        If not used no result will be seen.

    (string) target_property (optional)
        The property of the html dom element that will be changed.
        May be any property of a html dom element (e.g. 'style.backgroundColor').
        Default is 'innerHTML'

    (string) target_value (optional)
        if specified this will be used instead of the result. (not ready yet)


Available actions:

    module_action
        This action performs any kind of action of a CMSms module.
        This function expects the params to be an array that contains at least one index 'module' that contains the name of the module to process:

        {
        	module: 'Name of the module (required)',
        	params: {
        		action: 'Action of the module (optional - default is the default module action)',
        		any_valid_module_param: 'any valid value',
        		...
        	}
        }


    plugin
        This action processes any plugin that is allowed to be processed.
        This action expects the params to be an array that contains at least one index 'plugin' that contains the name of the plugin to process:

        {
        	plugin: 'Name of the plugin (required)',
        	params: {
        		any_valid_plugin_param: 'any valid value',
        		...
        	}
        }


    udt
        This action processes any allowed udt that is prefixed with a certain value.
        You must not specify the prefix when calling the xajax_tools javascript function in frontend!
        It is recommended to hide the prefix from the public!
        This action expects the params to be an array that contains at least one index 'udt' that contains the name of the udt to process:

        {
        	plugin: 'Name of the udt (required - no udt prefix here!)',
        	params: {
        		any_valid_udt_param: 'any valid value',
        		...
        	}
        }


    will be continued ...


Example usage:

<head>
	...
	{xajax_tools}
</head>
<body>
	...
	<label for="toggle_news">Toggle the News Module: </label>
	<input id="toggle_news" name="toggle_news" type="checkbox" value="1" onchange="if(this.checked){ xajax_tools('module_action', {module: 'News', params:{articleid:-1,action:'detail'}}, 'news_container') } else { document.getElementById('news_container').innerHTML = 'This is where the news will be loaded into';}" />
	<div id="news_container">This is where the news will be loaded into</div>
	...
</body>


Support

This plugin does not include commercial support. However, there are a number of resources available to help you with it:

    Discussion of this plugin may be found in the CMS Made Simple Forums:
    http://forum.cmsmadesimple.de
    http://forum.cmsmadesimple.org


Please report any kind of feedback.


Copyright and License

As per the GPL, this software is provided as-is.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Or read it online: http://www.gnu.org/licenses/licenses.html#GPL
Please read the text of the license for the full disclaimer.

Copyright (c) 2011, Georg Busch (NaN). All Rights Are Reserved.

This plugin has been released under the GNU Public License. You must agree to this license before using the plugin.