[Pieforms-commit] SF.net SVN: pieforms: [288] pieforms-php5/trunk/src/pieform.php
Status: Alpha
Brought to you by:
oracleshinoda
From: <ora...@us...> - 2008-01-30 02:33:25
|
Revision: 288 http://pieforms.svn.sourceforge.net/pieforms/?rev=288&view=rev Author: oracleshinoda Date: 2008-01-29 18:33:29 -0800 (Tue, 29 Jan 2008) Log Message: ----------- Added a new method, 'reply', to handle JSON replying or calling a PHP reply callback. I'm sure this feature is badly designed and needs work, but it's in Mahara for now. Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2008-01-29 04:27:29 UTC (rev 287) +++ pieforms-php5/trunk/src/pieform.php 2008-01-30 02:33:29 UTC (rev 288) @@ -222,6 +222,10 @@ $this->data['successcallback'] = $this->name . '_submit'; } + if (!$this->data['replycallback']) { + $this->data['replycallback'] = $this->name . '_reply'; + } + $this->data['configdirs'] = array_map( create_function('$a', 'return substr($a, -1) == "/" ? substr($a, 0, -1) : $a;'), (array) $this->data['configdirs']); @@ -426,7 +430,7 @@ call_user_func_array($function, array($this, $values)); if ($this->data['dieaftersubmit']) { if ($this->data['jsform']) { - $message = 'Your ' . $this->name . '_submit function should use $form->json_reply to send a response'; + $message = 'Your ' . $this->name . '_submit function should use $form->reply to send a response, which should redirect or exit when it is done. Perhaps you want to make your reply callback do this?'; } else { $message = 'Your ' . $this->name . '_submit function should redirect or exit when it is done'; @@ -763,6 +767,20 @@ }/*}}}*/ /** + * Sends a message back to a form + */ + public function reply($returncode, $message) { + if ($this->submitted_by_js()) { + $this->json_reply($returncode, $message); + } + + $function = $this->get_property('replycallback'); + if (function_exists($function)) { + call_user_func_array($function, array($returncode, $message)); + } + } + + /** * Sends a message back to a jsform. * * The message can contain almost any data, although how it is used is up to @@ -1307,6 +1325,10 @@ // button in the form 'successcallback' => '', + // The PHP callback called to handle replying to the form after + // either a success or fail. Optional + 'replycallback' => '', + // The PHP callback called if there is any validation error. Optional 'errorcallback' => '', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |