| Current Path : /home/chauffn/www/components/com_creativecontactform/helpers/ |
| Current File : /home/chauffn/www/components/com_creativecontactform/helpers/helper.php |
<?php
/**
* Joomla! component Creative Contact Form
*
* @version $Id: 2012-04-05 14:30:25 svn $
* @author creative-solutions.net
* @package Creative Contact Form
* @subpackage com_creativecontactform
* @license GNU/GPL
*
*/
// no direct access
defined('_JEXEC') or die('Restircted access');
class CreativecontactformHelper
{
//function to add scripts/styles
private function add_scripts() {
$version = '4.6.1';
$document = JFactory::getDocument();
$types_array = $this->types_array;
$form_id = $this->form_id;
$cssFile = JURI::base(true).'/components/com_creativecontactform/assets/css/main.css?version='.$version;
$document->addStyleSheet($cssFile, 'text/css', null, array());
$cssFile = JURI::base(true).'/components/com_creativecontactform/assets/css/creativecss-ui.css';
$document->addStyleSheet($cssFile, 'text/css', null, array());
$cssFile = JURI::base(true).'/components/com_creativecontactform/assets/css/creative-scroll.css';
$document->addStyleSheet($cssFile, 'text/css', null, array());
$cssFile = JURI::base(true).'/index.php?option=com_creativecontactform&view=creativestyles&format=raw&id_form='.$form_id.'&module_id=0';
$document->addStyleSheet($cssFile, 'text/css', null, array());
$cssFile = JURI::base(true).'/components/com_creativecontactform/assets/css/creative-tooltip.css';
$document->addStyleSheet($cssFile, 'text/css', null, array());
if(in_array('file-upload',$types_array)) {
$cssFile = JURI::base(true).'/components/com_creativecontactform/assets/css/creative-upload.css';
$document->addStyleSheet($cssFile, 'text/css', null, array());
}
if(in_array('datepicker',$types_array)) {
$cssFile = JURI::base(true).'/components/com_creativecontactform/assets/css/creative-datepicker.css';
$document->addStyleSheet($cssFile, 'text/css', null, array());
}
$jsFile = JURI::base(true).'/components/com_creativecontactform/assets/js/creativelib.js';
$document->addScript($jsFile);
$jsFile = JURI::base(true).'/components/com_creativecontactform/assets/js/creativelib-ui.js';
$document->addScript($jsFile);
$jsFile = JURI::base(true).'/components/com_creativecontactform/assets/js/creative-mousewheel.js';
$document->addScript($jsFile);
$jsFile = JURI::base(true).'/components/com_creativecontactform/assets/js/creative-scroll.js';
$document->addScript($jsFile);
if(in_array('file-upload',$types_array)) {
$jsFile = JURI::base(true).'/components/com_creativecontactform/assets/js/jquery.iframe-transport.js';
$document->addScript($jsFile);
$jsFile = JURI::base(true).'/components/com_creativecontactform/assets/js/jquery.fileupload.js';
$document->addScript($jsFile);
$jsFile = JURI::base(true).'/components/com_creativecontactform/assets/js/jquery.fileupload-process.js';
$document->addScript($jsFile);
$jsFile = JURI::base(true).'/components/com_creativecontactform/assets/js/jquery.fileupload-validate.js';
$document->addScript($jsFile);
}
$jsFile = JURI::base(true).'/components/com_creativecontactform/assets/js/creativecontactform.js?version='.$version;
$document->addScript($jsFile);
if(in_array('google-recaptcha',$types_array)) {
$jsFile = "https://www.google.com/recaptcha/api.js?onload=ccf_recaptcha_onload&render=explicit";
$document->addScript($jsFile);
}
}
private function getBrowser() {
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$bname = 'Unknown';
$platform = 'Unknown';
$version= "";
$ub = "";
//First get the platform?
if (preg_match('/linux/i', $u_agent)) {
$platform = 'linux';
}
elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
$platform = 'mac';
}
elseif (preg_match('/windows|win32/i', $u_agent)) {
$platform = 'windows';
}
// Next get the name of the useragent yes seperately and for good reason
if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent))
{
$bname = 'Internet Explorer';
$ub = "MSIE";
}
elseif(preg_match('/Firefox/i',$u_agent))
{
$bname = 'Mozilla Firefox';
$ub = "Firefox";
}
elseif(preg_match('/Chrome/i',$u_agent))
{
$bname = 'Google Chrome';
$ub = "Chrome";
}
elseif(preg_match('/Safari/i',$u_agent))
{
$bname = 'Apple Safari';
$ub = "Safari";
}
elseif(preg_match('/Opera/i',$u_agent))
{
$bname = 'Opera';
$ub = "Opera";
}
elseif(preg_match('/Netscape/i',$u_agent))
{
$bname = 'Netscape';
$ub = "Netscape";
}
// finally get the correct version number
$known = array('Version', $ub, 'other');
$pattern = '#(?<browser>' . join('|', $known) .
')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $u_agent, $matches)) {
// we have no matching number just continue
}
// see how many we have
$i = count($matches['browser']);
if ($i != 1) {
//we will have two since we are not using 'other' argument yet
//see if version is before or after the name
if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
$version= $matches['version'][0];
}
else {
if(!isset($matches['version'][1]))
$matches['version'][1] == '';
$version= $matches['version'][1];
}
}
else {
$version= $matches['version'][0];
}
// check if we have a number
if ($version==null || $version=="") {$version="?";}
return array(
'userAgent' => $u_agent,
'name' => $bname,
'version' => $version,
'platform' => $platform,
'pattern' => $pattern
);
}
private function getOS() {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$os_platform = "Unknown OS Platform";
$os_array = array(
'/windows nt 6.3/i' => 'Windows 8.1',
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
'/windows nt 6.0/i' => 'Windows Vista',
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
'/windows nt 5.1/i' => 'Windows XP',
'/windows xp/i' => 'Windows XP',
'/windows nt 5.0/i' => 'Windows 2000',
'/windows me/i' => 'Windows ME',
'/win98/i' => 'Windows 98',
'/win95/i' => 'Windows 95',
'/win16/i' => 'Windows 3.11',
'/macintosh|mac os x/i' => 'Mac OS X',
'/mac_powerpc/i' => 'Mac OS 9',
'/linux/i' => 'Linux',
'/ubuntu/i' => 'Ubuntu',
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile'
);
foreach ($os_array as $regex => $value) {
if (preg_match($regex, $user_agent)) {
$os_platform = $value;
}
}
return $os_platform;
}
private function get_data() {
$db = JFactory::getDBO();
//get field types array/////////////////////////////////////////////////////////////////////////////////////////////////
$query = "
SELECT
sp.id,
st.name as type
FROM
`#__creative_fields` sp
JOIN `#__creative_field_types` st ON st.id = sp.id_type
WHERE sp.published = '1'
AND sp.id_form = '".$this->form_id."'
ORDER BY sp.ordering,sp.id
";
$db->setQuery($query);
$types_array_data = $db->loadAssocList();
$types_array_index = 1;
$types_array = array();
if(is_array($types_array_data)) {
foreach($types_array_data as $type) {
$types_array[$types_array_index] = strtolower(str_replace(' ','-',str_replace('-','',$type['type'])));
$types_array_index ++;
}
}
$this->types_array = $types_array;
// set field index
if(!isset($this->field_index))
$this->field_index = 1;
//get form data/////////////////////////////////////////////////////////////////////////////////////////////////
$query = "
SELECT
sp.`id_template`,
sp.name,
sp.top_text,
sp.pre_text,
sp.thank_you_text,
sp.send_text,
sp.send_new_text,
sp.close_alert_text,
sp.form_width,
sp.redirect,
sp.redirect_itemid,
sp.redirect_url,
sp.redirect_delay,
sp.shake_count,
sp.shake_distanse,
sp.send_copy_enable,
sp.send_copy_text,
sp.shake_duration,
sp.custom_css,
st.styles,
sp.render_type,
sp.popup_button_text,
sp.static_button_position,
sp.static_button_offset,
sp.appear_animation_type,
sp.check_token,
sp.next_button_text,
sp.prev_button_text,
sp.email_template
FROM
`#__creative_forms` sp
LEFT JOIN `#__contact_templates` st ON st.id = sp.id_template
WHERE sp.published = '1'
AND sp.id = '".$this->form_id."'";
$db->setQuery($query);
$this->form_data = $db->loadAssoc();
//sp.id_template
//get fields data/////////////////////////////////////////////////////////////////////////////////////////////////
$query = "
SELECT
sp.id,
sp.name,
sp.tooltip_text,
sp.required,
sp.ordering_field,
sp.select_default_text,
sp.show_parent_label,
sp.select_no_match_text,
sp.width,
sp.field_margin_top,
sp.select_show_scroll_after,
sp.select_show_search_after,
sp.upload_button_text,
sp.upload_minfilesize,
sp.upload_maxfilesize,
sp.upload_acceptfiletypes,
sp.upload_minfilesize_message,
sp.upload_maxfilesize_message,
sp.upload_acceptfiletypes_message,
sp.captcha_wrong_message,
sp.datepicker_date_format,
sp.datepicker_animation,
sp.datepicker_style,
sp.datepicker_icon_style,
sp.datepicker_show_icon,
sp.datepicker_input_readonly,
sp.datepicker_number_months,
sp.datepicker_mindate,
sp.datepicker_maxdate,
sp.datepicker_changemonths,
sp.datepicker_changeyears,
sp.column_type,
sp.custom_html,
sp.google_maps,
sp.heading,
sp.recaptcha_site_key,
sp.recaptcha_wrong_message,
sp.recaptcha_theme,
sp.recaptcha_type,
sp.contact_data,
sp.contact_data_width,
sp.creative_popup,
sp.creative_popup_embed,
sp.m_recipients_value,
sp.m_recipients_multiple,
sp.pagebreak_type,
sp.pagebreak_page_title,
sp.if_id,
sp.if_val,
sp.then_id,
sp.hidden_val,
st.name as type
FROM
`#__creative_fields` sp
JOIN `#__creative_field_types` st ON st.id = sp.id_type
WHERE sp.published = '1'
AND sp.id_form = '".$this->form_id."'
ORDER BY sp.ordering,sp.id
";
$db->setQuery($query);
$this->field_data = $db->loadAssocList();
//get fields data/////////////////////////////////////////////////////////////////////////////////////////////////
$REMOTE_ADDR = null;
if(isset($_SERVER['REMOTE_ADDR'])) {
$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
}
elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$REMOTE_ADDR = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
elseif(isset($_SERVER['HTTP_CLIENT_IP'])) {
$REMOTE_ADDR = $_SERVER['HTTP_CLIENT_IP'];
}
elseif(isset($_SERVER['HTTP_VIA'])) {
$REMOTE_ADDR = $_SERVER['HTTP_VIA'];
}
else { $REMOTE_ADDR = 'Unknown';
}
$this->remote_addr = $REMOTE_ADDR;
}
private function get_rule_from_row($key,$row) {
preg_match('/'.$key.'~([^\|]+)\|/',$row,$m);
if(isset($m[1]))
return $m[1];
else
return '';
}
private function get_last_rule_from_row($key,$row) {
preg_match('/'.$key.'~([^\|]+)$/',$row,$m);
if(isset($m[1]))
return $m[1];
else
return '';
}
private function process_sections($matched_sections) {
$sections_width = isset($this->sections_width) ? $this->sections_width : 120;
$section_type = $matched_sections[1];
$section_label = $matched_sections[2];
$section_content = $matched_sections[3];
$section_id = $this->section_id;
$contact_data = '<div class="ccf_content_element ccf_content_element_'.$section_id.'">';
$contact_data .= '<div class="ccf_content_element_content_wrapper">';
$contact_data .= '<div style="margin-left: '.$sections_width.'px;" class="ccf_section_margin_control_'.$section_id.'">';
$contact_data .= '<span>';
$contact_data .= $section_content;
$contact_data .= '</span>';
$contact_data .= '</div>';
$contact_data .= '</div>';
$contact_data .= '<div class="ccf_content_element_icon_wrapper ccf_section_width_control_'.$section_id.'" style="width: '.$sections_width.'px;" >';
$contact_data .= '<span class="ccf_content_icon ccf_content_icon_'.$section_type.'"></span>';
$contact_data .= '<span class="ccf_content_element_label">'.$section_label.'</span>';
$contact_data .= '</div>';
$contact_data .= '</div>';
$this->section_id ++;
return $contact_data;
}
private function process_txt($txt,$process_types_array) {
if(in_array('sections',$process_types_array)) {
// preg_match_all('/{section type=\"([a-zA-Z]*)\" label=\"(.*?)\"}(.*?){\/section}/s',$sections,$matched_sections);
$txt = preg_replace_callback('/{section icon=\"([a-zA-Z]*)\" label=\"(.*?)\"}(.*?){\/section}/s', array($this, 'process_sections'), $txt);
}
if(in_array('num',$process_types_array)) {
$txt = preg_replace('/{num}(.*?){\/num}/s','<span class="ccf_content_styling">$1</span>', $txt);
}
if(in_array('popup',$process_types_array)) {
$txt = preg_replace('/{creative_popup id="(.*?)" size="(\d+)X(\d+)"}(.*?){\/creative_popup}/s','<span class="ccf_popup_link" popup_id="$1" w="$2" h="$3">$4</span>', $txt);
}
if(in_array('heading',$process_types_array)) {
$txt = preg_replace('/{heading}(.*?){\/heading}/s','<div class="creativecontactform_heading '.$this->heading_text_font_effect.'"><div class="creativecontactform_heading_inner">$1</div></div>', $txt);
}
return $txt;
}
private function print_fields_array_html($field_data) {
$db = JFactory::getDBO();
//Get variables////////////////////////////////////////////////////////////////////////////////////////////////////
$module_id = $this->module_id;
$form_data = $this->form_data;
$types_array = $this->types_array;
$form_id = $this->form_id;
$templateid = $form_data['id_template'];
$styles_row = $form_data['styles'];
$tooltip_style = $this->get_rule_from_row(505,$styles_row);
$tooltip_style = $tooltip_style == '' ? 'white' : $tooltip_style;
$ccf_datepicker_style = $this->get_rule_from_row(562,$styles_row);
$ccf_datepicker_icon_style = $this->get_rule_from_row(563,$styles_row);
$ccf_global_icons_style = $this->get_rule_from_row(589,$styles_row);
$top_text_font_effect = $this->get_rule_from_row(510,$styles_row);
$heading_text_font_effect = $this->get_rule_from_row(530,$styles_row);
$pre_text_font_effect = $this->get_rule_from_row(511,$styles_row);
$label_text_font_effect = $this->get_rule_from_row(512,$styles_row);
$label_hover_text_font_effect = $this->get_rule_from_row(513,$styles_row);
$label_error_text_font_effect = $this->get_rule_from_row(514,$styles_row);
$send_font_effect = $this->get_rule_from_row(515,$styles_row);
$send_hover_font_effect = $this->get_rule_from_row(516,$styles_row);
$this->heading_text_font_effect = $heading_text_font_effect;
$focus_anim_enabled = $label_text_font_effect == $label_hover_text_font_effect ? 0 : 1;
$error_anim_enabled = $label_text_font_effect == $label_error_text_font_effect ? 0 : 1;
$user = JFactory::getUser();
$is_textarea_exist = false;
foreach($field_data as $field) {
$field_index = $this->field_index;
$field_type = strtolower(str_replace(' ','-',str_replace('-','',$field['type'])));
$field_width = $field['width'] != '' ? 'style="width: '.$field['width'].' !important"' : '';
$field_width_select = $field['width'] != '' ? $field['width'] : '';
$field_margin = $field['field_margin_top'] != '' ? 'style="margin: '.$field['field_margin_top'].' !important"' : '';
$field_name = stripslashes($field['name']);
$field_name = $this->process_txt($field_name,array('num','popup'));
$field_tooltip_text = stripslashes($field['tooltip_text']);
$element_id = $field_type.'_'.$module_id.'_'.$field['id'];
$required_classname = $field['required'] == 1 ? 'creativecontactform_required' : '';
$required_symbol = $field['required'] == 1 ? ' <span class="creativecontactform_field_required">*</span>' : '';
$predefined_value = $field_type == 'name' ? $user->name : ($field_type == 'email' ? $user->email : '');
if($field_type == 'text-area')
$is_textarea_exist = true;
//input html
$input_type_text_arrays = array('text-input','name','address','email','phone','number','url');
if(in_array($field_type,$input_type_text_arrays)) {
$input_html = '<div class="creativecontactform_input_element '.$required_classname.'"><div class="creative_input_dummy_wrapper">';
if($field_tooltip_text != '')
$input_html .= '<span class="the-tooltip top right '.$tooltip_style.'"><span class="tooltip_inner creative_tooltip_ivisible">'.$field_tooltip_text.'</span></span>';
$input_html .= '<input class="creative_'.$field_type.' '.$required_classname.' creative_input_reset" pre_value="'.str_replace('"','',$predefined_value).'" value="'.str_replace('"','',$predefined_value).'" type="text" id="'.$element_id.'" name="creativecontactform_fields['.$field_index.'][0]"></div></div>';
}
elseif($field_type == 'datepicker') {
$cursor_val = $field["datepicker_input_readonly"] == 1 ? 'style="cursor: pointer !important;" readonly="readonly"' : '';
$dt_option = 'juri="'.JURI::base(true).'" datepicker_date_format="'.str_replace('"','',$field["datepicker_date_format"]).'" datepicker_animation="'.str_replace('"','',$field["datepicker_animation"]).'" datepicker_style="'.$ccf_datepicker_style.'" datepicker_icon_style="'.$ccf_datepicker_icon_style.'" datepicker_show_icon="'.$field["datepicker_show_icon"].'" datepicker_input_readonly="'.$field["datepicker_input_readonly"].'" datepicker_number_months="'.$field["datepicker_number_months"].'" datepicker_mindate="'.str_replace('"','',$field["datepicker_mindate"]).'" datepicker_maxdate="'.str_replace('"','',$field["datepicker_maxdate"]).'" datepicker_changemonths="'.$field["datepicker_changemonths"].'" datepicker_changeyears="'.$field["datepicker_changeyears"].'" ';
$input_html = '<div class="creativecontactform_input_element '.$required_classname.'" '.$cursor_val.'><div class="creative_input_dummy_wrapper" '.$dt_option.'>';
if($field_tooltip_text != '')
$input_html .= '<span class="the-tooltip top right '.$tooltip_style.'"><span class="tooltip_inner creative_tooltip_ivisible">'.$field_tooltip_text.'</span></span>';
$input_html .= '<input class="creative_'.$field_type.' '.$required_classname.' creative_input_reset" value="" type="text" id="'.$element_id.'" name="creativecontactform_fields['.$field_index.'][0]" '.$cursor_val.'></div></div>';
}
elseif($field_type == 'creative-popup') {
$popup_text = stripslashes($field["creative_popup"]);
$processed_data = $this->process_txt($popup_text,array('sections','num','heading'));
$popup_embed = stripslashes($field["creative_popup_embed"]);
$processed_data1 = $this->process_txt($popup_embed,array('sections','num','heading'));
$input_html = '<div style="display: none" id="popup_'.$field["id"].'">'.$processed_data.$processed_data1.'</div>';
}
elseif($field_type == 'contact-data') {
$sections_width = (int) $field["contact_data_width"];
$this->sections_width = $sections_width;
$sections_html = stripslashes($field["contact_data"]);
$processed_data = $this->process_txt($sections_html,array('sections','num','popup','heading'));
$input_html = $processed_data;
}
elseif($field_type == 'custom-html') {
$custom_html = stripslashes($field['custom_html']);
$processed_data = $this->process_txt($custom_html,array('sections','num','popup','heading'));
$input_html = $processed_data;
}
elseif($field_type == 'google-recaptcha') {
$el_id = 'ccf_recaptcha_'.$module_id.'_'.$field['id'];
$rcp = '<div class="ccf_recaptcha_wrapper" id="'.$el_id.'"></div>';
$rcp .= '<input type="hidden" class="ccf_recaptcha" id="hidden_'.$el_id.'" value="0" />';
$input_html = $rcp;
}
elseif($field_type == 'heading') {
$heading = stripslashes($field['heading']);
$heading = $this->process_txt($heading,array('numpopup'));
$input_html = '<div class="creativecontactform_heading '.$heading_text_font_effect.'"><div class="creativecontactform_heading_inner">'.$heading.'</div></div>';
}
elseif($field_type == 'google-maps') {
$google_maps = stripslashes($field['google_maps']);
$google_maps = $this->process_txt($google_maps,array('popup'));
$input_html = $google_maps;
}
elseif($field_type == 'text-area') {
$input_html = '<div class="creativecontactform_input_element creative_textarea_wrapper '.$required_classname.'"><div class="creative_textarea_dummy_wrapper">';
if($field_tooltip_text != '')
$input_html .= '<span class="the-tooltip top right '.$tooltip_style.'"><span class="tooltip_inner creative_tooltip_ivisible">'.$field_tooltip_text.'</span></span>';
$input_html .= '<textarea class="creative_textarea creative_'.$field_type.' '.$required_classname.' creative_textarea_reset" value="'.$predefined_value.'" cols="30" rows="15" id="'.$element_id.'" name="creativecontactform_fields['.$field_index.'][0]"></textarea></div></div>';
}
elseif($field_type == 'select' || $field_type == 'multiple-select' || $field_type == 'radio' || $field_type == 'checkbox') {
//get child options
$query = "
SELECT
spo.name,
spo.id,
spo.value,
spo.selected
FROM
`#__creative_form_options` spo
WHERE spo.id_parent = '".$field['id']."'
AND spo.showrow = '1'
ORDER BY ";
if($field['ordering_field'] == 0)
$query .= "spo.ordering";
else
$query .= "spo.name";
$db->setQuery($query);
$childs_array = $db->loadAssocList();
if (sizeof($childs_array) > 0)
{
$childs_length = sizeof($childs_array);
if($field_type == 'select' || $field_type == 'multiple-select') {
$selected_count = 0;
foreach ($childs_array as $key => $value)
{
if($value['selected'] == 1) {
$selected_count= 1;
break;
}
}
$def_selection = $selected_count == 0 ? 'selected="selected"' : '';
$show_search = $childs_length >= $field["select_show_search_after"] ? 'show' : 'hide';
$scroll_after = (int)$field["select_show_scroll_after"] > 3 ? (int)$field["select_show_scroll_after"] : 3;
$multile_info = $field_type == 'multiple-select' ? 'multiple="multiple"' : '';
$multile_info_val = $field_type == 'multiple-select' ? '[]' : '';
$input_html = '<select show_search="'.$show_search.'" scroll_after="'.$scroll_after.'" special_width="'.$field_width_select.'" select_no_match_text="'.stripslashes(str_replace('"','',$field["select_no_match_text"])).'" class="will_be_creative_select '.$required_classname.'" '.$multile_info.' name="creativecontactform_fields['.$field_index.'][0]'.$multile_info_val.'">';
$input_html .= '<option '.$def_selection.' class="def_value" value="creative_empty">'.$field["select_default_text"].'</option>';
$selected = '';
$pre_val='';
$seted_value = false;
foreach ($childs_array as $key => $value)
{
if(!$seted_value && $field_type == 'select' && $value['selected'] == '1') {
$selected = 'selected="selected"';
$pre_val = 'pre_val="selected"';
$seted_value = true;
}
elseif($field_type == 'multiple-select' && $value['selected'] == '1') {
$selected = 'selected="selected"';
$pre_val = 'pre_val="selected"';
}
else {
$selected = '';
$pre_val = '';
}
$input_html .= '<option id="'.$module_id.'_'.$field["id"].'_'.$value["id"].'" value="'.stripslashes(str_replace('"','',$value["value"])).'" '.$selected.' '.$pre_val.'>'.stripslashes($value["name"]).'</option>';
}
$input_html .= '</select>';
}
elseif($field_type == 'radio' || $field_type == 'checkbox') {
$input_html = '';
$colors_array = array("black","blue","red","litegreen","yellow","liteblue","green","crimson","litecrimson");
$selected = '';
$pre_val='';
$seted_value = false;
foreach ($childs_array as $key => $value)
{
if($field_type == 'radio' && !$seted_value && $value['selected'] == '1') {
$selected = 'checked="checked"';
$pre_val = 'pre_val="checked"';
$seted_value = true;
}
elseif($field_type == 'checkbox' && $value['selected'] == '1') {
$selected = 'checked="checked"';
$pre_val = 'pre_val="checked"';
}
else {
$selected = '';
$pre_val = '';
}
$data_color_index = $key % 8;
$current_label = stripslashes($value["name"]);
$current_label = $this->process_txt($current_label,array('num','popup'));
$label_class = $field['show_parent_label'] == 0 ? 'without_parent_label' : '';
$req_symbol = ($field['show_parent_label'] == 0 && $key == 0) ? $required_symbol : '';
$input_html .= '<div class="creative_checkbox_wrapper centered"><div class="answer_name"><label uniq_index="'.$module_id.'_'.$field["id"].'_'.$value["id"].'" class="twoglux_label '.$label_class.'"><span class="creative_checkbox_label_wrapper">'.$current_label.' '.$req_symbol.'</span></label></div>';
$input_html .= '<div class="answer_input">';
if($field_type == 'radio')
$input_html .= '<input '.$selected.' '.$pre_val.' id="'.$module_id.'_'.$field["id"].'_'.$value["id"].'" type="radio" class="creative_ch_r_element creativeform_twoglux_styled elem_'.$module_id.'_'.$field["id"].'" value="'.stripslashes(str_replace('"','',$value["value"])).'" uniq_index="elem_'.$module_id.'_'.$field["id"].'" name="remove_this_partcreativecontactform_fields['.$field_index.'][0]" data-color="'.$colors_array[$data_color_index].'" />';
else
$input_html .= '<input '.$selected.' '.$pre_val.' id="'.$module_id.'_'.$field["id"].'_'.$value["id"].'" type="checkbox" class="creative_ch_r_element creativeform_twoglux_styled" value="'.stripslashes(str_replace('"','',$value["value"])).'" name="creativecontactform_fields['.$field_index.'][0][]" data-color="'.$colors_array[$data_color_index].'" />';
$input_html .= '</div></div><div class="creative_clear"></div>';
}
}
}
else {
$input_html = 'There are no options to be shown.';
}
}
elseif($field_type == 'captcha') {
$input_html = '<img id="creative_captcha_'.$module_id.'_'.$field["id"].'" class="creative_captcha" src="components/com_creativecontactform/captcha.php?fid='.$field["id"].'&r='.rand(100000,999999).'" /><div fid="'.$field["id"].'" holder="creative_captcha_'.$module_id.'_'.$field["id"].'" class="reload_creative_captcha icon_'.$ccf_global_icons_style.'"></div><div class="creative_clear"></div>';
$input_html .= '<div style="width: 200px !important;" class="creativecontactform_input_element creativecontactform_required creative_captcha_input_wrapper"><div class="creative_input_dummy_wrapper"><input class="creative_'.$field_type.' creativecontactform_required creative_input_reset" value="" type="text" id="'.$element_id.'" name="creativecontactform_captcha['.$field["id"].']"></div></div><div class="creative_captcha_info" style="display:none">'.stripslashes($field["captcha_wrong_message"]).'</div>';
}
elseif($field_type == 'file-upload') {
$input_html = '
<div class="creative_fileupload_wrapper icon_'.$ccf_global_icons_style.'">
<span class="creative_fileupload '.$send_font_effect.'" normal_effect_class="'.$send_font_effect.'" hover_effect_class="'.$send_hover_font_effect.'">
'.$field["upload_button_text"].'
<input class="creative_fileupload_submit" type="file" name="files[]" multiple>
</span>
<div class="creative_progress">
<div class="bar"></div>
</div>
<div class="creative_uploaded_files"></div>
<div class="creative_upload_info" style="display: none"
upload_maxfilesize="'.$field["upload_maxfilesize"].'"
upload_minfilesize="'.$field["upload_minfilesize"].'"
upload_acceptfiletypes="'.$field["upload_acceptfiletypes"].'"
upload_minfilesize_message="'.str_replace('"','',$field["upload_minfilesize_message"]).'"
upload_maxfilesize_message="'.str_replace('"','',$field["upload_maxfilesize_message"]).'"
upload_acceptfiletypes_message="'.str_replace('"','',$field["upload_acceptfiletypes_message"]).'">
</div>
<div class="creative_clear"></div>
</div>';
}
// v4.5.0
elseif($field_type == 'multiple-recipients') {
$m_rec_value = $field["m_recipients_value"];
$m_rec_mult = $field["m_recipients_multiple"];
$m_rec_array = explode("\n", $m_rec_value);
$m_rec_data = array();
if(is_array($m_rec_array)) {
foreach ($m_rec_array as $key => $value) {
$m_rec_piece = explode("|", $value);
$m_rec_data[$key][0] = $m_rec_piece[0];
$m_rec_data[$key][1] = $m_rec_piece[1];
$selected = isset($m_rec_piece[2]) ? true : false;
if($selected)
$m_rec_data[$key][2] = 'selected';
else
$m_rec_data[$key][2] = '';
}
}
$selected_count = 0;
foreach ($m_rec_data as $key => $value)
{
if($value[2] == 'selected') {
$selected_count= 1;
break;
}
}
$def_selection = $selected_count == 0 ? 'selected="selected"' : '';
$show_search = 'hide';
$scroll_after = 10;
$multile_info = $m_rec_mult == 1 ? 'multiple="multiple"' : '';
$multile_info_val =$m_rec_mult == 1 ? '[]' : '';
$input_html = '<select show_search="'.$show_search.'" scroll_after="'.$scroll_after.'" special_width="'.$field_width_select.'" select_no_match_text="'.stripslashes(str_replace('"','',$field["select_no_match_text"])).'" class="will_be_creative_select '.$required_classname.'" '.$multile_info.' name="creativecontactform_fields['.$field_index.'][0]'.$multile_info_val.'">';
$input_html .= '<option '.$def_selection.' class="def_value" value="creative_empty">'.$field["select_default_text"].'</option>';
$selected = '';
$pre_val='';
$seted_value = false;
foreach ($m_rec_data as $key => $value)
{
if(!$seted_value && $m_rec_mult == 0 && $value[2] == 'selected') {
$selected = 'selected="selected"';
$pre_val = 'pre_val="selected"';
$seted_value = true;
}
elseif($m_rec_mult == 1 && $value[2] == 'selected') {
$selected = 'selected="selected"';
$pre_val = 'pre_val="selected"';
}
else {
$selected = '';
$pre_val = '';
}
$opt_id_geted = $key;
$input_html .= '<option id="'.$module_id.'_'.$field["id"].'_'.$opt_id_geted.'" value="'.stripslashes(str_replace('"','',$value[1])).'" '.$selected.' '.$pre_val.'>'.stripslashes($value[0]).'</option>';
}
$input_html .= '</select>';
}
elseif($field_type == 'time') {
$def_selection = '';
$show_search = 'hide';
$scroll_after = 12;
$field_width_select = "81px";
$multile_info = '';
$multile_info_val = '';
$input_html = '<select show_search="'.$show_search.'" scroll_after="'.$scroll_after.'" special_width="'.$field_width_select.'" select_no_match_text="'.stripslashes(str_replace('"','',$field["select_no_match_text"])).'" class="will_be_creative_select '.$required_classname.'" '.$multile_info.' name="creativecontactform_fields['.$field_index.'][0][0]'.$multile_info_val.'">';
$input_html .= '<option '.$def_selection.' class="def_value" value="creative_empty">Hour</option>';
$selected = '';
$pre_val='';
$seted_value = false;
$hours_array = array("01","02","03","04","05","06","07","08","09","10","11","12");
foreach ($hours_array as $key => $value)
{
$selected = '';
$pre_val = '';
$input_html .= '<option id="'.$module_id.'_'.$field["id"].'_'.$value.'" value="'.stripslashes(str_replace('"','',$value)).'" '.$selected.' '.$pre_val.'>'.stripslashes($value).'</option>';
}
$input_html .= '</select>';
$input_html .= '<select show_search="'.$show_search.'" scroll_after="'.$scroll_after.'" special_width="'.$field_width_select.'" select_no_match_text="'.stripslashes(str_replace('"','',$field["select_no_match_text"])).'" class="will_be_creative_select '.$required_classname.'" '.$multile_info.' name="creativecontactform_fields['.$field_index.'][0][1]'.$multile_info_val.'">';
$input_html .= '<option '.$def_selection.' class="def_value" value="creative_empty">Minute</option>';
$selected = '';
$pre_val='';
$seted_value = false;
$hours_array = array("00","05","10","15","20","25","30","35","40","45","50","55");
foreach ($hours_array as $key => $value)
{
$selected = '';
$pre_val = '';
$input_html .= '<option id="'.$module_id.'_'.$field["id"].'_'.$value.'" value="'.stripslashes(str_replace('"','',$value)).'" '.$selected.' '.$pre_val.'>'.stripslashes($value).'</option>';
}
$input_html .= '</select>';
$input_html .= '<select show_search="'.$show_search.'" scroll_after="'.$scroll_after.'" special_width="'.$field_width_select.'" select_no_match_text="'.stripslashes(str_replace('"','',$field["select_no_match_text"])).'" class="will_be_creative_select '.$required_classname.'" '.$multile_info.' name="creativecontactform_fields['.$field_index.'][0][2]'.$multile_info_val.'">';
$input_html .= '<option '.$def_selection.' class="def_value" value="creative_empty">am/pm</option>';
$selected = '';
$pre_val='';
$seted_value = false;
$hours_array = array("AM","PM");
foreach ($hours_array as $key => $value)
{
$selected = '';
$pre_val = '';
$input_html .= '<option id="'.$module_id.'_'.$field["id"].'_'.$value.'" value="'.stripslashes(str_replace('"','',$value)).'" '.$selected.' '.$pre_val.'>'.stripslashes($value).'</option>';
}
$input_html .= '</select>';
}
elseif($field_type == 'stars') {
$input_html = '<input type="hidden" class="cs_stars_input '.$required_classname.'" name="creativecontactform_fields['.$field_index.'][0]" value="" />';
$input_html .= '<div class="ccf_stars_wrapper">
<div class="ccf_star ccf_star_empty ccf_star_1" star_index="1"></div>
<div class="ccf_star ccf_star_empty ccf_star_2" star_index="2"></div>
<div class="ccf_star ccf_star_empty ccf_star_3" star_index="3"></div>
<div class="ccf_star ccf_star_empty ccf_star_4" star_index="4"></div>
<div class="ccf_star ccf_star_empty ccf_star_5" star_index="5"></div>
<div class="ccf_star_reset" style="display: none"></div>
</div>';
}
elseif($field_type == 'esignature') {
$input_html =
'
<div class="ccf_canvas_wrapper" style="width: 302px;">
<div class="ccf_canvas_inner" >
<canvas class="ccf_canvas" width="300" height="200"></canvas>
<img class="ccf_canvasimg" style="display:none;">
<input type="hidden" class="ccf_signature_img '.$required_classname.'" value="" name="creativecontactform_fields['.$field_index.'][0]" />
</div>
<div class="ccf_colors_wrapper">
<div data-color="green" class="ccf_change_cnv_color ccf_change_cnv_color_green"></div>
<div data-color="blue" class="ccf_change_cnv_color ccf_change_cnv_color_blue" ></div>
<div data-color="red" class="ccf_change_cnv_color ccf_change_cnv_color_red" ></div>
<div data-color="yellow" class="ccf_change_cnv_color ccf_change_cnv_color_yellow" ></div>
<div data-color="orange" class="ccf_change_cnv_color ccf_change_cnv_color_orange" ></div>
<div data-color="black" class="ccf_change_cnv_color ccf_change_cnv_color_black"></div>
<div data-color="white" class="ccf_change_cnv_color ccf_change_cnv_color_white" ></div>
</div>
<div class="ccf_canvas_btn_wrapper">
<div class="ccf_save_canvas">Save</div>
<div class="ccf_clear_canvas">Clear</div>
</div>
</div>
';
}
elseif($field_type == 'page-break' || $field_type == 'ifthen') {
continue;
}
elseif($field_type == 'hidden') {
$input_html = '<div class="creativecontactform_input_element "><div class="creative_input_dummy_wrapper">';
$input_html .= '<input class="creative_'.$field_type.' " value="'.str_replace('"','',$field["hidden_val"]).'" type="hidden" id="'.$element_id.'" name="creativecontactform_fields['.$field_index.'][0]"></div></div>';
}
$hidden_field_types = array('file-upload','captcha','custom-html','heading','google-maps','google-recaptcha','contact-data','social-links','creative-popup');
if(!in_array($field_type,$hidden_field_types)) {
$input_html .= '<input type="hidden" name="creativecontactform_fields['.$field_index.'][1]" value="'.stripslashes(str_replace('"','',$field_name)).'" />';
$input_html .= '<input type="hidden" name="creativecontactform_fields['.$field_index.'][2]" value="'.$field_type.'" />';
$input_html .= '<input type="hidden" name="creativecontactform_fields['.$field_index.'][3]" value="'.$field["id"].'" />';
}
//start printing html
$radio_checkbox_class = ($field_type == 'radio' || $field_type == 'checkbox' || $field_type == 'file-upload') ? 'creative_'.$field_type : '';
$radio_checkbox_req_class = ($field_type == 'radio' || $field_type == 'checkbox' || $field_type == 'file-upload') ? $required_classname : '';
if($field_type == 'radio' || $field_type == 'checkbox' || $field_type == 'file-upload' || $field_type == 'captcha') {
$box_inner_class = $is_textarea_exist ? 'creativecontactform_field_box_textarea_inner' : 'creativecontactform_field_box_inner';
}
else {
$box_inner_class = $field_type == 'text-area' ? 'creativecontactform_field_box_textarea_inner' : 'creativecontactform_field_box_inner';
// v4.5.0
if($field_type == 'time')
$box_inner_class = $box_inner_class . ' creativecontactform_field_box_inner_no_min_w';
}
//start printing boxes
$wrapper_id = $field_type == 'google-recaptcha' ? $element_id : '';
$field_box_style = $field_type == 'creative-popup' ? 'style="display: none"' : '';
echo '<div id="'.$wrapper_id.'" '.$field_margin.' class="creativecontactform_field_box creative_timing_'.$field_index.' creative_timing_'.$field_type.' '.$radio_checkbox_class.' '.$radio_checkbox_req_class.' ccf_field_box_'.$field["id"].'" field_id="'.$field["id"].'"><div '.$field_width.' class="'.$box_inner_class.'">';
$show_label = ($field['show_parent_label'] == 0 || $field_type == 'heading') ? 'style="display:none !important"' : '';
echo '<label normal_effect_class="'.$label_text_font_effect.'" hover_effect_class="'.$label_hover_text_font_effect.'" error_effect_class="'.$label_error_text_font_effect.'" class="creativecontactform_field_name '.$label_text_font_effect.'" for="'.$element_id.'" '.$show_label.'><span class="creative_label_txt_wrapper">'.$field_name;
if($field_type == 'captcha')
echo ' <span class="creativecontactform_field_required">*</span></label>';
else
echo $required_symbol.'</span></label>';
echo $input_html;
echo '</div></div>';
// echo '</div>';
$this->field_index ++;
}
}
private function print_fields_columns($fields_final_array, $field_box_animation_class) {
foreach($fields_final_array as $k => $field_columns_array) {
// echo '<div style="clear: both">'.$k.'</div>';
//print left columns
if(isset($field_columns_array['1']) || isset($field_columns_array['2'])) {
echo '<div class="creative_field_box_wrapper creative_field_box_wrapper_1 '.$field_box_animation_class.'"><div class="creative_field_box_wrapper_1_inner">';
if(isset($field_columns_array['1'])) {
$this->print_fields_array_html($field_columns_array['1']);
}
echo '</div></div>';
}
if(isset($field_columns_array['2'])) {
//print right column
echo '<div class="creative_field_box_wrapper creative_field_box_wrapper_2 '.$field_box_animation_class.'"><div class="creative_field_box_wrapper_2_inner">';
if(isset($field_columns_array['2'])) {
$this->print_fields_array_html($field_columns_array['2']);
}
echo '</div></div>';
}
// print both columns
if(isset($field_columns_array['0'])) {
//print right column
echo '<div class="creativecontactform_clear"></div><div class="creative_field_box_wrapper creative_field_box_wrapper_0 '.$field_box_animation_class.'">';
if(isset($field_columns_array['0'])) {
$this->print_fields_array_html($field_columns_array['0']);
}
echo '</div>';
}
}
}
private function generate_final_array($field_data) {
// split data
$fields_final_array = array();
$k = 0;
$separate_col_0 = false;
$separate_col_12 = false;
foreach($field_data as $field) {
// $is_page_break = $field['type'];
$column_type = $field['column_type'];
if($column_type != 0) {
if($separate_col_12) {
$k ++;
$separate_col_12 = false;
}
$fields_final_array[$k][$column_type][] = $field;
$separate_col_0 = true;
}
else {
if($separate_col_0) {
$k ++;
$separate_col_0 = false;
}
$fields_final_array[$k][$column_type][] = $field;
$separate_col_12 = true;
}
}
return $fields_final_array;
}
public function render_html()
{
$db = JFactory::getDBO();
$document = JFactory::getDocument();
$browser_data = $this -> getBrowser();
$browser = $browser_data["name"] . ' ' . $browser_data["version"];
$op_s = $this -> getOs();
//get data/////////////////////////////////////////////////////////////////////////////////////////////////////////
$this->get_data();
//add scripts/////////////////////////////////////////////////////////////////////////////////////////////////////
if($this->type != 'plugin')
$this->add_scripts();
//Get variables////////////////////////////////////////////////////////////////////////////////////////////////////
$module_id = $this->module_id;
$form_data = $this->form_data;
$field_data = $this->field_data;
$types_array = $this->types_array;
$form_id = $this->form_id;
$templateid = $form_data['id_template'];
$styles_row = $form_data['styles'];
$this->section_id = 0;
$tooltip_style = $this->get_rule_from_row(505,$styles_row);
$tooltip_style = $tooltip_style == '' ? 'white' : $tooltip_style;
$scrollbar_popup_style = $this->get_rule_from_row(629,$styles_row);
$scrollbar_popup_style = $scrollbar_popup_style == '' ? 'inset-2-dark' : $scrollbar_popup_style;
$scrollbar_content_style = $this->get_rule_from_row(630,$styles_row);
$scrollbar_content_style = $scrollbar_content_style == '' ? 'inset-2-dark' : $scrollbar_content_style;
$custom_js = $this->get_last_rule_from_row(628,$styles_row);
$ccf_global_icons_style = $this->get_rule_from_row(589,$styles_row);
$ccf_sections_icons_style = $this->get_rule_from_row(552,$styles_row);
$top_text_font_effect = $this->get_rule_from_row(510,$styles_row);
$heading_text_font_effect = $this->get_rule_from_row(530,$styles_row);
$pre_text_font_effect = $this->get_rule_from_row(511,$styles_row);
$label_text_font_effect = $this->get_rule_from_row(512,$styles_row);
$label_hover_text_font_effect = $this->get_rule_from_row(513,$styles_row);
$label_error_text_font_effect = $this->get_rule_from_row(514,$styles_row);
$send_font_effect = $this->get_rule_from_row(515,$styles_row);
$send_hover_font_effect = $this->get_rule_from_row(516,$styles_row);
$focus_anim_enabled = $label_text_font_effect == $label_hover_text_font_effect ? 0 : 1;
$error_anim_enabled = $label_text_font_effect == $label_error_text_font_effect ? 0 : 1;
// version 4.0 updates
$render_type = $form_data['render_type'];
$popup_button_text = $form_data['popup_button_text'];
$static_button_position = $form_data['static_button_position'];
$static_button_offset = $form_data['static_button_offset'];
$appear_animation_type = $form_data['appear_animation_type'];
$check_token = $form_data['check_token'];
$next_button_text = $form_data['next_button_text'];
$prev_button_text = $form_data['prev_button_text'];
//get reqired google fonts
$ccf_fonts_indexes_array = array(506,507,508,509,131,112,202,152,529);
$ccf_google_requested_fonts = array();
foreach($ccf_fonts_indexes_array as $key) {
$ccf_googlefont = 'ccf-googlewebfont-';
preg_match('/'.$key.'~([^\|]+)\|/',$styles_row,$m);
if(is_array($m) && sizeof($m) > 0) {
$ccf_font_rule = $m[1];
if (strpos($ccf_font_rule,$ccf_googlefont) !== false) {
$ccf_font_rule = str_replace($ccf_googlefont, '', $ccf_font_rule);
$ccf_font_rule = str_replace(' ', '+', $ccf_font_rule);
$ccf_google_requested_fonts[] = $ccf_font_rule;
}
}
}
if(sizeof($ccf_google_requested_fonts) > 0) {
$ccf_google_requested_fonts = implode('|',$ccf_google_requested_fonts);
$ccf_google_font_link = 'https://fonts.googleapis.com/css?family='.$ccf_google_requested_fonts;
$ccf_google_link = '<link rel="stylesheet" type="text/css" href="'.$ccf_google_font_link.'">';
}
else
$ccf_google_link = '';
$REMOTE_ADDR = $this->remote_addr;
$user = JFactory::getUser();
$toptxt = $form_data['top_text'];
$pretxt = stripcslashes($form_data['pre_text']);
$pretxt = $this->process_txt($pretxt,array('num','popup'));
$form_width = $form_data['form_width'];
$custom_css = $form_data['custom_css'];
$redirect_enable = $form_data['redirect'];
$redirect = '';
if ($redirect_enable) {
$redirectItemId = (int) $form_data['redirect_itemid'] == 0 ? 1 : (int) $form_data['redirect_itemid'];
$redirectUrl = $form_data['redirect_url'];
if ($redirectUrl != '') {
$redirect = JRoute::_($redirectUrl, false);
} else {
$redirect = JRoute::_('index.php?Itemid='.$redirectItemId);
}
}
$redirect_delay = (int) $form_data['redirect_delay'];
$thank_you_text = htmlspecialchars($form_data['thank_you_text'],ENT_QUOTES);
$send_text = htmlspecialchars($form_data['send_text'],ENT_QUOTES);
$send_new_text = htmlspecialchars($form_data['send_new_text'],ENT_QUOTES);
$close_alert_text = htmlspecialchars($form_data['close_alert_text'],ENT_QUOTES);
//validation options
$shake_count = (int) $form_data['shake_count'];
$shake_distanse = (int) $form_data['shake_distanse'];
$shake_duration = (int) $form_data['shake_duration'];
//send copy options
$send_copy_enable= (int) $form_data['send_copy_enable'];
$send_copy_text=htmlspecialchars($form_data['send_copy_text'],ENT_QUOTES);
// zoom in animation
$wrapper_animation_class = '';
$header_animation_class = '';
$body_animation_class = '';
$field_box_animation_class = '';
$footer_animation_class = '';
if($appear_animation_type == 1) {
if($render_type == 0) {
$wrapper_animation_class = 'creative_wrapper_animation_state_1';
$header_animation_class = 'creative_header_animation_state_1';
$field_box_animation_class = 'creative_field_box_animation_state_1';
$footer_animation_class = 'creative_footer_animation_state_1';
}
elseif($render_type == 1 || $render_type == 2) {
$wrapper_animation_class = 'creative_wrapper_animation_state_1_short';
$header_animation_class = 'creative_header_animation_state_1_short';
$field_box_animation_class = 'creative_field_box_animation_state_1_short';
$footer_animation_class = 'creative_footer_animation_state_1_short';
}
}
$opacity_0_class = $render_type == 0 && $appear_animation_type == 2 ? 'opacity_0' : '';
$popup_hidden_class = $render_type == 0 ? '' : 'ccf_popup_hidden';
//strat rendering html///////////////////////////////////////////////////////////////////////////////////////////////
ob_start();
if(sizeof($field_data) > 0) {
?>
<?php echo $ccf_google_link;?>
<div render_type="<?php echo $render_type; ?>" class="creativecontactform_wrapper <?php echo $wrapper_animation_class;?> <?php echo $opacity_0_class; ?> creative_form_module creative_form_<?php echo $form_id;?> ccf_icon_<?php echo $ccf_global_icons_style;?> ccf_sections_template_<?php echo $ccf_sections_icons_style;?> <?php echo $popup_hidden_class;?>" <?php if($form_width != '') { echo 'style="width: '.$form_width.' !important"'; }?> focus_anim_enabled="<?php echo $focus_anim_enabled;?>" error_anim_enabled="<?php echo $error_anim_enabled;?>" scrollbar_popup_style="<?php echo $scrollbar_popup_style;?>" scrollbar_content_style="<?php echo $scrollbar_content_style;?>">
<div class="v4_data" popup_button_text="<?php echo $popup_button_text; ?>" static_button_position="<?php echo $static_button_position; ?>" static_button_offset="<?php echo $static_button_offset; ?>" appear_animation_type="<?php echo $appear_animation_type; ?>" next_button_text="<?php echo $next_button_text; ?>" prev_button_text="<?php echo $prev_button_text; ?>" form_id="<?php echo $form_id; ?>" form_w="<?php echo $form_width; ?>" module_id="<?php echo $module_id; ?>"></div>
<div class="creativecontactform_wrapper_inner">
<div class="creativecontactform_loading_wrapper"><table style="border: none;width: 100%;height: 100%"><tr><td align="center" valign="middle"><img src="<?php echo JURI::base(true).'/components/com_creativecontactform/assets/images/ajax-loader.gif';?>" /></td></tr></table></div>
<div class="creativecontactform_header <?php echo $header_animation_class;?>">
<div class="creativecontactform_title <?php echo $top_text_font_effect;?>"><?php echo $toptxt;?></div>
<?php if($pretxt != '') {?><div class="creativecontactform_pre_text <?php echo $pre_text_font_effect;?>"><?php echo $pretxt;?></div><?php }?>
</div>
<form class="creativecontactform_form">
<div class="creativecontactform_body <?php echo $body_animation_class;?>">
<?php
if(sizeof($field_data) > 0) {
$fields_pages_array = array();
$fields_pages_titles_array = array();
$k = 0;
$page_seperate_type = '';
$if_then_array = array();
foreach ($field_data as $key => $field) {
$field_type = $field['type'];
if($field_type == 'If-Then') {
$if_then_array[] = array($field["if_id"],$field["if_val"],$field["then_id"]);
continue;
}
if($field_type == 'Page Break') {
$page_seperate_type = $field['pagebreak_type'];
$fields_pages_titles_array[$k] = $field['pagebreak_page_title'];
$k ++;
continue;
}
$fields_pages_array[$k][] = $field;
}
$pages_count = sizeof($fields_pages_array);
// if then logic
foreach ($if_then_array as $key => $value) {
echo '<div class="ccf_if_then" if_id="'.$value["0"].'" if_val="'.$value["1"].'" then_id="'.$value["2"].'"></div>';
}
$final_pages_array = array();
foreach ($fields_pages_array as $k => $fields_page_array) {
$final_pages_array[$k] = $this->generate_final_array($fields_page_array);
}
// generate tabs
if($page_seperate_type == 1) {
echo '<div class="ccf_tabs_wrapper">';
echo '<div class="ccf_tabs_inner">';
foreach($fields_pages_titles_array as $k => $tab_data) {
$active_class = $k == 0 ? 'ccf_active' : '';
echo '<div class="ccf_tab_item ccf_tab_'.$k.' '.$active_class.'" tab_index="'.$k.'">'.$tab_data.'</div>';
}
echo '</div>';
echo '</div>';
}
// render next/prev page structure, tabs
if($page_seperate_type == 0 || $page_seperate_type == 1) {
echo '<div class="ccf_pages_wrapper" pages_count="'.$pages_count.'" current_page="0" page_seperate_type="'.$page_seperate_type.'">';
echo '<div class="ccf_pages_inner">';
foreach($final_pages_array as $k => $final_page_data) {
$page_title = isset($fields_pages_titles_array[$k]) ? $fields_pages_titles_array[$k] : '';
echo '<div class="ccf_page_item ccf_page_'.$k.'" page_index="'.$k.'" page_title="'.$page_title.'">';
$this->print_fields_columns($final_page_data, $field_box_animation_class);
echo '<div class="creative_clear"></div>';
echo '</div>';
}
echo '</div>';
echo '</div>';
}
elseif($page_seperate_type == 2) { // acordion
echo '<div class="ccf_pages_wrapper" pages_count="'.$pages_count.'" current_page="0" page_seperate_type="'.$page_seperate_type.'">';
echo '<div class="ccf_pages_inner">';
foreach($final_pages_array as $k => $final_page_data) {
$active_class = $k == 0 ? 'ccf_acordion_active' : '';
$page_title = isset($fields_pages_titles_array[$k]) ? $fields_pages_titles_array[$k] : '';
echo '<div class="ccf_acordion_item ccf_acordion_'.$k.' '.$active_class.'" page_index="'.$k.'" >'.$page_title.'</div>';
echo '<div class="ccf_page_item ccf_page_'.$k.' ccf_page_mgtop" page_index="'.$k.'" page_title="'.$page_title.'">';
$this->print_fields_columns($final_page_data, $field_box_animation_class);
echo '<div class="creative_clear"></div>';
echo '</div>';
}
echo '</div>';
echo '</div>';
}
}
if($send_copy_enable == 1) {
// $field_index ++;
echo '<div class="creativecontactform_clear"></div><div class="creativecontactform_field_box creative_timing_sendmecopy creative_timing_6 '.$field_box_animation_class.'"><div class="creativecontactform_field_box_textarea_inner">';
echo '
<div class="answer_name"><label uniq_index="'.$module_id.'_0_0" class="twoglux_label without_parent_label">'.$send_copy_text.'</label></div>
<div class="answer_input"><input id="'.$module_id.'_0_0" type="checkbox" class="creativeform_twoglux_styled" value="1" name="creativecontactform_send_copy_enable" data-color="blue" /></div><div class="creative_clear"></div>';
echo '</div></div>';
}
?>
<div class="creative_clear"></div>
</div>
<div class="creativecontactform_footer <?php echo $footer_animation_class;?>">
<?php
if($page_seperate_type == 0 && $pages_count > 1) {
echo '<div class="ccf_pages_buttons_wrapper">';
echo '<div class="ccf_prev_page_button ccf_cursor_default">'.$prev_button_text.'</div>';
echo '<div class="ccf_next_page_button">'.$next_button_text.'</div>';
echo '<div class="creative_clear"></div>';
echo '</div>';
echo '<div class="creative_clear"></div>';
}
?>
<div class="creativecontactform_submit_wrapper">
<input type="button" value="<?php echo $send_text;?>" class="creativecontactform_send <?php echo $send_font_effect;?>" roll="<?php echo $form_id;?>" normal_effect_class="<?php echo $send_font_effect;?>" hover_effect_class="<?php echo $send_hover_font_effect;?>"/>
<input type="button" value="<?php echo $send_new_text;?>" class="creativecontactform_send_new creativecontactform_hidden <?php echo $send_font_effect;?>" roll="<?php echo $form_id;?>" normal_effect_class="<?php echo $send_font_effect;?>" hover_effect_class="<?php echo $send_hover_font_effect;?>"/>
<div class="creativecontactform_clear"></div>
</div>
<div class="creativecontactform_clear"></div>
<input type="hidden" name="<?php echo JSession::getFormToken();?>" class="creativecontactform_token" value="1" />
<input type="hidden" value="<?php echo $REMOTE_ADDR;?>" name="creativecontactform_ip" />
<input type="hidden" value="<?php echo JURI::current();?>" name="creativecontactform_referrer" />
<input type="hidden" value="<?php echo $document->getTitle();?>" name="creativecontactform_page_title" />
<input type="hidden" value="<?php echo $browser;?>" name="creativecontactform_browser" />
<input type="hidden" value="<?php echo $op_s;?>" name="creativecontactform_operating_system" />
<input type="hidden" value="" class="ccf_sc_res" name="creativecontactform_sc_res" />
<input type="hidden" value="<?php echo $module_id;?>" class="creativecontactform_module_id" name="creativecontactform_module_id" />
<input type="hidden" value="<?php echo $form_id;?>" class="creativecontactform_form_id" name="creativecontactform_form_id" />
</div>
</form>
</div>
</div>
<?php
//including custom javascript/////////////////////////////////////////////////////////////////////////////////////////////////
$jsInclude = ' if (typeof creativecontactform_shake_count_array === \'undefined\') { var creativecontactform_shake_count_array = new Array();};';
$jsInclude .= 'creativecontactform_shake_count_array['.$form_id.'] = "'.$shake_count.'";';
$jsInclude .= ' if (typeof creativecontactform_shake_distanse_array === \'undefined\') { var creativecontactform_shake_distanse_array = new Array();};';
$jsInclude .= 'creativecontactform_shake_distanse_array['.$form_id.'] = "'.$shake_distanse.'";';
$jsInclude .= ' if (typeof creativecontactform_shake_duration_array === \'undefined\') { var creativecontactform_shake_duration_array = new Array();};';
$jsInclude .= 'creativecontactform_shake_duration_array['.$form_id.'] = "'.$shake_duration.'";';
$jsInclude .= 'var creativecontactform_path = "'.JURI::base(true).'/components/com_creativecontactform/";';
$jsInclude .= ' if (typeof creativecontactform_redirect_enable_array === \'undefined\') { var creativecontactform_redirect_enable_array = new Array();};';
$jsInclude .= 'creativecontactform_redirect_enable_array['.$form_id.'] = "'.$redirect_enable.'";';
$jsInclude .= ' if (typeof creativecontactform_redirect_array === \'undefined\') { var creativecontactform_redirect_array = new Array();};';
$jsInclude .= 'creativecontactform_redirect_array['.$form_id.'] = "'.$redirect.'";';
$jsInclude .= ' if (typeof creativecontactform_redirect_delay_array === \'undefined\') { var creativecontactform_redirect_delay_array = new Array();};';
$jsInclude .= 'creativecontactform_redirect_delay_array['.$form_id.'] = "'.$redirect_delay.'";';
$jsInclude .= ' if (typeof creativecontactform_thank_you_text_array === \'undefined\') { var creativecontactform_thank_you_text_array = new Array();};';
$jsInclude .= 'creativecontactform_thank_you_text_array['.$form_id.'] = "'.$thank_you_text.'";';
// $jsInclude .= ' if (typeof creativecontactform_pre_text_array === \'undefined\') { var creativecontactform_pre_text_array = new Array();};';
// $jsInclude .= 'creativecontactform_pre_text_array['.$form_id.'] = "'.$pretxt.'";';
$jsInclude .= ' if (typeof close_alert_text === \'undefined\') { var close_alert_text = new Array();};';
$jsInclude .= 'close_alert_text['.$form_id.'] = "'.$close_alert_text.'";';
$jsInclude .= 'creativecontactform_juri = "'.JURI::base( true ).'";';
if($this->type != 'plugin') {
$document = JFactory::getDocument();
$document->addScriptDeclaration ( $jsInclude );
}
else {
echo $jstoinclude = '<script type="text/javascript">'.$jsInclude.'</script>';
}
// custom css
if($custom_css != '') {
$custom_css = str_replace('FORM_ID', $form_id, $custom_css);
echo '<style type="text/css">'.$custom_css.'</style>';
}
// custom js
if($custom_js != '') {
$custom_js = str_replace('FORM_ID', $form_id, $custom_js);
echo '<script type="text/javascript">(function($) {$(document).ready(function() {'.$custom_js.'})})(creativeJ);</script>';
}
//google recaptcha javascript
if(in_array('google-recaptcha',$types_array)) {
$query_captcha = "
SELECT
sp.id,
sp.recaptcha_site_key,
sp.recaptcha_theme,
sp.recaptcha_type
FROM
`#__creative_fields` sp
WHERE sp.published = '1'
AND sp.id_type = '19'
AND sp.id_form = '".$form_id."'";
$db->setQuery($query_captcha);
$recaptcha_array = $db->loadAssocList();
if(is_array($recaptcha_array)) {
$rcp_verify_functions = '';
$rcp_onload_functions = '';
foreach ($recaptcha_array as $rcp_key => $rcp_data) {
$el_id = 'ccf_recaptcha_'.$module_id.'_'.$rcp_data['id'];
$element_id = 'google-recaptcha_'.$module_id.'_'.$rcp_data['id'];
$rcp_verify_functions .= '
var verify_callback_'.$el_id.' = function (response) {
document.getElementById("hidden_'.$el_id.'").value = "1";
var field_box_class = document.getElementById("'.$element_id.'").className;
field_box_class = field_box_class.replace(\' creativecontactform_error\',\'\');
document.getElementById("'.$element_id.'").className = field_box_class;
};';
$rcp_onload_functions .= 'var ccf_rcp_'.$el_id.' = grecaptcha.render(\''.$el_id.'\', {
\'sitekey\' : \''.$rcp_data["recaptcha_site_key"].'\',
\'theme\' : \''.$rcp_data["recaptcha_theme"].'\',
\'type\' : \''.$rcp_data["recaptcha_type"].'\',
\'callback\' : verify_callback_'.$el_id.'
});document.getElementById("'.$element_id.'").setAttribute("rcp_id", ccf_rcp_'.$el_id.');';
}
$rcp_js = '<script class="ccf_recaptcha_script" type="text/javascript">
'.$rcp_verify_functions.'
var ccf_recaptcha_onload = function() {
'.$rcp_onload_functions.'
}
</script>
';
echo $rcp_js;
echo '<script type="text/javascript">setTimeout(function() {try{ccf_recaptcha_onload();}catch(err){}},1200)</script>';
}
}
//END google recaptcha javascript
}
else {
echo 'Creative Contact Form: There is nothing to show!';
}
?>
<?php
return $render_html = ob_get_clean();
}
}