本文整理汇总了PHP中RSFormProHelper::explode方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::explode方法的具体用法?PHP RSFormProHelper::explode怎么用?PHP RSFormProHelper::explode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::explode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: getEditFields
function getEditFields()
{
$isPDF = JRequest::getVar('format') == 'pdf';
$cid = $this->getSubmissionId();
$return = array();
$this->_db->setQuery("SELECT * FROM #__rsform_submissions WHERE SubmissionId='" . $cid . "'");
$submission = $this->_db->loadObject();
if (empty($submission)) {
$mainframe = JFactory::getApplication();
$mainframe->redirect('index.php?option=com_rsform&task=submissions.manage');
return $return;
}
if ($isPDF) {
$this->_db->setQuery("SELECT MultipleSeparator, TextareaNewLines FROM #__rsform_forms WHERE FormId='" . $submission->FormId . "'");
$form = $this->_db->loadObject();
$form->MultipleSeparator = str_replace(array('\\n', '\\r', '\\t'), array("\n", "\r", "\t"), $form->MultipleSeparator);
}
$this->_db->setQuery("SELECT FieldName, FieldValue FROM #__rsform_submission_values WHERE SubmissionId='" . $cid . "'");
$fields = $this->_db->loadObjectList();
foreach ($fields as $field) {
$submission->values[$field->FieldName] = $field->FieldValue;
}
unset($fields);
$this->_db->setQuery("SELECT p.PropertyValue, ct.ComponentTypeName, c.ComponentId FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (p.ComponentId=c.ComponentId) LEFT JOIN #__rsform_component_types ct ON (c.ComponentTypeId=ct.ComponentTypeId) WHERE c.FormId='" . $submission->FormId . "' AND c.Published='1' AND p.PropertyName='NAME' ORDER BY `Order`");
$fields = $this->_db->loadObjectList();
if (empty($fields)) {
return $return;
}
$componentIds = array();
foreach ($fields as $field) {
$componentIds[] = $field->ComponentId;
}
$properties = RSFormProHelper::getComponentProperties($componentIds);
foreach ($fields as $field) {
$data = $properties[$field->ComponentId];
$new_field = array();
$new_field[0] = $field->PropertyValue;
$name = $field->PropertyValue;
$value = isset($submission->values[$field->PropertyValue]) ? $submission->values[$field->PropertyValue] : '';
if ($data['NAME'] == 'RSEProPayment') {
$field->ComponentTypeName = 'rsepropayment';
}
switch ($field->ComponentTypeName) {
// skip this field for now, no need to edit it
case 'freeText':
continue 2;
break;
default:
if ($isPDF) {
$new_field[1] = RSFormProHelper::htmlEscape($value);
} else {
if (strpos($value, "\n") !== false || strpos($value, "\r") !== false) {
$new_field[1] = '<textarea style="width: 95%" class="rs_textarea" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>';
} else {
$new_field[1] = '<input class="rs_inp rs_80"" size="105" type="text" name="form[' . $name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" />';
}
}
break;
case 'textArea':
if ($isPDF) {
if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') {
$value = $value;
} elseif ($form->TextareaNewLines) {
$value = nl2br(RSFormProHelper::htmlEscape($value));
}
$new_field[1] = $value;
} elseif (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') {
$new_field[1] = RSFormProHelper::WYSIWYG('form[' . $name . ']', RSFormProHelper::htmlEscape($value), '', 600, 100, 60, 10);
} else {
$new_field[1] = '<textarea style="width: 95%" class="rs_textarea" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>';
}
break;
case 'radioGroup':
case 'checkboxGroup':
case 'selectList':
if ($isPDF) {
$new_field[1] = str_replace("\n", $form->MultipleSeparator, $value);
break;
}
if ($field->ComponentTypeName == 'radioGroup') {
$data['SIZE'] = 0;
$data['MULTIPLE'] = 'NO';
} elseif ($field->ComponentTypeName == 'checkboxGroup') {
$data['SIZE'] = 5;
$data['MULTIPLE'] = 'YES';
}
$value = RSFormProHelper::explode($value);
$items = RSFormProHelper::isCode($data['ITEMS']);
$items = RSFormProHelper::explode($items);
$options = array();
foreach ($items as $item) {
// <OPTGROUP>
if (preg_match('/\\[g\\]/', $item)) {
$item = str_replace('[g]', '', $item);
$optgroup = new stdClass();
$optgroup->value = '<OPTGROUP>';
$optgroup->text = $item;
$options[] = $optgroup;
continue;
}
//.........这里部分代码省略.........
示例3: 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]');
//.........这里部分代码省略.........
示例4: 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'));
}
示例5: 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);
}
}
}