本文整理汇总了PHP中RSFormProHelper::isCode方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::isCode方法的具体用法?PHP RSFormProHelper::isCode怎么用?PHP RSFormProHelper::isCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::isCode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptionFields
function getOptionFields()
{
$formId = $this->getFormId();
$this->_db->setQuery("SELECT p.PropertyValue, p.PropertyName, p.ComponentId, c.ComponentTypeId FROM #__rsform_properties p LEFT JOIN #__rsform_components c ON (p.ComponentId = c.ComponentId) WHERE c.FormId='" . $formId . "' AND (p.PropertyName='DEFAULTVALUE' OR p.PropertyName='ITEMS') AND c.ComponentTypeId IN (3, 4, 5, 22) ORDER BY c.Order");
$results = $this->_db->loadObjectList();
$lang = RSFormProHelper::getCurrentLanguage($formId);
$translations = RSFormProHelper::getTranslations('properties', $formId, $lang);
foreach ($results as $i => $result) {
$reference_id = $result->ComponentId . '.' . $result->PropertyName;
if (isset($translations[$reference_id])) {
$result->PropertyValue = $translations[$reference_id];
}
$result->PropertyValue = RSFormProHelper::isCode($result->PropertyValue);
$result->PropertyValue = str_replace(array("\r\n", "\r"), "\n", $result->PropertyValue);
$result->PropertyValue = str_replace(array('[c]', '[g]'), '', $result->PropertyValue);
$result->PropertyValue = explode("\n", $result->PropertyValue);
foreach ($result->PropertyValue as $k => $v) {
$v = explode('|', $v, 2);
// paypal ?
if ($result->ComponentTypeId == 22) {
$v[0] = $v[1];
} else {
if (!isset($v[1])) {
$v[1] = $v[0];
}
}
$result->PropertyValue[$k] = $v;
}
$results[$i] = $result;
}
return $results;
}
示例2: getOptionFields
function getOptionFields()
{
$app = JFactory::getApplication();
$types = array(3, 4, 5, 22);
$formId = $this->getFormId();
$app->triggerEvent('rsfp_bk_onCreateConditionOptionFields', array(array('types' => &$types, 'formId' => $formId)));
JArrayHelper::toInteger($types);
$this->_db->setQuery("SELECT p.PropertyValue, p.PropertyName, p.ComponentId, c.ComponentTypeId FROM #__rsform_properties p LEFT JOIN #__rsform_components c ON (p.ComponentId = c.ComponentId) WHERE c.FormId='" . $formId . "' AND (p.PropertyName='DEFAULTVALUE' OR p.PropertyName='ITEMS') AND c.ComponentTypeId IN (" . implode(',', $types) . ") ORDER BY c.Order");
$results = $this->_db->loadObjectList();
$lang = RSFormProHelper::getCurrentLanguage($formId);
$translations = RSFormProHelper::getTranslations('properties', $formId, $lang);
foreach ($results as $i => $result) {
$reference_id = $result->ComponentId . '.' . $result->PropertyName;
if (isset($translations[$reference_id])) {
$result->PropertyValue = $translations[$reference_id];
}
$result->PropertyValue = RSFormProHelper::isCode($result->PropertyValue);
$result->PropertyValue = preg_replace('#\\[p(.*?)\\]#is', '', $result->PropertyValue);
$result->PropertyValue = str_replace(array("\r\n", "\r"), "\n", $result->PropertyValue);
$result->PropertyValue = str_replace(array('[c]', '[g]'), '', $result->PropertyValue);
$result->PropertyValue = explode("\n", $result->PropertyValue);
foreach ($result->PropertyValue as $k => $v) {
$v = explode('|', $v, 2);
// paypal ?
if ($result->ComponentTypeId == 22) {
$v[0] = $v[1];
} else {
if (!isset($v[1])) {
$v[1] = $v[0];
}
}
$result->PropertyValue[$k] = $v;
}
$results[$i] = $result;
}
return $results;
}
示例3: getComponentFields
function getComponentFields()
{
$db = JFactory::getDBO();
$lang = JFactory::getLanguage();
$return = array();
$data = $this->getComponentData();
$formId = JRequest::getInt('formId');
$general = array('NAME', 'CAPTION', 'LABEL', 'DEFAULTVALUE', 'ITEMS', 'TEXT', 'DESCRIPTION', 'COMPONENTTYPE');
$validations = array('REQUIRED', 'VALIDATIONRULE', 'VALIDATIONMESSAGE', 'VALIDATIONEXTRA');
$componentId = $this->getComponentId();
$componentType = $this->getComponentType();
$results = $this->_getList("SELECT * FROM #__rsform_component_type_fields WHERE ComponentTypeId='" . $componentType . "' ORDER BY Ordering ASC");
$translatable = RSFormProHelper::getTranslatableProperties();
foreach ($results as $i => $result) {
if ($result->FieldName == 'ADDITIONALATTRIBUTES') {
$results[$i]->Ordering = 1001;
}
}
usort($results, array('RSFormModelFormAjax', 'sortFields'));
foreach ($results as $result) {
$field = new stdClass();
$field->name = $result->FieldName;
$field->body = '';
switch ($result->FieldType) {
case 'textbox':
if ($lang->hasKey('RSFP_COMP_FIELD_' . $field->name)) {
$field->body = JText::_('RSFP_COMP_FIELD_' . $field->name);
} else {
$field->body = $field->name;
}
$field->body = '<span id="caption' . $field->name . '">' . $field->body . '</span>';
$field->body .= '<br/>';
if ($componentId > 0) {
$value = isset($data[$field->name]) ? $data[$field->name] : '';
} else {
$values = RSFormProHelper::isCode($result->FieldValues);
if ($lang->hasKey('RSFP_COMP_FVALUE_' . $values)) {
$value = JText::_('RSFP_COMP_FVALUE_' . $values);
} else {
$value = $values;
}
}
$additional = '';
if ($result->FieldName == 'FILESIZE') {
$additional = 'onkeyup="javascript:this.value=this.value.replace(/[^0-9]/g, \'\');"';
}
$field->body .= '<input type="text" id="' . $field->name . '" name="param[' . $field->name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" ' . $additional . ' class="rsform_inp" />';
break;
case 'textarea':
if ($lang->hasKey('RSFP_COMP_FIELD_' . $field->name)) {
$field->body = JText::_('RSFP_COMP_FIELD_' . $field->name);
} else {
$field->body = $field->name;
}
$field->body = '<span id="caption' . $field->name . '">' . $field->body . '</span>';
$field->body .= '<br />';
if ($componentId > 0) {
if (!isset($data[$field->name])) {
$data[$field->name] = '';
}
if ($lang->hasKey('RSFP_COMP_FVALUE_' . $data[$field->name])) {
$value = JText::_('RSFP_COMP_FVALUE_' . $data[$field->name]);
} else {
$value = $data[$field->name];
}
} else {
$values = RSFormProHelper::isCode($result->FieldValues);
if ($lang->hasKey('RSFP_COMP_FVALUE_' . $values)) {
$value = JText::_('RSFP_COMP_FVALUE_' . $values);
} else {
$value = $values;
}
}
$field->body .= '<textarea id="' . $field->name . '" name="param[' . $field->name . ']" rows="5" cols="20" class="rsform_txtarea">' . RSFormProHelper::htmlEscape($value) . '</textarea></td>';
break;
case 'select':
if ($lang->hasKey('RSFP_COMP_FIELD_' . $field->name)) {
$field->body = JText::_('RSFP_COMP_FIELD_' . $field->name);
} else {
$field->body = $field->name;
}
$field->body = '<span id="caption' . $field->name . '">' . $field->body . '</span>';
$field->body .= '<br />';
$field->body .= '<select name="param[' . $field->name . ']" id="' . $field->name . '" onchange="changeValidation(this);">';
if (!isset($data[$field->name])) {
$data[$field->name] = '';
}
$result->FieldValues = str_replace("\r", '', $result->FieldValues);
$items = RSFormProHelper::isCode($result->FieldValues);
$items = explode("\n", $items);
foreach ($items as $item) {
$buf = explode('|', $item);
$option_value = $buf[0];
$option_shown = count($buf) == 1 ? $buf[0] : $buf[1];
if ($lang->hasKey('RSFP_COMP_FVALUE_' . $option_shown)) {
$label = JText::_('RSFP_COMP_FVALUE_' . $option_shown);
} else {
$label = $option_shown;
}
$field->body .= '<option ' . ($componentId > 0 && $data[$field->name] == $option_value ? 'selected="selected"' : '') . ' value="' . $option_value . '">' . RSFormProHelper::htmlEscape($label) . '</option>';
//.........这里部分代码省略.........
示例4: save
function save()
{
$db = JFactory::getDBO();
$componentType = JRequest::getInt('COMPONENTTYPE');
$componentIdToEdit = JRequest::getInt('componentIdToEdit');
$formId = JRequest::getInt('formId');
$params = JRequest::getVar('param', array(), 'post', 'none', JREQUEST_ALLOWRAW);
$params['EMAILATTACH'] = !empty($params['EMAILATTACH']) ? implode(',', $params['EMAILATTACH']) : '';
$just_added = false;
if ($componentIdToEdit < 1) {
$db->setQuery("SELECT MAX(`Order`)+1 AS MO FROM #__rsform_components WHERE FormId='" . $formId . "'");
$nextOrder = $db->loadResult();
$db->setQuery("INSERT INTO #__rsform_components SET FormId='" . $formId . "', ComponentTypeId='" . $componentType . "', `Order`='" . $nextOrder . "'");
$db->query();
$componentIdToEdit = $db->insertid();
$just_added = true;
}
$model = $this->getModel('forms');
$lang = $model->getLang();
if (!$just_added && isset($params['ITEMS'])) {
$db->setQuery("SELECT cd.* FROM #__rsform_condition_details cd LEFT JOIN #__rsform_conditions c ON (cd.condition_id=c.id) WHERE cd.component_id='" . $componentIdToEdit . "' AND c.lang_code=" . $db->quote($lang));
if ($conditions = $db->loadObjectList()) {
$data = RSFormProHelper::getComponentProperties($componentIdToEdit);
$oldvalues = RSFormProHelper::explode(RSFormProHelper::isCode($data['ITEMS']));
$newvalues = RSFormProHelper::explode(RSFormProHelper::isCode($params['ITEMS']));
foreach ($oldvalues as $i => $oldvalue) {
$oldvalue = reset(explode('|', $oldvalue, 2));
$oldvalue = str_replace(array('[c]', '[g]'), '', $oldvalue);
$oldvalues[$i] = $oldvalue;
}
foreach ($newvalues as $i => $newvalue) {
$newvalue = reset(explode('|', $newvalue, 2));
$newvalue = str_replace(array('[c]', '[g]'), '', $newvalue);
$newvalues[$i] = $newvalue;
}
foreach ($conditions as $condition) {
$pos = array_search($condition->value, $oldvalues);
if ($pos !== false && isset($newvalues[$pos])) {
$newvalue = $newvalues[$pos];
if ($condition->value != $newvalue) {
$db->setQuery("UPDATE #__rsform_condition_details SET `value`=" . $db->quote($newvalue) . " WHERE id='" . $condition->id . "'");
$db->query();
}
}
}
}
}
array_walk($params, array('RSFormProHelper', 'escapeArray'));
if ($model->_form->Lang != $lang) {
$model->saveFormPropertyTranslation($formId, $componentIdToEdit, $params, $lang, $just_added);
}
if ($componentIdToEdit > 0) {
$db->setQuery("SELECT PropertyName FROM #__rsform_properties WHERE ComponentId='" . $componentIdToEdit . "' AND PropertyName IN ('" . implode("','", array_keys($params)) . "')");
$properties = $db->loadResultArray();
foreach ($params as $key => $val) {
if (in_array($key, $properties)) {
$db->setQuery("UPDATE #__rsform_properties SET PropertyValue='" . $val . "' WHERE PropertyName='" . $key . "' AND ComponentId='" . $componentIdToEdit . "'");
} else {
$db->setQuery("INSERT INTO #__rsform_properties SET PropertyValue='" . $val . "', PropertyName='" . $key . "', ComponentId='" . $componentIdToEdit . "'");
}
$db->query();
}
}
$link = 'index.php?option=com_rsform&task=forms.edit&formId=' . $formId;
if (JRequest::getVar('tmpl') == 'component') {
$link .= '&tmpl=component';
}
$this->setRedirect($link);
}
示例5: save
function save()
{
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
$app = JFactory::getApplication();
$offset = $app->getCfg('offset');
$cid = $this->getSubmissionId();
$form = JRequest::getVar('form', array(), 'post', 'none', JREQUEST_ALLOWRAW);
$static = JRequest::getVar('formStatic', array(), 'post', 'none', JREQUEST_ALLOWRAW);
$date = JFactory::getDate($static['DateSubmitted'], $offset);
$static['DateSubmitted'] = $date->toSql();
$formId = JRequest::getInt('formId');
$files = JRequest::getVar('upload', array(), 'files', 'none', JREQUEST_ALLOWRAW);
// Handle file uploads first
if (!empty($files['error'])) {
foreach ($files['error'] as $field => $error) {
if ($error) {
continue;
}
$this->_db->setQuery("SELECT FieldValue FROM #__rsform_submission_values WHERE FieldName='" . $this->_db->escape($field) . "' AND SubmissionId='" . $cid . "' LIMIT 1");
$original = $this->_db->loadResult();
// already uploaded
if (!empty($form[$field])) {
// Path has changed, remove the original file to save up space
if ($original != $form[$field] && JFile::exists($original) && is_file($original)) {
JFile::delete($original);
}
if (JFolder::exists(dirname($form[$field]))) {
JFile::upload($files['tmp_name'][$field], $form[$field]);
}
} else {
$this->_db->setQuery("SELECT c.ComponentId FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId) WHERE c.FormId='" . $formId . "' AND p.PropertyName='NAME' AND p.PropertyValue='" . $this->_db->escape($field) . "'");
$componentId = $this->_db->loadResult();
if ($componentId) {
$data = RSFormProHelper::getComponentProperties($componentId);
// Prefix
$prefix = uniqid('') . '-';
if (isset($data['PREFIX']) && strlen(trim($data['PREFIX'])) > 0) {
$prefix = RSFormProHelper::isCode($data['PREFIX']);
}
if (JFolder::exists($data['DESTINATION'])) {
// Path
$realpath = realpath($data['DESTINATION'] . '/');
if (substr($realpath, -1) != DIRECTORY_SEPARATOR) {
$realpath .= DIRECTORY_SEPARATOR;
}
$path = $realpath . $prefix . '-' . $files['name'][$field];
$form[$field] = $path;
JFile::upload($files['tmp_name'][$field], $path);
}
}
}
}
}
$update = array();
foreach ($static as $field => $value) {
$update[] = "`" . $this->_db->escape($field) . "`='" . $this->_db->escape($value) . "'";
}
if (!empty($update)) {
$this->_db->setQuery("UPDATE #__rsform_submissions SET " . implode(',', $update) . " WHERE SubmissionId='" . $cid . "'");
$this->_db->execute();
}
// Update fields
foreach ($form as $field => $value) {
if (is_array($value)) {
$value = implode("\n", $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) {
// Check if this is an upload field
if (isset($files['error'][$field]) && JFile::exists($original->FieldValue) && is_file($original->FieldValue)) {
// Move the file to the new location
if (!empty($value) && JFolder::exists(dirname($value))) {
JFile::move($original->FieldValue, $value);
} elseif (empty($value)) {
JFile::delete($original->FieldValue);
}
}
$this->_db->setQuery("UPDATE #__rsform_submission_values SET FieldValue='" . $this->_db->escape($value) . "' WHERE SubmissionValueId='" . $original->SubmissionValueId . "' LIMIT 1");
$this->_db->execute();
}
}
}
// Checkboxes don't send a value if nothing is checked
$this->_db->setQuery("SELECT p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId) WHERE c.ComponentTypeId='4' AND p.PropertyName='NAME' AND c.FormId='" . $formId . "'");
$checkboxes = $this->_db->loadColumn();
foreach ($checkboxes as $checkbox) {
$value = isset($form[$checkbox]) ? $form[$checkbox] : '';
if (is_array($value)) {
$value = implode("\n", $value);
}
$this->_db->setQuery("UPDATE #__rsform_submission_values SET FieldValue='" . $this->_db->escape($value) . "' WHERE FieldName='" . $this->_db->escape($checkbox) . "' AND FormId='" . $formId . "' AND SubmissionId='" . $cid . "' LIMIT 1");
$this->_db->execute();
}
//.........这里部分代码省略.........
示例6: getComponentPrice
public static function getComponentPrice($property, $submission)
{
$price = 0;
$pattern = '#\\[p(.*?)\\]#is';
if (isset($property['ITEMS'])) {
$products = array();
$special = array('[c]', '[g]', '[d]');
if ($items = RSFormProHelper::explode(RSFormProHelper::isCode($property['ITEMS']))) {
foreach ($items as $item) {
$item = str_replace($special, '', $item);
@(list($item_val, $item_text) = explode("|", $item, 2));
if (preg_match($pattern, $item, $match)) {
$item_val = preg_replace($pattern, '', $item_val);
$products[$item_val] = $match[1];
}
}
}
if (isset($submission->values[$property['NAME']])) {
$value = $submission->values[$property['NAME']];
$all_values = explode("\n", $value);
foreach ($all_values as $val) {
$price += isset($products[$val]) ? (double) $products[$val] : 0;
}
}
}
return number_format($price, RSFormProHelper::getConfig('calculations.nodecimals'), RSFormProHelper::getConfig('calculations.decimal'), RSFormProHelper::getConfig('calculations.thousands'));
}
示例7: 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();
//.........这里部分代码省略.........
示例8: getFrontComponentBody
public static function getFrontComponentBody($formId, $componentId, $data, $value = array(), $invalid = false, $layoutName)
{
$mainframe = JFactory::getApplication();
$formId = (int) $formId;
$componentId = (int) $componentId;
$db = JFactory::getDBO();
// For legacy reasons...
$r = array();
$r['ComponentTypeId'] = $data['componentTypeId'];
$r['Order'] = @$data['Order'];
$out = '';
//Trigger Event - rsfp_bk_onBeforeCreateFrontComponentBody
$mainframe->triggerEvent('rsfp_bk_onBeforeCreateFrontComponentBody', array(array('out' => &$out, 'formId' => $formId, 'componentId' => $componentId, 'data' => &$data, 'value' => &$value)));
switch ($data['ComponentTypeName']) {
case 1:
case 'textBox':
if (isset($data['VALIDATIONRULE']) && $data['VALIDATIONRULE'] == 'password') {
$defaultValue = '';
} else {
$defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
}
$className = 'rsform-input-box';
if ($invalid) {
$className .= ' rsform-error';
}
RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
$out .= '<input type="text" value="' . (isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue)) . '" size="' . $data['SIZE'] . '" ' . ((int) $data['MAXSIZE'] > 0 ? 'maxlength="' . (int) $data['MAXSIZE'] . '"' : '') . ' name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '/>';
break;
case 2:
case 'textArea':
$defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
$className = 'rsform-text-box';
if ($invalid) {
$className .= ' rsform-error';
}
RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') {
$out .= RSFormProHelper::WYSIWYG('form[' . $data['NAME'] . ']', isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue), 'id[' . $data['NAME'] . ']', $data['COLS'] * 10, $data['ROWS'] * 10, $data['COLS'], $data['ROWS']);
} else {
$out .= '<textarea cols="' . (int) $data['COLS'] . '" rows="' . (int) $data['ROWS'] . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '>' . (isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue)) . '</textarea>';
}
break;
case 3:
case 'selectList':
$className = 'rsform-select-box';
if ($invalid) {
$className .= ' rsform-error';
}
RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
$out .= '<select ' . ($data['MULTIPLE'] == 'YES' ? 'multiple="multiple"' : '') . ' name="form[' . $data['NAME'] . '][]" ' . ((int) $data['SIZE'] > 0 ? 'size="' . (int) $data['SIZE'] . '"' : '') . ' id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' >';
$items = RSFormProHelper::explode(RSFormProHelper::isCode($data['ITEMS']));
$special = array('[c]', '[g]', '[d]');
foreach ($items as $item) {
@(list($val, $txt) = @explode('|', str_replace($special, '', $item), 2));
if (is_null($txt)) {
$txt = $val;
}
// <optgroup>
if (strpos($item, '[g]') !== false) {
$out .= '<optgroup label="' . RSFormProHelper::htmlEscape($val) . '">';
continue;
}
// </optgroup>
if (strpos($item, '[/g]') !== false) {
$out .= '</optgroup>';
continue;
}
$additional = '';
// selected
if (strpos($item, '[c]') !== false && empty($value) || isset($value[$data['NAME']]) && in_array($val, $value[$data['NAME']])) {
$additional .= 'selected="selected"';
}
// disabled
if (strpos($item, '[d]') !== false) {
$additional .= 'disabled="disabled"';
}
$out .= '<option ' . $additional . ' value="' . RSFormProHelper::htmlEscape($val) . '">' . RSFormProHelper::htmlEscape($txt) . '</option>';
}
$out .= '</select>';
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$layout = JRequest::getCmd('layout');
if ($option == 'com_rsevents' && $view == 'events' && $layout == 'subscribe' && $data['NAME'] == 'RSEventsTickets') {
$db->setQuery("SELECT ConfigValue FROM #__rsevents_config WHERE ConfigName = 'event.multiple.tickets' ");
$multipleTickets = $db->loadResult();
if ($multipleTickets) {
$lang = JFactory::getLanguage();
$lang->load('com_rsevents', JPATH_SITE);
$out .= ' <a onclick="add_ticket(1,\'' . JText::_('RSE_REMOVE_TICKET', true) . '\');" href="javascript:void(0)">' . JText::_('RSE_ADD_TICKET') . '</a> ';
$out .= '<br /><span id="tickets"></span>';
$out .= '<span id="rse_tickets_ids"></span>' . "\n";
$out .= '<span id="rse_tickets_no"></span>' . "\n";
}
}
break;
case 4:
case 'checkboxGroup':
$i = 0;
$items = RSFormProHelper::explode(RSFormProHelper::isCode($data['ITEMS']));
$special = array('[c]', '[d]');
//.........这里部分代码省略.........
示例9: getFrontComponentBody
function getFrontComponentBody($formId, $componentId, $data, $value = '', $invalid = false)
{
$mainframe =& JFactory::getApplication();
$formId = (int) $formId;
$componentId = (int) $componentId;
$db = JFactory::getDBO();
// Optimized, don't need this anymore
//$db->setQuery("SELECT `ComponentTypeId`, `Order` FROM #__rsform_components WHERE ComponentId='".$componentId."' LIMIT 1");
//$r = $db->loadAssoc();
// For legacy reasons...
$r = array();
$r['ComponentTypeId'] = $data['componentTypeId'];
$r['Order'] = @$data['Order'];
$out = '';
//Trigger Event - rsfp_bk_onBeforeCreateFrontComponentBody
$mainframe->triggerEvent('rsfp_bk_onBeforeCreateFrontComponentBody', array(array('out' => &$out, 'formId' => $formId, 'componentId' => $componentId, 'data' => $data, 'value' => $value)));
switch ($data['ComponentTypeName']) {
case 1:
case 'textBox':
$defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
$className = 'rsform-input-box';
if ($invalid) {
$className .= ' rsform-error';
}
RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
$out .= '<input type="text" value="' . (isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue)) . '" size="' . $data['SIZE'] . '" ' . ((int) $data['MAXSIZE'] > 0 ? 'maxlength="' . (int) $data['MAXSIZE'] . '"' : '') . ' name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '/>';
break;
case 2:
case 'textArea':
$defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
$className = 'rsform-text-box';
if ($invalid) {
$className .= ' rsform-error';
}
RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') {
$out .= RSFormProHelper::WYSIWYG('form[' . $data['NAME'] . ']', isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue), 'id[' . $data['NAME'] . ']', $data['COLS'] * 10, $data['ROWS'] * 10, $data['COLS'], $data['ROWS']);
} else {
$out .= '<textarea cols="' . (int) $data['COLS'] . '" rows="' . (int) $data['ROWS'] . '" name="form[' . $data['NAME'] . ']" id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . '>' . (isset($value[$data['NAME']]) ? RSFormProHelper::htmlEscape($value[$data['NAME']]) : RSFormProHelper::htmlEscape($defaultValue)) . '</textarea>';
}
break;
case 3:
case 'selectList':
$className = 'rsform-select-box';
if ($invalid) {
$className .= ' rsform-error';
}
RSFormProHelper::addClass($data['ADDITIONALATTRIBUTES'], $className);
$out .= '<select ' . ($data['MULTIPLE'] == 'YES' ? 'multiple="multiple"' : '') . ' name="form[' . $data['NAME'] . '][]" ' . ((int) $data['SIZE'] > 0 ? 'size="' . (int) $data['SIZE'] . '"' : '') . ' id="' . $data['NAME'] . '" ' . $data['ADDITIONALATTRIBUTES'] . ' >';
$items = RSFormProHelper::isCode($data['ITEMS']);
$items = str_replace("\r", "", $items);
$items = explode("\n", $items);
foreach ($items as $item) {
$buf = explode('|', $item, 2);
if (preg_match('/\\[g\\]/', $item)) {
$out .= '<optgroup label="' . RSFormProHelper::htmlEscape(str_replace('[g]', '', $item)) . '">';
continue;
}
if (preg_match('/\\[\\/g\\]/', $item)) {
$out .= '</optgroup>';
continue;
}
$option_value = $buf[0];
$option_value_trimmed = str_replace('[c]', '', $option_value);
$option_shown = count($buf) == 1 ? $buf[0] : $buf[1];
$option_shown_trimmed = str_replace('[c]', '', $option_shown);
$option_checked = false;
if (empty($value) && preg_match('/\\[c\\]/', $option_shown)) {
$option_checked = true;
}
if (isset($value[$data['NAME']]) && in_array($option_value_trimmed, $value[$data['NAME']])) {
$option_checked = true;
}
$out .= '<option ' . ($option_checked ? 'selected="selected"' : '') . ' value="' . RSFormProHelper::htmlEscape($option_value_trimmed) . '">' . RSFormProHelper::htmlEscape($option_shown_trimmed) . '</option>';
}
$out .= '</select>';
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$layout = JRequest::getCmd('layout');
if ($option == 'com_rsevents' && $view == 'events' && $layout == 'subscribe' && $data['NAME'] == 'RSEventsTickets') {
$db->setQuery("SELECT ConfigValue FROM #__rsevents_config WHERE ConfigName = 'event.multiple.tickets' ");
$multipleTickets = $db->loadResult();
if ($multipleTickets) {
$lang =& JFactory::getLanguage();
$lang->load('com_rsevents', JPATH_SITE);
$out .= ' <a onclick="add_ticket(1,\'' . JText::_('RSE_REMOVE_TICKET', true) . '\');" href="javascript:void(0)">' . JText::_('RSE_ADD_TICKET') . '</a> ';
$out .= '<br /><span id="tickets"></span>';
$out .= '<span id="rse_tickets_ids"></span>' . "\n";
$out .= '<span id="rse_tickets_no"></span>' . "\n";
}
}
break;
case 4:
case 'checkboxGroup':
$i = 0;
$items = RSFormProHelper::isCode($data['ITEMS']);
$items = str_replace("\r", "", $items);
$items = explode("\n", $items);
foreach ($items as $item) {
$buf = explode('|', $item, 2);
//.........这里部分代码省略.........
示例10: rsfp_onAfterCreatePlaceholders
public function rsfp_onAfterCreatePlaceholders($args)
{
$formId = $args['form']->FormId;
$submissionId = $args['submission']->SubmissionId;
$multipleSeparator = $args['form']->MultipleSeparator;
if (RSFormProHelper::componentExists($formId, $this->newComponents)) {
$singleProduct = RSFormProHelper::componentExists($formId, 21);
$multipleProducts = RSFormProHelper::componentExists($formId, 22);
$total = RSFormProHelper::componentExists($formId, 23);
$donationProduct = RSFormProHelper::componentExists($formId, 28);
$choosePayment = RSFormProHelper::componentExists($formId, 27);
// choose payment
if (!empty($choosePayment)) {
$details = RSFormProHelper::getComponentProperties($choosePayment[0]);
$items = $this->_getPayments($formId);
$value = $this->_getSubmissionValue($submissionId, $choosePayment[0]);
$text = '';
if ($items) {
foreach ($items as $item) {
if ($item->value == $value) {
$text = $item->text;
break;
}
}
}
$args['placeholders'][] = '{' . $details['NAME'] . ':text}';
$args['values'][] = $text;
}
// multiple products
if (!empty($multipleProducts)) {
foreach ($multipleProducts as $product) {
$pdetail = RSFormProHelper::getComponentProperties($product);
$detail = $this->_getSubmissionValue($submissionId, $product);
if ($detail == '') {
continue;
}
$detail = explode("\n", $detail);
$items = RSFormProHelper::explode(RSFormProHelper::isCode($pdetail['ITEMS']));
$replace = '{' . $pdetail['NAME'] . ':price}';
$with = array();
foreach ($items as $item) {
@(list($val, $txt) = @explode('|', str_replace($special, '', $item), 2));
if (is_null($txt)) {
$txt = $val;
}
if (!$val) {
$val = 0;
}
if (in_array($txt, $detail)) {
$txt_price = $this->_getPriceMask($txt, $val);
$with[] = $txt_price;
}
}
$args['placeholders'][] = $replace;
$args['values'][] = implode($multipleSeparator, $with);
}
}
// donation
if (!empty($donationProduct)) {
$price = $this->_getSubmissionValue($submissionId, $donationProduct[0]);
$details = RSFormProHelper::getComponentProperties($donationProduct[0]);
$args['placeholders'][] = '{' . $details['NAME'] . ':price}';
$args['values'][] = $this->_getPriceMask($details['CAPTION'], $price);
}
// single product
if (!empty($singleProduct)) {
//Get Component properties
$data = RSFormProHelper::getComponentProperties($this->_getComponentId('rsfp_Product', $formId));
$price = $data['PRICE'];
$args['placeholders'][] = '{rsfp_Product:price}';
$args['values'][] = $this->_getPriceMask($data['CAPTION'], $price);
}
if (!empty($total)) {
$price = $this->_getSubmissionValue($submissionId, $total[0]);
$details = RSFormProHelper::getComponentProperties($total[0]);
$args['placeholders'][] = '{' . $details['NAME'] . ':price}';
$args['values'][] = $this->_getPriceMask($details['CAPTION'], $price);
}
}
}