本文整理汇总了PHP中RSFormProHelper::getConditions方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::getConditions方法的具体用法?PHP RSFormProHelper::getConditions怎么用?PHP RSFormProHelper::getConditions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::getConditions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public static function create($formIds, $submissions, $filename)
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
$app = JFactory::getApplication();
$config = JFactory::getConfig();
$version = new RSFormProVersion();
$xml = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
$xml .= '<RSinstall type="rsformbackup">' . "\n";
$xml .= '<name>RSform backup</name>' . "\n";
$xml .= '<creationDate>' . date('Y-m-d') . '</creationDate>' . "\n";
$xml .= '<author>' . $user->username . '</author>' . "\n";
$xml .= '<copyright>(C) ' . date('Y') . ' ' . JURI::root() . '</copyright>' . "\n";
$xml .= '<authorEmail>' . $config->get('mailfrom') . '</authorEmail>' . "\n";
$xml .= '<authorUrl>' . JURI::root() . '</authorUrl>' . "\n";
$xml .= '<version>' . (string) $version . '</version>' . "\n";
$xml .= '<revision>' . $version->revision . '</revision>' . "\n";
$xml .= '<description>RSForm! Pro Backup</description>' . "\n";
$xml .= '<tasks>' . "\n";
// We need to see all available languages here, because the conditions are attached to languages
$lang = JFactory::getLanguage();
$languages = $lang->getKnownLanguages(JPATH_SITE);
//LOAD FORMS
$db->setQuery("SELECT * FROM #__rsform_forms WHERE FormId IN ('" . implode("','", $formIds) . "') ORDER BY FormId");
$form_rows = $db->loadObjectList();
foreach ($form_rows as $form_row) {
$xml .= RSFormProBackup::createXMLEntry('#__rsform_forms', $form_row, 'FormId') . "\n";
$xml .= "\t" . '<task type="eval"><![CDATA[$GLOBALS[\'q_FormId\'] = $db->insertid();]]></task>' . "\n";
$db->setQuery("SELECT * FROM #__rsform_translations WHERE `form_id`='" . $form_row->FormId . "' AND `reference`='forms'");
$translations = $db->loadObjectList();
foreach ($translations as $translation) {
$xml .= RSFormProBackup::createXMLEntry('#__rsform_translations', $translation, 'id') . "\n";
}
$xml .= "\t" . '<task type="eval"><![CDATA[$GLOBALS[\'ComponentIds\'] = array();]]></task>' . "\n";
//LOAD COMPONENTS
$db->setQuery("SELECT * FROM #__rsform_components WHERE FormId = '" . $form_row->FormId . "'");
$component_rows = $db->loadObjectList();
foreach ($component_rows as $component_row) {
$xml .= RSFormProBackup::createXMLEntry('#__rsform_components', $component_row, 'ComponentId', 'FormId') . "\n";
$xml .= "\t" . '<task type="eval"><![CDATA[$GLOBALS[\'q_ComponentId\'] = $db->insertid();]]></task>' . "\n";
//LOAD PROPERTIES
$db->setQuery("SELECT * FROM #__rsform_properties WHERE ComponentId = '" . $component_row->ComponentId . "'");
$property_rows = $db->loadObjectList();
$ComponentName = '';
foreach ($property_rows as $property_row) {
if ($property_row->PropertyName == 'NAME') {
$ComponentName = $property_row->PropertyValue;
}
$xml .= RSFormProBackup::createXMLEntry('#__rsform_properties', $property_row, 'PropertyId', 'ComponentId') . "\n";
}
if ($ComponentName) {
$xml .= "\t" . '<task type="eval"><![CDATA[$GLOBALS[\'ComponentIds\'][\'' . $ComponentName . '\'] = $GLOBALS[\'q_ComponentId\'];]]></task>' . "\n";
}
//LOAD TRANSLATIONS
$db->setQuery("SELECT * FROM #__rsform_translations WHERE `form_id`='" . $form_row->FormId . "' AND `reference_id` LIKE '" . $component_row->ComponentId . ".%'");
$translations = $db->loadObjectList();
foreach ($translations as $translation) {
$xml .= RSFormProBackup::createXMLEntry('#__rsform_translations', $translation, 'id') . "\n";
}
}
if ($submissions) {
//LOAD SUBMISSIONS
$db->setQuery("SELECT * FROM #__rsform_submissions WHERE FormId = '" . $form_row->FormId . "'");
$submission_rows = $db->loadObjectList();
foreach ($submission_rows as $submission_row) {
$xml .= RSFormProBackup::createXMLEntry('#__rsform_submissions', $submission_row, 'SubmissionId', 'FormId') . "\n";
$xml .= "\t" . '<task type="eval"><![CDATA[$GLOBALS[\'q_SubmissionId\'] = $db->insertid();]]></task>' . "\n";
//LOAD SUBMISSION_VALUES
$db->setQuery("SELECT * FROM #__rsform_submission_values WHERE SubmissionId = '" . $submission_row->SubmissionId . "'");
$submission_value_rows = $db->loadObjectList();
foreach ($submission_value_rows as $submission_value_row) {
$xml .= RSFormProBackup::createXMLEntry('#__rsform_submission_values', $submission_value_row, 'SubmissionValueId', array('SubmissionId', 'FormId')) . "\n";
}
}
}
//LOAD CONDITIONS
foreach ($languages as $tag => $properties) {
$conditions = RSFormProHelper::getConditions($form_row->FormId, $tag);
if ($conditions) {
foreach ($conditions as $condition) {
$xml .= RSFormProBackup::createXMLEntry('#__rsform_conditions', $condition, array('id')) . "\n";
$xml .= "\t" . '<task type="eval"><![CDATA[$GLOBALS[\'q_ConditionId\'] = $db->insertid();]]></task>' . "\n";
if ($condition->details) {
foreach ($condition->details as $detail) {
$xml .= RSFormProBackup::createXMLEntry('#__rsform_condition_details', $detail, array('id')) . "\n";
}
}
}
}
}
//LOAD POSTS
$db->setQuery("SELECT * FROM #__rsform_posts WHERE `form_id`='" . $form_row->FormId . "'");
if ($post = $db->loadObject()) {
$xml .= RSFormProBackup::createXMLEntry('#__rsform_posts', $post, null, null, true) . "\n";
}
//LOAD CALCULATIONS
if ($calculations = RSFormProHelper::getCalculations($form_row->FormId)) {
foreach ($calculations as $calculation) {
$xml .= RSFormProBackup::createXMLEntry('#__rsform_calculations', $calculation, null, null, true) . "\n";
}
//.........这里部分代码省略.........
示例2: 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
//.........这里部分代码省略.........
示例3: 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'];
//.........这里部分代码省略.........