<?php
/**
* Rule checking the value via a callback function (method) with logical negation
*
* PHP version 5
*
* LICENSE
*
* This source file is subject to BSD 3-Clause License that is bundled
* with this package in the file LICENSE and available at the URL
* https://raw.githubusercontent.com/pear/HTML_QuickForm2/trunk/docs/LICENSE
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @copyright 2006-2019 Alexey Borzov <avb@php.net>, Bertrand Mansion <golgote@mamasam.com>
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
* @link https://pear.php.net/package/HTML_QuickForm2
*/
/**
* Rule checking the value via a callback function (method)
*/
require_once 'HTML/QuickForm2/Rule/Callback.php';
/**
* Rule checking the value via a callback function (method) with logical negation
*
* The Rule accepts the same configuration parameters as the Callback Rule
* does, but the callback is expected to return false if the element is valid
* and true if it is invalid.
*
* @category HTML
* @package HTML_QuickForm2
* @author Alexey Borzov <avb@php.net>
* @author Bertrand Mansion <golgote@mamasam.com>
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
* @version Release: 2.1.0
* @link https://pear.php.net/package/HTML_QuickForm2
*/
class HTML_QuickForm2_Rule_NotCallback extends HTML_QuickForm2_Rule_Callback
{
/**
* Validates the owner element
*
* @return bool negated result of a callback function
*/
protected function validateOwner()
{
$value = $this->owner->getValue();
$config = $this->getConfig();
return !call_user_func_array(
$config['callback'], array_merge(array($value), $config['arguments'])
);
}
protected function getJavascriptCallback()
{
HTML_QuickForm2_Loader::loadClass('HTML_QuickForm2_JavascriptBuilder');
$config = $this->getConfig();
$arguments = array($this->owner->getJavascriptValue());
foreach ($config['arguments'] as $arg) {
$arguments[] = HTML_QuickForm2_JavascriptBuilder::encode($arg);
}
return "function() { return !" . $this->findJavascriptName() .
"(" . implode(', ', $arguments) . "); }";
}
}
?>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez