| 1 |
<?php |
| 2 |
function rednao_smart_forms_load_form($title,$form_id,$returnComponent) |
| 3 |
{ |
| 4 |
$options=get_transient("rednao_smart_forms_$form_id"); |
| 5 |
$options=false; |
| 6 |
if($options==false) |
| 7 |
{ |
| 8 |
global $wpdb; |
| 9 |
$result=$wpdb->get_results($wpdb->prepare("select form_id,element_options,form_options,client_form_options from ".SMART_FORMS_TABLE_NAME." where form_id=%d",$form_id)); |
| 10 |
if(count($result)>0) |
| 11 |
{ |
| 12 |
$result=$result[0]; |
| 13 |
$options=array( 'elements'=>$result->element_options, |
| 14 |
'options'=>$result->form_options, |
| 15 |
'form_id'=>$result->form_id, |
| 16 |
'client_form_options'=>$result->client_form_options |
| 17 |
); |
| 18 |
|
| 19 |
set_transient("rednao_smart_forms_$form_id",$options); |
| 20 |
} |
| 21 |
|
| 22 |
} |
| 23 |
wp_enqueue_script('jquery'); |
| 24 |
wp_enqueue_script('smart-forms-event-manager',SMART_FORMS_DIR_URL.'js/formBuilder/eventmanager.js',array('isolated-slider')); |
| 25 |
wp_enqueue_script('isolated-slider',plugin_dir_url(__FILE__).'js/rednao-isolated-jq.js'); |
| 26 |
wp_enqueue_script('smart-forms-generator',plugin_dir_url(__FILE__).'js/form-generator.js',array('isolated-slider',)); |
| 27 |
wp_enqueue_script('smart-forms-form-elements',plugin_dir_url(__FILE__).'js/formBuilder/formelements.js',array('smart-forms-generator')); |
| 28 |
wp_enqueue_script('smart-forms-formula',SMART_FORMS_DIR_URL.'js/formBuilder/formula/formula.js',array('isolated-slider','smart-forms-event-manager')); |
| 29 |
wp_enqueue_script('smart-forms-formula-manager',SMART_FORMS_DIR_URL.'js/formBuilder/formula/formulamanager.js',array('isolated-slider','smart-forms-event-manager','smart-forms-formula')); |
| 30 |
wp_enqueue_script('smart-forms-elements-manipulators',SMART_FORMS_DIR_URL.'js/formBuilder/properties/manipulators.js',array('isolated-slider')); |
| 31 |
|
| 32 |
wp_enqueue_style('smart-forms-Slider',SMART_FORMS_DIR_URL.'css/smartFormsSlider/jquery-ui-1.10.2.custom.min.css'); |
| 33 |
wp_enqueue_style('smart-forms-custom-elements',plugin_dir_url(__FILE__).'css/formBuilder/custom.css'); |
| 34 |
echo "<script type=\"text/javascript\">var ajaxurl = '".admin_url('admin-ajax.php')."';</script>"; |
| 35 |
$random=rand(); |
| 36 |
|
| 37 |
if($returnComponent==false) |
| 38 |
{ |
| 39 |
if($options==null) |
| 40 |
return; |
| 41 |
|
| 42 |
if($title) |
| 43 |
echo "<div class='widget-wrapper'><h3 class='widgettitle'>$title</h3>" |
| 44 |
|
| 45 |
?> |
| 46 |
|
| 47 |
<div id="formContainer<?php echo $random?>" class='rednaoFormContainer'></div> |
| 48 |
|
| 49 |
<script> |
| 50 |
var smartFormsPath="<?php echo plugin_dir_url(__FILE__)?>"; |
| 51 |
|
| 52 |
if(!window.smartFormsItemsToLoad) |
| 53 |
window.smartFormsItemsToLoad=new Array();; |
| 54 |
|
| 55 |
window.smartFormsItemsToLoad.push({'form_id':<?php echo $options['form_id']?>, 'elements':<?php echo $options['elements']?>,'client_form_options':<?php echo $options['client_form_options']?>,'container':'formContainer<?php echo $random?>'}); |
| 56 |
|
| 57 |
</script> |
| 58 |
<?php |
| 59 |
if($title) |
| 60 |
echo "</div>"; |
| 61 |
|
| 62 |
}else{ |
| 63 |
if($options==null) |
| 64 |
return ""; |
| 65 |
return "<div id='formContainer$random' class='rednaoFormContainer'></div> |
| 66 |
<script> |
| 67 |
var smartDonationsRootPath=\"".plugin_dir_url(__FILE__)."\"; |
| 68 |
if(!window.smartFormsItemsToLoad) |
| 69 |
window.smartFormsItemsToLoad=new Array();; |
| 70 |
window.smartFormsItemsToLoad.push({ 'form_id':".$options['form_id'].", 'elements':".$options['elements'].",'client_form_options':".$options['client_form_options'].",'container':'formContainer$random'}); |
| 71 |
</script> |
| 72 |
"; |
| 73 |
} |
| 74 |
} |