本文整理汇总了PHP中RSFormProHelper::getComponentId方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::getComponentId方法的具体用法?PHP RSFormProHelper::getComponentId怎么用?PHP RSFormProHelper::getComponentId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::getComponentId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkOrderData
public static function checkOrderData($formData, $invalid = array(), $ccDataPrefix = 'cc_')
{
if ($formData == null) {
$formData = $_POST['form'];
}
if (self::canAcquireCCData($formData)) {
$prefix = $ccDataPrefix;
foreach ($formData as $key => $value) {
// for each field
if (substr($key, 0, strlen($prefix)) === $prefix) {
// if it is a field we are searching for (prefixed)
if ($value == '') {
// if the value for the field is empty
$invalid[] = RSFormProHelper::getComponentId($key);
// add it to the invalid array
}
}
}
}
}
示例2: save
public function save()
{
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
$cid = JRequest::getInt('id');
$form = JRequest::getVar('form', array(), 'post', 'none', JREQUEST_ALLOWRAW);
$static = JRequest::getVar('formStatic', array(), 'post', 'none', JREQUEST_ALLOWRAW);
$formId = JRequest::getInt('formId');
$files = JRequest::getVar('form', array(), 'files', 'none', JREQUEST_ALLOWRAW);
$validation = RSFormProHelper::validateForm($formId, 'directory', $cid);
if (!empty($validation)) {
return false;
}
$formFields = RSFormProHelper::getDirectoryFields($formId);
$headers = RSFormProHelper::getDirectoryStaticHeaders();
$staticFields = array();
$allowed = array();
foreach ($formFields as $field) {
if ($field->editable) {
if ($field->componentId < 0 && isset($headers[$field->componentId])) {
$staticFields[] = $field->FieldName;
} else {
$allowed[] = $field->FieldName;
}
}
}
//Trigger Event - onBeforeDirectorySave
$this->_app->triggerEvent('rsfp_f_onBeforeDirectorySave', array(array('SubmissionId' => &$cid, 'formId' => $formId, 'post' => &$form)));
// Handle file uploads first
if (!empty($files['error'])) {
foreach ($files['error'] as $field => $error) {
if (!in_array($field, $allowed) || $error) {
continue;
}
// The above $validation should suffice
$this->_db->setQuery("SELECT FieldValue FROM #__rsform_submission_values WHERE FieldName='" . $this->_db->escape($field) . "' AND SubmissionId='" . $cid . "' LIMIT 1");
$original = $this->_db->loadResult();
// Prefix
$componentId = RSFormProHelper::getComponentId($field, $formId);
$data = RSFormProHelper::getComponentProperties($componentId);
$prefix = uniqid('') . '-';
if (isset($data['PREFIX']) && strlen(trim($data['PREFIX'])) > 0) {
$prefix = RSFormProHelper::isCode($data['PREFIX']);
}
// Path
$realpath = realpath($data['DESTINATION'] . DIRECTORY_SEPARATOR);
if (substr($realpath, -1) != DIRECTORY_SEPARATOR) {
$realpath .= DIRECTORY_SEPARATOR;
}
// Filename
$file = $realpath . $prefix . $files['name'][$field];
// Upload File
if (JFile::upload($files['tmp_name'][$field], $file) && $file != $original) {
// Remove the original file to save up space
if (file_exists($original) && is_file($original)) {
JFile::delete($original);
}
// Add to db (submission value)
$form[$field] = $file;
}
}
}
// Update fields
foreach ($form as $field => $value) {
if (!in_array($field, $allowed)) {
continue;
}
if (is_array($value)) {
$value = implode("\n", $value);
}
// Dynamic field - update value.
$this->_db->setQuery("SELECT SubmissionValueId, FieldValue FROM #__rsform_submission_values WHERE FieldName='" . $this->_db->escape($field) . "' AND SubmissionId='" . $cid . "' LIMIT 1");
$original = $this->_db->loadObject();
if (!$original) {
$this->_db->setQuery("INSERT INTO #__rsform_submission_values SET FormId='" . $formId . "', SubmissionId='" . $cid . "', FieldName='" . $this->_db->escape($field) . "', FieldValue='" . $this->_db->escape($value) . "'");
$this->_db->execute();
} else {
// Update only if we've changed something
if ($original->FieldValue != $value) {
$this->_db->setQuery("UPDATE #__rsform_submission_values SET FieldValue='" . $this->_db->escape($value) . "' WHERE SubmissionValueId='" . $original->SubmissionValueId . "' LIMIT 1");
$this->_db->execute();
}
}
}
$offset = JFactory::getConfig()->get('offset');
if ($static && $staticFields) {
// Static, update submission
$query = $this->_db->getQuery(true);
$query->update('#__rsform_submissions')->where($this->_db->qn('SubmissionId') . '=' . $this->_db->q($cid));
foreach ($staticFields as $field) {
if (!isset($static[$field])) {
$static[$field] = '';
}
if ($field == 'DateSubmitted') {
$static[$field] = JFactory::getDate($static[$field], $offset)->toSql();
}
$query->set($this->_db->qn($field) . '=' . $this->_db->q($static[$field]));
}
$this->_db->setQuery($query);
$this->_db->execute();
//.........这里部分代码省略.........