本文整理汇总了PHP中RSFormProHelper::getCalculations方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::getCalculations方法的具体用法?PHP RSFormProHelper::getCalculations怎么用?PHP RSFormProHelper::getCalculations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::getCalculations方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showForm
//.........这里部分代码省略.........
$formLayout .= "\n" . '<script type="text/javascript">' . "\n" . implode("\n", $prices) . "\n" . '</script>' . "\n";
}
if (!empty($calendars)) {
$formLayout .= "\n" . '<script type="text/javascript" src="' . JURI::root(true) . '/components/com_rsform/assets/calendar/cal.js?v=' . _RSFORM_REVISION . '"></script>' . "\n";
$formLayout .= '<script type="text/javascript">' . RSFormProHelper::getCalendarJS() . '</script>' . "\n";
$formLayout .= '<script type="text/javascript" defer="defer">rsf_CALENDAR.util.Event.addListener(window, "load", rsfp_init(' . $formId . ',{ layouts: Array(' . $calendarsLayout . '), formats: Array(' . $calendarsFormat . '), values: Array(' . $calendarsValues . '), extra: Array(' . $calendarsExtra . ') }));</script>' . "\n";
}
if (!empty($pages)) {
$formLayout .= '<script type="text/javascript" src="' . JURI::root(true) . '/components/com_rsform/assets/js/pages.js?v=' . _RSFORM_REVISION . '"></script>' . "\n";
$formLayout .= '<script type="text/javascript">rsfp_changePage(' . $formId . ', ' . $start_page . ', ' . count($pages) . ');</script>' . "\n";
}
if ($form->AjaxValidation || !empty($pages)) {
$formLayout .= '<script type="text/javascript">var rsfp_ajax_root = \'' . addslashes(JURI::root(true)) . '\';</script>';
}
if ($form->AjaxValidation) {
$formLayout .= '<script type="text/javascript">rsfp_addEvent(window, \'load\', function(){var form = rsfp_getForm(' . $formId . '); form.onsubmit = ajaxValidation;});</script>';
}
$ajaxScript = '';
$mainframe->triggerEvent('rsfp_f_onAJAXScriptCreate', array(array('script' => &$ajaxScript, 'formId' => $formId)));
$formLayout .= '<script type="text/javascript">';
$formLayout .= 'ajaxExtraValidationScript[' . $formId . '] = function(task, formId, data) {';
$formLayout .= 'var formComponents = {};';
foreach ($components as $component) {
if (in_array($component->ComponentTypeId, array(7, 9, 10, 11, 12, 13, 15, 41))) {
continue;
}
$formLayout .= "formComponents[" . $component->ComponentId . "]='" . $component->name . "';";
}
$formLayout .= "if (task == 'afterSend') {";
$formLayout .= "\r\n\t\tvar ids = data.response[0].split(',');\r\n\t\tfor (var i=0; i<ids.length; i++) {\r\n\t\t\tvar id = parseInt(ids[i]);\r\n\t\t\tif (!isNaN(id) && typeof formComponents[id] != 'undefined') {\r\n\t\t\t\tvar formComponent = rsfp_getFieldsByName(formId, formComponents[id]);\r\n\t\t\t\tif (formComponent && formComponent.length > 0) {\r\n\t\t\t\t\tfor (var j=0; j<formComponent.length; j++) {\r\n\t\t\t\t\t\tif (formComponent[j]) {\r\n\t\t\t\t\t\t\tformComponent[j].className = formComponent[j].className.replace(' rsform-error', '');\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tvar ids = data.response[1].split(',');\r\n\t\tfor (var i=0; i<ids.length; i++) {\r\n\t\t\tvar id = parseInt(ids[i]);\r\n\t\t\tif (!isNaN(id) && typeof formComponents[id] != 'undefined') {\r\n\t\t\t\tvar formComponent = rsfp_getFieldsByName(formId, formComponents[id]);\r\n\t\t\t\tif (formComponent && formComponent.length > 0) {\r\n\t\t\t\t\tfor (var j=0; j<formComponent.length; j++) {\r\n\t\t\t\t\t\tif (formComponent[j]) {\r\n\t\t\t\t\t\t\tformComponent[j].className = formComponent[j].className.replace(' rsform-error', '') + ' rsform-error';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t";
$formLayout .= "}\n";
// has this been modified?
if ($ajaxScript) {
$formLayout .= $ajaxScript;
}
$formLayout .= '}';
$formLayout .= '</script>';
if ($conditions = RSFormProHelper::getConditions($formId)) {
$formLayout .= '<script type="text/javascript">';
foreach ($conditions as $condition) {
$formLayout .= "\n" . 'function rsfp_runCondition' . $condition->id . '(){';
if ($condition->details) {
$condition_vars = array();
foreach ($condition->details as $detail) {
$formLayout .= "\n" . "isChecked = rsfp_verifyChecked(" . $formId . ", '" . addslashes($detail->ComponentName) . "', '" . addslashes($detail->value) . "');";
$formLayout .= "\n" . "condition" . $detail->id . " = isChecked == " . ($detail->operator == 'is' ? 'true' : 'false') . ";";
$condition_vars[] = "condition" . $detail->id;
}
if ($condition->block) {
$block = JFilterOutput::stringURLSafe($condition->ComponentName);
$formLayout .= "\n" . "items = rsfp_getBlock(" . $formId . ", '" . addslashes($block) . "');";
} else {
$formLayout .= "\n" . "items = rsfp_getFieldsByName(" . $formId . ", '" . addslashes($condition->ComponentName) . "');";
}
$formLayout .= "\n" . "if (items) {";
$formLayout .= "\n" . "if (" . implode($condition->condition == 'all' ? '&&' : '||', $condition_vars) . ")";
$formLayout .= "\n" . "rsfp_setDisplay(items, '" . ($condition->action == 'show' ? '' : 'none') . "');";
$formLayout .= "\n" . 'else';
$formLayout .= "\n" . "rsfp_setDisplay(items, '" . ($condition->action == 'show' ? 'none' : '') . "');";
$formLayout .= "\n" . "}";
}
$formLayout .= "\n" . '}';
$formLayout .= "\n" . 'rsfp_runCondition' . $condition->id . '();';
if ($condition->details) {
foreach ($condition->details as $detail) {
$formLayout .= "\n" . "rsfp_addCondition(" . $formId . ", '" . addslashes($detail->ComponentName) . "', rsfp_runCondition" . $condition->id . ");";
}
}
}
$formLayout .= "\n" . '</script>';
}
if ($calculations = RSFormProHelper::getCalculations($formId)) {
require_once dirname(__FILE__) . '/calculations.php';
$formLayout .= "\n" . '<script type="text/javascript">';
$formLayout .= "\n" . 'function rsfp_Calculations' . $formId . '(){';
foreach ($calculations as $calculation) {
$expression = RSFormProCalculations::expression($calculation, $formId);
$formLayout .= "\n" . $expression . "\n";
}
$formLayout .= "\n" . '}';
$formLayout .= "\n" . 'rsfp_Calculations' . $formId . '();';
$formLayout .= RSFormProCalculations::getFields($calculations, $formId);
$formLayout .= "\n" . 'rsfp_setCalculationsEvents(' . $formId . ',rsfpCalculationFields' . $formId . ');';
$formLayout .= "\n" . '</script>';
}
$maps = RSFormProHelper::componentExists($formId, 212);
//212 is the componentTypeId for maps
if (!empty($maps)) {
$formLayout .= "\n" . '<script type="text/javascript">';
foreach ($maps as $map) {
$formLayout .= RSFormProHelper::generateMap($map, $validation);
}
$formLayout .= "\n" . '</script>';
}
$RSadapter = RSFormProHelper::getLegacyAdapter();
eval($form->ScriptDisplay);
//Trigger Event - onBeforeFormDisplay
$mainframe->triggerEvent('rsfp_f_onBeforeFormDisplay', array(array('formLayout' => &$formLayout, 'formId' => $formId)));
return $formLayout;
}
示例2: display
public function display($tpl = null)
{
$mainframe = JFactory::getApplication();
$document = JFactory::getDocument();
$document->addCustomTag('<!--[if IE 7]><link href="' . JURI::root() . 'administrator/components/com_rsform/assets/css/styleie.css" rel="stylesheet" type="text/css" /><![endif]-->');
RSFormProHelper::loadCodeMirror();
JToolBarHelper::title('RSForm! Pro', 'rsform');
// adding the toolbar on 2.5
if (!RSFormProHelper::isJ('3.0')) {
$this->addToolbar();
}
$layout = $this->getLayout();
$this->isComponent = JRequest::getVar('tmpl') == 'component';
$this->tooltipClass = RSFormPRoHelper::getTooltipClass();
if ($layout == 'edit') {
$submissionsIcon = RSFormProHelper::isJ('3.0') ? 'database' : 'forward';
$previewIcon = RSFormProHelper::isJ('3.0') ? 'new tab' : 'preview';
$directoryIcon = RSFormProHelper::isJ('3.0') ? 'folder' : 'forward';
JToolBarHelper::apply('forms.apply');
JToolBarHelper::save('forms.save');
JToolBarHelper::spacer();
JToolBarHelper::custom('forms.preview', $previewIcon, $previewIcon, JText::_('JGLOBAL_PREVIEW'), false);
JToolBarHelper::custom('submissions.back', $submissionsIcon, $submissionsIcon, JText::_('RSFP_SUBMISSIONS'), false);
JToolBarHelper::custom('forms.directory', $directoryIcon, $directoryIcon, JText::_('RSFP_DIRECTORY'), false);
JToolBarHelper::custom('components.copy', 'copy', 'copy', JText::_('RSFP_COPY_TO_FORM'), false);
JToolBarHelper::custom('components.duplicate', 'copy', 'copy', JText::_('RSFP_DUPLICATE'), false);
JToolBarHelper::deleteList(JText::_('RSFP_ARE_YOU_SURE_DELETE'), 'components.remove', JText::_('JTOOLBAR_DELETE'));
JToolBarHelper::publishList('components.publish', JText::_('JTOOLBAR_PUBLISH'));
JToolBarHelper::unpublishList('components.unpublish', JText::_('JTOOLBAR_UNPUBLISH'));
JToolBarHelper::spacer();
JToolBarHelper::cancel('forms.cancel');
$this->tabposition = JRequest::getInt('tabposition', 0);
$this->tab = JRequest::getInt('tab', 0);
$this->form = $this->get('form');
$this->form_post = $this->get('formPost');
$this->hasSubmitButton = $this->get('hasSubmitButton');
JToolBarHelper::title('RSForm! Pro <small>[' . JText::sprintf('RSFP_EDITING_FORM', $this->form->FormTitle) . ']</small>', 'rsform');
$lists['Published'] = $this->renderHTML('select.booleanlist', 'Published', '', $this->form->Published);
$lists['ShowFormTitle'] = $this->renderHTML('select.booleanlist', 'ShowFormTitle', '', $this->form->ShowFormTitle);
$lists['keepdata'] = $this->renderHTML('select.booleanlist', 'Keepdata', '', $this->form->Keepdata);
$lists['confirmsubmission'] = $this->renderHTML('select.booleanlist', 'ConfirmSubmission', '', $this->form->ConfirmSubmission);
$lists['ShowThankyou'] = $this->renderHTML('select.booleanlist', 'ShowThankyou', 'onclick="enableThankyou(this.value);"', $this->form->ShowThankyou);
$lists['ShowContinue'] = $this->renderHTML('select.booleanlist', 'ShowContinue', !$this->form->ShowThankyou ? 'disabled="true"' : '', $this->form->ShowContinue);
$lists['UserEmailMode'] = $this->renderHTML('select.booleanlist', 'UserEmailMode', 'onclick="enableEmailMode(\'User\', this.value)"', $this->form->UserEmailMode, JText::_('HTML'), JText::_('RSFP_COMP_FIELD_TEXT'));
$lists['UserEmailAttach'] = $this->renderHTML('select.booleanlist', 'UserEmailAttach', 'onclick="enableAttachFile(this.value)"', $this->form->UserEmailAttach);
$lists['AdminEmailMode'] = $this->renderHTML('select.booleanlist', 'AdminEmailMode', 'onclick="enableEmailMode(\'Admin\', this.value)"', $this->form->AdminEmailMode, JText::_('HTML'), JText::_('RSFP_COMP_FIELD_TEXT'));
$lists['MetaTitle'] = $this->renderHTML('select.booleanlist', 'MetaTitle', '', $this->form->MetaTitle);
$lists['TextareaNewLines'] = $this->renderHTML('select.booleanlist', 'TextareaNewLines', '', $this->form->TextareaNewLines);
$lists['AjaxValidation'] = $this->renderHTML('select.booleanlist', 'AjaxValidation', '', $this->form->AjaxValidation);
$lists['FormLayoutAutogenerate'] = $this->renderHTML('select.booleanlist', 'FormLayoutAutogenerate', 'onclick="changeFormAutoGenerateLayout(' . $this->form->FormId . ', this.value);"', $this->form->FormLayoutAutogenerate);
$lists['post_enabled'] = $this->renderHTML('select.booleanlist', 'form_post[enabled]', '', $this->form_post->enabled);
$lists['post_method'] = $this->renderHTML('select.booleanlist', 'form_post[method]', '', $this->form_post->method, JText::_('RSFP_POST_METHOD_POST'), JText::_('RSFP_POST_METHOD_GET'));
$lists['post_silent'] = $this->renderHTML('select.booleanlist', 'form_post[silent]', '', $this->form_post->silent);
$this->themes = $this->get('themes');
$this->lang = $this->get('lang');
// workaround for first time visit
$session = JFactory::getSession();
$session->set('com_rsform.form.' . $this->form->FormId . '.lang', $this->lang);
$this->fields = $this->get('fields');
$this->totalFields = $this->get('totalfields');
$this->quickfields = $this->get('quickfields');
$this->pagination = $this->get('fieldspagination');
$this->calculations = RSFormProHelper::getCalculations($this->form->FormId);
$lists['Languages'] = JHTML::_('select.genericlist', $this->get('languages'), 'Language', 'onchange="submitbutton(\'changeLanguage\')"', 'value', 'text', $this->lang);
$lists['totalFields'] = JHTML::_('select.genericlist', $this->get('languages'), 'Language', 'onchange="submitbutton(\'changeLanguage\')"', 'value', 'text', $this->lang);
$this->mappings = $this->get('mappings');
$this->mpagination = $this->get('mpagination');
$this->conditions = $this->get('conditions');
$this->formId = $this->form->FormId;
$this->emails = $this->get('emails');
$this->lists = $lists;
} elseif ($layout == 'new') {
$nextIcon = RSFormProHelper::isJ('3.0') ? 'next' : 'forward';
JToolBarHelper::custom('forms.new.steptwo', $nextIcon, $nextIcon, JText::_('JNEXT'), false);
JToolBarHelper::cancel('forms.cancel');
} elseif ($layout == 'new2') {
$nextIcon = RSFormProHelper::isJ('3.0') ? 'next' : 'forward';
JToolBarHelper::custom('forms.new.stepthree', $nextIcon, $nextIcon, JText::_('JNEXT'), false);
JToolBarHelper::cancel('forms.cancel');
$lists['AdminEmail'] = $this->renderHTML('select.booleanlist', 'AdminEmail', 'onclick="changeAdminEmail(this.value)"', 1);
$lists['UserEmail'] = $this->renderHTML('select.booleanlist', 'UserEmail', '', 1);
$actions = array(JHTML::_('select.option', 'refresh', JText::_('RSFP_SUBMISSION_REFRESH_PAGE')), JHTML::_('select.option', 'thankyou', JText::_('RSFP_SUBMISSION_THANKYOU')), JHTML::_('select.option', 'redirect', JText::_('RSFP_SUBMISSION_REDIRECT_TO')));
$lists['SubmissionAction'] = JHTML::_('select.genericlist', $actions, 'SubmissionAction', 'onclick="changeSubmissionAction(this.value)"');
$this->adminEmail = $this->get('adminEmail');
$this->lists = $lists;
$this->editor = JFactory::getEditor();
} elseif ($layout == 'new3') {
$nextIcon = RSFormProHelper::isJ('3.0') ? 'next' : 'forward';
JToolBarHelper::custom('forms.new.stepfinal', $nextIcon, $nextIcon, JText::_('RSFP_FINISH'), false);
JToolBarHelper::cancel('forms.cancel');
$lists['predefinedForms'] = JHTML::_('select.genericlist', $this->get('predefinedforms'), 'predefinedForm', '');
$this->lists = $lists;
} elseif ($layout == 'component_copy') {
JToolBarHelper::custom('components.copy.process', 'copy', 'copy', JText::_('RSFP_COPY'), false);
JToolBarHelper::cancel('components.copy.cancel');
$formlist = $this->get('formlist');
$lists['forms'] = JHTML::_('select.genericlist', $formlist, 'toFormId', '', 'value', 'text');
$this->formId = JRequest::getInt('formId');
$this->cids = JRequest::getVar('cid', array());
$this->lists = $lists;
//.........这里部分代码省略.........
示例3: 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";
}
//.........这里部分代码省略.........