egroupware_official/etemplate/inc/class.etemplate_widget_button.inc.php
Ralf Becker 0d66dd98b7 fixed server-side valdation of autorepeated rows/columns
had to change signature of validate function to get information for autorepeating through
removed entity-encoding of square brackets, as they mess up validiation (havnt found any negative effects so far)
2012-05-03 14:17:47 +00:00

53 lines
1.8 KiB
PHP

<?php
/**
* EGroupware - eTemplate serverside button widget
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright 2002-11 by RalfBecker@outdoor-training.de
* @version $Id$
*/
/**
* eTemplate button widget
*/
class etemplate_widget_button extends etemplate_widget
{
/**
* Validate buttons
*
* Readonly buttons can NOT be pressed!
*
* @param string $cname current namespace
* @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
* @param array $content
* @param array &$validated=array() validated content
* @return boolean true if no validation error, false otherwise
*/
public function validate($cname, array $expand, array $content, &$validated=array())
{
$form_name = self::form_name($cname, $this->id, $expand);
//error_log(__METHOD__."('$cname', ".array2string($expand).", ...) $this: get_array(\$content, '$form_name')=".array2string(self::get_array($content, $form_name)));
// need to check === true, as get_array() ignores a "[]" postfix and returns array() eg. for a not existing $row_cont[id] in "delete[$row_cont[id]]"
if (!$this->is_readonly($cname, $form_name) && self::get_array($content, $form_name) === true)
{
$valid =& self::get_array($validated, $form_name, true);
$valid = 'pressed'; // that's what it was in old etemplate
// recored pressed button globally, was in the template object before, not sure self::$request is the right place ...
if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name,-10) == '[cancel]')
{
self::$request->canceled = true;
}
else
{
self::$request->button_pressed = true;
}
}
}
}