[TYPO3-dev] Backend ajax: mID approach

Oliver Hader oh at inpublica.de
Sat Feb 10 15:19:33 CET 2007


Hi Maximo,

Maximo Cuadros wrote:
> Hi,
> 
> I updated the code plz check at:
> http://rafb.net/p/EogyLM22.html
> 
> Olver we can call mID as u want, this is not important.

That shouldn't also be a problem for me, too. ;-)

A call to the PHP AJAX should could IMO like this:
typo3/alt_doc_ajax.php?mID=IRRE&mACT=createNewRecord&ajax[0]=argument0&ajax[1]=...

So this leads to a general structure:
$TYPO3_CONF_VARS['BE']['mID_include'][<package>][<action>] = array(
	'handler' => '<handler>',
	'required' => array('<php-class-file-1>', '<php-class-file-2>'),
	'encodeUTF8' => <boolean>
);

I think we do not need a key 'init'. The incoming AJAX call will be
delegated to the handler-function and this one has to take care about
initialisation of its special environment. alt_doc_ajax.php is just
doing the necessary abstract stuff.

The key 'encodeUTF8' will perform a charset conversion to UTF-8 of the
result. Possibly only some parts of the result must be encoded, thus the
developer can decide. This assumes that AJAX responses are always
returned as UTF-8, of course.

The extended Backus-Naur (eBNF) form of the key 'handler':
handler ::= <static> | <instance>
static ::= <class> "::" <function>
instance ::= (<variable>|<class>) "->" {<object> "->"} <method>
variable ::= "$" <valid-php-identifier>
class ::= <valid-php-identifier>
object ::= <valid-php-identifier>
method ::= <valid-php-identifier>
(* @see http://www.php.net/manual/en/language.variables.php *)
valid-php-identifier = ? chars that are valid in PHP for variables ?

Examples:
"$this->tceforms->inline->createNewRecord"
"t3lib_TCEforms->inline->createNewRecord"
"t3lib_div::someOtherFunction"

Thus there has to be a general method which takes care about the string
provided in the key 'handler' and creates the instances. Finally this
path to the handler function/method is called via "call_user_func_array"
as it is like now.

So, here go with an example:
$TYPO3_CONF_VARS['BE']['mID_include']['IRRE']['createNewRecord']=array(
	'handler' => 't3lib_TCEforms->inline->createNewRecord',
	'required' => array(PATH_t3lib.'class.t3lib_tceforms.php'),
	'encodeUTF8' => false
);

What do you think?


olly
-- 
Oliver Hader
http://inpublica.de/




More information about the TYPO3-dev mailing list