/administrator/components/com_rsform/helpers/rsform.php
PHP | 3182 lines | 2568 code | 464 blank | 150 comment | 480 complexity | bdd0af366eb5ce7b1bb8307504cf05dd MD5 | raw file
Possible License(s): LGPL-3.0, GPL-2.0, MIT, BSD-3-Clause, LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * @version 1.4.0
- * @package RSform!Pro 1.4.0
- * @copyright (C) 2007-2011 www.rsjoomla.com
- * @license GPL, http://www.gnu.org/copyleft/gpl.html
- */
-
- defined('_JEXEC') or die('Restricted access');
-
- //PRODUCT INFO - DO NOT CHANGE
- DEFINE('_RSFORM_PRODUCT','RSform!Pro');
- DEFINE('_RSFORM_VERSION','1.4.0');
- DEFINE('_RSFORM_KEY','2XKJ3KS7JO');
- DEFINE('_RSFORM_COPYRIGHT','©2007-2012 www.rsjoomla.com');
- DEFINE('_RSFORM_LICENSE','GPL Commercial License');
- DEFINE('_RSFORM_AUTHOR','<a href="http://www.rsjoomla.com" target="_blank">www.rsjoomla.com</a>');
- DEFINE('_RSFORM_WEBSITE','http://www.rsjoomla.com/');
- if(!defined('_RSFORM_REVISION'))
- DEFINE('_RSFORM_REVISION','44');
-
- JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_rsform'.DS.'tables');
-
- $cache =& JFactory::getCache('com_rsform');
- $cache->clean();
-
- $lang =& JFactory::getLanguage();
- $lang->load('com_rsform', JPATH_ADMINISTRATOR, 'en-GB', true);
- $lang->load('com_rsform', JPATH_ADMINISTRATOR, $lang->getDefault(), true);
- $lang->load('com_rsform', JPATH_ADMINISTRATOR, null, true);
-
- // Create the Legacy adapter
- $GLOBALS['RSadapter'] = RSFormProHelper::getLegacyAdapter();
-
- // Legacy function -- RSgetValidationRules()
- function RSgetValidationRules()
- {
- return RSFormProHelper::getValidationRules();
- }
-
- function _modifyResponsiveTemplate()
- {
- $buffer = JResponse::getBody();
- $buffer = trim($buffer);
-
- $line = reset(RSFormProHelper::explode($buffer));
- if (strtolower($line) != '<!doctype html>')
- {
- $buffer = str_replace($line, '<!doctype html>', $buffer);
- JResponse::setBody($buffer);
- }
- }
-
- class RSFormProHelper
- {
- function isJ16()
- {
- static $compatible = null;
- if (is_null($compatible))
- {
- jimport('joomla.version');
- $version = new JVersion();
- $compatible = $version->isCompatible('1.6.0');
- }
-
- return $compatible;
- }
-
- function isJ170()
- {
- static $compatible = null;
- if (is_null($compatible))
- {
- jimport('joomla.version');
- $version = new JVersion();
- $compatible = version_compare($version->getShortVersion(), '1.7.0', 'eq');
- }
-
- return $compatible;
- }
-
- function getDate($date)
- {
- if (RSFormProHelper::isJ16())
- return JHTML::_('date', $date, 'Y-m-d H:i:s');
- else
- return JHTML::_('date', $date, '%Y-%m-%d %H:%M:%S');
- }
-
- function getLegacyAdapter()
- {
- static $adapter;
- if (empty($adapter))
- {
- require_once JPATH_ADMINISTRATOR.DS.'components'.DS.'com_rsform'.DS.'helpers'.DS.'legacy.php';
- $adapter = new RSAdapter();
- }
-
- return $adapter;
- }
-
- function getComponentId($name, $formId=0)
- {
- static $cache;
- if (!is_array($cache))
- $cache = array();
-
- if (empty($formId))
- {
- $formId = JRequest::getInt('formId');
- if (empty($formId))
- {
- $post = JRequest::getVar('form');
- $formId = (int) @$post['formId'];
- }
- }
-
- if (!isset($cache[$formId][$name]))
- $cache[$formId][$name] = RSFormProHelper::componentNameExists($name, $formId);
-
- return $cache[$formId][$name];
- }
-
- function checkValue($setvalue, $array)
- {
- if (!is_array($array))
- $array = RSFormProHelper::explode($array);
-
- if (strlen($setvalue))
- foreach ($array as $k => $v)
- {
- @list($value, $text) = explode("|", $v, 2);
- if ($value == $setvalue)
- $array[$k] = $v.'[c]';
- }
-
- return implode("\n", $array);
- }
-
- function createList($results, $value='value', $text='text')
- {
- $list = array();
- if (is_array($results))
- foreach ($results as $result)
- if (is_object($result))
- $list[] = $result->{$value}.'|'.$result->{$text};
- elseif (is_array($result))
- $list[] = $result[$value].'|'.$result[$text];
-
- return implode("\n", $list);
- }
-
- function displayForm($formId, $is_module=false)
- {
- $mainframe =& JFactory::getApplication();
-
- $db = JFactory::getDBO();
- $db->setQuery("SELECT Published, FormTitle, MetaTitle, MetaDesc, MetaKeywords, ShowThankyou FROM #__rsform_forms WHERE FormId='".(int) $formId."'");
- $form = $db->loadObject();
-
- if (empty($form) || !$form->Published)
- {
- JError::raiseWarning(500, JText::_('_NOT_EXIST'));
- return;
- }
-
- $lang = RSFormProHelper::getCurrentLanguage($formId);
- $translations = RSFormProHelper::getTranslations('forms', $formId, $lang);
- if ($translations)
- foreach ($translations as $field => $value)
- {
- if (isset($form->$field))
- $form->$field = $value;
- }
-
- $doc =& JFactory::getDocument();
- if (!$is_module)
- {
- if ($form->MetaDesc)
- $doc->setMetaData('description', $form->MetaDesc);
- if ($form->MetaKeywords)
- $doc->setMetaData('keywords', $form->MetaKeywords);
- if ($form->MetaTitle)
- $doc->setTitle($form->FormTitle);
- }
-
- $session =& JFactory::getSession();
- $formparams = $session->get('com_rsform.formparams.'.$formId);
-
- // Form has been processed ?
- if ($formparams && $formparams->formProcessed)
- {
- // Must show Thank You Message
- if ($form->ShowThankyou)
- {
- return RSFormProHelper::showThankYouMessage($formId);
- }
-
- // Clear
- $session->clear('com_rsform.formparams.'.$formId);
-
- // Must show small message
- $mainframe->enqueueMessage(JText::_('RSFP_THANKYOU_SMALL'));
- }
-
- // Must process form
- $post = JRequest::getVar('form', array(), 'post', 'none', JREQUEST_ALLOWRAW);
- if (isset($post['formId']) && $post['formId'] == $formId)
- {
- $invalid = RSFormProHelper::processForm($formId);
- // Did not pass validation - show the form
- if ($invalid)
- {
- $mainframe->triggerEvent('rsfp_f_onBeforeShowForm');
- return RSFormProHelper::showForm($formId, $post, $invalid);
- }
- }
-
- // Default - show the form
- $mainframe->triggerEvent('rsfp_f_onBeforeShowForm');
- return RSFormProHelper::showForm($formId);
- }
-
- function WYSIWYG($name, $content, $hiddenField, $width, $height, $col, $row)
- {
- $editor =& JFactory::getEditor();
- $params = array('relative_urls' => '0', 'cleanup_save' => '0', 'cleanup_startup' => '0', 'cleanup_entities' => '0');
-
- if (!RSFormProHelper::isJ16())
- {
- $content = $editor->display($name, $content , $width, $height, $col, $row, true, $params);
-
- if (RSFormProHelper::getConfig('global.editor'))
- {
- $doc =& JFactory::getDocument();
- $head = $doc->getHeadData();
-
- $editor_name = $editor->get('_name');
-
- if (!empty($editor_name))
- switch ($editor_name)
- {
- // Hack to remove the save_callback function from TinyMCE
- // save_callback strips the current site URL from any href/src it finds
- case 'tinymce':
- $data['custom'] = str_replace('save_callback : "TinyMCE_Save",', '', $head['custom']);
- break;
-
- // Hack to automatically set relative_urls and remove_script_host to false from JCE
- case 'jce':
- if (strpos($head['script']['text/javascript'], 'relative_urls: false,') === false && strpos($head['script']['text/javascript'], 'remove_script_host: false,') === false)
- {
- preg_match('#inlinepopups_skin: "(\w+)",#i', $head['script']['text/javascript'], $matches);
- $head['script']['text/javascript'] = str_replace($matches[0], $matches[0]."\r\n\t\t\t".'relative_urls: false,'."\r\n\t\t\t".'remove_script_host: false,', $head['script']['text/javascript']);
- $data['script'] = $head['script'];
- }
- break;
- }
-
- if (!empty($data))
- $doc->setHeadData($data);
- }
- }
- else
- {
- $id = trim(substr($name, 4), '][');
- $content = $editor->display($name, $content , $width, $height, $col, $row, true, $id, null, null, $params);
- }
-
- return $content;
- }
-
- function getValidationRules()
- {
- require_once JPATH_SITE.DS.'components'.DS.'com_rsform'.DS.'helpers'.DS.'validation.php';
- $results = get_class_methods('RSFormProValidations');
- return implode("\n",$results);
- }
-
- function readConfig($force=false)
- {
- static $rsformpro_config;
-
- if (!is_object($rsformpro_config) || $force)
- {
- $rsformpro_config = new stdClass();
-
- $db =& JFactory::getDBO();
- $db->setQuery("SELECT * FROM `#__rsform_config`");
- $config = $db->loadObjectList();
- if (!empty($config))
- foreach ($config as $config_item)
- $rsformpro_config->{$config_item->SettingName} = $config_item->SettingValue;
- }
-
- return $rsformpro_config;
- }
-
- function getConfig($name = null)
- {
- $config = RSFormProHelper::readConfig();
- if ($name != null)
- {
- if (isset($config->$name))
- return $config->$name;
- else
- return false;
- }
- else
- return $config;
- }
-
- function genKeyCode()
- {
- $code = RSFormProHelper::getConfig('global.register.code');
- return md5($code._RSFORM_KEY);
- }
-
- function componentNameExists($componentName, $formId, $currentComponentId=0)
- {
- $db = JFactory::getDBO();
-
- if ($componentName == 'formId')
- return true;
-
- $componentName = $db->getEscaped($componentName);
- $formId = (int) $formId;
- $currentComponentId = (int) $currentComponentId;
-
- $query = "SELECT c.ComponentId FROM #__rsform_properties p LEFT JOIN #__rsform_components c ON (p.ComponentId = c.ComponentId)";
- $query .= "WHERE c.FormId='".$formId."' AND p.PropertyName='NAME' AND p.PropertyValue='".$componentName."'";
- if ($currentComponentId)
- $query .= " AND c.ComponentId != '".$currentComponentId."'";
-
- $db->setQuery($query);
- $exists = $db->loadResult();
-
- return $exists;
- }
-
- function copyComponent($sourceComponentId, $toFormId)
- {
- $sourceComponentId = (int) $sourceComponentId;
- $toFormId = (int) $toFormId;
- $db = JFactory::getDBO();
-
- $db->setQuery("SELECT * FROM #__rsform_components WHERE ComponentId='".$sourceComponentId."'");
- $component = $db->loadObject();
- if (!$component)
- return false;
-
- //get max ordering
- $db->setQuery("SELECT MAX(`Order`)+1 FROM #__rsform_components WHERE FormId = '".$toFormId."'");
- $component->Order = $db->loadResult();
-
- $db->setQuery("INSERT INTO #__rsform_components SET `FormId`='".$toFormId."', `ComponentTypeId`='".$component->ComponentTypeId."', `Order`='".$component->Order."',`Published`='".$component->Published."'");
- $db->query();
- $newComponentId = $db->insertid();
-
- $db->setQuery("SELECT * FROM #__rsform_properties WHERE ComponentId='".$sourceComponentId."'");
- $properties = $db->loadObjectList();
-
- foreach ($properties as $property)
- {
- if ($property->PropertyName == 'NAME' && $toFormId == $component->FormId)
- {
- $property->PropertyValue .= ' copy';
-
- while (RSFormProHelper::componentNameExists($property->PropertyValue, $toFormId))
- $property->PropertyValue .= mt_rand(0,9);
- }
-
- $db->setQuery("INSERT INTO #__rsform_properties SET ComponentId='".$newComponentId."', PropertyName='".$db->getEscaped($property->PropertyName)."', PropertyValue='".$db->getEscaped($property->PropertyValue)."'");
- $db->query();
- }
-
- // copy language
- $db->setQuery("SELECT * FROM #__rsform_translations WHERE `reference`='properties' AND `reference_id` LIKE '".$sourceComponentId.".%'");
- $translations = $db->loadObjectList();
- foreach ($translations as $translation)
- {
- $reference_id = $newComponentId.'.'.end(explode('.', $translation->reference_id, 2));
-
- $db->setQuery("INSERT INTO #__rsform_translations SET `form_id`='".$toFormId."', `lang_code`='".$db->getEscaped($translation->lang_code)."', `reference`='properties', `reference_id`='".$db->getEscaped($reference_id)."', `value`='".$db->getEscaped($translation->value)."'");
- $db->query();
- }
-
- return $newComponentId;
- }
-
- function getCurrentLanguage($formId=null)
- {
- $mainframe =& JFactory::getApplication();
- $lang = JFactory::getLanguage();
-
- $session =& JFactory::getSession();
- $formId = !$formId ? JRequest::getInt('formId') || JRequest::getInt('FormId') : $formId;
-
- // editing in backend ?
- if ($mainframe->isAdmin())
- {
- if (JRequest::getVar('task') == 'submissions.edit')
- {
- $cid = JRequest::getVar('cid', array());
- if (is_array($cid))
- $cid = (int) @$cid[0];
-
- $db =& JFactory::getDBO();
- $db->setQuery("SELECT `Lang` FROM #__rsform_submissions WHERE SubmissionId='".$cid."'");
- $language = $db->loadResult();
-
- return $language;
- }
-
- return $session->get('com_rsform.form.'.$formId.'.lang', $lang->getTag());
- }
- // frontend
- else
- {
- return $lang->getTag();
- }
- }
-
- function getComponentProperties($components)
- {
- $db = JFactory::getDBO();
-
- if (is_numeric($components))
- {
- $componentId = (int) $components;
-
- //load component properties
- $db->setQuery("SELECT `PropertyName`, `PropertyValue` FROM #__rsform_properties WHERE `ComponentId`='".$componentId."'");
- $properties = $db->loadObjectList();
-
- //set up data array with component properties
- $data = array();
- foreach($properties as $property)
- $data[$property->PropertyName] = $property->PropertyValue;
- $data['componentId'] = $componentId;
-
- unset($properties);
-
- $db->setQuery("SELECT FormId FROM #__rsform_components WHERE ComponentId='".$componentId."'");
- $formId = $db->loadResult();
-
- // language
- $lang = RSFormProHelper::getCurrentLanguage($formId);
- $translations = RSFormProHelper::getTranslations('properties', $formId, $lang);
- foreach ($data as $property => $value)
- {
- $reference_id = $componentId.'.'.$property;
- if (isset($translations[$reference_id]))
- $data[$property] = $translations[$reference_id];
- }
-
- return $data;
- }
- elseif (is_array($components))
- {
- $componentIds = array();
- foreach ($components as $componentId)
- {
- if (is_object($componentId) && !empty($componentId->ComponentId))
- $componentIds[] = (int) $componentId->ComponentId;
- elseif (is_array($componentId) && !empty($componentId['ComponentId']))
- $componentIds[] = (int) $componentId['ComponentId'];
- else
- $componentIds[] = (int) $componentId;
- }
- if (!empty($componentIds))
- {
- $db->setQuery("SELECT `PropertyName`, `PropertyValue`, `ComponentId` FROM #__rsform_properties WHERE `ComponentId` IN (".implode(',', $componentIds).")");
- $results = $db->loadObjectList();
-
- $all_data = array();
- foreach ($results as $result)
- $all_data[$result->ComponentId][$result->PropertyName] = $result->PropertyValue;
-
- foreach ($all_data as $componentId => $properties)
- $all_data[$componentId]['componentId'] = $componentId;
-
- $db->setQuery("SELECT FormId FROM #__rsform_components WHERE ComponentId='".$componentIds[0]."'");
- $formId = $db->loadResult();
-
- // language
- $lang = RSFormProHelper::getCurrentLanguage($formId);
- $translations = RSFormProHelper::getTranslations('properties', $formId, $lang);
- foreach ($all_data as $componentId => $properties)
- {
- foreach ($properties as $property => $value)
- {
- $reference_id = $componentId.'.'.$property;
- if (isset($translations[$reference_id]))
- $properties[$property] = $translations[$reference_id];
- }
- $all_data[$componentId] = $properties;
- }
-
- return $all_data;
- }
- }
-
- return false;
- }
-
- function isCode($value)
- {
- $RSadapter = RSFormProHelper::getLegacyAdapter();
-
- if (strpos($value, '<code>') !== false)
- return eval($value);
-
- return $value;
- }
-
- function showPreview($formId, $componentId, $data)
- {
- $mainframe =& JFactory::getApplication();
-
- $formId = (int) $formId;
- $componentId = (int) $componentId;
-
- // Legacy
- $r = array();
- $r['ComponentTypeName'] = $data['ComponentTypeName'];
-
- $out ='';
-
- //Trigger Event - rsfp_bk_onBeforeCreateComponentPreview
- $mainframe->triggerEvent('rsfp_bk_onBeforeCreateComponentPreview',array(array('out'=>&$out,'formId'=>$formId,'componentId'=>$componentId,'ComponentTypeName'=>$r['ComponentTypeName'],'data'=>$data)));
-
- static $passedPageBreak;
-
- switch($r['ComponentTypeName'])
- {
- case 'textBox':
- {
- $defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
-
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td><input type="text" value="'.RSFormProHelper::htmlEscape($defaultValue).'" size="'.$data['SIZE'].'" /></td>';
- }
- break;
-
- case 'textArea':
- {
- $defaultValue = RSFormProHelper::isCode($data['DEFAULTVALUE']);
-
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td><textarea cols="'.$data['COLS'].'" rows="'.$data['ROWS'].'">'.RSFormProHelper::htmlEscape($defaultValue).'</textarea></td>';
- }
- break;
-
- case 'selectList':
- {
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td><select '.($data['MULTIPLE']=='YES' ? 'multiple="multiple"' : '').' size="'.$data['SIZE'].'">';
-
- $items = RSFormProHelper::isCode($data['ITEMS']);
- $items = str_replace(array("\r\n", "\r"), "\n", $items);
- $items = explode("\n",$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)
- $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></td>';
- }
- break;
-
- case 'checkboxGroup':
- {
- $i=0;
-
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td>';
-
- $items = RSFormProHelper::isCode($data['ITEMS']);
- $items = str_replace(array("\r\n", "\r"), "\n", $items);
- $items = explode("\n",$items);
-
- $special = array('[c]', '[d]');
-
- foreach ($items as $item)
- {
- @list($val, $txt) = @explode('|', str_replace($special, '', $item), 2);
- if (is_null($txt))
- $txt = $val;
-
- $additional = '';
- // checked
- if (strpos($item, '[c]') !== false)
- $additional .= 'checked="checked"';
- // disabled
- if (strpos($item, '[d]') !== false)
- $additional .= 'disabled="disabled"';
-
- $out.='<input type="checkbox" '.$additional.' value="'.RSFormProHelper::htmlEscape($val).'" id="'.$data['NAME'].$i.'"/><label for="'.$data['NAME'].$i.'">'.$txt.'</label>';
- if($data['FLOW']=='VERTICAL') $out.='<br/>';
- $i++;
- }
- $out.='</td>';
-
- }
- break;
-
- case 'radioGroup':
- {
- $i=0;
-
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td>';
-
- $items = RSFormProHelper::isCode($data['ITEMS']);
- $items = str_replace(array("\r\n", "\r"), "\n", $items);
- $items = explode("\n",$items);
-
- $special = array('[c]', '[d]');
-
- foreach ($items as $item)
- {
- @list($val, $txt) = @explode('|', str_replace($special, '', $item), 2);
- if (is_null($txt))
- $txt = $val;
-
- $additional = '';
- // checked
- if (strpos($item, '[c]') !== false)
- $additional .= 'checked="checked"';
- // disabled
- if (strpos($item, '[d]') !== false)
- $additional .= 'disabled="disabled"';
-
- $out.='<input type="radio" '.$additional.' value="'.RSFormProHelper::htmlEscape($val).'" id="'.$data['NAME'].$i.'"/><label for="'.$data['NAME'].$i.'">'.$txt.'</label>';
- if ($data['FLOW']=='VERTICAL') $out.='<br/>';
- $i++;
- }
- $out.='</td>';
-
- }
- break;
-
- case 'calendar':
- {
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td><img src="'.JURI::root(true).'/administrator/components/com_rsform/assets/images/icons/calendar.png" /> '.JText::_('RSFP_COMP_FVALUE_'.$data['CALENDARLAYOUT']).'</td>';
- }
- break;
-
- case 'captcha':
- {
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td>';
- switch (@$data['IMAGETYPE'])
- {
- default:
- case 'FREETYPE':
- case 'NOFREETYPE':
- $out.='<img src="index.php?option=com_rsform&task=captcha&componentId='.$componentId.'&tmpl=component&sid='.mt_rand().'" id="captcha'.$componentId.'" alt="'.$data['CAPTION'].'"/>';
- $out.=($data['FLOW']=='HORIZONTAL') ? '':'<br/>';
- $out.='<input type="text" value="" id="captchaTxt'.$componentId.'" '.$data['ADDITIONALATTRIBUTES'].' />';
- $out.=($data['SHOWREFRESH']=='YES') ? ' <a href="" onclick="refreshCaptcha('.$componentId.',\'index.php?option=com_rsform&task=captcha&componentId='.$componentId.'&tmpl=component\'); return false;">'.$data['REFRESHTEXT'].'</a>':'';
- break;
-
- case 'INVISIBLE':
- $out.='{hidden captcha}';
- break;
- }
- $out.='</td>';
- }
- break;
-
- case 'fileUpload':
- {
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td><input type="file" /></td>';
- }
- break;
-
- case 'freeText':
- {
- $out.='<td> </td>';
- $out.='<td>'.$data['TEXT'].'</td>';
- }
- break;
-
- case 'hidden':
- {
- $out.='<td> </td>';
- $out.='<td>{hidden field}</td>';
- }
- break;
-
- case 'imageButton':
- {
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td>';
- $out.='<input type="image" src="'.RSFormProHelper::htmlEscape($data['IMAGEBUTTON']).'"/>';
- if($data['RESET']=='YES')
- $out.=' <input type="image" src="'.RSFormProHelper::htmlEscape($data['IMAGERESET']).'"/>';
- $out.='</td>';
- }
- break;
-
- case 'button':
- case 'submitButton':
- {
- $out.='<td>'.$data['CAPTION'].'</td>';
-
- if (isset($data['BUTTONTYPE']) && $data['BUTTONTYPE'] == 'TYPEBUTTON')
- $out.='<td><button type="button">'.RSFormProHelper::htmlEscape($data['LABEL']).'</button>';
- else
- $out.='<td><input type="button" value="'.RSFormProHelper::htmlEscape($data['LABEL']).'" />';
-
- if($data['RESET']=='YES')
- {
- if (isset($data['BUTTONTYPE']) && $data['BUTTONTYPE'] == 'TYPEBUTTON')
- $out.=' <button type="reset">'.RSFormProHelper::htmlEscape($data['RESETLABEL']).'</button>';
- else
- $out.=' <input type="reset" value="'.RSFormProHelper::htmlEscape($data['RESETLABEL']).'"/>';
- }
- $out.='</td>';
- }
- break;
-
- case 'password':
- {
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td><input type="password" value="'.RSFormProHelper::htmlEscape($data['DEFAULTVALUE']).'" size="'.$data['SIZE'].'"/></td>';
- }
- break;
-
- case 'ticket':
- {
- $out.='<td> </td>';
- $out.='<td>'.RSFormProHelper::generateString($data['LENGTH'],$data['CHARACTERS']).'</td>';
- }
- break;
-
- case 'pageBreak':
- $out.='<td> </td>';
- $out.='<td>'.($passedPageBreak ? '<input type="button" value="'.RSFormProHelper::htmlEscape($data['PREVBUTTON']).'" />' : '').' <input type="button" value="'.RSFormProHelper::htmlEscape($data['NEXTBUTTON']).'" /></td>';
- $passedPageBreak = true;
- break;
-
- case 'rseprotickets':
- $out.='<td>'.$data['CAPTION'].'</td>';
- $out.='<td>'.JText::_('RSFP_RSEVENTSPRO_TICKETS').'</td>';
- break;
-
- default:
- $out = '<td colspan="2" style="color:#333333"><em>'.JText::_('RSFP_COMP_PREVIEW_NOT_AVAILABLE').'</em></td>';
- break;
- }
-
- //Trigger Event - rsfp_bk_onAfterCreateComponentPreview
- $mainframe->triggerEvent('rsfp_bk_onAfterCreateComponentPreview',array(array('out'=>&$out, 'formId'=>$formId, 'componentId'=>$componentId, 'ComponentTypeName'=>$r['ComponentTypeName'],'data'=>$data)));
-
- return $out;
- }
-
- function htmlEscape($val)
- {
- return htmlentities($val, ENT_COMPAT, 'UTF-8');
- }
-
- function explode($value)
- {
- $value = str_replace(array("\r\n", "\r"), "\n", $value);
- $value = explode("\n", $value);
-
- return $value;
- }
-
- function readFile($file, $download_name=null)
- {
- if (empty($download_name))
- $download_name = basename($file);
-
- $fsize = filesize($file);
-
- header("Cache-Control: public, must-revalidate");
- header('Cache-Control: pre-check=0, post-check=0, max-age=0');
- if (!preg_match('#MSIE#', $_SERVER['HTTP_USER_AGENT']))
- header("Pragma: no-cache");
- header("Expires: 0");
- header("Content-Description: File Transfer");
- header("Expires: Sat, 01 Jan 2000 01:00:00 GMT");
- if (preg_match('#Opera#', $_SERVER['HTTP_USER_AGENT']))
- header("Content-Type: application/octetstream");
- else
- header("Content-Type: application/octet-stream");
- header("Content-Length: ".(string) ($fsize));
- header('Content-Disposition: attachment; filename="'.$download_name.'"');
- header("Content-Transfer-Encoding: binary\n");
- ob_end_flush();
- RSFormProHelper::readFileChunked($file);
- exit();
- }
-
- function readFileChunked($filename, $retbytes=true)
- {
- $chunksize = 1*(1024*1024); // how many bytes per chunk
- $buffer = '';
- $cnt =0;
- $handle = fopen($filename, 'rb');
- if ($handle === false) {
- return false;
- }
- while (!feof($handle)) {
- $buffer = fread($handle, $chunksize);
- echo $buffer;
- if ($retbytes) {
- $cnt += strlen($buffer);
- }
- }
- $status = fclose($handle);
- if ($retbytes && $status) {
- return $cnt; // return num. bytes delivered like readfile() does.
- }
- return $status;
- }
-
- function getReplacements($SubmissionId, $skip_globals=false)
- {
- // Small hack
- return RSFormProHelper::sendSubmissionEmails($SubmissionId, true, $skip_globals);
- }
-
- function sendSubmissionEmails($SubmissionId, $only_return_replacements=false, $skip_globals=false)
- {
- $db = JFactory::getDBO();
- $u = JFactory::getURI();
- $config = JFactory::getConfig();
- $SubmissionId = (int) $SubmissionId;
- $mainframe =& JFactory::getApplication();
- $Itemid = JRequest::getInt('Itemid');
- $Itemid = $Itemid ? '&Itemid='.$Itemid : '';
-
- $db->setQuery("SELECT * FROM #__rsform_submissions WHERE SubmissionId='".$SubmissionId."'");
- $submission = $db->loadObject();
-
- $submission->values = array();
- $db->setQuery("SELECT FieldName, FieldValue FROM #__rsform_submission_values WHERE SubmissionId='".$SubmissionId."'");
- $fields = $db->loadObjectList();
- foreach ($fields as $field)
- $submission->values[$field->FieldName] = $field->FieldValue;
- unset($fields);
-
- $formId = $submission->FormId;
- $db->setQuery("SELECT * FROM #__rsform_forms WHERE FormId='".$formId."'");
- $form = $db->loadObject();
- $form->MultipleSeparator = str_replace(array('\n', '\r', '\t'), array("\n", "\r", "\t"), $form->MultipleSeparator);
-
- if (empty($submission->Lang))
- {
- if (!empty($form->Lang))
- $submission->Lang = $form->Lang;
- else
- {
- $lang =& JFactory::getLanguage();
- $language = $lang->getDefault();
- $submission->Lang = $language;
- }
- $db->setQuery("UPDATE #__rsform_submissions SET Lang='".$db->getEscaped($submission->Lang)."' WHERE SubmissionId='".$submission->SubmissionId."'");
- $db->query();
- }
-
- $translations = RSFormProHelper::getTranslations('forms', $form->FormId, $submission->Lang);
- if ($translations)
- foreach ($translations as $field => $value)
- {
- if (isset($form->$field))
- $form->$field = $value;
- }
-
- $placeholders = array();
- $values = array();
-
- $db->setQuery("SELECT c.ComponentTypeId, p.ComponentId, p.PropertyName, p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId) WHERE c.FormId='".$formId."' AND c.Published='1' AND p.PropertyName IN ('NAME', 'CAPTION', 'EMAILATTACH', 'WYSIWYG', 'ITEMS')");
- $components = $db->loadObjectList();
- $properties = array();
- $uploadFields = array();
- $multipleFields = array();
- $textareaFields = array();
- $userEmailUploads = array();
- $adminEmailUploads = array();
- $additionalEmailUploads = array();
- $additionalEmailUploadsIds = array();
-
- foreach ($components as $component)
- {
- // Upload fields - grab by NAME so that we can use it later on when checking $_FILES
- if ($component->ComponentTypeId == 9)
- {
- if ($component->PropertyName == 'EMAILATTACH')
- {
- $emailsvalues = $component->PropertyValue;
- $emailsvalues = trim($emailsvalues) != '' ? explode(',',$emailsvalues) : array();
-
- if (!empty($emailsvalues))
- foreach ($emailsvalues as $emailvalue)
- {
- if ($emailvalue == 'useremail' || $emailvalue == 'adminemail') continue;
- $additionalEmailUploadsIds[] = $emailvalue;
- }
-
- $additionalEmailUploadsIds = array_unique($additionalEmailUploadsIds);
-
- if (!empty($additionalEmailUploadsIds))
- foreach ($additionalEmailUploadsIds as $additionalEmailUploadsId)
- {
- if (in_array($additionalEmailUploadsId,$emailsvalues))
- $additionalEmailUploads[$additionalEmailUploadsId][] = $component->ComponentId;
- }
- }
-
- if ($component->PropertyName == 'NAME')
- $uploadFields[] = $component->PropertyValue;
-
- if ($component->PropertyName == 'EMAILATTACH' && !empty($component->PropertyValue))
- {
- $emailvalues = explode(',',$component->PropertyValue);
-
- if (in_array('useremail',$emailvalues))
- {
- $userEmailUploads[] = $component->ComponentId;
- //continue;
- }
-
- if (in_array('adminemail',$emailvalues))
- {
- $adminEmailUploads[] = $component->ComponentId;
- //continue;
- }
- }
- }
- // Multiple fields - grab by ComponentId for performance
- elseif (in_array($component->ComponentTypeId, array(3, 4)))
- {
- if ($component->PropertyName == 'NAME')
- $multipleFields[] = $component->ComponentId;
- }
- // Textarea fields - grab by ComponentId for performance
- elseif ($component->ComponentTypeId == 2)
- {
- if ($component->PropertyName == 'WYSIWYG' && $component->PropertyValue == 'NO')
- $textareaFields[] = $component->ComponentId;
- }
-
- $properties[$component->ComponentId][$component->PropertyName] = $component->PropertyValue;
- }
-
- // language
- $translations = RSFormProHelper::getTranslations('properties', $formId, $submission->Lang);
- foreach ($properties as $componentId => $componentProperties)
- {
- foreach ($componentProperties as $property => $value)
- {
- $reference_id = $componentId.'.'.$property;
- if (isset($translations[$reference_id]))
- $componentProperties[$property] = $translations[$reference_id];
- }
- $properties[$componentId] = $componentProperties;
- }
-
- $secret = $config->getValue('config.secret');
- foreach ($properties as $ComponentId => $property)
- {
- // {component:caption}
- $placeholders[] = '{'.$property['NAME'].':caption}';
- $values[] = isset($property['CAPTION']) ? $property['CAPTION'] : '';
-
- // {component:name}
- $placeholders[] = '{'.$property['NAME'].':name}';
- $values[] = $property['NAME'];
-
- // {component:value}
- $placeholders[] = '{'.$property['NAME'].':value}';
- $value = '';
- if (isset($submission->values[$property['NAME']]))
- {
- $value = $submission->values[$property['NAME']];
-
- // Check if this is an upload field
- if (in_array($property['NAME'], $uploadFields))
- $value = '<a href="'.JURI::root().'index.php?option=com_rsform&task=submissions.view.file&hash='.md5($submission->SubmissionId.$secret.$property['NAME']).$Itemid.'">'.basename($submission->values[$property['NAME']]).'</a>';
- // Check if this is a multiple field
- elseif (in_array($ComponentId, $multipleFields))
- $value = str_replace("\n", $form->MultipleSeparator, $value);
- elseif ($form->TextareaNewLines && in_array($ComponentId, $textareaFields))
- $value = nl2br($value);
- }
- $values[] = $value;
-
- if (isset($property['ITEMS']) && isset($submission->values[$property['NAME']]))
- {
- $value = $submission->values[$property['NAME']];
- $placeholders[] = '{'.$property['NAME'].':text}';
- $items = RSFormProHelper::explode(RSFormProHelper::isCode($property['ITEMS']));
- foreach ($items as $item)
- {
- @list($item_val, $item_text) = explode("|", $item, 2);
- if ($item_text && $item_val == $value)
- {
- $value = $item_text;
- break;
- }
- }
- $values[] = $value;
- }
-
- // {component:path}
- if (in_array($property['NAME'], $uploadFields))
- {
- $placeholders[] = '{'.$property['NAME'].':path}';
- if (isset($submission->values[$property['NAME']]))
- {
- $filepath = $submission->values[$property['NAME']];
- $filepath = str_replace(JPATH_SITE.DS, JURI::root(), $filepath);
- $filepath = str_replace(array('\\', '\\/', '//\\'), '/', $filepath);
- $values[] = $filepath;
- }
- else
- $values[] = '';
- }
- }
- $placeholders[] = '{_STATUS:value}';
- $values[] = isset($submission->values['_STATUS']) ? JText::_('RSFP_PAYPAL_STATUS_'.$submission->values['_STATUS']) : '';
-
- $placeholders[] = '{_ANZ_STATUS:value}';
- $values[] = isset($submission->values['_ANZ_STATUS']) ? JText::_('RSFP_ANZ_STATUS_'.$submission->values['_ANZ_STATUS']) : '';
-
- $user = JFactory::getUser($submission->UserId);
- if (empty($user->id))
- $user = JFactory::getUser(0);
-
- $root = $mainframe->isAdmin() ? JURI::root() : $u->toString(array('scheme','host', 'port'));
- $confirmation_hash = md5($submission->SubmissionId.$formId.$submission->DateSubmitted);
- $hash_link = 'index.php?option=com_rsform&task=confirm&hash='.$confirmation_hash;
- $confirmation = $root.($mainframe->isAdmin() ? $hash_link : JRoute::_($hash_link));
-
- if (!$skip_globals)
- {
- array_push($placeholders, '{global:username}', '{global:userid}', '{global:useremail}', '{global:fullname}', '{global:userip}', '{global:date_added}', '{global:sitename}', '{global:siteurl}','{global:confirmation}','{global:submissionid}', '{global:submission_id}');
- array_push($values, $user->username, $user->id, $user->email, $user->name, isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', $submission->DateSubmitted, $config->getValue('config.sitename'), JURI::root(),$confirmation, $submission->SubmissionId, $submission->SubmissionId);
- }
-
- $mainframe->triggerEvent('rsfp_onAfterCreatePlaceholders', array(array('form' => &$form, 'placeholders' => &$placeholders, 'values' => &$values, 'submission' => $submission)));
-
- if ($only_return_replacements)
- return array($placeholders, $values);
-
- $userEmail = array(
- 'to' => str_replace($placeholders, $values, $form->UserEmailTo),
- 'cc' => str_replace($placeholders, $values, $form->UserEmailCC),
- 'bcc' => str_replace($placeholders, $values, $form->UserEmailBCC),
- 'from' => str_replace($placeholders, $values, $form->UserEmailFrom),
- 'replyto' => str_replace($placeholders, $values, $form->UserEmailReplyTo),
- 'fromName' => str_replace($placeholders, $values, $form->UserEmailFromName),
- 'text' => str_replace($placeholders, $values, $form->UserEmailText),
- 'subject' => str_replace($placeholders, $values, $form->UserEmailSubject),
- 'mode' => $form->UserEmailMode,
- 'files' => array()
- );
-
- // user cc
- if (strpos($userEmail['cc'], ',') !== false)
- $userEmail['cc'] = explode(',', $userEmail['cc']);
- // user bcc
- if (strpos($userEmail['bcc'], ',') !== false)
- $userEmail['bcc'] = explode(',', $userEmail['bcc']);
-
- jimport('joomla.filesystem.file');
-
- $file = str_replace($placeholders, $values, $form->UserEmailAttachFile);
- if ($form->UserEmailAttach && JFile::exists($file))
- $userEmail['files'][] = $file;
-
- // Need to attach files
- // User Email
- foreach ($userEmailUploads as $componentId)
- {
- $name = $properties[$componentId]['NAME'];
- if (!empty($submission->values[$name]))
- $userEmail['files'][] = $submission->values[$name];
- }
-
- $adminEmail = array(
- 'to' => str_replace($placeholders, $values, $form->AdminEmailTo),
- 'cc' => str_replace($placeholders, $values, $form->AdminEmailCC),
- 'bcc' => str_replace($placeholders, $values, $form->AdminEmailBCC),
- 'from' => str_replace($placeholders, $values, $form->AdminEmailFrom),
- 'replyto' => str_replace($placeholders, $values, $form->AdminEmailReplyTo),
- 'fromName' => str_replace($placeholders, $values, $form->AdminEmailFromName),
- 'text' => str_replace($placeholders, $values, $form->AdminEmailText),
- 'subject' => str_replace($placeholders, $values, $form->AdminEmailSubject),
- 'mode' => $form->AdminEmailMode,
- 'files' => array()
- );
-
- // admin cc
- if (strpos($adminEmail['cc'], ',') !== false)
- $adminEmail['cc'] = explode(',', $adminEmail['cc']);
- // admin bcc
- if (strpos($adminEmail['bcc'], ',') !== false)
- $adminEmail['bcc'] = explode(',', $adminEmail['bcc']);
-
- // Admin Email
- foreach ($adminEmailUploads as $componentId)
- {
- $name = $properties[$componentId]['NAME'];
- if (!empty($submission->values[$name]))
- $adminEmail['files'][] = $submission->values[$name];
- }
-
- $mainframe->triggerEvent('rsfp_beforeUserEmail', array(array('form' => &$form, 'placeholders' => &$placeholders, 'values' => &$values, 'submissionId' => $SubmissionId, 'userEmail'=>&$userEmail)));
-
- // Script called before the User Email is sent.
- eval($form->UserEmailScript);
-
- // mail users
- $recipients = explode(',',$userEmail['to']);
- if(!empty($recipients))
- foreach($recipients as $recipient)
- if(!empty($recipient))
- RSFormProHelper::sendMail($userEmail['from'], $userEmail['fromName'], $recipient, $userEmail['subject'], $userEmail['text'], $userEmail['mode'], !empty($userEmail['cc']) ? $userEmail['cc'] : null, !empty($userEmail['bcc']) ? $userEmail['bcc'] : null, $userEmail['files'], !empty($userEmail['replyto']) ? $userEmail['replyto'] : '');
-
- $mainframe->triggerEvent('rsfp_beforeAdminEmail', array(array('form' => &$form, 'placeholders' => &$placeholders, 'values' => &$values, 'submissionId' => $SubmissionId, 'adminEmail'=>&$adminEmail)));
-
- // Script called before the Admin Email is sent.
- eval($form->AdminEmailScript);
-
- //mail admins
- $recipients = explode(',',$adminEmail['to']);
- if(!empty($recipients))
- foreach($recipients as $recipient)
- if(!empty($recipient))
- RSFormProHelper::sendMail($adminEmail['from'], $adminEmail['fromName'], $recipient, $adminEmail['subject'], $adminEmail['text'], $adminEmail['mode'], !empty($adminEmail['cc']) ? $adminEmail['cc'] : null, !empty($adminEmail['bcc']) ? $adminEmail['bcc'] : null, $adminEmail['files'], !empty($adminEmail['replyto']) ? $adminEmail['replyto'] : '');
-
-
- //additional emails
- $db->setQuery("SELECT * FROM #__rsform_emails WHERE formId = ".$formId." ");
- $emails = $db->loadObjectList();
- $etranslations = RSFormProHelper::getTranslations('emails', $formId, $submission->Lang);
-
- if (!empty($emails))
- foreach ($emails as $email)
- {
- if (empty($email->from) || empty($email->fromname) || empty($email->subject) || empty($email->message)) continue;
- $fromname = isset($etranslations[$email->id.'.fromname']) ? $etranslations[$email->id.'.fromname'] : $email->fromname;
- $subject = isset($etranslations[$email->id.'.subject']) ? $etranslations[$email->id.'.subject'] : $email->subject;
- $message = isset($etranslations[$email->id.'.message']) ? $etranslations[$email->id.'.message'] : $email->message;
-
- $additionalEmail = array(
- 'to' => str_replace($placeholders, $values, $email->to),
- 'cc' => str_replace($placeholders, $values, $email->cc),
- 'bcc' => str_replace($placeholders, $values, $email->bcc),
- 'from' => str_replace($placeholders, $values, $email->from),
- 'replyto' => str_replace($placeholders, $values, $email->replyto),
- 'fromName' => str_replace($placeholders, $values, $fromname),
- 'text' => str_replace($placeholders, $values, $message),
- 'subject' => str_replace($placeholders, $values, $subject),
- 'mode' => $email->mode,
- 'files' => array()
- );
-
- if (!empty($additionalEmailUploads))
- foreach ($additionalEmailUploads as $additionalEmailId => $additionalEmailUpload)
- {
- if ($additionalEmailId == $email->id)
- foreach ($additionalEmailUpload as $componentId)
- {
- $name = $properties[$componentId]['NAME'];
- if (!empty($submission->values[$name]))
- $additionalEmail['files'][] = $submission->values[$name];
- }
- }
-
- // additional cc
- if (strpos($additionalEmail['cc'], ',') !== false)
- $additionalEmail['cc'] = explode(',', $additionalEmail['cc']);
- // additional bcc
- if (strpos($additionalEmail['bcc'], ',') !== false)
- $additionalEmail['bcc'] = explode(',', $additionalEmail['bcc']);
-
- $mainframe->triggerEvent('rsfp_beforeAdditionalEmail', array(array('form' => &$form, 'placeholders' => &$placeholders, 'values' => &$values, 'submissionId' => $SubmissionId, 'additionalEmail'=>&$additionalEmail)));
- eval($form->AdditionalEmailsScript);
-
- // mail users
- $recipients = explode(',',$additionalEmail['to']);
- if(!empty($recipients))
- foreach($recipients as $recipient)
- if(!empty($recipient))
- RSFormProHelper::sendMail($additionalEmail['from'], $additionalEmail['fromName'], $recipient, $additionalEmail['subject'], $additionalEmail['text'], $additionalEmail['mode'], !empty($additionalEmail['cc']) ? $additionalEmail['cc'] : null, !empty($additionalEmail['bcc']) ? $additionalEmail['bcc'] : null, $additionalEmail['files'], !empty($additionalEmail['replyto']) ? $additionalEmail['replyto'] : '');
-
- }
-
- return array($placeholders, $values);
- }
-
- function escapeArray(&$val, &$key)
- {
- $db = JFactory::getDBO();
- $val = $db->getEscaped($val);
- $key = $db->getEscaped($key);
- }
-
- function componentExists($formId, $componentTypeId)
- {
- $formId = (int) $formId;
- $db = JFactory::getDBO();
-
- if (is_array($componentTypeId))
- {
- JArrayHelper::toInteger($componentTypeId);
- $db->setQuery("SELECT ComponentId FROM #__rsform_components WHERE ComponentTypeId IN (".implode(',', $componentTypeId).") AND FormId='".$formId."' AND Published='1'");
- }
- else
- {
- $componentTypeId = (int) $componentTypeId;
- $db->setQuery("SELECT ComponentId FROM #__rsform_components WHERE ComponentTypeId='".$componentTypeId."' AND FormId='".$formId."' AND Published='1'");
- }
-
- return $db->loadResultArray();
- }
-
- function cleanCache()
- {
- jimport('joomla.html.parameter');
-
- $config = JFactory::getConfig();
- $plugin = JPluginHelper::getPlugin('system', 'cache');
-
- $params = new JParameter($plugin->params);
- $options = array(
- 'cachebase' => JPATH_BASE.DS.'cache',
- 'defaultgroup' => 'page',
- 'lifetime' => $params->get('cachetime', 15) * 60,
- 'browsercache' => $params->get('browsercache', false),
- 'caching' => false,
- 'language' => $config->getValue('config.language', 'en-GB')
- );
- $cache =& JCache::getInstance('page', $options);
-
- if (!RSFormProHelper::isJ16())
- $id = $cache->_makeId();
- else
- $id = $cache->makeId();
-
- $handler =& $cache->_getStorage();
- if (!JError::isError($handler))
- $handler->remove($id, 'page');
-
- // Test this
- // $cache->clean();
- }
-
- function loadTheme($form)
- {
- jimport('joomla.html.parameter');
-
- $doc =& JFactory::getDocument();
- $form->ThemeParams = new JParameter($form->ThemeParams);
-
- if ($form->ThemeParams->get('num_css', 0) > 0)
- for ($i=0; $i<$form->ThemeParams->get('num_css'); $i++)
- {
- $css = $form->ThemeParams->get('css'.$i);
- $doc->addStyleSheet(JURI::root(true).'/components/com_rsform/assets/themes/'.$form->ThemeParams->get('name').'/'.$css);
- }
- if ($form->ThemeParams->get('num_js', 0) > 0)
- for ($i=0; $i<$form->ThemeParams->get('num_js'); $i++)
- {
- $js = $form->ThemeParams->get('js'.$i);
- $doc->addScript(JURI::root(true).'/components/com_rsform/assets/themes/'.$form->ThemeParams->get('name').'/'.$js);
- }
- }
-
- // conditions
- function getConditions($formId, $lang=null)
- {
- $db =& JFactory::getDBO();
-
- if (!$lang)
- $lang = RSFormProHelper::getCurrentLanguage();
-
- // get all conditions
- $db->setQuery("SELECT c.*,p.PropertyValue AS ComponentName FROM `#__rsform_conditions` c LEFT JOIN #__rsform_properties p ON (c.component_id = p.ComponentId) LEFT JOIN #__rsform_components comp ON (comp.ComponentId=p.ComponentId) WHERE c.`form_id` = ".$formId." AND c.lang_code='".$db->getEscaped($lang)."' AND comp.Published = 1 AND p.PropertyName='NAME' ORDER BY c.`id` ASC");
- if ($conditions = $db->loadObjectList())
- {
- // put them all in an array so we can use only one query
- $cids = array();
- foreach ($conditions as $condition)
- $cids[] = $condition->id;
-
- // get details
- $db->setQuery("SELECT d.*,p.PropertyValue AS ComponentName FROM #__rsform_condition_details d LEFT JOIN #__rsform_properties p ON (d.component_id = p.ComponentId) LEFT JOIN #__rsform_components comp ON (comp.ComponentId=p.ComponentId) WHERE d.condition_id IN (".implode(",", $cids).") AND comp.Published = 1 AND p.PropertyName='NAME'");
- $details = $db->loadObjectList();
-
- // arrange details within conditions
- foreach ($conditions as $i => $condition)
- {
- $condition->details = array();
- foreach ($details as $detail)
- {
- if ($detail->condition_id != $condition->id) continue;
- $condition->details[] = $detail;
- }
-
- $conditions[$i] = $condition;
- }
- // all done
- return $conditions;
- }
- // nothing found
- return false;
- }
-
- function showForm($formId, $val='', $validation=array())
- {
- $mainframe =& JFactory::getApplication();
-
- $formId = (int) $formId;
-
- $db = JFactory::getDBO();
- $doc =& JFactory::getDocument();
-
- $db->setQuery("SELECT `FormId`, `FormLayoutName`, `FormLayout`, `ScriptDisplay`, `ErrorMessage`, `FormTitle`, `CSS`, `JS`, `CSSClass`, `CSSId`, `CSSName`, `CSSAction`, `CSSAdditionalAttributes`, `AjaxValidation`, `ThemeParams` FROM #__rsform_forms WHERE FormId='".$formId."' AND `Published`='1'");
- $form = $db->loadObject();
-
- $lang = RSFormProHelper::getCurrentLanguage();
- $translations = RSFormProHelper::getTranslations('forms', $form->FormId, $lang);
- if ($translations)
- foreach ($translations as $field => $value)
- {
- if (isset($form->$field))
- $form->$field = $value;
- }
-
- if ($form->JS)
- $doc->addCustomTag($form->JS);
- if ($form->CSS)
- $doc->addCustomTag($form->CSS);
- if ($form->ThemeParams)
- RSFormProHelper::loadTheme($form);
-
- $doc->addStyleSheet(JURI::root(true).'/components/com_rsform/assets/css/front.css');
- if ($doc->getDirection() == 'rtl')
- $doc->addStyleSheet(JURI::root(true).'/components/com_rsform/assets/css/front-rtl.css');
- $doc->addScript(JURI::root(true).'/components/com_rsform/assets/js/script.js');
-
- $calendars = RSFormProHelper::componentExists($formId, 6); //6 is the componentTypeId for calendar
- if(!empty($calendars))
- {
- $doc->addStyleSheet(JURI::root(true).'/components/com_rsform/assets/calendar/calendar.css');
-
- $hidden = JRequest::getVar('hidden');
- $all_data = RSFormProHelper::getComponentProperties($calendars);
- foreach($calendars as $i => $calendarComponentId)
- {
- $data = $all_data[$calendarComponentId];
-
- $calendars['CALENDARLAYOUT'][$i] = $data['CALENDARLAYOUT'];
- $calendars['DATEFORMAT'][$i] = $data['DATEFORMAT'];
- $calendars['VALUES'][$i] = '';
- $calendars['EXTRA'][$i] = array();
- if (!empty($hidden[$data['NAME']]))
- $calendars['VALUES'][$i] = preg_replace('#[^0-9\/]+#i', '', $hidden[$data['NAME']]);
-
- if (!empty($data['MINDATE']))
- $calendars['EXTRA'][$i][] = "'mindate': '".$data['MINDATE']."'";
- if (!empty($data['MAXDATE']))
- $calendars['EXTRA'][$i][] = "'maxdate': '".$data['MAXDATE']."'";
-
- $calendars['EXTRA'][$i] = '{'.implode(', ', $calendars['EXTRA'][$i]).'}';
- }
- unset($all_data);
-
- $calendarsLayout = "'".implode("','", $calendars['CALENDARLAYOUT'])."'";
- $calendarsFormat = "'".implode("','", $calendars['DATEFORMAT'])."'";
- $calendarsValues = "'".implode("','", $calendars['VALUES'])."'";
- $calendarsExtra = implode(',', $calendars['EXTRA']);
- }
-
- $formLayout = $form->FormLayout;
- unset($form->FormLayout);
- $errorMessage = $form->ErrorMessage;
- unset($form->ErrorMessage);
-
- $db->setQuery("SELECT p.PropertyValue AS name, c.ComponentId, c.ComponentTypeId, ct.ComponentTypeName, c.Order FROM #__rsform_properties p LEFT JOIN #__rsform_components c ON (c.ComponentId=p.ComponentId) LEFT JOIN #__rsform_component_types ct ON (ct.ComponentTypeId=c.ComponentTypeId) WHERE c.FormId='".$formId."' AND p.PropertyName='NAME' AND c.Published='1' ORDER BY c.Order");
- $components = $db->loadObjectList();
-
- $pages = array();
- $page_progress = array();
- $submits = array();
- foreach ($component…
Large files files are truncated, but you can click here to view the full file