本文整理汇总了PHP中RSFormProHelper::verifyChecked方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::verifyChecked方法的具体用法?PHP RSFormProHelper::verifyChecked怎么用?PHP RSFormProHelper::verifyChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::verifyChecked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateForm
public static function validateForm($formId, $validationType = 'form', $SubmissionId = 0)
{
$mainframe = JFactory::getApplication();
$db = JFactory::getDbo();
$invalid = array();
$formId = (int) $formId;
$post = JRequest::get('post', JREQUEST_ALLOWRAW);
$query = $db->getQuery(true);
$query->select($db->qn('c.ComponentId'))->select($db->qn('c.ComponentTypeId'))->from($db->qn('#__rsform_components', 'c'))->where($db->qn('FormId') . '=' . $db->q($formId))->where($db->qn('Published') . '=' . $db->q(1))->order($db->qn('Order') . ' ' . $db->escape('asc'));
// if $type is directory, we need to validate the fields that are editable in the directory
if ($validationType == 'directory') {
$subquery = $db->getQuery(true);
$subquery->select($db->qn('componentId'))->from($db->qn('#__rsform_directory_fields'))->where($db->qn('formId') . '=' . $db->q($formId))->where($db->qn('editable') . '=' . $db->q(1));
$query->where($db->qn('ComponentId') . ' IN (' . (string) $subquery . ')');
}
$db->setQuery($query);
if ($components = $db->loadObjectList('ComponentId')) {
$componentIds = array_keys($components);
// load properties
$all_data = RSFormProHelper::getComponentProperties($componentIds);
if (empty($all_data)) {
return $invalid;
}
// load conditions
if ($conditions = RSFormProHelper::getConditions($formId)) {
foreach ($conditions as $condition) {
if ($condition->details) {
$condition_vars = array();
foreach ($condition->details as $detail) {
$isChecked = RSFormProHelper::verifyChecked($detail->ComponentName, $detail->value, $post);
$condition_vars[] = $detail->operator == 'is' ? $isChecked : !$isChecked;
}
// this check is performed like this
// 'all' must be true (ie. no 0s in the array); 'any' can be true (ie. one value of 1 in the array will do)
$result = $condition->condition == 'all' ? !in_array(0, $condition_vars) : in_array(1, $condition_vars);
// if the item is hidden, no need to validate it
if ($condition->action == 'show' && !$result || $condition->action == 'hide' && $result) {
foreach ($components as $i => $component) {
if ($component->ComponentId == $condition->component_id) {
// ... just remove it from the components array
unset($components[$i]);
break;
}
}
}
}
}
}
// load validation rules
require_once JPATH_SITE . '/components/com_rsform/helpers/validation.php';
require_once JPATH_SITE . '/components/com_rsform/helpers/datevalidation.php';
$validations = array_flip(get_class_methods('RSFormProValidations'));
$dateValidations = array_flip(get_class_methods('RSFormProDateValidations'));
// validate through components
foreach ($components as $component) {
$data = $all_data[$component->ComponentId];
$required = !empty($data['REQUIRED']) && $data['REQUIRED'] == 'YES';
$validationRule = !empty($data['VALIDATIONRULE']) ? $data['VALIDATIONRULE'] : '';
$typeId = $component->ComponentTypeId;
// birthDay field
if ($typeId == 211) {
// flag to check if we need to run the validation functions
$runValidations = false;
if ($required) {
// we need all of the fields to be selected
if ($data['SHOWDAY'] == 'YES' && empty($post['form'][$data['NAME']]['d']) || $data['SHOWMONTH'] == 'YES' && empty($post['form'][$data['NAME']]['m']) || $data['SHOWYEAR'] == 'YES' && empty($post['form'][$data['NAME']]['y'])) {
$invalid[] = $data['componentId'];
continue;
}
$runValidations = true;
} else {
// the field is not required, but if a selection is made it needs to be valid
$selections = array();
if ($data['SHOWDAY'] == 'YES') {
$selections[] = !empty($post['form'][$data['NAME']]['d']) ? $post['form'][$data['NAME']]['d'] : '';
}
if ($data['SHOWMONTH'] == 'YES') {
$selections[] = !empty($post['form'][$data['NAME']]['m']) ? $post['form'][$data['NAME']]['m'] : '';
}
if ($data['SHOWYEAR'] == 'YES') {
$selections[] = !empty($post['form'][$data['NAME']]['y']) ? $post['form'][$data['NAME']]['y'] : '';
}
$foundEmpty = false;
$foundValue = false;
foreach ($selections as $selection) {
if ($selection == '') {
$foundEmpty = true;
} else {
$foundValue = true;
}
}
// at least 1 value has been selected but we've found empty values as well, make sure the selection is valid first!
if ($foundEmpty && $foundValue) {
$invalid[] = $data['componentId'];
continue;
} elseif ($foundValue && !$foundEmpty) {
$runValidations = true;
}
}
// we have all the info we need, validations only work when all fields are selected
//.........这里部分代码省略.........
示例2: validateForm
function validateForm($formId)
{
require_once JPATH_SITE . DS . 'components' . DS . 'com_rsform' . DS . 'helpers' . DS . 'validation.php';
$mainframe =& JFactory::getApplication();
$db = JFactory::getDBO();
$invalid = array();
$formId = (int) $formId;
$post = JRequest::get('post', JREQUEST_ALLOWRAW);
$db->setQuery("SELECT ComponentId, ComponentTypeId FROM #__rsform_components WHERE FormId='" . $formId . "' AND Published=1 ORDER BY `Order`");
if ($components = $db->loadObjectList()) {
$componentIds = array();
foreach ($components as $component) {
$componentIds[] = $component->ComponentId;
}
$all_data = RSFormProHelper::getComponentProperties($componentIds);
if (empty($all_data)) {
return $invalid;
}
if ($conditions = RSFormProHelper::getConditions($formId)) {
foreach ($conditions as $condition) {
if ($condition->details) {
$condition_vars = array();
foreach ($condition->details as $detail) {
$isChecked = RSFormProHelper::verifyChecked($detail->ComponentName, $detail->value, $post);
$condition_vars[] = $detail->operator == 'is' ? $isChecked : !$isChecked;
}
// this check is performed like this
// 'all' must be true (ie. no 0s in the array); 'any' can be true (ie. one value of 1 in the array will do)
$result = $condition->condition == 'all' ? !in_array(0, $condition_vars) : in_array(1, $condition_vars);
// if the item is hidden, no need to validate it
if ($condition->action == 'show' && !$result || $condition->action == 'hide' && $result) {
foreach ($components as $i => $component) {
if ($component->ComponentId == $condition->component_id) {
// ... just remove it from the components array
unset($components[$i]);
break;
}
}
}
}
}
}
foreach ($components as $component) {
$data = $all_data[$component->ComponentId];
$required = isset($data['REQUIRED']) ? $data['REQUIRED'] : 'NO';
$validationRule = isset($data['VALIDATIONRULE']) ? $data['VALIDATIONRULE'] : '';
$typeId = $component->ComponentTypeId;
// CAPTCHA
if ($typeId == 8) {
$session =& JFactory::getSession();
$captchaCode = $session->get('com_rsform.captcha.' . $component->ComponentId);
if ($data['IMAGETYPE'] == 'INVISIBLE') {
$words = RSFormProHelper::getInvisibleCaptchaWords();
if (!empty($post[$captchaCode])) {
$invalid[] = $data['componentId'];
}
foreach ($words as $word) {
if (!empty($post[$word])) {
$invalid[] = $data['componentId'];
}
}
} else {
if (empty($post['form'][$data['NAME']]) || empty($captchaCode) || $post['form'][$data['NAME']] != $captchaCode) {
$invalid[] = $data['componentId'];
}
}
}
// Trigger Event - rsfp_bk_validate_onSubmitValidateRecaptcha
if ($typeId == 24) {
$mainframe->triggerEvent('rsfp_bk_validate_onSubmitValidateRecaptcha', array(array('data' => &$data, 'invalid' => &$invalid)));
}
if ($typeId == 9) {
$files = JRequest::getVar('form', null, 'files');
// File has been *sent* to the server
if (isset($files['tmp_name'][$data['NAME']]) && $files['error'][$data['NAME']] != 4) {
// File has been uploaded correctly to the server
if ($files['error'][$data['NAME']] == 0) {
// Let's check if the extension is allowed
$ext = strtolower(end(explode('.', $files['name'][$data['NAME']])));
$acceptedExts = !empty($data['ACCEPTEDFILES']) ? RSFormProHelper::explode($data['ACCEPTEDFILES']) : false;
// Let's check only if accepted extensions are set
if ($acceptedExts) {
$accepted = false;
foreach ($acceptedExts as $acceptedExt) {
$acceptedExt = trim(strtolower($acceptedExt));
if (strlen($acceptedExt) && $acceptedExt == $ext) {
$accepted = true;
break;
}
}
if (!$accepted) {
$invalid[] = $data['componentId'];
}
}
// Let's check if it's the correct size
if ($files['size'][$data['NAME']] > 0 && $data['FILESIZE'] > 0 && $files['size'][$data['NAME']] > $data['FILESIZE'] * 1024) {
$invalid[] = $data['componentId'];
}
} else {
$invalid[] = $data['componentId'];
//.........这里部分代码省略.........