Caldera Forms – More Than Contact Forms - Version 1.1.0

Version Description

(* August, 2014) =

Download this release

Release Info

Developer Desertsnowman
Plugin Icon 128x128 Caldera Forms – More Than Contact Forms
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.91 to 1.1.0

assets/css/admin.css CHANGED
@@ -448,6 +448,7 @@ textarea.block-input.field-config {
448
  }
449
  .block-input.field-config {
450
  width: 100%;
 
451
  }
452
  .field-config.field-checkbox {
453
  margin-top: 4px;
@@ -469,7 +470,7 @@ h3.caldera-editor-field-title {
469
  color: #3f3f3f;
470
  }
471
  .caldera-editor-body.caldera-config-editor-panel.caldera-config-has-side {
472
- margin-right: 370px;
473
  }
474
  .caldera-config-editor-main-panel {
475
  float: left;
@@ -477,22 +478,20 @@ h3.caldera-editor-field-title {
477
  }
478
  .caldera-config-editor-side-panel {
479
  bottom: 30px;
480
- overflow: auto;
481
  padding-right: 15px;
482
  position: fixed;
483
  right: 0;
484
  top: 172px;
485
- width: 350px;
486
  }
487
  .caldera-config-editor-panel-group {
488
  border-bottom: 1px solid #DFDFDF;
489
  margin-bottom: 30px;
490
  padding-bottom: 20px;
491
  }
492
- .add-new-h2.caldera-add-page,
493
- .add-new-h2.caldera-add-row,
494
- .add-new-h2.caldera-add-row:active,
495
- .add-new-h2.caldera-add-page:active {
496
  font-size: 10px;
497
  margin: 4px 10px 4px 10px;
498
  }
@@ -529,6 +528,50 @@ h3.caldera-editor-field-title {
529
  display: inline-block;
530
  margin-bottom: 12px;
531
  width: 100%;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
532
  }
533
  .caldera-config-field-break {
534
  clear: both;
@@ -1494,3 +1537,9 @@ input.disabled-input {
1494
  .form-panel .affix {
1495
  position: fixed;
1496
  }
 
 
 
 
 
 
448
  }
449
  .block-input.field-config {
450
  width: 100%;
451
+ line-height: 20px;
452
  }
453
  .field-config.field-checkbox {
454
  margin-top: 4px;
470
  color: #3f3f3f;
471
  }
472
  .caldera-editor-body.caldera-config-editor-panel.caldera-config-has-side {
473
+ margin-right: 420px;
474
  }
475
  .caldera-config-editor-main-panel {
476
  float: left;
478
  }
479
  .caldera-config-editor-side-panel {
480
  bottom: 30px;
481
+ overflow-y: scroll;
482
  padding-right: 15px;
483
  position: fixed;
484
  right: 0;
485
  top: 172px;
486
+ width: 400px;
487
  }
488
  .caldera-config-editor-panel-group {
489
  border-bottom: 1px solid #DFDFDF;
490
  margin-bottom: 30px;
491
  padding-bottom: 20px;
492
  }
493
+ .caldera-config-editor-panel .add-new-h2 ,
494
+ .caldera-config-editor-panel .add-new-h2:active{
 
 
495
  font-size: 10px;
496
  margin: 4px 10px 4px 10px;
497
  }
528
  display: inline-block;
529
  margin-bottom: 12px;
530
  width: 100%;
531
+ position: relative;
532
+ }
533
+ .magic-tags-autocomplete {
534
+ background-color: #fff;
535
+ border: 1px solid #ddd;
536
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07);
537
+ box-sizing: border-box;
538
+ margin: 1px;
539
+ max-height: 160px;
540
+ overflow: auto;
541
+ padding: 0;
542
+ position: absolute;
543
+ top: auto;
544
+ width: 100%;
545
+ z-index: 999999;
546
+ }
547
+ .toggle_option_row .magic-tags-autocomplete {
548
+ width: 279px;
549
+ }
550
+ .magic-tags-autocomplete > ul {
551
+ margin: 0;
552
+ padding: 0;
553
+ }
554
+ .magic-tags-autocomplete > ul > li {
555
+ border-bottom: 1px solid #dfdfdf;
556
+ margin: 0;
557
+ padding: 5px 6px 6px 12px;
558
+ white-space: nowrap;
559
+ }
560
+ .magic-tags-autocomplete > ul > li.header {
561
+ border-bottom: 1px solid #dfdfdf;
562
+ font-style: italic;
563
+ font-weight: bold;
564
+ margin: 0;
565
+ padding: 5px 6px 6px;
566
+ }
567
+ .magic-tags-autocomplete > ul > li.tag {
568
+ cursor: pointer;
569
+ }
570
+ .magic-tags-autocomplete > ul > li.tag:hover {
571
+ background: none repeat scroll 0 0 #f5f5f5;
572
+ }
573
+ .magic-tags-autocomplete > ul > li.tag > strong {
574
+ color: #df2020;
575
  }
576
  .caldera-config-field-break {
577
  clear: both;
1537
  .form-panel .affix {
1538
  position: fixed;
1539
  }
1540
+ #extend_cf_baldrickModalBody h2 {
1541
+ font-size: 1.1em;
1542
+ margin: 0;
1543
+ padding: 4px 6px 6px;
1544
+ color: inherit;
1545
+ }
assets/css/caldera-form.css CHANGED
@@ -25,7 +25,6 @@
25
  box-shadow: none;
26
  -webkit-transition: none;
27
  transition: none;
28
- -webkit-appearance: none;
29
  }
30
  .caldera-grid .form-control:hover {
31
  border: 1px solid #b9b9b9;
@@ -1176,7 +1175,7 @@
1176
 
1177
  .caldera-grid .breadcrumb {
1178
  padding: 6px 12px;
1179
- margin-bottom: 20px;
1180
  list-style: none;
1181
  background-color: #f5f5f5;
1182
  border-radius: 4px;
25
  box-shadow: none;
26
  -webkit-transition: none;
27
  transition: none;
 
28
  }
29
  .caldera-grid .form-control:hover {
30
  border: 1px solid #b9b9b9;
1175
 
1176
  .caldera-grid .breadcrumb {
1177
  padding: 6px 12px;
1178
+ margin: 0 0 20px;
1179
  list-style: none;
1180
  background-color: #f5f5f5;
1181
  border-radius: 4px;
assets/css/editor-grid.css CHANGED
@@ -132,13 +132,15 @@
132
  padding: 12px 0;
133
  position: relative;
134
  }
135
- .column-fieldinsert .dashicons.dashicons-plus-alt {
 
136
  background: none repeat scroll 0 0 #EFEFEF;
137
  color: #6C6C6C;
138
  font-size: 13px;
139
  margin-top: -3px;
140
  padding: 2px;
141
  }
 
142
  .column-fieldinsert.column-tools {
143
  bottom: -10px;
144
  left: 50%;
@@ -308,14 +310,39 @@
308
  .caldera-condition-line:first-child .caldera-condition-line-label{
309
  display: none;
310
  }
 
 
 
 
 
311
  .caldera-editor-field-config-wrapper .caldera-conditional-value-field {
312
- margin: 12px;
313
  max-width: 263px !important;
314
  width: 263px !important;
315
  }
316
  .caldera-editor-field-config-wrapper .button.remove-conditional-line.pull-right {
317
  margin-top: -12px;
318
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  .settings-panel.settings-core{ display: block;}
320
 
321
  .layout-new-form-field .drag-handle,
132
  padding: 12px 0;
133
  position: relative;
134
  }
135
+ .column-fieldinsert .dashicons.dashicons-admin-generic,
136
+ .column-fieldinsert .dashicons.dashicons-plus-alt {
137
  background: none repeat scroll 0 0 #EFEFEF;
138
  color: #6C6C6C;
139
  font-size: 13px;
140
  margin-top: -3px;
141
  padding: 2px;
142
  }
143
+ .column-fieldinsert.column-tools ,
144
  .column-fieldinsert.column-tools {
145
  bottom: -10px;
146
  left: 50%;
310
  .caldera-condition-line:first-child .caldera-condition-line-label{
311
  display: none;
312
  }
313
+ .caldera-editor-field-config-wrapper .caldera-conditional-field-value {
314
+ display: inline-block;
315
+ margin: 12px 12px 0 0;
316
+ position: relative;
317
+ }
318
  .caldera-editor-field-config-wrapper .caldera-conditional-value-field {
 
319
  max-width: 263px !important;
320
  width: 263px !important;
321
  }
322
  .caldera-editor-field-config-wrapper .button.remove-conditional-line.pull-right {
323
  margin-top: -12px;
324
  }
325
+ .icn-code.magic-tag-init {
326
+ background: none repeat scroll 0 0 #f9f9f9;
327
+ border-bottom: 1px solid #ddd;
328
+ border-left: 1px solid #ddd;
329
+ cursor: pointer;
330
+ opacity: 0.5;
331
+ padding: 7px 6px 6px;
332
+ position: absolute;
333
+ right: 1px;
334
+ top: 2px;
335
+ }
336
+ .icn-code.magic-tag-init:hover {
337
+ color: #404040;
338
+ opacity: 1;
339
+ }
340
+ .field-config.magic-tag-enabled {
341
+ padding-right: 26px;
342
+ }
343
+ textarea.field-config.magic-tag-enabled {
344
+ resize: vertical;
345
+ }
346
  .settings-panel.settings-core{ display: block;}
347
 
348
  .layout-new-form-field .drag-handle,
assets/css/modals.css CHANGED
@@ -26,9 +26,17 @@
26
  width: 500px;
27
  z-index: 100105;
28
  }
 
 
 
 
 
 
 
29
  .caldera-modal-title {
30
  border-bottom: 1px solid #EFEFEF;
31
  }
 
32
  .caldera-modal-closer {
33
  color: #808080;
34
  float: right;
@@ -36,6 +44,17 @@
36
  padding: 12px;
37
  text-decoration: none;
38
  }
 
 
 
 
 
 
 
 
 
 
 
39
  .caldera-modal-title > h3 {
40
  font-weight: 400;
41
  margin: 0;
@@ -54,7 +73,15 @@
54
  padding: 12px 12px 8.9px;
55
  position: absolute;
56
  right: 0;
57
- top: 43px;
 
 
 
 
 
 
 
 
58
  }
59
  .caldera-modal-body .import-warning{
60
  margin: 0;
@@ -238,4 +265,18 @@ input.disabled-input {
238
 
239
  .modal-tab-panel {
240
  margin-left: 150px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  }
26
  width: 500px;
27
  z-index: 100105;
28
  }
29
+ .caldera-modal-wrap.caldera-front-modal-wrap{
30
+ position: absolute;
31
+ bottom: auto;
32
+ width: 600px;
33
+ margin-left: -300px;
34
+ margin-top: 0;
35
+ }
36
  .caldera-modal-title {
37
  border-bottom: 1px solid #EFEFEF;
38
  }
39
+
40
  .caldera-modal-closer {
41
  color: #808080;
42
  float: right;
44
  padding: 12px;
45
  text-decoration: none;
46
  }
47
+ .caldera-modal-closer.caldera-front-modal-closer{
48
+ position: absolute;
49
+ right: 0;
50
+ text-decoration: none;
51
+ color: inherit;
52
+ }
53
+ .caldera-modal-closer.caldera-front-modal-closer:hover,
54
+ .caldera-modal-closer.caldera-front-modal-closer:active{
55
+ text-decoration: none;
56
+ color: inherit;
57
+ }
58
  .caldera-modal-title > h3 {
59
  font-weight: 400;
60
  margin: 0;
73
  padding: 12px 12px 8.9px;
74
  position: absolute;
75
  right: 0;
76
+ top: 43px;
77
+ }
78
+ #extend_cf_baldrickModalBody{
79
+ overflow: auto;
80
+ }
81
+ .caldera-modal-body.caldera-front-modal-body {
82
+ bottom: auto;
83
+ position: relative;
84
+ top: auto;
85
  }
86
  .caldera-modal-body .import-warning{
87
  margin: 0;
265
 
266
  .modal-tab-panel {
267
  margin-left: 150px;
268
+ }
269
+
270
+ @media (max-width: 600px) {
271
+ /* Small Screens */
272
+ .caldera-modal-wrap.caldera-front-modal-wrap{
273
+ bottom: 0;
274
+ display: block;
275
+ left: 0;
276
+ margin: 0 !important;
277
+ overflow: auto;
278
+ padding: 0 !important;
279
+ top: 0;
280
+ width: 100% !important;
281
+ }
282
  }
assets/js/admin.js CHANGED
@@ -1,7 +1,7 @@
1
  var baldrickTriggers, loop_loader;
2
 
3
  jQuery(function($){
4
-
5
  // admin stuff!
6
  // Baldrick Bindings
7
  baldrickTriggers = function(){
@@ -42,7 +42,6 @@ jQuery(function($){
42
 
43
  panels.hide();
44
  panel.show();
45
-
46
  });
47
 
48
  // Profile Repeatable Group Remove
@@ -73,4 +72,4 @@ jQuery(function($){
73
 
74
 
75
 
76
- });
1
  var baldrickTriggers, loop_loader;
2
 
3
  jQuery(function($){
4
+
5
  // admin stuff!
6
  // Baldrick Bindings
7
  baldrickTriggers = function(){
42
 
43
  panels.hide();
44
  panel.show();
 
45
  });
46
 
47
  // Profile Repeatable Group Remove
72
 
73
 
74
 
75
+ });
assets/js/edit.js CHANGED
@@ -182,7 +182,6 @@ jQuery(function($){
182
  // seup options
183
  parent.find('.toggle_show_values').trigger('change');
184
 
185
-
186
  }
187
 
188
  function build_field_preview(id){
@@ -760,14 +759,14 @@ jQuery(function($){
760
  lineid = field.data('line'),
761
  target = $('#' + lineid + "_value"),
762
  curval = target.find('.caldera-conditional-value-field').first();
763
- //console.log(lineid + "_value");
764
 
765
  // check if a value is present
766
 
767
  if(curval.length){
768
  if(curval.val().length){
769
  target.data('value', curval.val());
770
- console.log(curval.val());
771
  }
772
  }
773
 
@@ -782,7 +781,6 @@ jQuery(function($){
782
 
783
  if(target.data('value')){
784
  if(target.data('value').toString() === value){
785
- console.log('YES');
786
  sel = ' selected="selected"';
787
  }
788
  }
@@ -794,7 +792,7 @@ jQuery(function($){
794
 
795
  }else{
796
 
797
- out = '<input name="' + name + '[value]" type="text" class="caldera-conditional-value-field" value="' + (target.data('value') ? target.data('value') : '') + '" style="max-width: 165px;">';
798
  }
799
 
800
 
@@ -843,11 +841,11 @@ jQuery(function($){
843
  field_lables = wrap.find('.caldera-config-group-option-labels');
844
 
845
  if(!clicked.prop('checked')){
846
- values.prop('disabled', true).hide();
847
  lables.css('width', 245);
848
  field_lables.hide();
849
  }else{
850
- values.prop('disabled', false).show();
851
  lables.css('width', '');
852
  field_lables.show();
853
  }
@@ -855,5 +853,215 @@ jQuery(function($){
855
  lables.trigger('toggle.values');
856
 
857
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
858
  });//
859
 
182
  // seup options
183
  parent.find('.toggle_show_values').trigger('change');
184
 
 
185
  }
186
 
187
  function build_field_preview(id){
759
  lineid = field.data('line'),
760
  target = $('#' + lineid + "_value"),
761
  curval = target.find('.caldera-conditional-value-field').first();
762
+
763
 
764
  // check if a value is present
765
 
766
  if(curval.length){
767
  if(curval.val().length){
768
  target.data('value', curval.val());
769
+
770
  }
771
  }
772
 
781
 
782
  if(target.data('value')){
783
  if(target.data('value').toString() === value){
 
784
  sel = ' selected="selected"';
785
  }
786
  }
792
 
793
  }else{
794
 
795
+ out = '<input name="' + name + '[value]" type="text" class="caldera-conditional-value-field magic-tag-enabled" value="' + (target.data('value') ? target.data('value') : '') + '" style="max-width: 165px;">';
796
  }
797
 
798
 
841
  field_lables = wrap.find('.caldera-config-group-option-labels');
842
 
843
  if(!clicked.prop('checked')){
844
+ values.prop('disabled', true).hide().parent().hide();
845
  lables.css('width', 245);
846
  field_lables.hide();
847
  }else{
848
+ values.prop('disabled', false).show().parent().show();
849
  lables.css('width', '');
850
  field_lables.show();
851
  }
853
  lables.trigger('toggle.values');
854
 
855
  });
856
+
857
+ // autopopulate
858
+ $('.caldera-editor-body').on('change', '.auto-populate-type', function(){
859
+ $(this).closest('.wrapper-instance-pane').find('.auto-populate-options').trigger('change');
860
+ });
861
+ $('.caldera-editor-body').on('change', '.auto-populate-options', function(){
862
+ var clicked = $(this),
863
+ wrap = clicked.closest('.wrapper-instance-pane'),
864
+ manual = wrap.find('.caldera-config-group-toggle-options'),
865
+ autotype_wrap = wrap.find('.caldera-config-group-auto-options'),
866
+ autotype = autotype_wrap.find('.auto-populate-type');
867
+
868
+ autotype_wrap.find('.auto-populate-type-panel').hide();
869
+
870
+ if(clicked.prop('checked')){
871
+ manual.hide();
872
+ autotype_wrap.show();
873
+ }else{
874
+ manual.show();
875
+ autotype_wrap.hide();
876
+ }
877
+
878
+ autotype_wrap.find('.caldera-config-group-auto-' + autotype.val()).show();
879
+
880
+ });
881
+
882
+
883
+ $('body').on('click', '.magic-tag-init', function(e){
884
+ var clicked = $(this),
885
+ input = clicked.prev();
886
+
887
+ input.focus().trigger('init.magic');
888
+
889
+ });
890
+ // show magic tag autocompletes
891
+ $('body').on('keyup blur focus select click init.magic', '.magic-tag-enabled', function(e){
892
+ var input = $(this),
893
+ wrap = input.parent(),
894
+ fieldtype = ( wrap.closest('.wrapper-instance-pane').find('.caldera-select-field-type').val() ? wrap.closest('.wrapper-instance-pane').find('.caldera-select-field-type').val() : 'hidden' ),
895
+ tags = wrap.find('.magic-tags-autocomplete'),
896
+ list = tags.find('ul'),
897
+ //basevalue = this.value.substr( this.selectionEnd ),
898
+ stream = this.value,//.substr(0, this.selectionStart ),
899
+ tag = [],
900
+ type_instances = [],
901
+ current_tag = '',
902
+ start = this.selectionStart,
903
+ end = this.selectionEnd;
904
+
905
+ //reset typed tag
906
+ input.data('tag','');
907
+ if(this.selectionEnd > this.selectionStart){
908
+ current_tag = this.value.substr(this.selectionStart, ( this.selectionEnd - this.selectionStart) );
909
+ }else{
910
+
911
+ if( ( e.type === 'select' || e.type === 'keyup' ) && ( e.which !== 40 && e.which !== 38 && e.which !== 39 && e.which !== 37 ) ){
912
+
913
+ for( start=this.selectionStart; start > 0; start--){
914
+
915
+ var ch = stream.substr(start-1,1);
916
+
917
+ if(ch === ' ' || ch === "\n" || ( ( ch === '%' || ch === '}' ) && this.selectionStart === start ) ){
918
+ break;
919
+ }
920
+ }
921
+ for( end=this.selectionStart; end < stream.length; end++){
922
+
923
+ var ch = stream.substr(end,1);
924
+
925
+ if(ch === ' ' || ch === "\n" || ( ( ch === '%' || ch === '{' ) && this.selectionStart === end ) ){
926
+ break;
927
+ }
928
+ }
929
+ //if(end > this.selectionEnd){
930
+ current_tag = stream.substr(start, ( end - start ) );
931
+ }
932
+ //}
933
+ }
934
+
935
+ // start matching
936
+ if( e.type !== 'focusout' ){
937
+
938
+ if( e.type !== 'init' && current_tag.length < 3 ){
939
+ if(tags.length){
940
+ tags.remove();
941
+ }
942
+ return;
943
+ }
944
+ if(!tags.length){
945
+ tags = $('<div class="magic-tags-autocomplete"></div>');
946
+ list = $('<ul></ul>');
947
+ list.appendTo(tags);
948
+ tags.insertAfter(input);
949
+ }
950
+
951
+ //populate
952
+ list.empty();
953
+ // compatibility
954
+ var tagtypes = 'system';
955
+ var is_static = false;
956
+ if(fieldtype === 'hidden' || fieldtype === 'dropdown' || fieldtype === 'radio' || fieldtype === 'toggle_switch' || fieldtype === 'checkbox'){
957
+ is_static = true;
958
+ fieldtype = 'text';
959
+ tagtypes = 'all';
960
+ }else if(fieldtype === 'paragraph' || fieldtype === 'html'){
961
+ fieldtype = 'text';
962
+ }
963
+ // type set
964
+ if(input.data('type')){
965
+ fieldtype = input.data('type');
966
+ }
967
+ // search em!
968
+ fieldtype = fieldtype.split(',');
969
+ fieldtype.push('vars');
970
+ for( var ft = 0; ft < fieldtype.length; ft++){
971
+ for( var tp in system_values ){
972
+ if(typeof system_values[tp].tags[fieldtype[ft]] === 'undefined'){
973
+ continue;
974
+ }
975
+
976
+ type_instances = [tp];
977
+ if(tp !== 'system' && tp !== 'variable' && tp !== 'field'){
978
+ var type_instance_confs = jQuery(".processor-" + tp),
979
+ wrapper = input.closest('.caldera-editor-processor-config-wrapper'),
980
+ wrapper_id = wrapper.prop('id');
981
+ type_instances = [];
982
+ // processor based - orderd
983
+ for(var c = 0; c<type_instance_confs.length; c++){
984
+ if(!wrapper.length && is_static === true ){
985
+ // static non processor - can be used
986
+ type_instances.push(type_instance_confs[c].id);
987
+ }else{
988
+ if(wrapper_id === type_instance_confs[c].id){
989
+ continue;
990
+ }
991
+
992
+ // check index order is valid
993
+ if(jQuery('li.'+type_instance_confs[c].id).index() < jQuery('li.'+wrapper_id).index()){
994
+ type_instances.push(type_instance_confs[c].id);
995
+ }
996
+ }
997
+
998
+ }
999
+
1000
+ }
1001
+ // all instances of tag
1002
+ for( var instance = 0; instance < type_instances.length; instance++){
1003
+ if(tagtypes === 'all' || tagtypes === tp || tp === 'variable'){
1004
+
1005
+ var heading = $('<li class="header">' + system_values[tp].type + ( instance > 0 ? ' ['+(instance+1)+']' : '' ) +'</li>'),
1006
+ matches = 0;
1007
+ heading.appendTo(list);
1008
+
1009
+ for( var i = 0; i < system_values[tp].tags[fieldtype[ft]].length; i++){
1010
+
1011
+ if(input.data('parent')){
1012
+ if('variable:'+input.data('parent') === system_values[tp].tags[fieldtype[ft]][i]){
1013
+ continue;
1014
+ }
1015
+ }
1016
+
1017
+ var this_tag = system_values[tp].wrap[0] + system_values[tp].tags[fieldtype[ft]][i]+system_values[tp].wrap[1];
1018
+ if(type_instances[instance] !== tp && type_instances.length > 1){
1019
+ this_tag = system_values[tp].wrap[0] + system_values[tp].tags[fieldtype[ft]][i]+':'+type_instances[instance]+system_values[tp].wrap[1];
1020
+ }
1021
+ if( this_tag.indexOf(current_tag) >= 0 || e.type === 'init'){
1022
+
1023
+ matches += 1;
1024
+ var view_tag = this_tag.replace(current_tag, '<strong>' + current_tag + '</strong>');
1025
+
1026
+ var linetag = $('<li class="tag" data-tag="'+this_tag+'">' + view_tag + '</li>');
1027
+
1028
+
1029
+ linetag.on('click', function(){
1030
+ var selected = $(this).data('tag');
1031
+
1032
+
1033
+ input.val( stream.substr(0, start ) + selected + stream.substr( end ) ).trigger('change').focus();
1034
+ input[0].selectionStart = start + selected.length - ( selected.indexOf('*') > 0 ? 2 : 0 );
1035
+ input[0].selectionEnd = start + selected.length - ( selected.indexOf('*') > 0 ? 1 : 0 );
1036
+
1037
+ });
1038
+
1039
+ linetag.appendTo(list);
1040
+ }
1041
+ }
1042
+ if(matches === 0){
1043
+ heading.remove();
1044
+ }
1045
+ }
1046
+ }
1047
+ }
1048
+ }
1049
+ }
1050
+ // count results found
1051
+ if(!list.children().length){
1052
+ tags.remove();
1053
+ }
1054
+
1055
+ // focus out - remove
1056
+ if(e.type === 'focusout'){
1057
+ setTimeout(function(){
1058
+
1059
+ tags.remove();
1060
+ }, 200);
1061
+ }
1062
+
1063
+
1064
+ })
1065
+
1066
  });//
1067
 
assets/js/frontend-script-init.js CHANGED
@@ -8,7 +8,17 @@
8
  }
9
  });
10
  });
11
-
 
 
 
 
 
 
 
 
 
 
12
  // Page navigation
13
  $(document).on('click', '[data-page]', function(e){
14
  var clicked = $(this),
@@ -23,7 +33,7 @@
23
  if(breadcrumb){
24
  breadcrumb.find('li.active').removeClass('active');
25
  }
26
- next = $('.caldera-form-page[data-formpage="'+ ( page + 1 ) +'"]');
27
  if(next.length){
28
  page_box.hide();
29
  next.show();
@@ -35,7 +45,7 @@
35
  if(breadcrumb){
36
  breadcrumb.find('li.active').removeClass('active');
37
  }
38
- prev = $('.caldera-form-page[data-formpage="'+ ( page - 1 ) +'"]');
39
  if(prev.length){
40
  page_box.hide();
41
  prev.show();
@@ -48,7 +58,7 @@
48
  e.preventDefault();
49
  clicked.closest('.breadcrumb').find('li.active').removeClass('active');
50
  $('#' + clicked.data('pagenav') + ' .caldera-form-page').hide();
51
- $('.caldera-form-page[data-formpage="'+ ( clicked.data('page') ) +'"]').show();
52
  clicked.parent().addClass('active');
53
  }
54
 
@@ -63,7 +73,7 @@
63
  $(v).find('a[data-pagenav]').each(function(i,e){
64
  var tab = $(e),
65
  form = tab.data('pagenav'),
66
- page = $('.caldera-form-page[data-formpage="' + tab.data('page') + '"]');
67
 
68
  if(page.find('.has-error').length){
69
  tab.parent().addClass('error');
8
  }
9
  });
10
  });
11
+ // modals activation
12
+ $(document).on('click', '.cf_modal_button', function(e){
13
+ e.preventDefault();
14
+ var clicked = $(this);
15
+ $(clicked.attr('href')).show();
16
+ });
17
+ $(document).on('click', '.caldera-front-modal-closer', function(e){
18
+ e.preventDefault();
19
+ var clicked = $(this);
20
+ clicked.closest('.caldera-front-modal-container').hide();
21
+ });
22
  // Page navigation
23
  $(document).on('click', '[data-page]', function(e){
24
  var clicked = $(this),
33
  if(breadcrumb){
34
  breadcrumb.find('li.active').removeClass('active');
35
  }
36
+ next = form.find('.caldera-form-page[data-formpage="'+ ( page + 1 ) +'"]');
37
  if(next.length){
38
  page_box.hide();
39
  next.show();
45
  if(breadcrumb){
46
  breadcrumb.find('li.active').removeClass('active');
47
  }
48
+ prev = form.find('.caldera-form-page[data-formpage="'+ ( page - 1 ) +'"]');
49
  if(prev.length){
50
  page_box.hide();
51
  prev.show();
58
  e.preventDefault();
59
  clicked.closest('.breadcrumb').find('li.active').removeClass('active');
60
  $('#' + clicked.data('pagenav') + ' .caldera-form-page').hide();
61
+ $('#' + clicked.data('pagenav') + ' .caldera-form-page[data-formpage="'+ ( clicked.data('page') ) +'"]').show();
62
  clicked.parent().addClass('active');
63
  }
64
 
73
  $(v).find('a[data-pagenav]').each(function(i,e){
74
  var tab = $(e),
75
  form = tab.data('pagenav'),
76
+ page = $('#'+ form +' .caldera-form-page[data-formpage="' + tab.data('page') + '"]');
77
 
78
  if(page.find('.has-error').length){
79
  tab.parent().addClass('error');
assets/js/handlebars.js CHANGED
@@ -2744,3 +2744,31 @@ var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, _
2744
 
2745
  return __module0__;
2746
  })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2744
 
2745
  return __module0__;
2746
  })();
2747
+
2748
+
2749
+ /* custom helpers */
2750
+ Handlebars.registerHelper("is_single", function(value, options) {
2751
+ if(Object.keys(value).length !== 1){
2752
+ return false;
2753
+ }else{
2754
+ return options.fn(this);
2755
+ }
2756
+ });
2757
+ Handlebars.registerHelper("script", function(options) {
2758
+ if(options.hash.src){
2759
+ return '<script type="text/javascript" src="' + options.fn(this) + '"></script>';
2760
+ }else{
2761
+ return '<script type="text/javascript">' + options.fn(this) + '</script>';
2762
+ }
2763
+ });
2764
+ Handlebars.registerHelper("is", function(value, options) {
2765
+
2766
+ if(options.hash.value === '@key'){
2767
+ options.hash.value = options.data.key;
2768
+ }
2769
+ if(options.hash.value === value){
2770
+ return options.fn(this);
2771
+ }else{
2772
+ return false;
2773
+ }
2774
+ });
assets/js/layout-grid.js CHANGED
@@ -1,11 +1,41 @@
1
- var rebuild_field_binding, rebind_field_bindings, current_form_fields = {}, required_errors = {}, add_new_grid_page, add_page_grid;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  rebuild_field_binding = function(){
4
 
5
  var fields = jQuery('.caldera-editor-field-config-wrapper');
6
-
7
  // clear list
8
  current_form_fields = {};
 
 
 
 
 
 
 
 
9
 
10
  fields.each(function(fk,fv){
11
  var field_id = jQuery(fv).prop('id'),
@@ -13,6 +43,15 @@ rebuild_field_binding = function(){
13
  slug = jQuery('#' + field_id + '_slug').val(),
14
  type = jQuery('#' + field_id + '_type').val();
15
 
 
 
 
 
 
 
 
 
 
16
  current_form_fields[field_id] = {
17
  label: label,
18
  slug: slug,
@@ -20,13 +59,15 @@ rebuild_field_binding = function(){
20
  };
21
 
22
  });
23
-
24
  rebind_field_bindings();
25
 
26
  };
27
 
28
  rebind_field_bindings = function(){
29
 
 
 
 
30
  var bindings = jQuery('.caldera-field-bind'),
31
  type_instances,
32
  processor_li;
@@ -40,63 +81,69 @@ rebind_field_bindings = function(){
40
  count = 0,
41
  wrapper = field.closest('.caldera-editor-processor-config-wrapper'),
42
  wrapper_id = wrapper.prop('id'),
43
- valid;
44
 
45
  if(default_sel){
46
  current = default_sel;
47
  }
48
 
49
- field.empty();
 
50
 
51
- var optgroup = jQuery('<optgroup label="Fields">');
52
- for(var fid in current_form_fields){
53
- if(field.data('type')){
54
- if(field.data('type').split(',').indexOf(current_form_fields[fid].type) < 0){
55
- continue;
56
- }
57
 
58
- }
59
- optgroup.append('<option value="' + fid + '"' + ( current === fid ? 'selected="selected"' : '' ) + '>' + current_form_fields[fid].label + ' [' + current_form_fields[fid].slug + ']</option>');
60
- count += 1;
61
- }
62
- optgroup.appendTo(field);
63
- // system values
64
- if(count === 0){
65
- field.empty();
66
- }
67
-
68
- for(var type in system_values){
69
- type_instances = [];
70
-
71
- if(excludes){
72
- if( excludes.split(',').indexOf(type) >= 0 ){
73
- continue;
74
  }
 
 
75
  }
76
-
77
- if(type !== 'system' ){
78
- type_instance_confs = jQuery(".processor-" + type);
79
-
80
- for(var c = 0; c<type_instance_confs.length; c++){
81
- if(wrapper_id === type_instance_confs[c].id){
 
 
 
 
 
82
  continue;
83
  }
 
 
 
84
 
85
- type_instances.push(type_instance_confs[c].id);
86
- if(type_instance_confs.length > 1){
87
- if(processor_li = jQuery('li.'+type_instance_confs[c].id + ' .processor-line-number')){
88
- processor_li.html('[' + ( c + 1 ) + ']');
 
89
  }
90
- }
91
 
92
- }
93
- }else{
94
- type_instances.push('__system__');
95
- }
96
-
97
- if(field.data('type')){
98
 
99
- var types = field.data('type').split(',');
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  for(var t = 0; t<types.length; t++){
102
  if(system_values[type].tags[types[t]]){
@@ -105,8 +152,9 @@ rebind_field_bindings = function(){
105
 
106
  // check index order is valid
107
  if(jQuery('li.'+type_instances[instance]).index() > jQuery('li.'+wrapper_id).index() && type_instances[instance] !== '__system__'){
108
- //console.log('lower');
109
- valid = ' disabled="disabled"';
 
110
  }else{
111
  valid = '';
112
  }
@@ -139,64 +187,31 @@ rebind_field_bindings = function(){
139
 
140
  }
141
  }
142
- }else{
143
-
144
- if(system_values[type].tags.text){
145
-
146
- for( var instance = 0; instance < type_instances.length; instance++){
147
-
148
- // check index order is valid
149
- if(jQuery('li.'+type_instances[instance]).index() > jQuery('li.'+wrapper_id).index() && type_instances[instance] !== '__system__'){
150
- //console.log('lower');
151
- valid = ' disabled="disabled"';
152
- }else{
153
- valid = '';
154
- }
155
-
156
- var optgroup = jQuery('<optgroup label="' + system_values[type].type + ( type_instances[instance] !== '__system__' ? ' ' + ( jQuery('li.'+type_instances[instance]).find('.processor-line-number').html() ) : '' ) + '"' + valid + '>');
157
-
158
-
159
- for( var i = 0; i < system_values[type].tags.text.length; i++){
160
-
161
- var bind_value = system_values[type].tags.text[i];
162
- // update labels on multiple
163
- if(type_instances[instance] !== '__system__'){
164
- bind_value = bind_value.replace(type ,type_instances[instance]);
165
- }
166
-
167
- optgroup.append('<option value="{' + bind_value + '}"' + ( current === '{'+bind_value+'}' ? 'selected="selected"' : '' ) + valid + '>' + system_values[type].tags.text[i] + '</option>');
168
- count += 1;
169
-
170
- }
171
-
172
- if(optgroup.children().length){
173
- optgroup.appendTo(field);
174
- }
175
-
176
- }
177
-
178
- }
179
 
180
  }
181
-
182
- }
183
- if(count === 0){
184
- field.empty();
185
- if(field.data('type')){
186
- field.append('<option value="">No ' + field.data('type').split(',').join(' or ') + ' in form</option>').prop('disabled', true);
187
- var no_options = true;
 
188
  }
 
 
 
 
 
189
  }else{
190
- field.prop('disabled', false);
 
191
  }
192
-
193
- if(!field.hasClass('required') && typeof no_options === 'undefined'){
194
- field.prepend('<option value=""></option>');
195
- }
196
- field.val(current);
197
  });
198
 
199
  check_required_bindings();
 
 
200
  };
201
 
202
  function setup_field_type(obj){
@@ -224,15 +239,17 @@ function check_required_bindings(){
224
  required_errors = {};
225
 
226
  fields.each(function(k,v){
227
- if(!v.value.length){
228
- var field = jQuery(v),
229
- panel = field.closest('.caldera-config-editor-panel'),
230
- is_field = field.closest('.caldera-editor-field-config-wrapper'),
231
- is_process = field.closest('.caldera-editor-processor-config-wrapper');
232
 
 
233
  if(!required_errors[panel.prop('id')]){
234
  required_errors[panel.prop('id')] = 0;
235
  }
 
 
 
 
236
  if(is_field.length){
237
  jQuery('.layout-form-field[data-config="'+is_field.prop('id')+'"]').addClass('has-error');
238
  }
@@ -244,6 +261,33 @@ function check_required_bindings(){
244
 
245
  //tab.append('<span class="error-tag">' + required_errors[panel.prop('id')] + '</span>');
246
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  }
248
  });
249
 
@@ -456,13 +500,16 @@ jQuery(function($) {
456
  };
457
  buildSortables();
458
 
459
- $('#grid-pages-panel').on('click','.column-fieldinsert', function(e){
460
  //newfield-tool
461
  var target = $(this).closest('.column-container'),
462
  newfield = $('#newfield-tool').clone();
463
 
464
  insert_new_field(newfield, target);
465
 
 
 
 
466
  });
467
  /*
468
  $('#grid-pages-panel').on('click','.icon-filter', function(e){
@@ -686,6 +733,8 @@ jQuery(function($) {
686
  }
687
 
688
  $(document).trigger('show.' + panel.data('config'));
 
 
689
  });
690
  $('body').on('click', '.layout-modal-edit-closer,.layout-modal-save-action', function(e){
691
 
@@ -895,31 +944,7 @@ jQuery(function($) {
895
 
896
 
897
 
898
- Handlebars.registerHelper("is_single", function(value, options) {
899
- if(Object.keys(value).length !== 1){
900
- return false;
901
- }else{
902
- return options.fn(this);
903
- }
904
- });
905
- Handlebars.registerHelper("script", function(options) {
906
- if(options.hash.src){
907
- return '<script type="text/javascript" src="' + options.fn(this) + '"></script>';
908
- }else{
909
- return '<script type="text/javascript">' + options.fn(this) + '</script>';
910
- }
911
- });
912
- Handlebars.registerHelper("is", function(value, options) {
913
- //console.log(value);
914
- if(options.hash.value === '@key'){
915
- options.hash.value = options.data.key;
916
- }
917
- if(options.hash.value === value){
918
- return options.fn(this);
919
- }else{
920
- return false;
921
- }
922
- });
923
  Handlebars.registerHelper("_options_config", function() {
924
  //console.log(this);
925
  });
1
+ var rebuild_field_binding, rebind_field_bindings, current_form_fields = {}, required_errors = {}, add_new_grid_page, add_page_grid, init_magic_tags;
2
+
3
+ init_magic_tags = function(){
4
+ //init magic tags
5
+ var magicfields = jQuery('.magic-tag-enabled').not('.magic-tag-init-bound');
6
+
7
+ magicfields.each(function(k,v){
8
+ var input = jQuery(v);
9
+
10
+ /*if(input.hasClass('magic-tag-init-bound')){
11
+ return;
12
+ }*/
13
+ var magictag = jQuery('<span class="icn-code magic-tag-init"></span>'),
14
+ wrapper = jQuery('<span style="position:relative;display:inline-block; width:100%;"></span>');
15
+
16
+ if(input.is('input')){
17
+ magictag.css('borderBottom', 'none');
18
+ }
19
+ input.wrap(wrapper);
20
+ magictag.insertAfter(input);
21
+ input.addClass('magic-tag-init-bound');
22
+ });
23
+ }
24
 
25
  rebuild_field_binding = function(){
26
 
27
  var fields = jQuery('.caldera-editor-field-config-wrapper');
28
+
29
  // clear list
30
  current_form_fields = {};
31
+ // set object
32
+ system_values.field = {
33
+ tags : {
34
+ text : []
35
+ },
36
+ type : "Fields",
37
+ wrap : ['%','%']
38
+ };
39
 
40
  fields.each(function(fk,fv){
41
  var field_id = jQuery(fv).prop('id'),
43
  slug = jQuery('#' + field_id + '_slug').val(),
44
  type = jQuery('#' + field_id + '_type').val();
45
 
46
+
47
+ if(typeof system_values.field.tags[type] === 'undefined'){
48
+ system_values.field.tags[type] = [];
49
+ }
50
+ system_values.field.tags[type].push( slug );
51
+ if(type !== 'text'){
52
+ system_values.field.tags.text.push( slug );
53
+ }
54
+
55
  current_form_fields[field_id] = {
56
  label: label,
57
  slug: slug,
59
  };
60
 
61
  });
 
62
  rebind_field_bindings();
63
 
64
  };
65
 
66
  rebind_field_bindings = function(){
67
 
68
+ //check_required_bindings();
69
+
70
+ //return;
71
  var bindings = jQuery('.caldera-field-bind'),
72
  type_instances,
73
  processor_li;
81
  count = 0,
82
  wrapper = field.closest('.caldera-editor-processor-config-wrapper'),
83
  wrapper_id = wrapper.prop('id'),
84
+ valid = '';
85
 
86
  if(default_sel){
87
  current = default_sel;
88
  }
89
 
90
+ if(field.is('select')){
91
+ field.empty();
92
 
93
+ var optgroup = jQuery('<optgroup label="Fields">');
94
+ for(var fid in current_form_fields){
95
+ if(field.data('type')){
96
+ if(field.data('type').split(',').indexOf(current_form_fields[fid].type) < 0){
97
+ continue;
98
+ }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
+ optgroup.append('<option value="' + fid + '"' + ( current === fid ? 'selected="selected"' : '' ) + '>' + current_form_fields[fid].label + ' [' + current_form_fields[fid].slug + ']</option>');
102
+ count += 1;
103
  }
104
+ optgroup.appendTo(field);
105
+ // system values
106
+ if(count === 0){
107
+ field.empty();
108
+ }
109
+
110
+ for(var type in system_values){
111
+ type_instances = [];
112
+
113
+ if(excludes){
114
+ if( excludes.split(',').indexOf(type) >= 0 ){
115
  continue;
116
  }
117
+ }
118
+
119
+ if(type !== 'system' && type !== 'variable'){
120
 
121
+ var type_instance_confs = jQuery(".processor-" + type);
122
+
123
+ for(var c = 0; c<type_instance_confs.length; c++){
124
+ if(wrapper_id === type_instance_confs[c].id){
125
+ continue;
126
  }
 
127
 
128
+ type_instances.push(type_instance_confs[c].id);
129
+ if(type_instance_confs.length > 1){
130
+ if(processor_li = jQuery('li.'+type_instance_confs[c].id + ' .processor-line-number')){
131
+ processor_li.html('[' + ( c + 1 ) + ']');
132
+ }
133
+ }
134
 
135
+ }
136
+ }else{
137
+ type_instances.push('__system__');
138
+ }
139
+
140
+ var types = [];
141
+ if(field.data('type')){
142
+ types = field.data('type').split(',');
143
+ types.push('vars');
144
+ }else{
145
+ types = ['text','vars'];
146
+ }
147
 
148
  for(var t = 0; t<types.length; t++){
149
  if(system_values[type].tags[types[t]]){
152
 
153
  // check index order is valid
154
  if(jQuery('li.'+type_instances[instance]).index() > jQuery('li.'+wrapper_id).index() && type_instances[instance] !== '__system__'){
155
+ if( field.closest('.caldera-editor-processors-panel-wrap').length ){
156
+ valid = ' disabled="disabled"';
157
+ }
158
  }else{
159
  valid = '';
160
  }
187
 
188
  }
189
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
 
191
  }
192
+ if(count === 0){
193
+ field.empty();
194
+ if(field.data('type')){
195
+ field.append('<option value="">No ' + field.data('type').split(',').join(' or ') + ' in form</option>').prop('disabled', true);
196
+ var no_options = true;
197
+ }
198
+ }else{
199
+ field.prop('disabled', false);
200
  }
201
+
202
+ if(!field.hasClass('required') && typeof no_options === 'undefined'){
203
+ field.prepend('<option value=""></option>');
204
+ }
205
+ field.val(current);
206
  }else{
207
+ // text types
208
+ //console.log(field.val())
209
  }
 
 
 
 
 
210
  });
211
 
212
  check_required_bindings();
213
+ init_magic_tags();
214
+ jQuery(document).trigger('bound.fields');
215
  };
216
 
217
  function setup_field_type(obj){
239
  required_errors = {};
240
 
241
  fields.each(function(k,v){
242
+ var field = jQuery(v),
243
+ panel = field.closest('.caldera-config-editor-panel');
 
 
 
244
 
245
+ if(!v.value.length){
246
  if(!required_errors[panel.prop('id')]){
247
  required_errors[panel.prop('id')] = 0;
248
  }
249
+
250
+ var is_field = field.closest('.caldera-editor-field-config-wrapper'),
251
+ is_process = field.closest('.caldera-editor-processor-config-wrapper');
252
+
253
  if(is_field.length){
254
  jQuery('.layout-form-field[data-config="'+is_field.prop('id')+'"]').addClass('has-error');
255
  }
261
 
262
  //tab.append('<span class="error-tag">' + required_errors[panel.prop('id')] + '</span>');
263
 
264
+ }else{
265
+ //unique
266
+ if( field.hasClass('field-slug') ){
267
+ var slugs = jQuery('.field-slug').not(field);
268
+
269
+ for(var s = 0; s < slugs.length; s++){
270
+ if( slugs[s].value === v.value ){
271
+ var field = jQuery(slugs[s]);
272
+
273
+ if(!required_errors[panel.prop('id')]){
274
+ required_errors[panel.prop('id')] = 0;
275
+ }
276
+ var is_field = field.closest('.caldera-editor-field-config-wrapper'),
277
+ is_process = field.closest('.caldera-editor-processor-config-wrapper');
278
+
279
+ if(is_field.length){
280
+ jQuery('.layout-form-field[data-config="'+is_field.prop('id')+'"]').addClass('has-error');
281
+ }
282
+ if(is_process.length){
283
+ jQuery('.'+is_process.prop('id')).addClass('has-error');
284
+ }
285
+ required_errors[panel.prop('id')] += 1;
286
+ field.addClass('has-error');
287
+ break;
288
+ }
289
+ };
290
+ }
291
  }
292
  });
293
 
500
  };
501
  buildSortables();
502
 
503
+ $('#grid-pages-panel').on('click','.column-fieldinsert .dashicons-plus-alt', function(e){
504
  //newfield-tool
505
  var target = $(this).closest('.column-container'),
506
  newfield = $('#newfield-tool').clone();
507
 
508
  insert_new_field(newfield, target);
509
 
510
+ });
511
+ $('#grid-pages-panel').on('click','.column-fieldinsert .dashicons-admin-generic', function(e){
512
+
513
  });
514
  /*
515
  $('#grid-pages-panel').on('click','.icon-filter', function(e){
733
  }
734
 
735
  $(document).trigger('show.' + panel.data('config'));
736
+
737
+ $('#' + panel.data('config')).find('.auto-populate-options').trigger('change');
738
  });
739
  $('body').on('click', '.layout-modal-edit-closer,.layout-modal-save-action', function(e){
740
 
944
 
945
 
946
 
947
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
948
  Handlebars.registerHelper("_options_config", function() {
949
  //console.log(this);
950
  });
assets/js/processors-edit.js CHANGED
@@ -6,7 +6,7 @@ jQuery(function($){
6
  // set sortable groups
7
  $( ".caldera-editor-processors-panel ul" ).sortable({
8
  update: function(){
9
- rebind_field_bindings();
10
  }
11
  });
12
 
@@ -46,12 +46,12 @@ jQuery(function($){
46
  // place config
47
  process_conf.append( new_conf_templ( new_proc ) );
48
 
49
- // reset sortable
50
- build_sortables()
51
  $('#form_processor_baldrickModalCloser').trigger('click');
52
  $('.caldera-processor-nav a').last().trigger('click');
53
- $('#fp_' + processid + '_type').val(clicked.data('type')).trigger('change');
54
- rebuild_field_binding();
 
55
 
56
  baldrickTriggers();
57
  });
@@ -182,11 +182,12 @@ Handlebars.registerHelper('_field', function(args) {
182
  if(args.hash.array){
183
  is_array = "[]";
184
  if(args.hash.array !== 'true'){
185
- default_val = 'data-default="' + args.hash.array + '"';
186
  }
187
  }
188
 
189
  out = '<select ' + ( args.hash.type ? 'data-type="' + args.hash.type + '"' : '' ) + default_val +' ' + exclude + ' name="' + this._name + '[' + args.hash.slug + ']' + is_array + '" id="' + this._id + '_' + args.hash.slug + '" class="block-input field-config caldera-field-bind' + required + '">';
 
190
 
191
  if(!args.hash.required){
192
  out += '<option value=""></option>';
6
  // set sortable groups
7
  $( ".caldera-editor-processors-panel ul" ).sortable({
8
  update: function(){
9
+ rebuild_field_binding();
10
  }
11
  });
12
 
46
  // place config
47
  process_conf.append( new_conf_templ( new_proc ) );
48
 
49
+ // reset sortable
 
50
  $('#form_processor_baldrickModalCloser').trigger('click');
51
  $('.caldera-processor-nav a').last().trigger('click');
52
+ $('#fp_' + processid + '_type').val(clicked.data('type')).trigger('change');
53
+ build_sortables();
54
+ //rebuild_field_binding();
55
 
56
  baldrickTriggers();
57
  });
182
  if(args.hash.array){
183
  is_array = "[]";
184
  if(args.hash.array !== 'true'){
185
+ default_val = 'value="' + args.hash.array + '"';
186
  }
187
  }
188
 
189
  out = '<select ' + ( args.hash.type ? 'data-type="' + args.hash.type + '"' : '' ) + default_val +' ' + exclude + ' name="' + this._name + '[' + args.hash.slug + ']' + is_array + '" id="' + this._id + '_' + args.hash.slug + '" class="block-input field-config caldera-field-bind' + required + '">';
190
+ //out = '<input type="text" ' + ( args.hash.type ? 'data-type="' + args.hash.type + '"' : '' ) + default_val +' ' + exclude + ' name="' + this._name + '[' + args.hash.slug + ']' + is_array + '" id="' + this._id + '_' + args.hash.slug + '" class="block-input field-config magic-tag-enabled caldera-field-bind' + required + '">';
191
 
192
  if(!args.hash.required){
193
  out += '<option value=""></option>';
caldera-core.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin URI: http://digilab.co.za
5
  Description: Create simple to complex grid based, responsive forms quickly and easily.
6
  Author: David Cramer
7
- Version: 1.0.91
8
  Author URI: http://digilab.co.za
9
  */
10
 
@@ -17,8 +17,8 @@ if ( ! defined( 'WPINC' ) ) {
17
 
18
  define('CFCORE_PATH', plugin_dir_path(__FILE__));
19
  define('CFCORE_URL', plugin_dir_url(__FILE__));
20
- define('CFCORE_VER', '1.0.91');
21
- define('CFCORE_EXTEND_URL', 'http://digilab.co.za');
22
 
23
  include_once CFCORE_PATH . 'classes/core.php';
24
  include_once CFCORE_PATH . 'classes/widget.php';
4
  Plugin URI: http://digilab.co.za
5
  Description: Create simple to complex grid based, responsive forms quickly and easily.
6
  Author: David Cramer
7
+ Version: 1.1.0
8
  Author URI: http://digilab.co.za
9
  */
10
 
17
 
18
  define('CFCORE_PATH', plugin_dir_path(__FILE__));
19
  define('CFCORE_URL', plugin_dir_url(__FILE__));
20
+ define('CFCORE_VER', '1.1.0');
21
+ define('CFCORE_EXTEND_URL', 'http://api.calderaforms.com/1.0/');
22
 
23
  include_once CFCORE_PATH . 'classes/core.php';
24
  include_once CFCORE_PATH . 'classes/widget.php';
classes/admin.php CHANGED
@@ -172,6 +172,7 @@ class Caldera_Forms_Admin {
172
  }
173
 
174
  public static function get_admin_templates(){
 
175
  include CFCORE_PATH . 'ui/admin_templates.php';
176
  }
177
  public static function get_admin_meta_templates(){
@@ -873,6 +874,11 @@ class Caldera_Forms_Admin {
873
  unset($forms[$data['ID']]['settings']);
874
  }
875
 
 
 
 
 
 
876
  // combine structure pages
877
  $data['layout_grid']['structure'] = implode('#', $data['layout_grid']['structure']);
878
 
@@ -977,6 +983,15 @@ class Caldera_Forms_Admin {
977
  "label" => __("Form Processors", 'caldera-forms'),
978
  "canvas" => $path . "processors.php",
979
  ),
 
 
 
 
 
 
 
 
 
980
  "responsive" => array(
981
  "name" => __("Responsive", 'caldera-forms'),
982
  "location" => "lower",
172
  }
173
 
174
  public static function get_admin_templates(){
175
+ include CFCORE_PATH . 'ui/news_templates.php';
176
  include CFCORE_PATH . 'ui/admin_templates.php';
177
  }
178
  public static function get_admin_meta_templates(){
874
  unset($forms[$data['ID']]['settings']);
875
  }
876
 
877
+ foreach($forms as $form_id=>$form_config){
878
+ if(empty($form_config)){
879
+ unset( $forms[$form_id] );
880
+ }
881
+ }
882
  // combine structure pages
883
  $data['layout_grid']['structure'] = implode('#', $data['layout_grid']['structure']);
884
 
983
  "label" => __("Form Processors", 'caldera-forms'),
984
  "canvas" => $path . "processors.php",
985
  ),
986
+ "variables" => array(
987
+ "name" => __("Variables", 'caldera-forms'),
988
+ "location" => "lower",
989
+ "label" => __("Variables", 'caldera-forms'),
990
+ "canvas" => $path . "variables.php",
991
+ "actions" => array(
992
+ $path . "variable_add.php"
993
+ )
994
+ ),
995
  "responsive" => array(
996
  "name" => __("Responsive", 'caldera-forms'),
997
  "location" => "lower",
classes/core.php CHANGED
@@ -48,6 +48,10 @@ class Caldera_Forms {
48
  add_filter('caldera_forms_get_form_processors', array( $this, 'get_form_processors'));
49
  add_filter('caldera_forms_submit_redirect_complete', array( $this, 'do_redirect'),10, 4);
50
  add_action('caldera_forms_edit_end', array($this, 'calculations_templates') );
 
 
 
 
51
 
52
  // magic tags
53
  //add_filter('caldera_forms_render_magic_tag', array( $this, 'do_magic_tags'));
@@ -64,6 +68,9 @@ class Caldera_Forms {
64
 
65
  // render shortcode
66
  add_shortcode( 'caldera_form', array( $this, 'render_form') );
 
 
 
67
 
68
  // check update version
69
  $version = get_option('_calderaforms_lastupdate');
@@ -256,22 +263,44 @@ class Caldera_Forms {
256
 
257
  public static function update_field_data($field, $entry_id, $form){
258
  global $wpdb, $form;
259
-
260
- $data = self::get_field_data($field['ID'], $form);
261
-
262
- if(empty($data)){
 
 
 
 
 
 
 
 
 
 
263
  return;
264
  }
265
 
266
  if( has_filter( 'caldera_forms_save_field' ) ){
267
- $data = apply_filters( 'caldera_forms_update_field', $data, $field, $form );
268
  }
269
 
270
  if( has_filter( 'caldera_forms_save_field_' . $field['type'] ) ){
271
- $data = apply_filters( 'caldera_forms_update_field_' . $field['type'], $data, $field, $form );
272
- }
 
 
 
 
 
 
 
 
 
 
 
273
 
274
- $wpdb->update($wpdb->prefix . 'cf_form_entry_values', array('value' => $data), array('entry_id' => $entry_id, 'field_id' => $field['ID']));
 
275
 
276
  }
277
 
@@ -298,7 +327,7 @@ class Caldera_Forms {
298
  'entry_id' => $entry_id,
299
  'field_id' => $field['ID'],
300
  'slug' => $field['slug'],
301
- 'value' => $entry
302
  );
303
  // named key kets .key to slug
304
  if(!is_int($key)){
@@ -348,7 +377,8 @@ class Caldera_Forms {
348
 
349
  }
350
 
351
- }
 
352
 
353
  if(!empty($form['db_support'])){
354
  // new entry or update
@@ -557,20 +587,23 @@ class Caldera_Forms {
557
  }
558
 
559
  $key = $form['fields'][$field_id]['slug'];
560
-
561
  if(is_array($row)){
562
- $keys = array_keys($row);
563
- if(is_int($keys[0])){
564
- $row = implode(', ', $row);
565
- }else{
566
- $tmp = array();
567
- foreach($row as $linekey=>$item){
568
- if(is_array($item)){
569
- $item = '( ' . implode(', ', $item).' )';
 
 
 
570
  }
571
- $tmp[] = $linekey.': '.$item;
572
  }
573
- $row = implode(', ', $tmp);
 
574
  }
575
  }
576
  $mail['message'] = str_replace('%'.$key.'%', $row, $mail['message']);
@@ -656,9 +689,32 @@ class Caldera_Forms {
656
  continue;
657
  }
658
  }
659
-
660
  if(!empty($processor['config']['url'])){
661
- return $processor['config']['url'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
  }
663
  }
664
  }
@@ -679,43 +735,16 @@ class Caldera_Forms {
679
  $value = self::do_magic_tags( $value );
680
  }
681
  }
 
682
  // set header
683
  $headers = 'From: ' . $config['sender_name'] . ' <' . $config['sender_email'] . '>' . "\r\n";
684
-
685
- $regex = "/%(.*?)%/";
686
- preg_match_all($regex, $message, $matches);
687
- if(!empty($matches[1])){
688
- foreach($matches[1] as $key=>$tag){
689
- $entry = self::get_slug_data($tag, $form);
690
- if(!empty($entry)){
691
- if(is_array($entry)){
692
- if(count($entry) === 1){
693
- $entry = array_shift($entry);
694
- }elseif(count($entry) === 2){
695
- $entry = implode(' & ', $entry);
696
- }elseif(count($entry) > 2){
697
- $last = array_pop($entry);
698
- $entry = implode(', ', $entry).' & '.$last;
699
- }else{
700
- continue;
701
- }
702
- }
703
- }else{
704
- $entry = '';
705
- }
706
 
707
- $message = str_replace($matches[0][$key], $entry, $message);
708
- }
709
- }
710
  $message = self::do_magic_tags( $message );
711
 
712
  // setup mailer
713
- $recipient_name = self::get_field_data($config['recipient_name'], $form);
714
- $recipient_email = self::get_field_data($config['recipient_email'], $form);
715
  $subject = $config['subject'];
716
  do_action( 'caldera_forms_do_autoresponse', $config, $form);
717
-
718
- wp_mail($recipient_name.' <'.$recipient_email.'>', $subject, $message, $headers );
719
 
720
  }
721
 
@@ -807,7 +836,7 @@ class Caldera_Forms {
807
  "file" => CFCORE_PATH . "fields/calculation/field.php",
808
  "handler" => array($this, "run_calculation"),
809
  "category" => __("Special,Math", "cladera-forms"),
810
- "description" => __('Calculate values', "cladera-forms"),
811
  "setup" => array(
812
  "template" => CFCORE_PATH . "fields/calculation/config.php",
813
  "preview" => CFCORE_PATH . "fields/calculation/preview.php",
@@ -981,7 +1010,8 @@ class Caldera_Forms {
981
  "not_supported" => array(
982
  'hide_label',
983
  'caption',
984
- 'required'
 
985
  )
986
  )
987
  ),
@@ -998,7 +1028,6 @@ class Caldera_Forms {
998
  'hide_label',
999
  'caption',
1000
  'required',
1001
-
1002
  )
1003
  )
1004
  ),
@@ -1186,6 +1215,43 @@ class Caldera_Forms {
1186
 
1187
  }
1188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1189
  static public function check_condition($conditions, $form){
1190
 
1191
  $trues = array();
@@ -1347,6 +1413,10 @@ class Caldera_Forms {
1347
  'text',
1348
  'email'
1349
  ),
 
 
 
 
1350
  'embed_post:ID',
1351
  'embed_post:post_title',
1352
  'embed_post:permalink',
@@ -1365,19 +1435,21 @@ class Caldera_Forms {
1365
 
1366
  $tags['system'] = array(
1367
  'type' => __('System Tags', 'caldera-forms'),
1368
- 'tags' => $system_tags
 
1369
  );
1370
  // get processor tags
1371
  $processors = apply_filters('caldera_forms_get_form_processors', array() );
1372
  if(!empty($processors)){
1373
  foreach($processors as $processor_key=>$processor){
1374
- if(isset($processor['magic_tags'])){
1375
  foreach($processor['magic_tags'] as $key_tag=>$value_tag){
1376
 
1377
  if(!isset($tags[$processor_key])){
1378
  $tags[$processor_key] = array(
1379
  'type' => $processor['name'],
1380
- 'tags' => array()
 
1381
  );
1382
  }
1383
  if(is_array($value_tag)){
@@ -1406,7 +1478,7 @@ class Caldera_Forms {
1406
  return $tags;
1407
  }
1408
 
1409
- static public function do_magic_tags($value){
1410
 
1411
  global $processed_meta, $form;
1412
  /// get meta entry for magic tags defined.
@@ -1441,6 +1513,20 @@ class Caldera_Forms {
1441
  $magic_tag = null;
1442
  }
1443
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1444
  case 'date':
1445
  $magic_tag = date($magic[1]);
1446
  break;
@@ -1541,6 +1627,13 @@ class Caldera_Forms {
1541
  if(!empty($form['ID']) ){
1542
  //dump($processed_meta[$form['ID']]);
1543
 
 
 
 
 
 
 
 
1544
  // check if its a process id or processor slug
1545
  if( empty($processed_meta[$form['ID']][$magic[0]]) && !empty($form['processors']) ){
1546
 
@@ -1578,6 +1671,31 @@ class Caldera_Forms {
1578
  }
1579
  }
1580
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1581
  return $value;
1582
  }
1583
 
@@ -1674,20 +1792,19 @@ class Caldera_Forms {
1674
  //dump($processed_data[$form['ID']],0);
1675
  //echo $field_id.'<br>';
1676
  if(is_string($form)){
1677
- // get processed cached item using the form id
1678
- if(isset($processed_data[$form][$field_id])){
1679
- return $processed_data[$form][$field_id];
1680
- }
1681
-
1682
  $form = get_option( $form );
1683
  if(!isset($form['ID']) || $form['ID'] !== $form){
1684
-
1685
  return null;
1686
  }
1687
  }
 
 
 
 
 
1688
  // get processed cached item
1689
- if(isset($processed_data[$form['ID']][$field_id])){
1690
- return $processed_data[$form['ID']][$field_id];
1691
  }
1692
  // entry fetch
1693
  if(!empty($entry_id) && isset($form['fields'][$field_id])){
@@ -1697,21 +1814,24 @@ class Caldera_Forms {
1697
  $entry = $wpdb->get_results($wpdb->prepare("
1698
  SELECT `value` FROM `" . $wpdb->prefix ."cf_form_entry_values` WHERE `entry_id` = %d AND `field_id` = %s AND `slug` = %s", $entry_id, $field_id, $form['fields'][$field_id]['slug']), ARRAY_A);
1699
 
 
 
 
1700
  if(!empty($entry)){
1701
  if( count( $entry ) > 1){
1702
  $out = array();
1703
  foreach($entry as $item){
1704
  $out[] = $item['value'];
1705
  }
1706
- $processed_data[$form['ID']][$field_id] = $out;
1707
  }else{
1708
- $processed_data[$form['ID']][$field_id] = $entry[0]['value'];
1709
  }
1710
  }else{
1711
- $processed_data[$form['ID']][$field_id] = null;
1712
  }
1713
- return $processed_data[$form['ID']][$field_id];
1714
- //return $processed_data[$form['ID']][$field_id] = ;
1715
  }
1716
 
1717
  if(isset($form['fields'][$field_id])){
@@ -1731,7 +1851,7 @@ class Caldera_Forms {
1731
  // dont bother if conditions say it shouldnt be here.
1732
  if(!empty($field['conditions']['type'])){
1733
  if(!self::check_condition($field['conditions'], $form)){
1734
- $processed_data[$form['ID']][$field_id] = $entry;
1735
  return $entry;
1736
  }
1737
  }
@@ -1745,7 +1865,7 @@ class Caldera_Forms {
1745
  if(has_filter('caldera_forms_process_field_' . $field['type'])){
1746
  $entry = apply_filters( 'caldera_forms_process_field_' . $field['type'] , $entry, $field, $form );
1747
  if( is_wp_error( $entry ) ) {
1748
- $processed_data[$form['ID']][$field_id] = $entry;
1749
  return $entry;
1750
  }
1751
  }
@@ -1772,33 +1892,33 @@ class Caldera_Forms {
1772
  $out[] = self::do_magic_tags($field['config']['option'][$option_id]['value']);
1773
  }
1774
  }
1775
- $processed_data[$form['ID']][$field_id] = $out;
1776
  }else{
1777
  if(!empty($field['config']['option'])){
1778
  foreach($field['config']['option'] as $option){
1779
  if($option['value'] == $entry){
1780
- $processed_data[$form['ID']][$field_id] = self::do_magic_tags($entry);
1781
  break;
1782
  }
1783
  }
1784
  }
1785
  }
1786
  }else{
1787
- $processed_data[$form['ID']][$field_id] = self::do_magic_tags($field['config']['default']);
1788
  }
1789
  }else{
1790
  // dynamic
1791
- $processed_data[$form['ID']][$field_id] = $entry;
1792
  }
1793
  }else{
1794
  $is_tag = self::do_magic_tags($field_id);
1795
  if($is_tag !== $field_id){
1796
- $processed_data[$form['ID']][$field_id] = $is_tag;
1797
  }
1798
  }
1799
 
1800
- if(isset($processed_data[$form['ID']][$field_id])){
1801
- return $processed_data[$form['ID']][$field_id];
1802
  }
1803
 
1804
 
@@ -1819,57 +1939,11 @@ class Caldera_Forms {
1819
 
1820
  if($field['slug'] == $slug){
1821
 
1822
- if(isset($_POST[$field_id])){
1823
- if(!empty($slug_parts)){
1824
- // just the part
1825
- $line = stripslashes_deep( $_POST[$field_id] );
1826
- foreach($slug_parts as $part){
1827
- if(isset($line[$part])){
1828
- $line = $line[$part];
1829
- }
1830
- }
1831
- $out[] = $line;
1832
- }else{
1833
- //the whole thing
1834
- $entry = stripslashes_deep( $_POST[$field_id] );
1835
-
1836
- //$entry = apply_filters('caldera_forms_view_field_' . $field['type'], $entry, $field, $form);
1837
 
1838
- /*if(isset($field_types[$field['type']]['viewer'])){
1839
-
1840
- if(is_array($field_types[$field['type']]['viewer'])){
1841
- $entry = call_user_func_array($field_types[$field['type']]['viewer'],array($entry, $field, $form));
1842
- }else{
1843
- if(function_exists($field_types[$field['type']]['viewer'])){
1844
- $func = $field_types[$field['type']]['viewer'];
1845
- $entry = $func($entry, $field, $form);
1846
- }
1847
- }
1848
- }*/
1849
- if(is_array($entry)){
1850
- if(isset($entry[0])){
1851
- // list
1852
- $entry = $field['label'].': '. implode(',' , $entry);
1853
- }else{
1854
- // named
1855
- foreach($entry as $item_key=>$item){
1856
- if(is_array($item)){
1857
- $item = $item_key.' ('.implode(', ', $item).')';
1858
- }
1859
- $out[] = $item;
1860
- }
1861
- }
1862
- }else{
1863
- $out[] = $entry;
1864
- }
1865
- }
1866
- }
1867
  }
1868
  }
1869
- if(count($out) === 1){
1870
- $out = array_shift($out);
1871
- }
1872
- return $out;
1873
  }
1874
  static public function get_entry_detail($entry_id, $form){
1875
  global $wpdb;
@@ -1877,90 +1951,109 @@ class Caldera_Forms {
1877
  $entry = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . $wpdb->prefix ."cf_form_entries` WHERE `id` = %d", $entry_id), ARRAY_A);
1878
  if(!empty($entry)){
1879
  // get meta if any
1880
- $entry_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . $wpdb->prefix ."cf_form_entry_meta` WHERE `entry_id` = %d", $entry_id), ARRAY_A);
1881
- if(!empty($entry_meta)){
1882
- $processors = apply_filters('caldera_forms_get_form_processors', array() );
1883
- $entry['meta'] = array();
1884
- foreach($entry_meta as $meta_index=>$meta){
1885
- // is json?
1886
- if( false !== strpos($meta['meta_value'], '{') || false !== strpos($meta['meta_value'], '[') ){
1887
- $meta['meta_value'] = json_decode($meta['meta_value'], ARRAY_A);
1888
- }else{
1889
- $meta['meta_value'] = $meta['meta_value'];
1890
- }
1891
 
1892
- $group = 'meta';
1893
- $meta = apply_filters('caldera_forms_get_entry_meta', $meta, $form);
 
 
 
 
 
 
 
 
 
 
 
 
 
1894
 
1895
- if(isset($form['processors'][$meta['process_id']])){
 
1896
 
1897
- $process_config = array();
1898
- if(isset($form['processors'][$meta['process_id']]['config'])){
1899
- $process_config = $form['processors'][$meta['process_id']]['config'];
1900
- }
1901
 
1902
- $group = $form['processors'][$meta['process_id']]['type'];
1903
- $meta = apply_filters('caldera_forms_get_entry_meta_' . $form['processors'][$meta['process_id']]['type'], $meta, $process_config , $form);
 
 
1904
 
1905
-
1906
- // allows plugins to remove it.
1907
- if(!empty($meta)){
1908
- if(!isset($entry['meta'][$group])){
1909
- // is processor
1910
- if(isset($form['processors'][$meta['process_id']]['type'])){
1911
- $meta_name = $processors[$form['processors'][$meta['process_id']]['type']]['name'];
1912
- }else{
1913
- $meta_name = $meta['process_id'];
1914
- }
1915
- $entry['meta'][$group] = array(
1916
- 'name' => $meta_name,
1917
- 'data' => array()
1918
- );
1919
- // custom template
1920
- if( isset( $processors[$form['processors'][$meta['process_id']]['type']]['meta_template'] ) && file_exists( $processors[$form['processors'][$meta['process_id']]['type']]['meta_template'] ) ){
1921
- $entry['meta'][$group][$group.'_template'] = $entry['meta'][$group]['template'] = true;
1922
- }
1923
  }
 
 
 
 
 
 
 
 
 
1924
 
1925
- //if(!empty($meta['meta_title'])){
1926
- // $entry['meta'][$group]['data'][$meta['process_id']]['title'] = $meta['meta_title'];
1927
- //}
1928
 
1929
- $entry['meta'][$group]['data'][$meta['process_id']]['entry'][] = $meta;
1930
 
1931
-
1932
- /*if(is_array($meta['meta_value'])){
1933
- foreach($meta['meta_value'] as $mkey=>$mval){
1934
- $entry['meta'][$group]['data'][$meta['process_id']]['title'] = $meta['meta_key'];
1935
- $entry['meta'][$group]['data'][$meta['process_id']]['entry'][] = array(
1936
- 'meta_key' => $mkey,
1937
- 'meta_value' => $mval
1938
- );
1939
- }
1940
- }else{
1941
  $entry['meta'][$group]['data'][$meta['process_id']]['entry'][] = array(
1942
- 'meta_key' => $meta['meta_key'],
1943
- 'meta_value' => $meta['meta_value']
1944
- );
1945
- }*/
 
 
 
 
 
 
1946
 
1947
- }
1948
  }
1949
  }
1950
  }
1951
  }
1952
- $entry = apply_filters( 'caldera_forms_get_entry_detail', $entry, $entry_id, $form );
1953
- return $entry;
 
 
 
 
 
 
1954
  }
1955
 
1956
  static public function get_submission_data($form, $entry_id = false){
1957
  global $processed_data;
1958
 
1959
  if(is_string($form)){
1960
- // get processed cached item using the form id
1961
- if(isset($processed_data[$form])){
1962
- return $processed_data[$form];
1963
- }
1964
  $form_id = $form;
1965
  $form = get_option( $form );
1966
  if(!isset($form['ID']) || $form['ID'] !== $form_id){
@@ -1968,13 +2061,22 @@ class Caldera_Forms {
1968
  }
1969
  }
1970
 
 
 
 
 
 
 
 
 
 
1971
 
1972
  // initialize process data
1973
  foreach($form['fields'] as $field_id=>$field){
1974
  self::get_field_data( $field_id, $form, $entry_id);
1975
  }
1976
 
1977
- return $processed_data[$form['ID']];
1978
  }
1979
 
1980
  static public function process_submission(){
@@ -2012,6 +2114,12 @@ class Caldera_Forms {
2012
  // init filter
2013
  $form = apply_filters('caldera_forms_submit_get_form', $form);
2014
 
 
 
 
 
 
 
2015
  // instance number
2016
  $form_instance_number = 1;
2017
  if(isset($_POST['_cf_frm_ct'])){
@@ -2127,6 +2235,7 @@ class Caldera_Forms {
2127
  if(isset($_POST['_cf_frm_edt'])){
2128
  // is edit
2129
  //check user can edit this item.
 
2130
  $user_id = get_current_user_id();
2131
  if(empty($user_id)){
2132
  $transdata['error'] = true;
@@ -2248,11 +2357,11 @@ class Caldera_Forms {
2248
  $config = array_merge($config, $processor['config']);
2249
  }
2250
  if(is_array($process['pre_processor'])){
2251
- $process_line_data = call_user_func_array($process['pre_processor'],array($config, $form, $processid));
2252
  }else{
2253
  if(function_exists($process['pre_processor'])){
2254
  $func = $process['pre_processor'];
2255
- $process_line_data = $func($config, $form);
2256
  }
2257
  }
2258
  // pre processors should not return unless a break in action for further
@@ -2318,6 +2427,7 @@ class Caldera_Forms {
2318
  $hasmeta = null;
2319
  // set default config
2320
  $config = array();
 
2321
  if(isset($process['default'])){
2322
  $config = $process['default'];
2323
  }
@@ -2326,11 +2436,11 @@ class Caldera_Forms {
2326
  $config = array_merge($config, $processor['config']);
2327
  }
2328
  if(is_array($process['processor'])){
2329
- $hasmeta = call_user_func_array($process['processor'],array($config, $form));
2330
  }else{
2331
  if(function_exists($process['processor'])){
2332
  $func = $process['processor'];
2333
- $hasmeta = $func($config, $form);
2334
  }
2335
  }
2336
  if($hasmeta !== null){
@@ -2392,6 +2502,7 @@ class Caldera_Forms {
2392
  }
2393
  // set default config
2394
  $config = array();
 
2395
  if(isset($process['default'])){
2396
  $config = $process['default'];
2397
  }
@@ -2400,11 +2511,11 @@ class Caldera_Forms {
2400
  $config = array_merge($config, $processor['config']);
2401
  }
2402
  if(is_array($process['post_processor'])){
2403
- $hasmeta = call_user_func_array($process['post_processor'],array($config, $form));
2404
  }else{
2405
  if(function_exists($process['post_processor'])){
2406
  $func = $process['post_processor'];
2407
- $hasmeta = $func($config, $form);
2408
  }
2409
  }
2410
  if($hasmeta !== null){
@@ -2423,6 +2534,14 @@ class Caldera_Forms {
2423
 
2424
  // redirect back or to result page
2425
  $referrer['query']['cf_su'] = $form_instance_number;
 
 
 
 
 
 
 
 
2426
  $referrer = $referrer['path'] . '?' . http_build_query($referrer['query']);
2427
 
2428
  // filter refer
@@ -2635,6 +2754,11 @@ class Caldera_Forms {
2635
  }
2636
  }
2637
  }
 
 
 
 
 
2638
  }
2639
  }
2640
  }
@@ -2654,7 +2778,7 @@ class Caldera_Forms {
2654
  return $found;
2655
  }
2656
 
2657
- static public function get_entry($entry_id = null){
2658
 
2659
  if(empty($entry_id)){
2660
  if(!empty($_POST['form'])){
@@ -2663,9 +2787,6 @@ class Caldera_Forms {
2663
  if(empty($form)){
2664
  return;
2665
  }
2666
-
2667
- $field_types = self::get_field_types();
2668
-
2669
  $fields = array();
2670
  foreach ($form['fields'] as $field_id => $field) {
2671
  $fields[$field['slug']] = $field;
@@ -2676,124 +2797,53 @@ class Caldera_Forms {
2676
  }
2677
 
2678
  }
2679
-
2680
- global $wpdb;
2681
-
2682
- $rawdata = $wpdb->get_results($wpdb->prepare("
2683
- SELECT
2684
- `entry`.`form_id` AS `_form_id`,
2685
- `entry`.`datestamp` AS `_date_submitted`,
2686
- `entry`.`user_id` AS `_user_id`,
2687
- `value`.*
2688
-
2689
- FROM `" . $wpdb->prefix ."cf_form_entries` AS `entry`
2690
- LEFT JOIN `" . $wpdb->prefix ."cf_form_entry_values` AS `value` ON (`entry`.`id` = `value`.`entry_id`)
2691
- WHERE `entry`.`id` = %d;", $entry_id ));
2692
-
2693
- if(empty($rawdata)){
2694
- return array();
2695
  }
2696
- $data = array();
2697
- $dateformat = get_option('date_format');
2698
- $timeformat = get_option('time_format');
2699
- $gmt_offset = get_option( 'gmt_offset' );
2700
-
2701
- foreach($rawdata as $row){
2702
- if(empty($form)){
2703
- $form = get_option($row->_form_id);
2704
- if(empty($form)){
2705
- return array();
2706
- }
 
2707
  }
2708
 
2709
- if(isset($fields[$row->slug])){
2710
- $field = $fields[$row->slug];
2711
-
2712
- if(isset($field_types[$field['type']]['viewer'])){
2713
- // is json?
2714
- if(substr($row->value, 0,2) === '{"' && substr($row->value, strlen($row->value)-2 ) === '"}'){
2715
- $is_value = json_decode($row->value, ARRAY_A);
2716
- if(!empty($is_value)){
2717
- $row->value = $is_value;
2718
- }
2719
- }
2720
-
2721
- $row->value = apply_filters('caldera_forms_view_field_' . $field['type'], $row->value, $field, $form);
2722
- //$row->value = apply_filters( $tag, $value );
2723
- /*
2724
- if(is_array($field_types[$field['type']]['viewer'])){
2725
- $row->value = call_user_func_array($field_types[$field['type']]['viewer'],array($row->value, $field, $form));
2726
- }elseif(is_object($field_types[$field['type']]['viewer'])){
2727
-
2728
- $row->value = call_user_func_array($field_types[$field['type']]['viewer'],array($row->value, $field, $form));
2729
-
2730
- }elseif(function_exists($field_types[$field['type']]['viewer'])){
2731
- $func = $field_types[$field['type']]['viewer'];
2732
- $row->value = $func($row->value, $field, $form);
2733
- }*/
2734
- }
2735
-
2736
-
2737
- if(substr($row->value, 0,2) === '{"' && substr($row->value, strlen($row->value)-2 ) === '"}'){
2738
- $line = json_decode($row->value, true);
2739
- if(!empty($line)){
2740
- $keys = array_keys($line);
2741
- if(is_int($keys[0])){
2742
- $line = implode(', ', $line);
2743
- }else{
2744
- $tmp = array();
2745
- foreach($line as $key=>$item){
2746
- if(is_array($item)){
2747
- $item = '( ' . implode(', ', $item).' )';
2748
- }
2749
- $tmp[] = $key.': '.$item;
2750
- }
2751
- $line = implode(', ', $tmp);
2752
- }
2753
- $row->value = $line;
2754
- }
2755
- }
2756
- if(is_array($row->value)){
2757
- $keys = array_keys($line);
2758
- if(is_int($keys[0])){
2759
- $line = implode(', ', $line);
2760
- }else{
2761
- $tmp = array();
2762
- foreach($line as $key=>$item){
2763
- if(is_array($item)){
2764
- $item = '( ' . implode(', ', $item).' )';
2765
- }
2766
- $tmp[] = $key.': '.$item;
2767
- }
2768
- $line = implode(', ', $tmp);
2769
- }
2770
- $row->value = $line;
2771
  }
 
 
2772
 
2773
- $data['date'] = date_i18n( $dateformat.' '.$timeformat, strtotime($row->_date_submitted), $gmt_offset);
2774
- $data['user'] = $row->_user_id;
2775
-
2776
- $data['data'][$row->slug]['label'] = $field['label'];
2777
- if(isset($data['data'][$row->slug]['value'])){
2778
- $data['data'][$row->slug]['value'] = implode(', ', array($data['data'][$row->slug]['value'], $row->value));
2779
- }else{
2780
- $data['data'][$row->slug]['value'] = $row->value;
2781
- }
2782
 
2783
- }else{
2784
- // front end for editing. no filtering just values to array.
2785
- $data[$row->slug] = $row->value;
2786
- }
 
2787
  }
 
2788
  // get meta
 
 
 
2789
  $entry_detail = self::get_entry_detail($entry_id, $form);
 
 
2790
  if(!empty($entry_detail['meta'])){
2791
  $data['meta'] = $entry_detail['meta'];
2792
  }
2793
 
2794
 
2795
- if(!empty($data['user'])){
2796
- $user = get_userdata( $data['user'] );
2797
  if(!empty($user)){
2798
  $data['user'] = array(
2799
  'ID' => $user->ID,
@@ -2822,6 +2872,70 @@ class Caldera_Forms {
2822
  return $data;
2823
  }
2824
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2825
  static public function render_form($atts, $entry_id = null){
2826
 
2827
  global $current_form_count;
@@ -2862,6 +2976,14 @@ class Caldera_Forms {
2862
 
2863
  }
2864
 
 
 
 
 
 
 
 
 
2865
  // set entry edit
2866
  if(!empty($atts['entry'])){
2867
  $entry_id = self::do_magic_tags( $atts['entry'] );
@@ -2996,7 +3118,11 @@ class Caldera_Forms {
2996
 
2997
  // load requested data
2998
  if(!empty($entry_id)){
2999
- $prev_data = self::get_entry($entry_id);
 
 
 
 
3000
  $prev_data = apply_filters('caldera_forms_render_get_entry', $prev_data, $form, $entry_id);
3001
  }
3002
 
@@ -3013,7 +3139,7 @@ class Caldera_Forms {
3013
  }
3014
 
3015
  if(!is_wp_error( $field_entry )){
3016
- $prev_data[$form['fields'][$field_id]['slug']] = $field_entry;
3017
  }
3018
  }
3019
  }
@@ -3108,7 +3234,7 @@ class Caldera_Forms {
3108
  if(!empty($form['layout_grid']['fields'])){
3109
 
3110
  foreach($form['layout_grid']['fields'] as $field_base_id=>$location){
3111
- //
3112
  if(isset($form['fields'][$field_base_id])){
3113
 
3114
  $field = apply_filters('caldera_forms_render_setup_field', $form['fields'][$field_base_id], $form);
@@ -3152,9 +3278,9 @@ class Caldera_Forms {
3152
  $field_input_class = $field_classes['field_wrapper'];
3153
  $field_class = $field_classes['field'];
3154
 
3155
- if(!empty($field_errors[$field['slug']])){
3156
  $field_input_class .= " " . $field_classes['field_error'];
3157
- $field_structure['field_caption'] = "<span class=\"" . $field_classes['field_caption'] . "\">" . $field_errors[$field['slug']] . "</span>\r\n";
3158
  }
3159
 
3160
  // value
@@ -3164,8 +3290,8 @@ class Caldera_Forms {
3164
  }
3165
 
3166
  // transient data
3167
- if(isset($prev_data[$field['slug']])){
3168
- $field_structure['field_value'] = $prev_data[$field['slug']];
3169
  }
3170
 
3171
  $field_structure = apply_filters('caldera_forms_render_field_structure', $field_structure, $form);
@@ -3173,13 +3299,15 @@ class Caldera_Forms {
3173
  $field_structure = apply_filters('caldera_forms_render_field_structure_slug-' . $field['slug'], $field_structure, $form);
3174
 
3175
  $field_name = $field_structure['name'];
3176
- $field_id = $field_structure['id'];
3177
  $field_label = $field_structure['label_before'] . $field_structure['label'] . $field_structure['label_required'] . $field_structure['label_after']."\r\n";
3178
  $field_placeholder = $field_structure['field_placeholder'];
3179
  $field_required = $field_structure['field_required'];
3180
  $field_caption = $field_structure['field_caption'];
3181
  // blank default
3182
  $field_value = $field_structure['field_value'];
 
 
3183
 
3184
  ob_start();
3185
  include $field_types[$field['type']]['file'];
@@ -3263,7 +3391,7 @@ class Caldera_Forms {
3263
  $out .= "<input type=\"hidden\" name=\"_cf_frm_tr\" value=\"" . $prev_post['transient'] . "\">\r\n";
3264
  }
3265
  // is edit?
3266
- if(!empty($entry_id)){
3267
  $out .= "<input type=\"hidden\" name=\"_cf_frm_edt\" value=\"" . $entry_id . "\">\r\n";
3268
  }
3269
 
@@ -3273,7 +3401,7 @@ class Caldera_Forms {
3273
  // retain query string
3274
  $qurystr = array();
3275
  parse_str( $_SERVER['QUERY_STRING'], $qurystr );
3276
- echo "<span class=\"caldera-grid\"><ol class=\"breadcrumb\" data-form=\"caldera_form_" . $current_form_count ."\">\r\n";
3277
  $current_page = 1;
3278
  if(!empty($_GET['cf_pg'])){
3279
  $current_page = $_GET['cf_pg'];
@@ -3287,9 +3415,9 @@ class Caldera_Forms {
3287
 
3288
  $qurystr['cf_pg'] = $page_key + 1;
3289
  $qurystr['_rdm_'] = rand(100000, 999999);
3290
- echo "<li" . $tabclass . "><a href=\"?". http_build_query($qurystr) . "\" data-page=\"" . ( $page_key + 1 ) ."\" data-pagenav=\"caldera_form_" . $current_form_count ."\">". $page_name . "</a></li>\r\n";
3291
  }
3292
- echo "</ol></span>\r\n";
3293
  }
3294
 
3295
  $out .= $grid->renderLayout();
48
  add_filter('caldera_forms_get_form_processors', array( $this, 'get_form_processors'));
49
  add_filter('caldera_forms_submit_redirect_complete', array( $this, 'do_redirect'),10, 4);
50
  add_action('caldera_forms_edit_end', array($this, 'calculations_templates') );
51
+ add_filter('caldera_forms_render_get_field_type-radio', array( $this, 'auto_populate_options_field' ), 10, 2);
52
+ add_filter('caldera_forms_render_get_field_type-checkbox', array( $this, 'auto_populate_options_field' ), 10, 2);
53
+ add_filter('caldera_forms_render_get_field_type-dropdown', array( $this, 'auto_populate_options_field' ), 10, 2);
54
+ add_filter('caldera_forms_render_get_field_type-toggle_switch', array( $this, 'auto_populate_options_field' ), 10, 2);
55
 
56
  // magic tags
57
  //add_filter('caldera_forms_render_magic_tag', array( $this, 'do_magic_tags'));
68
 
69
  // render shortcode
70
  add_shortcode( 'caldera_form', array( $this, 'render_form') );
71
+ // modal shortcode
72
+ add_shortcode( 'caldera_form_modal', array( $this, 'render_modal_form') );
73
+ add_action( 'wp_footer', array( $this, 'render_footer_modals') );
74
 
75
  // check update version
76
  $version = get_option('_calderaforms_lastupdate');
263
 
264
  public static function update_field_data($field, $entry_id, $form){
265
  global $wpdb, $form;
266
+
267
+ $field_types = self::get_field_types();
268
+ // is capture?
269
+ if(isset($field_types[$form['fields'][$field['ID']]['type']]['setup']['not_supported'])){
270
+ if(in_array('entry_list', $field_types[$form['fields'][$field['ID']]['type']]['setup']['not_supported'])){
271
+ return;
272
+ }
273
+ }
274
+
275
+ $new_data = self::get_field_data($field['ID'], $form);
276
+ $original_data = self::get_field_data($field['ID'], $form, $entry_id);
277
+
278
+ if($original_data === $new_data){
279
+ // no change
280
  return;
281
  }
282
 
283
  if( has_filter( 'caldera_forms_save_field' ) ){
284
+ $new_data = apply_filters( 'caldera_forms_update_field', $new_data, $field, $form );
285
  }
286
 
287
  if( has_filter( 'caldera_forms_save_field_' . $field['type'] ) ){
288
+ $new_data = apply_filters( 'caldera_forms_update_field_' . $field['type'], $new_data, $field, $form );
289
+ }
290
+ if($original_data === null){
291
+ // no entry - add first
292
+ $new_entry = array(
293
+ 'entry_id' => $entry_id,
294
+ 'field_id' => $field['ID'],
295
+ 'slug' => $field['slug'],
296
+ 'value' => $new_data,
297
+ );
298
+ $wpdb->insert($wpdb->prefix . 'cf_form_entry_values', $new_entry);
299
+
300
+ }else{
301
 
302
+ $wpdb->update($wpdb->prefix . 'cf_form_entry_values', array('value' => $new_data), array('entry_id' => $entry_id, 'field_id' => $field['ID']));
303
+ }
304
 
305
  }
306
 
327
  'entry_id' => $entry_id,
328
  'field_id' => $field['ID'],
329
  'slug' => $field['slug'],
330
+ 'value' => self::do_magic_tags( $entry )
331
  );
332
  // named key kets .key to slug
333
  if(!is_int($key)){
377
 
378
  }
379
 
380
+ }
381
+
382
 
383
  if(!empty($form['db_support'])){
384
  // new entry or update
587
  }
588
 
589
  $key = $form['fields'][$field_id]['slug'];
 
590
  if(is_array($row)){
591
+ if(!empty($row)){
592
+ $keys = array_keys($row);
593
+ if(is_int($keys[0])){
594
+ $row = implode(', ', $row);
595
+ }else{
596
+ $tmp = array();
597
+ foreach($row as $linekey=>$item){
598
+ if(is_array($item)){
599
+ $item = '( ' . implode(', ', $item).' )';
600
+ }
601
+ $tmp[] = $linekey.': '.$item;
602
  }
603
+ $row = implode(', ', $tmp);
604
  }
605
+ }else{
606
+ $row = null;
607
  }
608
  }
609
  $mail['message'] = str_replace('%'.$key.'%', $row, $mail['message']);
689
  continue;
690
  }
691
  }
 
692
  if(!empty($processor['config']['url'])){
693
+
694
+ //passback urls
695
+ $referrer = parse_url( $referrer );
696
+ $query_vars = array();
697
+ if(!empty($referrer['query'])){
698
+ parse_str($referrer['query'], $referrer['query']);
699
+ if(isset($referrer['query']['cf_su'])){
700
+ unset($referrer['query']['cf_su']);
701
+ }
702
+ $query_vars = array_merge($query_vars, $referrer['query']);
703
+ }
704
+ // get vars in url
705
+ $base_redirect = self::do_magic_tags( $processor['config']['url'] );
706
+ $redirect = parse_url( $base_redirect );
707
+
708
+ if(!empty($redirect['query'])){
709
+ parse_str($redirect['query'], $redirect['query']);
710
+ $base_redirect = explode('?', $base_redirect, 2);
711
+ $query_vars = array_merge($redirect['query'], $query_vars);
712
+ $redirect = $base_redirect[0] . '?' . http_build_query($query_vars);
713
+ }else{
714
+ $redirect = $base_redirect . '?' . http_build_query($query_vars);
715
+ }
716
+
717
+ return $redirect;
718
  }
719
  }
720
  }
735
  $value = self::do_magic_tags( $value );
736
  }
737
  }
738
+
739
  // set header
740
  $headers = 'From: ' . $config['sender_name'] . ' <' . $config['sender_email'] . '>' . "\r\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
741
 
 
 
 
742
  $message = self::do_magic_tags( $message );
743
 
744
  // setup mailer
 
 
745
  $subject = $config['subject'];
746
  do_action( 'caldera_forms_do_autoresponse', $config, $form);
747
+ wp_mail($config['recipient_name'].' <'.$config['recipient_email'].'>', $subject, $message, $headers );
 
748
 
749
  }
750
 
836
  "file" => CFCORE_PATH . "fields/calculation/field.php",
837
  "handler" => array($this, "run_calculation"),
838
  "category" => __("Special,Math", "cladera-forms"),
839
+ "description" => __('Calculate values', "cladera-forms"),
840
  "setup" => array(
841
  "template" => CFCORE_PATH . "fields/calculation/config.php",
842
  "preview" => CFCORE_PATH . "fields/calculation/preview.php",
1010
  "not_supported" => array(
1011
  'hide_label',
1012
  'caption',
1013
+ 'required',
1014
+ 'entry_list'
1015
  )
1016
  )
1017
  ),
1028
  'hide_label',
1029
  'caption',
1030
  'required',
 
1031
  )
1032
  )
1033
  ),
1215
 
1216
  }
1217
 
1218
+ public function auto_populate_options_field($field, $form){
1219
+
1220
+ if(!empty($field['config']['auto'])){
1221
+ $field['config']['option'] = array();
1222
+ switch($field['config']['auto_type']){
1223
+ case 'post_type':
1224
+ $posts = get_posts( array('post_type' => $field['config']['post_type'], 'post_status' => 'publish') );
1225
+ if($field['type'] === 'dropdown'){
1226
+ $field['config']['option'] = array(
1227
+ array(
1228
+ 'value' => '',
1229
+ 'label' => ''
1230
+ )
1231
+ );
1232
+ }
1233
+ foreach($posts as $post_item){
1234
+ $field['config']['option'][$post_item->ID] = array(
1235
+ 'value' => $post_item->ID,
1236
+ 'label' => $post_item->post_title
1237
+ );
1238
+ }
1239
+ break;
1240
+ case 'taxonomy':
1241
+ $taxos = get_terms( $field['config']['taxonomy'], 'orderby=count&hide_empty=0' );
1242
+
1243
+ foreach( $taxos as $term){
1244
+ $field['config']['option'][$term->term_id] = array(
1245
+ 'value' => $term->term_id,
1246
+ 'label' => $term->name
1247
+ );
1248
+ }
1249
+ break;
1250
+ }
1251
+ }
1252
+ return $field;
1253
+ }
1254
+
1255
  static public function check_condition($conditions, $form){
1256
 
1257
  $trues = array();
1413
  'text',
1414
  'email'
1415
  ),
1416
+ 'get:*',
1417
+ 'post:*',
1418
+ 'request:*',
1419
+ 'post_meta:*',
1420
  'embed_post:ID',
1421
  'embed_post:post_title',
1422
  'embed_post:permalink',
1435
 
1436
  $tags['system'] = array(
1437
  'type' => __('System Tags', 'caldera-forms'),
1438
+ 'tags' => $system_tags,
1439
+ 'wrap' => array('{','}')
1440
  );
1441
  // get processor tags
1442
  $processors = apply_filters('caldera_forms_get_form_processors', array() );
1443
  if(!empty($processors)){
1444
  foreach($processors as $processor_key=>$processor){
1445
+ if(isset($processor['magic_tags'])){
1446
  foreach($processor['magic_tags'] as $key_tag=>$value_tag){
1447
 
1448
  if(!isset($tags[$processor_key])){
1449
  $tags[$processor_key] = array(
1450
  'type' => $processor['name'],
1451
+ 'tags' => array(),
1452
+ 'wrap' => array('{','}')
1453
  );
1454
  }
1455
  if(is_array($value_tag)){
1478
  return $tags;
1479
  }
1480
 
1481
+ static public function do_magic_tags($value, $entry_id = null, $magic_caller = array()){
1482
 
1483
  global $processed_meta, $form;
1484
  /// get meta entry for magic tags defined.
1513
  $magic_tag = null;
1514
  }
1515
  break;
1516
+ case 'variable':
1517
+ if(!empty($form['variables']['keys'])){
1518
+ foreach($form['variables']['keys'] as $var_index=>$var_key){
1519
+ if( $var_key == $magic[1] ){
1520
+ if( !in_array($magic_tag, $magic_caller) ){
1521
+ $magic_caller[] = $magic_tag;
1522
+ $magic_tag = self::do_magic_tags( $form['variables']['values'][$var_index], $entry_id, $magic_caller );
1523
+ }else{
1524
+ $magic_tag = $form['variables']['values'][$var_index];
1525
+ }
1526
+ }
1527
+ }
1528
+ }
1529
+ break;
1530
  case 'date':
1531
  $magic_tag = date($magic[1]);
1532
  break;
1627
  if(!empty($form['ID']) ){
1628
  //dump($processed_meta[$form['ID']]);
1629
 
1630
+ // split processor
1631
+
1632
+ if(!empty($magic[1])){
1633
+ if( false !== strpos( $magic[1], ':' )){
1634
+ $magic = array_reverse( explode(':', $magic[1]) );
1635
+ }
1636
+ }
1637
  // check if its a process id or processor slug
1638
  if( empty($processed_meta[$form['ID']][$magic[0]]) && !empty($form['processors']) ){
1639
 
1671
  }
1672
  }
1673
  }
1674
+ // fields
1675
+ $regex = "/%(.*?)%/";
1676
+ preg_match_all($regex, $value, $matches);
1677
+ if(!empty($matches[1])){
1678
+ foreach($matches[1] as $key=>$tag){
1679
+ $entry = self::get_slug_data($tag, $form, $entry_id);
1680
+
1681
+ if($entry !== null){
1682
+ if(is_array($entry)){
1683
+ if(count($entry) === 1){
1684
+ $entry = array_shift($entry);
1685
+ }elseif(count($entry) === 2){
1686
+ $entry = implode(' & ', $entry);
1687
+ }elseif(count($entry) > 2){
1688
+ $last = array_pop($entry);
1689
+ $entry = implode(', ', $entry).' & '.$last;
1690
+ }else{
1691
+ continue;
1692
+ }
1693
+ }
1694
+ $value = str_replace($matches[0][$key], $entry, $value);
1695
+ }
1696
+ }
1697
+ }
1698
+
1699
  return $value;
1700
  }
1701
 
1792
  //dump($processed_data[$form['ID']],0);
1793
  //echo $field_id.'<br>';
1794
  if(is_string($form)){
 
 
 
 
 
1795
  $form = get_option( $form );
1796
  if(!isset($form['ID']) || $form['ID'] !== $form){
 
1797
  return null;
1798
  }
1799
  }
1800
+
1801
+ $indexkey = $form['ID'];
1802
+ if(!empty($entry_id)){
1803
+ $indexkey = $form['ID'] . '_' . $entry_id;
1804
+ }
1805
  // get processed cached item
1806
+ if(isset($processed_data[$indexkey][$field_id])){
1807
+ return $processed_data[$indexkey][$field_id];
1808
  }
1809
  // entry fetch
1810
  if(!empty($entry_id) && isset($form['fields'][$field_id])){
1814
  $entry = $wpdb->get_results($wpdb->prepare("
1815
  SELECT `value` FROM `" . $wpdb->prefix ."cf_form_entry_values` WHERE `entry_id` = %d AND `field_id` = %s AND `slug` = %s", $entry_id, $field_id, $form['fields'][$field_id]['slug']), ARRAY_A);
1816
 
1817
+ //allow plugins to alter the value
1818
+ $entry = apply_filters('caldera_forms_get_field_entry', $entry, $field_id, $form, $entry_id);
1819
+
1820
  if(!empty($entry)){
1821
  if( count( $entry ) > 1){
1822
  $out = array();
1823
  foreach($entry as $item){
1824
  $out[] = $item['value'];
1825
  }
1826
+ $processed_data[$indexkey][$field_id] = $out;
1827
  }else{
1828
+ $processed_data[$indexkey][$field_id] = $entry[0]['value'];
1829
  }
1830
  }else{
1831
+ $processed_data[$indexkey][$field_id] = null;
1832
  }
1833
+ return $processed_data[$indexkey][$field_id];
1834
+ //return $processed_data[$indexkey][$field_id] = ;
1835
  }
1836
 
1837
  if(isset($form['fields'][$field_id])){
1851
  // dont bother if conditions say it shouldnt be here.
1852
  if(!empty($field['conditions']['type'])){
1853
  if(!self::check_condition($field['conditions'], $form)){
1854
+ $processed_data[$indexkey][$field_id] = $entry;
1855
  return $entry;
1856
  }
1857
  }
1865
  if(has_filter('caldera_forms_process_field_' . $field['type'])){
1866
  $entry = apply_filters( 'caldera_forms_process_field_' . $field['type'] , $entry, $field, $form );
1867
  if( is_wp_error( $entry ) ) {
1868
+ $processed_data[$indexkey][$field_id] = $entry;
1869
  return $entry;
1870
  }
1871
  }
1892
  $out[] = self::do_magic_tags($field['config']['option'][$option_id]['value']);
1893
  }
1894
  }
1895
+ $processed_data[$indexkey][$field_id] = $out;
1896
  }else{
1897
  if(!empty($field['config']['option'])){
1898
  foreach($field['config']['option'] as $option){
1899
  if($option['value'] == $entry){
1900
+ $processed_data[$indexkey][$field_id] = self::do_magic_tags($entry);
1901
  break;
1902
  }
1903
  }
1904
  }
1905
  }
1906
  }else{
1907
+ $processed_data[$indexkey][$field_id] = self::do_magic_tags($field['config']['default']);
1908
  }
1909
  }else{
1910
  // dynamic
1911
+ $processed_data[$indexkey][$field_id] = $entry;
1912
  }
1913
  }else{
1914
  $is_tag = self::do_magic_tags($field_id);
1915
  if($is_tag !== $field_id){
1916
+ $processed_data[$indexkey][$field_id] = $is_tag;
1917
  }
1918
  }
1919
 
1920
+ if(isset($processed_data[$indexkey][$field_id])){
1921
+ return $processed_data[$indexkey][$field_id];
1922
  }
1923
 
1924
 
1939
 
1940
  if($field['slug'] == $slug){
1941
 
1942
+ return self::get_field_data( $field_id, $form, $entry_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1943
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1944
  }
1945
  }
1946
+
 
 
 
1947
  }
1948
  static public function get_entry_detail($entry_id, $form){
1949
  global $wpdb;
1951
  $entry = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . $wpdb->prefix ."cf_form_entries` WHERE `id` = %d", $entry_id), ARRAY_A);
1952
  if(!empty($entry)){
1953
  // get meta if any
1954
+ $meta = self::get_entry_meta($entry_id, $form);
1955
+ if(!empty($meta)){
1956
+ $entry['meta'] = $meta;
1957
+ }
1958
+ }
1959
+ $entry = apply_filters( 'caldera_forms_get_entry_detail', $entry, $entry_id, $form );
1960
+ return $entry;
1961
+ }
 
 
 
1962
 
1963
+ static public function get_entry_meta($entry_id, $form, $type = null){
1964
+ global $wpdb;
1965
+
1966
+ $entry_meta = array();
1967
+
1968
+ $entry_meta_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . $wpdb->prefix ."cf_form_entry_meta` WHERE `entry_id` = %d", $entry_id), ARRAY_A);
1969
+ if(!empty($entry_meta_data)){
1970
+ $processors = apply_filters('caldera_forms_get_form_processors', array() );
1971
+ foreach($entry_meta_data as $meta_index=>$meta){
1972
+ // is json?
1973
+ if( false !== strpos($meta['meta_value'], '{') || false !== strpos($meta['meta_value'], '[') ){
1974
+ $meta['meta_value'] = json_decode($meta['meta_value'], ARRAY_A);
1975
+ }else{
1976
+ $meta['meta_value'] = $meta['meta_value'];
1977
+ }
1978
 
1979
+ $group = 'meta';
1980
+ $meta = apply_filters('caldera_forms_get_entry_meta', $meta, $form);
1981
 
1982
+ if(isset($form['processors'][$meta['process_id']])){
 
 
 
1983
 
1984
+ $process_config = array();
1985
+ if(isset($form['processors'][$meta['process_id']]['config'])){
1986
+ $process_config = $form['processors'][$meta['process_id']]['config'];
1987
+ }
1988
 
1989
+ $group = $form['processors'][$meta['process_id']]['type'];
1990
+ if(!empty($type)){
1991
+ if($group != $type){
1992
+ continue;
1993
+ }
1994
+ }
1995
+ $meta = apply_filters('caldera_forms_get_entry_meta_' . $form['processors'][$meta['process_id']]['type'], $meta, $process_config , $form);
1996
+
1997
+
1998
+ // allows plugins to remove it.
1999
+ if(!empty($meta)){
2000
+ if(!isset($entry_meta[$group])){
2001
+ // is processor
2002
+ if(isset($form['processors'][$meta['process_id']]['type'])){
2003
+ $meta_name = $processors[$form['processors'][$meta['process_id']]['type']]['name'];
2004
+ }else{
2005
+ $meta_name = $meta['process_id'];
 
2006
  }
2007
+ $entry_meta[$group] = array(
2008
+ 'name' => $meta_name,
2009
+ 'data' => array()
2010
+ );
2011
+ // custom template
2012
+ if( isset( $processors[$form['processors'][$meta['process_id']]['type']]['meta_template'] ) && file_exists( $processors[$form['processors'][$meta['process_id']]['type']]['meta_template'] ) ){
2013
+ $entry_meta[$group][$group.'_template'] = $entry_meta[$group]['template'] = true;
2014
+ }
2015
+ }
2016
 
2017
+ //if(!empty($meta['meta_title'])){
2018
+ // $entry_meta[$group]['data'][$meta['process_id']]['title'] = $meta['meta_title'];
2019
+ //}
2020
 
2021
+ $entry_meta[$group]['data'][$meta['process_id']]['entry'][$meta['meta_key']] = $meta;
2022
 
2023
+
2024
+ /*if(is_array($meta['meta_value'])){
2025
+ foreach($meta['meta_value'] as $mkey=>$mval){
2026
+ $entry['meta'][$group]['data'][$meta['process_id']]['title'] = $meta['meta_key'];
 
 
 
 
 
 
2027
  $entry['meta'][$group]['data'][$meta['process_id']]['entry'][] = array(
2028
+ 'meta_key' => $mkey,
2029
+ 'meta_value' => $mval
2030
+ );
2031
+ }
2032
+ }else{
2033
+ $entry['meta'][$group]['data'][$meta['process_id']]['entry'][] = array(
2034
+ 'meta_key' => $meta['meta_key'],
2035
+ 'meta_value' => $meta['meta_value']
2036
+ );
2037
+ }*/
2038
 
 
2039
  }
2040
  }
2041
  }
2042
  }
2043
+ // if type
2044
+ if(!empty($type)){
2045
+ //return only type
2046
+ if(!empty($entry_meta[$type]['data'])){
2047
+ return $entry_meta[$type]['data'];
2048
+ }
2049
+ }
2050
+ return $entry_meta;
2051
  }
2052
 
2053
  static public function get_submission_data($form, $entry_id = false){
2054
  global $processed_data;
2055
 
2056
  if(is_string($form)){
 
 
 
 
2057
  $form_id = $form;
2058
  $form = get_option( $form );
2059
  if(!isset($form['ID']) || $form['ID'] !== $form_id){
2061
  }
2062
  }
2063
 
2064
+ $indexkey = $form['ID'];
2065
+ if(!empty($entry_id)){
2066
+ $indexkey = $form['ID'] . '_' . $entry_id;
2067
+ }
2068
+
2069
+ // get processed cached item using the form id
2070
+ if(isset($processed_data[$indexkey])){
2071
+ return $processed_data[$indexkey];
2072
+ }
2073
 
2074
  // initialize process data
2075
  foreach($form['fields'] as $field_id=>$field){
2076
  self::get_field_data( $field_id, $form, $entry_id);
2077
  }
2078
 
2079
+ return $processed_data[$indexkey];
2080
  }
2081
 
2082
  static public function process_submission(){
2114
  // init filter
2115
  $form = apply_filters('caldera_forms_submit_get_form', $form);
2116
 
2117
+ // check source is ajax to overide
2118
+ if( !empty($_POST['cfajax']) && $_POST['cfajax'] == $form['ID'] ){
2119
+ $form['form_ajax'] = 1;
2120
+ }
2121
+
2122
+
2123
  // instance number
2124
  $form_instance_number = 1;
2125
  if(isset($_POST['_cf_frm_ct'])){
2235
  if(isset($_POST['_cf_frm_edt'])){
2236
  // is edit
2237
  //check user can edit this item.
2238
+ $transdata['edit'] = (int) $_POST['_cf_frm_edt'];
2239
  $user_id = get_current_user_id();
2240
  if(empty($user_id)){
2241
  $transdata['error'] = true;
2357
  $config = array_merge($config, $processor['config']);
2358
  }
2359
  if(is_array($process['pre_processor'])){
2360
+ $process_line_data = call_user_func_array($process['pre_processor'],array($config, $form, $process_id));
2361
  }else{
2362
  if(function_exists($process['pre_processor'])){
2363
  $func = $process['pre_processor'];
2364
+ $process_line_data = $func($config, $form, $process_id);
2365
  }
2366
  }
2367
  // pre processors should not return unless a break in action for further
2427
  $hasmeta = null;
2428
  // set default config
2429
  $config = array();
2430
+ $config['processor_id'] = $processor_id;
2431
  if(isset($process['default'])){
2432
  $config = $process['default'];
2433
  }
2436
  $config = array_merge($config, $processor['config']);
2437
  }
2438
  if(is_array($process['processor'])){
2439
+ $hasmeta = call_user_func_array($process['processor'],array($config, $form, $process_id));
2440
  }else{
2441
  if(function_exists($process['processor'])){
2442
  $func = $process['processor'];
2443
+ $hasmeta = $func($config, $form, $process_id);
2444
  }
2445
  }
2446
  if($hasmeta !== null){
2502
  }
2503
  // set default config
2504
  $config = array();
2505
+ $config['processor_id'] = $processor_id;
2506
  if(isset($process['default'])){
2507
  $config = $process['default'];
2508
  }
2511
  $config = array_merge($config, $processor['config']);
2512
  }
2513
  if(is_array($process['post_processor'])){
2514
+ $hasmeta = call_user_func_array($process['post_processor'],array($config, $form, $process_id));
2515
  }else{
2516
  if(function_exists($process['post_processor'])){
2517
  $func = $process['post_processor'];
2518
+ $hasmeta = $func($config, $form, $process_id);
2519
  }
2520
  }
2521
  if($hasmeta !== null){
2534
 
2535
  // redirect back or to result page
2536
  $referrer['query']['cf_su'] = $form_instance_number;
2537
+ // passback values
2538
+ if( !empty( $form['variables']['types'] ) ){
2539
+ foreach($form['variables']['types'] as $variable_index=>$behavior_type){
2540
+ if($behavior_type == 'passback'){
2541
+ $referrer['query'][$form['variables']['keys'][$variable_index]] = self::do_magic_tags( $form['variables']['values'][$variable_index] );
2542
+ }
2543
+ }
2544
+ }
2545
  $referrer = $referrer['path'] . '?' . http_build_query($referrer['query']);
2546
 
2547
  // filter refer
2754
  }
2755
  }
2756
  }
2757
+ if($code == 'caldera_form_modal'){
2758
+ //dump($code);
2759
+ wp_enqueue_style( 'cf-modal-styles', CFCORE_URL . 'assets/css/modals.css', array(), self::VERSION );
2760
+ //caldera_form_modal
2761
+ }
2762
  }
2763
  }
2764
  }
2778
  return $found;
2779
  }
2780
 
2781
+ static public function get_entry($entry_id = null, $form = null){
2782
 
2783
  if(empty($entry_id)){
2784
  if(!empty($_POST['form'])){
2787
  if(empty($form)){
2788
  return;
2789
  }
 
 
 
2790
  $fields = array();
2791
  foreach ($form['fields'] as $field_id => $field) {
2792
  $fields[$field['slug']] = $field;
2797
  }
2798
 
2799
  }
2800
+ if(empty($form)){
2801
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2802
  }
2803
+ // get fields
2804
+ $field_types = self::get_field_types();
2805
+ // get data
2806
+
2807
+ $entry = self::get_submission_data($form, $entry_id);
2808
+ $data = array(
2809
+ 'data' => array()
2810
+ );
2811
+ foreach($entry as $field_id=>$field_value){
2812
+
2813
+ if(!isset($form['fields'][$field_id]) || !isset($field_types[$form['fields'][$field_id]['type']])){
2814
+ continue;
2815
  }
2816
 
2817
+ if(isset($field_types[$form['fields'][$field_id]['type']]['setup']['not_supported'])){
2818
+ if(in_array('entry_list', $field_types[$form['fields'][$field_id]['type']]['setup']['not_supported'])){
2819
+ continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2820
  }
2821
+ }
2822
+ //not_supported
2823
 
2824
+ $field = $form['fields'][$field_id];
 
 
 
 
 
 
 
 
2825
 
2826
+ $data['data'][$field_id] = array(
2827
+ 'label' => $field['label'],
2828
+ 'view' => apply_filters('caldera_forms_view_field_' . $field['type'], $field_value, $field, $form),
2829
+ 'value' => $field_value
2830
+ );
2831
  }
2832
+
2833
  // get meta
2834
+ $dateformat = get_option( 'date_format' );
2835
+ $timeformat = get_option( 'time_format' );
2836
+ $gmt_offset = get_option( 'gmt_offset' );
2837
  $entry_detail = self::get_entry_detail($entry_id, $form);
2838
+ $data['date'] = date_i18n( $dateformat.' '.$timeformat, strtotime($entry_detail['datestamp']), $gmt_offset);
2839
+
2840
  if(!empty($entry_detail['meta'])){
2841
  $data['meta'] = $entry_detail['meta'];
2842
  }
2843
 
2844
 
2845
+ if(!empty($entry_detail['user_id'])){
2846
+ $user = get_userdata( $entry_detail['user_id'] );
2847
  if(!empty($user)){
2848
  $data['user'] = array(
2849
  'ID' => $user->ID,
2872
  return $data;
2873
  }
2874
 
2875
+ static public function render_modal_form($atts, $content){
2876
+ global $footer_modals;
2877
+
2878
+ if(empty($atts['id'])){
2879
+ return $content;
2880
+ }
2881
+ $form = get_option( $atts['id'] );
2882
+ if(empty($form['ID']) || $form['ID'] != $atts['id']){
2883
+ return $content;
2884
+ }
2885
+
2886
+ $modal_button_classes = array(
2887
+ "cf_modal_button"
2888
+ );
2889
+
2890
+ if(!empty($atts['classes'])){
2891
+ $modal_button_classes = array_merge($modal_button_classes, explode(',', $atts['classes']));
2892
+ }
2893
+
2894
+ $modal_id = uniqid($form['ID']);
2895
+
2896
+ $out = "<a class=\" " . implode(' ', $modal_button_classes) . "\" href=\"#" . $modal_id . "\">" . $content . "</a>\r\n";
2897
+
2898
+ $current_state = 'style="display:none;"';
2899
+ if(!empty($_GET['cf_er'])){
2900
+ $transdata = get_transient( $_GET['cf_er'] );
2901
+ if($transdata['transient'] == $_GET['cf_er']){
2902
+ $current_state = 'style="display:block;"';
2903
+ }
2904
+ }
2905
+ if(!empty($_GET['cf_su'])){
2906
+ // disable notices
2907
+ unset($_GET['cf_su']);
2908
+ }
2909
+
2910
+ $width = '';
2911
+ if(!empty($atts['width'])){
2912
+ $width = ' width: ' . floatval( $atts['width'] ).'px; margin-left: -' . ( floatval( $atts['width'] ) / 2 ) . 'px;';
2913
+ }
2914
+
2915
+ ob_start();
2916
+ ?>
2917
+ <div id="<?php echo $modal_id; ?>" class="caldera-front-modal-container" <?php echo $current_state; ?>>
2918
+ <div class="caldera-backdrop"></div>
2919
+ <div id="<?php echo $modal_id; ?>_modal_wrap" tabindex="-1" arialabelled-by="<?php echo $modal_id; ?>_modal_label" class="caldera-modal-wrap caldera-front-modal-wrap" style="display: block; <?php echo $width; ?>">
2920
+ <div class="caldera-modal-title" id="<?php echo $modal_id; ?>_modal_title" style="display: block;">
2921
+ <a href="#close" class="caldera-modal-closer caldera-front-modal-closer" data-dismiss="modal" aria-hidden="true" id="<?php echo $modal_id; ?>_modal_closer">&times;</a>
2922
+ <h3 class="modal-label" id="<?php echo $modal_id; ?>_modal_label"><?php echo $form['name']; ?></h3>
2923
+ </div>
2924
+ <div class="caldera-modal-body caldera-front-modal-body" id="<?php echo $modal_id; ?>_modal_body">
2925
+ <?php echo self::render_form( array('id'=>$form['ID'],'ajax'=>true) ); ?>
2926
+ </div>
2927
+ </div>
2928
+ </div>
2929
+ <?php
2930
+ $footer_modals .= ob_get_clean();
2931
+ return $out;
2932
+ }
2933
+ static public function render_footer_modals(){
2934
+ global $footer_modals;
2935
+ if(!empty($footer_modals)){
2936
+ echo $footer_modals;
2937
+ }
2938
+ }
2939
  static public function render_form($atts, $entry_id = null){
2940
 
2941
  global $current_form_count;
2976
 
2977
  }
2978
 
2979
+ if(isset($atts['ajax'])){
2980
+ if(!empty($atts['ajax'])){
2981
+ $form['form_ajax'] = 1;
2982
+ }else{
2983
+ $form['form_ajax'] = 0;
2984
+ }
2985
+ }
2986
+
2987
  // set entry edit
2988
  if(!empty($atts['entry'])){
2989
  $entry_id = self::do_magic_tags( $atts['entry'] );
3118
 
3119
  // load requested data
3120
  if(!empty($entry_id)){
3121
+ $prev_entry = self::get_entry($entry_id, $form);
3122
+ $prev_data = array();
3123
+ foreach($prev_entry['data'] as $field_id=>$entry_data){
3124
+ $prev_data[$field_id] = $entry_data['value'];
3125
+ }
3126
  $prev_data = apply_filters('caldera_forms_render_get_entry', $prev_data, $form, $entry_id);
3127
  }
3128
 
3139
  }
3140
 
3141
  if(!is_wp_error( $field_entry )){
3142
+ $prev_data[$field_id] = $field_entry;
3143
  }
3144
  }
3145
  }
3234
  if(!empty($form['layout_grid']['fields'])){
3235
 
3236
  foreach($form['layout_grid']['fields'] as $field_base_id=>$location){
3237
+ // instance base
3238
  if(isset($form['fields'][$field_base_id])){
3239
 
3240
  $field = apply_filters('caldera_forms_render_setup_field', $form['fields'][$field_base_id], $form);
3278
  $field_input_class = $field_classes['field_wrapper'];
3279
  $field_class = $field_classes['field'];
3280
 
3281
+ if(!empty($field_errors[$field_base_id])){
3282
  $field_input_class .= " " . $field_classes['field_error'];
3283
+ $field_structure['field_caption'] = "<span class=\"" . $field_classes['field_caption'] . "\">" . $field_errors[$field_base_id] . "</span>\r\n";
3284
  }
3285
 
3286
  // value
3290
  }
3291
 
3292
  // transient data
3293
+ if(isset($prev_data[$field_base_id])){
3294
+ $field_structure['field_value'] = $prev_data[$field_base_id];
3295
  }
3296
 
3297
  $field_structure = apply_filters('caldera_forms_render_field_structure', $field_structure, $form);
3299
  $field_structure = apply_filters('caldera_forms_render_field_structure_slug-' . $field['slug'], $field_structure, $form);
3300
 
3301
  $field_name = $field_structure['name'];
3302
+ $field_id = $field_structure['id'] . '_' . $current_form_count;
3303
  $field_label = $field_structure['label_before'] . $field_structure['label'] . $field_structure['label_required'] . $field_structure['label_after']."\r\n";
3304
  $field_placeholder = $field_structure['field_placeholder'];
3305
  $field_required = $field_structure['field_required'];
3306
  $field_caption = $field_structure['field_caption'];
3307
  // blank default
3308
  $field_value = $field_structure['field_value'];
3309
+ // setup base instance ID
3310
+ $field_base_id = $field_base_id.'_'.$current_form_count;
3311
 
3312
  ob_start();
3313
  include $field_types[$field['type']]['file'];
3391
  $out .= "<input type=\"hidden\" name=\"_cf_frm_tr\" value=\"" . $prev_post['transient'] . "\">\r\n";
3392
  }
3393
  // is edit?
3394
+ if(!empty($entry_id)){
3395
  $out .= "<input type=\"hidden\" name=\"_cf_frm_edt\" value=\"" . $entry_id . "\">\r\n";
3396
  }
3397
 
3401
  // retain query string
3402
  $qurystr = array();
3403
  parse_str( $_SERVER['QUERY_STRING'], $qurystr );
3404
+ $out .= "<span class=\"caldera-grid\"><ol class=\"breadcrumb\" data-form=\"caldera_form_" . $current_form_count ."\">\r\n";
3405
  $current_page = 1;
3406
  if(!empty($_GET['cf_pg'])){
3407
  $current_page = $_GET['cf_pg'];
3415
 
3416
  $qurystr['cf_pg'] = $page_key + 1;
3417
  $qurystr['_rdm_'] = rand(100000, 999999);
3418
+ $out .= "<li" . $tabclass . "><a href=\"?". http_build_query($qurystr) . "\" data-page=\"" . ( $page_key + 1 ) ."\" data-pagenav=\"caldera_form_" . $current_form_count ."\">". $page_name . "</a></li>\r\n";
3419
  }
3420
+ $out .= "</ol></span>\r\n";
3421
  }
3422
 
3423
  $out .= $grid->renderLayout();
fields/calculation/field.php CHANGED
@@ -33,9 +33,9 @@ if(!empty($field['config']['manual'])){
33
 
34
  foreach($form['fields'] as $key_id=>$fcfg){
35
  if($fcfg['slug'] === $tag){
36
- $binds[] = '#'.$key_id;
37
- $bindfields[] = '"'.$key_id.'"';
38
- $formula = str_replace($hastags[0][$tag_key], $key_id, $formula);
39
  }
40
  }
41
  }
@@ -45,16 +45,17 @@ if(!empty($field['config']['manual'])){
45
 
46
  }
47
  $formula = str_replace("\r",'', str_replace("\n",'', str_replace(' ','', trim( self::do_magic_tags( $formula ) ) ) ) );
48
-
49
  $binds = array();
50
  $binds_wrap = array();
51
  $binds_vars = array();
52
  foreach($form['fields'] as $fid=>$cfg){
53
  if(false !== strpos($formula, $fid)){
54
- $binds_vars[] = $fid." = parseFloat( $('[data-field=\"".$fid."\"]').is(':checkbox') ? checked_total_" . $field_base_id. "($('[data-field=\"".$fid."\"]:checked')) : $('[data-field=\"".$fid."\"]').is(':radio') ? $('[data-field=\"".$fid."\"]:checked').val() : $('[data-field=\"".$fid."\"]').val() ) || 0 ";
55
- $binds[] = "[data-field=\"".$fid."\"]";
 
 
56
  // include a conditional wrapper
57
- $binds_wrap[] = "#conditional_".$fid;
58
  }
59
  }
60
 
33
 
34
  foreach($form['fields'] as $key_id=>$fcfg){
35
  if($fcfg['slug'] === $tag){
36
+ $binds[] = '#'.$key_id.'_'.$current_form_count;
37
+ $bindfields[] = '"'.$key_id.'_'.$current_form_count.'"';
38
+ $formula = str_replace($hastags[0][$tag_key], $key_id.'_'.$current_form_count, $formula);
39
  }
40
  }
41
  }
45
 
46
  }
47
  $formula = str_replace("\r",'', str_replace("\n",'', str_replace(' ','', trim( self::do_magic_tags( $formula ) ) ) ) );
 
48
  $binds = array();
49
  $binds_wrap = array();
50
  $binds_vars = array();
51
  foreach($form['fields'] as $fid=>$cfg){
52
  if(false !== strpos($formula, $fid)){
53
+ //dump($cfg,0);
54
+ $formula = str_replace($fid, $fid.'_'.$current_form_count, $formula);
55
+ $binds_vars[] = $fid.'_'.$current_form_count." = parseFloat( $('[data-field=\"".$fid.'_'.$current_form_count."\"]').is(':checkbox') ? checked_total_" . $field_base_id. "($('[data-field=\"".$fid.'_'.$current_form_count."\"]:checked')) : $('[data-field=\"".$fid.'_'.$current_form_count."\"]').is(':radio') ? $('[data-field=\"".$fid.'_'.$current_form_count."\"]:checked').val() : $('[data-field=\"".$fid.'_'.$current_form_count."\"]').val() ) || 0 ";
56
+ $binds[] = "[data-field=\"".$fid.'_'.$current_form_count."\"]";
57
  // include a conditional wrapper
58
+ $binds_wrap[] = "#conditional_".$fid.'_'.$current_form_count;
59
  }
60
  }
61
 
fields/checkbox/config_template.html CHANGED
@@ -1,6 +1,5 @@
1
  <div class="caldera-config-group">
2
- <label for="{{_id}}_inline">Inline</label>
3
  <div class="caldera-config-field">
4
- <input id="{{_id}}_inline" type="checkbox" class="field-config" name="{{_name}}[inline]" value="1" {{#if inline}}checked="checked"{{/if}}>
5
  </div>
6
  </div>
1
  <div class="caldera-config-group">
 
2
  <div class="caldera-config-field">
3
+ <label for="{{_id}}_inline"><input id="{{_id}}_inline" type="checkbox" class="field-config" name="{{_name}}[inline]" value="1" {{#if inline}}checked="checked"{{/if}}> Inline </label>
4
  </div>
5
  </div>
fields/checkbox/field.php CHANGED
@@ -2,12 +2,12 @@
2
  <?php echo $field_label; ?>
3
  <div class="<?php echo $field_input_class; ?>">
4
  <?php
5
- if(empty($field['config']['option'])){ ?>
 
 
 
 
6
 
7
- <input type="checkbox" id="<?php echo $field_id; ?>" data-field="<?php echo $field_base_id; ?>" class="field-config" name="<?php echo $field_name; ?>" value="1" <?php if(!empty($field_value)){ ?>checked="true"<?php } ?>>
8
-
9
- <?php }else{
10
-
11
  foreach($field['config']['option'] as $option_key=>$option){
12
  if(!isset($option['value'])){
13
  $option['value'] = htmlspecialchars( $option['label'] );
2
  <?php echo $field_label; ?>
3
  <div class="<?php echo $field_input_class; ?>">
4
  <?php
5
+ if(!empty($field['config']['option'])){
6
+
7
+
8
+ /*<input type="checkbox" id="<?php echo $field_id; ?>" data-field="<?php echo $field_base_id; ?>" class="field-config" name="<?php echo $field_name; ?>" value="1" <?php if(!empty($field_value)){ ?>checked="true"<?php } ?>>
9
+ */
10
 
 
 
 
 
11
  foreach($field['config']['option'] as $option_key=>$option){
12
  if(!isset($option['value'])){
13
  $option['value'] = htmlspecialchars( $option['label'] );
fields/date_picker/setup.html CHANGED
@@ -1,7 +1,7 @@
1
  <div class="caldera-config-group">
2
  <label>Default</label>
3
  <div class="caldera-config-field">
4
- <input type="text" class="block-input field-config is-datepicker" data-provide="datepicker" id="{{id}}" data-date-format="{{format}}" name="{{_name}}[default]" value="{{default}}">
5
  </div>
6
  </div>
7
  <div class="caldera-config-group">
1
  <div class="caldera-config-group">
2
  <label>Default</label>
3
  <div class="caldera-config-field">
4
+ <input type="text" class="block-input field-config is-not-datepicker magic-tag-enabled" data-dontprovide="datepicker" id="{{id}}" data-date-format="{{format}}" name="{{_name}}[default]" value="{{default}}">
5
  </div>
6
  </div>
7
  <div class="caldera-config-group">
fields/email/config.php CHANGED
@@ -7,6 +7,6 @@
7
  <div class="caldera-config-group">
8
  <label>Default</label>
9
  <div class="caldera-config-field">
10
- <input type="text" id="{{_id}}_default" class="block-input field-config" name="{{_name}}[default]" value="{{default}}">
11
  </div>
12
  </div>
7
  <div class="caldera-config-group">
8
  <label>Default</label>
9
  <div class="caldera-config-field">
10
+ <input type="text" id="{{_id}}_default" class="block-input field-config magic-tag-enabled" name="{{_name}}[default]" value="{{default}}">
11
  </div>
12
  </div>
fields/hidden/setup.php CHANGED
@@ -1,6 +1,6 @@
1
  <div class="caldera-config-group">
2
  <label>Value</label>
3
  <div class="caldera-config-field">
4
- <input type="text" class="block-input field-config" name="{{_name}}[default]" value="{{default}}">
5
  </div>
6
  </div>
1
  <div class="caldera-config-group">
2
  <label>Value</label>
3
  <div class="caldera-config-field">
4
+ <input type="text" class="block-input field-config magic-tag-enabled" name="{{_name}}[default]" value="{{default}}">
5
  </div>
6
  </div>
fields/html/config_template.php CHANGED
@@ -1,4 +1,6 @@
1
  <div class="caldera-config-group">
2
  <label>Default</label>
3
  </div>
4
- <textarea class="block-input field-config" name="{{_name}}[default]" id="{{_id}}editor" style="resize:vertical; height:200px;">{{default}}</textarea>
 
 
1
  <div class="caldera-config-group">
2
  <label>Default</label>
3
  </div>
4
+ <div style="position:relative;">
5
+ <textarea class="block-input field-config magic-tag-enabled" name="{{_name}}[default]" id="{{_id}}editor" style="resize:vertical; height:200px;">{{default}}</textarea>
6
+ </div>
fields/html/field.php CHANGED
@@ -10,9 +10,9 @@ if(!empty($hastags[1])){
10
 
11
  foreach($form['fields'] as $key_id=>$fcfg){
12
  if($fcfg['slug'] === $tag){
13
- $binds[] = '[data-field="'.$key_id.'"]';
14
- $bindfields[] = '"'.$key_id.'"';
15
- $field['config']['default'] = str_replace($hastags[0][$tag_key], '{{'.$key_id.'}}', $field['config']['default']);
16
  }
17
  }
18
  }
10
 
11
  foreach($form['fields'] as $key_id=>$fcfg){
12
  if($fcfg['slug'] === $tag){
13
+ $binds[] = '[data-field="'.$key_id.'_'.$current_form_count.'"]';
14
+ $bindfields[] = '"'.$key_id.'_'.$current_form_count.'"';
15
+ $field['config']['default'] = str_replace($hastags[0][$tag_key], '{{'.$key_id.'_'.$current_form_count.'}}', $field['config']['default']);
16
  }
17
  }
18
  }
fields/paragraph/config_template.html CHANGED
@@ -13,6 +13,6 @@
13
  <div class="caldera-config-group">
14
  <label>Default</label>
15
  <div class="caldera-config-field">
16
- <textarea class="block-input field-config" name="{{_name}}[default]">{{default}}</textarea>
17
  </div>
18
  </div>
13
  <div class="caldera-config-group">
14
  <label>Default</label>
15
  <div class="caldera-config-field">
16
+ <textarea class="block-input field-config magic-tag-enabled" name="{{_name}}[default]">{{default}}</textarea>
17
  </div>
18
  </div>
fields/text/config.php CHANGED
@@ -7,7 +7,7 @@
7
  <div class="caldera-config-group">
8
  <label>Default</label>
9
  <div class="caldera-config-field">
10
- <input type="text" id="{{_id}}_default" class="block-input field-config" name="{{_name}}[default]" value="{{default}}">
11
  </div>
12
  </div>
13
 
7
  <div class="caldera-config-group">
8
  <label>Default</label>
9
  <div class="caldera-config-field">
10
+ <input type="text" id="{{_id}}_default" class="block-input field-config magic-tag-enabled" name="{{_name}}[default]" value="{{default}}">
11
  </div>
12
  </div>
13
 
fields/toggle_switch/css/setup.css CHANGED
@@ -10,7 +10,7 @@
10
 
11
  .toggle_option_row .toggle_value_field,
12
  .toggle_option_row .toggle_label_field{
13
- width: 120px;
14
  }
15
 
16
  .toggle_option_preview .button {
10
 
11
  .toggle_option_row .toggle_value_field,
12
  .toggle_option_row .toggle_label_field{
13
+ width: 136px;
14
  }
15
 
16
  .toggle_option_preview .button {
includes/cf-ajax/js/ajax-core.js CHANGED
@@ -52,7 +52,11 @@ jQuery(function($){
52
  wrap.addClass('has-error').addClass('caldera_ajax_error_wrap');
53
  wrap.append('<span class="help-block caldera_ajax_error_block">' + obj.data.fields[i] + '</span>');
54
  }
55
- }
 
 
 
 
56
  }
57
  });
58
  };
52
  wrap.addClass('has-error').addClass('caldera_ajax_error_wrap');
53
  wrap.append('<span class="help-block caldera_ajax_error_block">' + obj.data.fields[i] + '</span>');
54
  }
55
+ }
56
+ // was modal?
57
+ //setTimeout(function(){
58
+ // obj.params.target.closest('.caldera-front-modal-container').hide();
59
+ //}, 1000);
60
  }
61
  });
62
  };
includes/cf-ajax/plugin.php CHANGED
@@ -131,7 +131,7 @@ function cf_ajax_redirect($type, $url, $form){
131
  // do notices
132
  foreach($notices as $note_type => $notice){
133
  if(!empty($notice['note'])){
134
- $html .= '<div class=" '. implode(' ', $note_classes[$note_type]) . '">' . $notice['note'] .'</div>';
135
  }
136
  }
137
 
131
  // do notices
132
  foreach($notices as $note_type => $notice){
133
  if(!empty($notice['note'])){
134
+ $html .= '<div class=" '. implode(' ', $note_classes[$note_type]) . '">' . Caldera_Forms::do_magic_tags( $notice['note'] ) .'</div>';
135
  }
136
  }
137
 
includes/custom_field_class.php CHANGED
@@ -20,7 +20,7 @@ function cf_custom_field_classes(){
20
  <div class="caldera-config-group">
21
  <label><?php echo __('Custom Class', 'caldera-forms'); ?> </label>
22
  <div class="caldera-config-field">
23
- <input type="text" class="block-input field-config" name="{{_name}}[custom_class]">
24
  </div>
25
  </div>
26
  <?php
20
  <div class="caldera-config-group">
21
  <label><?php echo __('Custom Class', 'caldera-forms'); ?> </label>
22
  <div class="caldera-config-field">
23
+ <input type="text" class="block-input field-config" name="{{_name}}[custom_class]" value="{{custom_class}}">
24
  </div>
25
  </div>
26
  <?php
processors/auto_responder/config.php CHANGED
@@ -1,37 +1,37 @@
1
  <div class="caldera-config-group">
2
  <label><?php echo __('From Name', 'caldera-forms'); ?> </label>
3
  <div class="caldera-config-field">
4
- <input type="text" class="block-input field-config required" name="{{_name}}[sender_name]" value="{{sender_name}}">
5
  </div>
6
  </div>
7
  <div class="caldera-config-group">
8
  <label><?php echo __('From Email', 'caldera-forms'); ?> </label>
9
  <div class="caldera-config-field">
10
- <input type="text" class="block-input field-config required" name="{{_name}}[sender_email]" value="{{sender_email}}">
11
  </div>
12
  </div>
13
  <div class="caldera-config-group">
14
  <label><?php echo __('Email Subject', 'caldera-forms'); ?> </label>
15
  <div class="caldera-config-field">
16
- <input type="text" class="block-input field-config required" name="{{_name}}[subject]" value="{{subject}}">
17
  </div>
18
  </div>
19
  <div class="caldera-config-group">
20
  <label><?php echo __('Recipient Name', 'caldera-forms'); ?> </label>
21
  <div class="caldera-config-field">
22
- {{{_field slug="recipient_name" type="name,text" required="true"}}}
23
  </div>
24
  </div>
25
  <div class="caldera-config-group">
26
  <label><?php echo __('Recipient Email', 'caldera-forms'); ?> </label>
27
  <div class="caldera-config-field">
28
- {{{_field slug="recipient_email" type="email" required="true"}}}
29
  </div>
30
  </div>
31
  <div class="caldera-config-group">
32
  <label><?php echo __('Message', 'caldera-forms'); ?> </label>
33
  <div class="caldera-config-field">
34
- <textarea rows="6" class="block-input field-config required" name="{{_name}}[message]">{{#if message}}{{message}}{{else}}Hi %recipient_name%.
35
  Thanks for your email.
36
  We'll get get back to you as soon as possible!
37
  {{/if}}</textarea>
1
  <div class="caldera-config-group">
2
  <label><?php echo __('From Name', 'caldera-forms'); ?> </label>
3
  <div class="caldera-config-field">
4
+ <input type="text" class="block-input field-config magic-tag-enabled required" name="{{_name}}[sender_name]" value="{{sender_name}}">
5
  </div>
6
  </div>
7
  <div class="caldera-config-group">
8
  <label><?php echo __('From Email', 'caldera-forms'); ?> </label>
9
  <div class="caldera-config-field">
10
+ <input type="text" class="block-input field-config magic-tag-enabled caldera-field-bind required" id="{{_id}}_sender_email" name="{{_name}}[sender_email]" value="{{sender_email}}">
11
  </div>
12
  </div>
13
  <div class="caldera-config-group">
14
  <label><?php echo __('Email Subject', 'caldera-forms'); ?> </label>
15
  <div class="caldera-config-field">
16
+ <input type="text" class="block-input field-config magic-tag-enabled caldera-field-bind required" id="{{_id}}_subject" name="{{_name}}[subject]" value="{{subject}}">
17
  </div>
18
  </div>
19
  <div class="caldera-config-group">
20
  <label><?php echo __('Recipient Name', 'caldera-forms'); ?> </label>
21
  <div class="caldera-config-field">
22
+ <input type="text" class="block-input field-config magic-tag-enabled caldera-field-bind required" id="{{_id}}_recipient_name" name="{{_name}}[recipient_name]" value="{{recipient_name}}">
23
  </div>
24
  </div>
25
  <div class="caldera-config-group">
26
  <label><?php echo __('Recipient Email', 'caldera-forms'); ?> </label>
27
  <div class="caldera-config-field">
28
+ <input type="text" class="block-input field-config magic-tag-enabled caldera-field-bind required" id="{{_id}}_recipient_email" name="{{_name}}[recipient_email]" value="{{recipient_email}}">
29
  </div>
30
  </div>
31
  <div class="caldera-config-group">
32
  <label><?php echo __('Message', 'caldera-forms'); ?> </label>
33
  <div class="caldera-config-field">
34
+ <textarea rows="6" class="block-input field-config required magic-tag-enabled" name="{{_name}}[message]">{{#if message}}{{message}}{{else}}Hi %recipient_name%.
35
  Thanks for your email.
36
  We'll get get back to you as soon as possible!
37
  {{/if}}</textarea>
processors/redirect/config.php CHANGED
@@ -1,6 +1,6 @@
1
  <div class="caldera-config-group">
2
  <label><?php echo __('URL', 'caldera-forms'); ?> </label>
3
  <div class="caldera-config-field">
4
- <input type="text" class="block-input field-config required" name="{{_name}}[url]" value="{{url}}">
5
  </div>
6
  </div>
1
  <div class="caldera-config-group">
2
  <label><?php echo __('URL', 'caldera-forms'); ?> </label>
3
  <div class="caldera-config-field">
4
+ <input type="text" class="block-input field-config magic-tag-enabled required" name="{{_name}}[url]" value="{{url}}">
5
  </div>
6
  </div>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Desertsnowman
3
  Tags: forms, formbuilder, form builder, contact form, contact, custom form, custom forms, forms creator
4
  Requires at least: 3.9
5
  Tested up to: 3.9.1
6
- Stable tag: 1.0.91
7
  License: GPLv2
8
 
9
  Create complex grid based, responsive forms easily with an easy to use drag and drop layout builder.
@@ -72,6 +72,19 @@ none yet.
72
 
73
  == Changelog ==
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  = 1.0.91 (27 July, 2014) =
76
 
77
  = Bugfix =
@@ -80,7 +93,6 @@ none yet.
80
  = Added =
81
  * Form ID added as form class
82
 
83
-
84
  = 1.0.9 (25 July, 2014) =
85
 
86
  = Bugfix =
3
  Tags: forms, formbuilder, form builder, contact form, contact, custom form, custom forms, forms creator
4
  Requires at least: 3.9
5
  Tested up to: 3.9.1
6
+ Stable tag: 1.1.0
7
  License: GPLv2
8
 
9
  Create complex grid based, responsive forms easily with an easy to use drag and drop layout builder.
72
 
73
  == Changelog ==
74
 
75
+ = 1.1.0 (* August, 2014) =
76
+
77
+ = Added =
78
+ * Variables tab: create custom magic tags and URL return values by combining other tags, processor values and static strings.
79
+ * Magic tag autocomplete to magic tag enabled inputs in editor.
80
+ * Autopopulate options from post type or taxonomy for static select fields (radio, checkboxes, dropdown, toggle switches)
81
+
82
+
83
+ = Enhanced =
84
+ * Rebuilt the get_entry and view methods to be easier to use for developers and be more reliable
85
+ * Form Instancing and field ID's - can have multiple instances of the same form.
86
+ * Additional hooks and filters
87
+
88
  = 1.0.91 (27 July, 2014) =
89
 
90
  = Bugfix =
93
  = Added =
94
  * Form ID added as form class
95
 
 
96
  = 1.0.9 (25 July, 2014) =
97
 
98
  = Bugfix =
ui/admin.php CHANGED
@@ -3,6 +3,7 @@
3
  // Just some basics.
4
  $per_page_limit = 20;
5
 
 
6
  // get all forms
7
  $forms = get_option( '_caldera_forms' );
8
  $forms = apply_filters( 'caldera_forms_admin_forms', $forms );
@@ -17,16 +18,7 @@ if(empty($style_includes)){
17
  update_option( '_caldera_forms_styleincludes', $style_includes);
18
  }
19
 
20
- // Modal Height
21
- $modal_height = '400';
22
 
23
- // check there are groups
24
- if(!empty($meta_groups['groups'])){
25
- if( count($meta_groups['groups']) > 7){
26
- $multiplier = count($meta_groups['groups']) - 7;
27
- $modal_height = $modal_height + ( 30 * $multiplier );
28
- }
29
- }
30
  // load fields
31
  //$field_types = apply_filters('caldera_forms_get_field_types', array() );
32
 
@@ -46,8 +38,14 @@ $modal_new_form = __('Create Form', 'caldera-forms').'|{"data-action" : "create_
46
  </li>
47
  <li class="caldera-forms-toolbar-item">
48
  <a class="button ajax-trigger" data-request="start_new_form" data-modal-width="400" data-modal-height="192" data-load-class="none" data-modal="new_form" data-template="#import-form-tmpl" data-modal-title="<?php echo __('Import Form', 'caldera-forms'); ?>" ><?php echo __('Import', 'caldera-forms'); ?></a>
49
- </li>
50
  <li class="caldera-forms-toolbar-item">
 
 
 
 
 
 
51
  &nbsp;
52
  </li>
53
  <li class="caldera-forms-headtext">
@@ -63,11 +61,6 @@ $modal_new_form = __('Create Form', 'caldera-forms').'|{"data-action" : "create_
63
  <li class="caldera-forms-toolbar-item">
64
  &nbsp;
65
  </li>
66
- <?php /*
67
- <li class="caldera-forms-toolbar-item">
68
- <button type="button" title="<?php echo __('View available extensions', 'caldera-forms'); ?>" data-modal-buttons="Close|dismiss" data-load-class="spinner" data-action="save_cf_setting" data-active-class="none" data-set="alert" data-request="<?php echo CFCORE_EXTEND_URL; ?>" data-modal="extend_cf" data-modal-width="650" data-modal-title="<?php echo __('Caldera Forms Extensions', 'caldera-forms'); ?>" class="ajax-trigger button"><?php echo __('Extensions' , 'caldera-forms'); ?></button>
69
- </li>
70
- */ ?>
71
 
72
  </ul>
73
  </div>
@@ -363,10 +356,28 @@ function update_setting_toggle(obj){
363
 
364
  }
365
 
 
 
 
 
366
  function start_new_form(){
367
  return {};
368
  }
369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370
 
371
  jQuery(function($){
372
 
3
  // Just some basics.
4
  $per_page_limit = 20;
5
 
6
+
7
  // get all forms
8
  $forms = get_option( '_caldera_forms' );
9
  $forms = apply_filters( 'caldera_forms_admin_forms', $forms );
18
  update_option( '_caldera_forms_styleincludes', $style_includes);
19
  }
20
 
 
 
21
 
 
 
 
 
 
 
 
22
  // load fields
23
  //$field_types = apply_filters('caldera_forms_get_field_types', array() );
24
 
38
  </li>
39
  <li class="caldera-forms-toolbar-item">
40
  <a class="button ajax-trigger" data-request="start_new_form" data-modal-width="400" data-modal-height="192" data-load-class="none" data-modal="new_form" data-template="#import-form-tmpl" data-modal-title="<?php echo __('Import Form', 'caldera-forms'); ?>" ><?php echo __('Import', 'caldera-forms'); ?></a>
41
+ </li>
42
  <li class="caldera-forms-toolbar-item">
43
+ <button type="button" id="updated-extensions-button" title="<?php echo __('Caldera Forms Extensions', 'caldera-forms'); ?>" data-modal-buttons="Close|dismiss" data-load-class="spinner" data-active-class="none" data-set="alert" data-request="<?php echo CFCORE_EXTEND_URL . 'extensions/?version=' . CFCORE_VER; ?>" data-modal="extend_cf" data-error="extend_fail_notice" data-template="#extensions-modal-tmpl" data-modal-width="720" data-modal-title="<?php echo __('Caldera Forms Extensions & Addons', 'caldera-forms'); ?>" class="ajax-trigger button"><?php echo __('Extensions' , 'caldera-forms'); ?></button>
44
+ </li>
45
+ <li class="caldera-forms-toolbar-item">
46
+ <button type="button" id="updated-news-button" title="<?php echo __('Caldera Forms Updates, News & Tips', 'caldera-forms'); ?>" data-modal-buttons="Close|dismiss" data-load-class="spinner" data-active-class="none" data-set="alert" data-request="<?php echo CFCORE_EXTEND_URL . 'updates/?version=' . CFCORE_VER; ?>" data-modal="extend_cf" data-error="extend_fail_notice" data-template="#extensions-modal-tmpl" data-modal-width="720" data-modal-title="<?php echo __('Caldera Forms Updates, News & Tips', 'caldera-forms'); ?>" class="ajax-trigger button"><?php echo __('Updates & Tips' , 'caldera-forms'); ?></button>
47
+ </li>
48
+ <li class="caldera-forms-toolbar-item ajax-trigger" data-request="<?php echo CFCORE_EXTEND_URL . 'freshness/?version=' . CFCORE_VER; ?>" data-callback="news_update_check" data-autoload="true" data-event="none">
49
  &nbsp;
50
  </li>
51
  <li class="caldera-forms-headtext">
61
  <li class="caldera-forms-toolbar-item">
62
  &nbsp;
63
  </li>
 
 
 
 
 
64
 
65
  </ul>
66
  </div>
356
 
357
  }
358
 
359
+ function extend_fail_notice(el){
360
+ jQuery("#extend_cf_baldrickModalBody").html('<div class="alert error"><p><?php echo __('Looks like something is not working. Please try again a little later or post to the <a href="http://wordpress.org/support/plugin/caldera-forms" target="_blank">support forum</a>.', 'caldera-forms'); ?></p></div>');
361
+ }
362
+
363
  function start_new_form(){
364
  return {};
365
  }
366
 
367
+ function news_update_check(obj){
368
+ if(obj.data.updates.days <= 5){
369
+ jQuery('#updated-news-button').addClass('button-primary');
370
+ if(obj.data.updates_title){
371
+ jQuery('#updated-news-button').html( obj.data.updates_title );
372
+ }
373
+ }
374
+ if(obj.data.extensions.days <= 5){
375
+ jQuery('#updated-extensions-button').addClass('button-primary');
376
+ if(obj.data.extensions_title){
377
+ jQuery('#updated-extensions-button').html( obj.data.extensions_title );
378
+ }
379
+ }
380
+ }
381
 
382
  jQuery(function($){
383
 
ui/edit-entry.php CHANGED
@@ -257,7 +257,7 @@ do_action('caldera_forms_edit_end', $element);
257
  <div class="toggle_option_row">
258
  <i class="dashicons dashicons-sort" style="padding: 4px 9px;"></i>
259
  <input type="radio" class="toggle_set_default field-config" name="{{../_name}}[default]" value="{{@key}}" {{#is ../default value="@key"}}checked="checked"{{/is}}>
260
- <input type="text" class="toggle_value_field field-config" name="{{../_name}}[option][{{@key}}][value]" value="{{value}}" placeholder="value">
261
  <input type="text" class="toggle_label_field field-config" name="{{../_name}}[option][{{@key}}][label]" value="{{label}}" placeholder="label">
262
  <button class="button button-small toggle-remove-option" type="button"><i class="icn-delete"></i></button>
263
  </div>
257
  <div class="toggle_option_row">
258
  <i class="dashicons dashicons-sort" style="padding: 4px 9px;"></i>
259
  <input type="radio" class="toggle_set_default field-config" name="{{../_name}}[default]" value="{{@key}}" {{#is ../default value="@key"}}checked="checked"{{/is}}>
260
+ <span style="position:relative;"><input type="text" class="toggle_value_field field-config magic-tag-enabled" name="{{../_name}}[option][{{@key}}][value]" value="{{value}}" placeholder="value"></span>
261
  <input type="text" class="toggle_label_field field-config" name="{{../_name}}[option][{{@key}}][label]" value="{{label}}" placeholder="label">
262
  <button class="button button-small toggle-remove-option" type="button"><i class="icn-delete"></i></button>
263
  </div>
ui/edit.php CHANGED
@@ -43,6 +43,58 @@ $field_type_defaults = array(
43
 
44
  // options based template
45
  $field_options_template = "
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  <div class=\"caldera-config-group-toggle-options\">
47
  <div class=\"caldera-config-group caldera-config-group-full\">
48
  <button type=\"button\" class=\"button add-toggle-option\" style=\"width: 220px;\">" . __('Add Option', 'caldera-forms') . "</button>
@@ -66,7 +118,7 @@ $field_options_template = "
66
  <div class=\"toggle_option_row\">
67
  <i class=\"dashicons dashicons-sort\" style=\"padding: 4px 9px;\"></i>
68
  <input type=\"radio\" class=\"toggle_set_default field-config\" name=\"{{../_name}}[default]\" value=\"{{@key}}\" {{#is ../default value=\"@key\"}}checked=\"checked\"{{/is}}>
69
- <input{{#unless ../show_values}} disabled=\"disabled\" style=\"display:none;\"{{/unless}} type=\"text\" class=\"toggle_value_field field-config\" name=\"{{../_name}}[option][{{@key}}][value]\" value=\"{{value}}\" placeholder=\"value\">
70
  <input{{#unless ../show_values}} style=\"width:245px;\"{{/unless}} type=\"text\" class=\"toggle_label_field field-config\" name=\"{{../_name}}[option][{{@key}}][label]\" value=\"{{label}}\" placeholder=\"label\">
71
  <button class=\"button button-small toggle-remove-option\" type=\"button\"><i class=\"icn-delete\"></i></button>
72
  </div>
@@ -373,6 +425,10 @@ function field_line_template($id = '{{id}}', $label = '{{label}}', $group = '{{g
373
  <li>
374
  <a href="#settings-panel"><?php echo __("General Settings", "caldera-forms"); ?></a>
375
  </li>
 
 
 
 
376
  </ul>
377
  <button class="button button-primary caldera-header-save-button" data-active-class="none" data-load-element="#save_indicator" type="button"><?php echo __('Update Form', 'caldera-forms'); ?><span id="save_indicator" class="spinner" style="position: absolute; right: -28px;"></span></button>
378
  <a class="button caldera-header-preview-button" target="_blank" href="<?php echo trailingslashit( get_site_url() ) . '?cf_preview=' . $element['ID']; ?>"><?php echo __('Preview Form', 'caldera-forms'); ?></a>
@@ -383,14 +439,14 @@ function field_line_template($id = '{{id}}', $label = '{{label}}', $group = '{{g
383
  <div class="caldera-config-group">
384
  <label><?php echo __('Form Name', 'caldera-forms'); ?> </label>
385
  <div class="caldera-config-field">
386
- <input type="text" class="field-config required" name="config[name]" value="<?php echo $element['name']; ?>" style="width:300px;" required="required">
387
  </div>
388
  </div>
389
 
390
  <div class="caldera-config-group">
391
  <label><?php echo __('Form Description', 'caldera-forms'); ?> </label>
392
  <div class="caldera-config-field">
393
- <textarea name="config[description]" class="field-config" style="width:300px;" rows="5"><?php echo htmlentities( $element['description'] ); ?></textarea>
394
  </div>
395
  </div>
396
 
@@ -409,16 +465,16 @@ function field_line_template($id = '{{id}}', $label = '{{label}}', $group = '{{g
409
  </div>
410
  </div>
411
 
412
- <div class="caldera-config-group">
413
  <label><?php echo __('Success Message', 'caldera-forms'); ?> </label>
414
  <div class="caldera-config-field">
415
- <input type="text" class="field-config required" name="config[success]" value="<?php echo $element['success']; ?>" style="width:300px;" required="required">
416
  </div>
417
  </div>
418
  <div class="caldera-config-group">
419
  <label><?php echo __('Gravatar Field', 'caldera-forms'); ?> </label>
420
  <div class="caldera-config-field">
421
- <select style="width:300px;" class="field-config caldera-field-bind" name="config[avatar_field]" data-exclude="system" data-default="<?php if(!empty($element['avatar_field'])){ echo $element['avatar_field']; } ?>" data-type="email"></select>
422
  <p class="description"><?php echo __('Used when viewing an entry from a non-logged in user.','caldera-forms'); ?></p>
423
  </div>
424
  </div>
@@ -695,7 +751,7 @@ do_action('caldera_forms_edit_end', $element);
695
  <div class="toggle_option_row">
696
  <i class="dashicons dashicons-sort" style="padding: 4px 9px;"></i>
697
  <input type="radio" class="toggle_set_default field-config" name="{{../_name}}[default]" value="{{@key}}" {{#is ../default value="@key"}}checked="checked"{{/is}}>
698
- <input type="text" class="toggle_value_field field-config" name="{{../_name}}[option][{{@key}}][value]" value="{{value}}" placeholder="value">
699
  <input type="text" class="toggle_label_field field-config" name="{{../_name}}[option][{{@key}}][label]" value="{{label}}" placeholder="label">
700
  <button class="button button-small toggle-remove-option" type="button"><i class="icn-delete"></i></button>
701
  </div>
@@ -755,6 +811,9 @@ do_action('caldera_forms_edit_end', $element);
755
  </div>
756
  </script>
757
  <?php
 
 
 
758
 
759
  /// Output the field templates
760
  foreach($field_type_templates as $key=>$template){
@@ -767,13 +826,16 @@ foreach($field_type_templates as $key=>$template){
767
  <?php
768
 
769
 
770
- $magic_script = array();
 
 
771
 
772
  foreach($magic_tags as $magic_set_key=>$magic_tags_set){
773
-
774
  $magic_script[$magic_set_key] = array(
775
  'type' => $magic_tags_set['type'],
776
- 'tags' => array()
 
777
  );
778
 
779
  foreach($magic_tags_set['tags'] as $tag_key=>$tag_value){
43
 
44
  // options based template
45
  $field_options_template = "
46
+ <div class=\"caldera-config-group caldera-config-group-full\">
47
+ <div class=\"caldera-config-group\">
48
+ <div class=\"caldera-config-field\">
49
+ <label><input id=\"{{_id}}_auto\" type=\"checkbox\" class=\"auto-populate-options field-config\" name=\"{{_name}}[auto]\" value=\"1\" {{#if auto}}checked=\"checked\"{{/if}}> ".__('Auto Populate', 'caldera-forms')."</label>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ <div class=\"caldera-config-group-auto-options\" style=\"display:none;\">
54
+ <div class=\"caldera-config-group\">
55
+ <label>". __('Auto Type', 'caldera-forms') . "</label>
56
+ <div class=\"caldera-config-field\">
57
+ <select class=\"block-input field-config auto-populate-type\" name=\"{{_name}}[auto_type]\">
58
+ <option value=\"\">" . __('Select a source', 'caldera-forms') . "</option>
59
+ <option value=\"post_type\"{{#is auto_type value=\"post_type\"}} selected=\"selected\"{{/is}}>" . __('Post Type', 'caldera-forms') . "</option>
60
+ <option value=\"taxonomy\"{{#is auto_type value=\"taxonomy\"}} selected=\"selected\"{{/is}}>" . __('Taxonomy', 'caldera-forms') . "</option>
61
+ </select>
62
+ </div>
63
+ </div>
64
+
65
+ <div class=\"caldera-config-group caldera-config-group-auto-taxonomy auto-populate-type-panel\" style=\"display:none;\">
66
+ <label>". __('Taxonomy', 'caldera-forms')."</label>
67
+ <div class=\"caldera-config-field\">
68
+ <select class=\"block-input field-config\" name=\"{{_name}}[taxonomy]\">";
69
+
70
+ $taxonomies = get_taxonomies();
71
+
72
+ foreach($taxonomies as $tax_type=>$tax_name){
73
+ $field_options_template .= "<option value=\"" . $tax_type . "\" {{#is taxonomy value=\"" . $tax_type . "\"}}selected=\"selected\"{{/is}}>" . $tax_name . "</option>\r\n";
74
+ }
75
+
76
+ $field_options_template .= "</select>
77
+
78
+ </div>
79
+ </div>
80
+
81
+ <div class=\"caldera-config-group caldera-config-group-auto-post_type auto-populate-type-panel\" style=\"display:none;\">
82
+ <label>".__('Post Type', 'caldera-forms') ."</label>
83
+ <div class=\"caldera-config-field\">
84
+ <select class=\"block-input field-config\" name=\"{{_name}}[post_type]\">";
85
+
86
+ $post_types = get_post_types(array(), 'objects');
87
+
88
+ foreach($post_types as $type){
89
+ $field_options_template .= "<option value=\"" . $type->name . "\" {{#is post_type value=\"" . $type->name . "\"}}selected=\"selected\"{{/is}}>" . $type->labels->name . "</option>\r\n";
90
+ }
91
+
92
+ $field_options_template .= "</select>
93
+
94
+ </div>
95
+ </div>
96
+
97
+ </div>
98
  <div class=\"caldera-config-group-toggle-options\">
99
  <div class=\"caldera-config-group caldera-config-group-full\">
100
  <button type=\"button\" class=\"button add-toggle-option\" style=\"width: 220px;\">" . __('Add Option', 'caldera-forms') . "</button>
118
  <div class=\"toggle_option_row\">
119
  <i class=\"dashicons dashicons-sort\" style=\"padding: 4px 9px;\"></i>
120
  <input type=\"radio\" class=\"toggle_set_default field-config\" name=\"{{../_name}}[default]\" value=\"{{@key}}\" {{#is ../default value=\"@key\"}}checked=\"checked\"{{/is}}>
121
+ <span style=\"position: relative; display: inline-block;\"><input{{#unless ../show_values}} disabled=\"disabled\" style=\"display:none;\"{{/unless}} type=\"text\" class=\"toggle_value_field field-config magic-tag-enabled\" name=\"{{../_name}}[option][{{@key}}][value]\" value=\"{{value}}\" placeholder=\"value\"></span>
122
  <input{{#unless ../show_values}} style=\"width:245px;\"{{/unless}} type=\"text\" class=\"toggle_label_field field-config\" name=\"{{../_name}}[option][{{@key}}][label]\" value=\"{{label}}\" placeholder=\"label\">
123
  <button class=\"button button-small toggle-remove-option\" type=\"button\"><i class=\"icn-delete\"></i></button>
124
  </div>
425
  <li>
426
  <a href="#settings-panel"><?php echo __("General Settings", "caldera-forms"); ?></a>
427
  </li>
428
+ <li class="caldera-forms-toolbar-item" style="padding-top:7px;">
429
+ <button type="button" id="updated-news-button" title="<?php echo __('Caldera Forms Updates, News & Tips', 'caldera-forms'); ?>" data-modal-buttons="Close|dismiss" data-load-class="spinner" data-active-class="none" data-set="alert" data-request="<?php echo CFCORE_EXTEND_URL . 'updates/?version=' . CFCORE_VER; ?>" data-modal="extend_cf" data-error="extend_fail_notice" data-template="#extensions-modal-tmpl" data-modal-width="720" data-modal-title="<?php echo __('Caldera Forms Updates, News & Tips', 'caldera-forms'); ?>" class="ajax-trigger button"><?php echo __('Updates & Tips' , 'caldera-forms'); ?></button>
430
+ </li>
431
+
432
  </ul>
433
  <button class="button button-primary caldera-header-save-button" data-active-class="none" data-load-element="#save_indicator" type="button"><?php echo __('Update Form', 'caldera-forms'); ?><span id="save_indicator" class="spinner" style="position: absolute; right: -28px;"></span></button>
434
  <a class="button caldera-header-preview-button" target="_blank" href="<?php echo trailingslashit( get_site_url() ) . '?cf_preview=' . $element['ID']; ?>"><?php echo __('Preview Form', 'caldera-forms'); ?></a>
439
  <div class="caldera-config-group">
440
  <label><?php echo __('Form Name', 'caldera-forms'); ?> </label>
441
  <div class="caldera-config-field">
442
+ <input type="text" class="field-config required" name="config[name]" value="<?php echo $element['name']; ?>" style="width:500px;" required="required">
443
  </div>
444
  </div>
445
 
446
  <div class="caldera-config-group">
447
  <label><?php echo __('Form Description', 'caldera-forms'); ?> </label>
448
  <div class="caldera-config-field">
449
+ <textarea name="config[description]" class="field-config" style="width:500px;" rows="5"><?php echo htmlentities( $element['description'] ); ?></textarea>
450
  </div>
451
  </div>
452
 
465
  </div>
466
  </div>
467
 
468
+ <div class="caldera-config-group" style="width:500px;">
469
  <label><?php echo __('Success Message', 'caldera-forms'); ?> </label>
470
  <div class="caldera-config-field">
471
+ <input type="text" class="field-config block-input magic-tag-enabled required" name="config[success]" value="<?php echo $element['success']; ?>" required="required">
472
  </div>
473
  </div>
474
  <div class="caldera-config-group">
475
  <label><?php echo __('Gravatar Field', 'caldera-forms'); ?> </label>
476
  <div class="caldera-config-field">
477
+ <select style="width:500px;" class="field-config caldera-field-bind" name="config[avatar_field]" data-exclude="system" data-default="<?php if(!empty($element['avatar_field'])){ echo $element['avatar_field']; } ?>" data-type="email"></select>
478
  <p class="description"><?php echo __('Used when viewing an entry from a non-logged in user.','caldera-forms'); ?></p>
479
  </div>
480
  </div>
751
  <div class="toggle_option_row">
752
  <i class="dashicons dashicons-sort" style="padding: 4px 9px;"></i>
753
  <input type="radio" class="toggle_set_default field-config" name="{{../_name}}[default]" value="{{@key}}" {{#is ../default value="@key"}}checked="checked"{{/is}}>
754
+ <span style="position: relative; display: inline-block;"><input type="text" class="toggle_value_field field-config magic-tag-enabled" name="{{../_name}}[option][{{@key}}][value]" value="{{value}}" placeholder="value"></span>
755
  <input type="text" class="toggle_label_field field-config" name="{{../_name}}[option][{{@key}}][label]" value="{{label}}" placeholder="label">
756
  <button class="button button-small toggle-remove-option" type="button"><i class="icn-delete"></i></button>
757
  </div>
811
  </div>
812
  </script>
813
  <?php
814
+ //news templates
815
+ include CFCORE_PATH . 'ui/news_templates.php';
816
+
817
 
818
  /// Output the field templates
819
  foreach($field_type_templates as $key=>$template){
826
  <?php
827
 
828
 
829
+ $magic_script = array(
830
+ 'field' => array()
831
+ );
832
 
833
  foreach($magic_tags as $magic_set_key=>$magic_tags_set){
834
+
835
  $magic_script[$magic_set_key] = array(
836
  'type' => $magic_tags_set['type'],
837
+ 'tags' => array(),
838
+ 'wrap' => $magic_tags_set['wrap']
839
  );
840
 
841
  foreach($magic_tags_set['tags'] as $tag_key=>$tag_value){
ui/news_templates.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/html" id="extensions-modal-tmpl">
2
+ {{#if extensions}}
3
+ {{#each extensions}}
4
+ <div style="margin: 10px; width: {{#if width}}{{width}}{{else}}200{{/if}}px; float: left; height: {{#if height}}{{height}}{{else}}200{{/if}}px; {{#if box}}overflow: auto; border: 1px solid rgba(0, 0, 0, 0.15); box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);{{/if}}{{#if background}} background:{{background}};{{/if}}{{#if color}} color:{{color}};{{/if}}position: relative;">
5
+ {{#if banner}}<img src="{{banner}}" style="width:100%;vertical-align: top;">{{/if}}
6
+ {{#if name}}<h2>{{name}}</h2>{{/if}}
7
+ {{#if html}}<div style="margin: 0px; padding: 6px 7px;">{{{html}}}</div>{{/if}}
8
+ {{#if buttons}}
9
+ <div style="position: absolute; bottom: 0px; padding: 6px; background: none repeat scroll 0 0 rgba(0, 0, 0, 0.03); left: 0px; right: 0px; border-top: 1px solid rgba(0, 0, 0, 0.06);">
10
+ {{#each buttons}}
11
+ <a class="button {{#if class}}{{class}}{{/if}}" href="{{link}}" target="_blank">{{title}}</a>
12
+ {{/each}}
13
+ </div>
14
+ {{/if}}
15
+ </div>
16
+ {{/each}}
17
+ {{else}}
18
+ {{#if message}}
19
+ <div class="alert updated"><p>{{{message}}}</p></div>
20
+ {{else}}
21
+ <div class="alert error"><p><?php echo __('Unable to connect or no extensions available.', 'caldera-forms'); ?></p></div>
22
+ {{/if}}
23
+ {{/if}}
24
+ </script>
ui/panels/variable_add.php ADDED
@@ -0,0 +1 @@
 
1
+ <a class="add-new-h2 caldera-panel-action caldera-add-variable" href="#add_var"><?php echo __('Add Variable', 'caldera-forms'); ?></a>
ui/panels/variables.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!isset($element['variables'])){
4
+ $element['variables'] = array();
5
+ }
6
+
7
+
8
+ ?>
9
+ <div class="caldera-config-group">
10
+ <label><?php echo __('Name'); ?></label>
11
+ <div class="caldera-config-field" style="margin: 0px; padding: 4px 0px; width: 401px;">
12
+ <div><?php echo __('Value'); ?></div>
13
+ </div>
14
+ <?php echo __('Behaviour', 'caldera-forms'); ?>
15
+ </div>
16
+ <div id="variable_entry_list_none" <?php if(!empty($element['variables'])){ echo 'style="display:none;"'; } ?>><p class="description"><?php echo __('No variables defined', 'caldera-forms'); ?></p></div>
17
+ <div id="variable_entry_list">
18
+
19
+ <?php
20
+ if(!empty($element['variables']['keys'])){
21
+ foreach($element['variables']['keys'] as $var_index=>$var_value){
22
+ ?>
23
+ <div class="caldera-config-group">
24
+ <label style="padding:2px 0;"><input type="text" class="block-input field-config set-system-variable" name="config[variables][keys][]" value="<?php echo $var_value; ?>"></label>
25
+ <div class="caldera-config-field" style="width:400px;">
26
+ <input type="text" class="field-config var-value block-input magic-tag-enabled" name="config[variables][values][]" value="<?php echo $element['variables']['values'][$var_index]; ?>">
27
+ </div>
28
+ <select name="config[variables][types][]" class="field-config" style="vertical-align: baseline;">
29
+ <option value="static" <?php if( $element['variables']['types'][$var_index] == 'static'){ echo 'selected="selected"'; } ?>><?php echo __('Static', 'caldera-forms'); ?></option>
30
+ <option value="passback" <?php if( $element['variables']['types'][$var_index] == 'passback'){ echo 'selected="selected"'; } ?>><?php echo __('Passback', 'caldera-forms'); ?></option>
31
+ </select>
32
+ &nbsp;<button type="button" class="button remove-this-variable">&times;</button>
33
+ </div>
34
+ <?php
35
+ }
36
+ }
37
+
38
+ ?>
39
+ </div>
40
+ <script type="text/html" id="variable-fields-tmpl">
41
+ <div class="caldera-config-group">
42
+ <label style="padding:2px 0;"><input type="text" class="block-input field-config set-system-variable" name="config[variables][keys][]" value=""></label>
43
+ <div class="caldera-config-field" style="width:400px;">
44
+ <input type="text" class="field-config var-value block-input magic-tag-enabled" name="config[variables][values][]" value="">
45
+ </div>
46
+ <select name="config[variables][types][]" class="field-config" style="vertical-align: baseline;">
47
+ <option value="static"><?php echo __('Static', 'caldera-forms'); ?></option>
48
+ <option value="passback"><?php echo __('Passback', 'caldera-forms'); ?></option>
49
+ </select>
50
+ &nbsp;<button type="button" class="button remove-this-variable">&times;</button>
51
+ </div>
52
+ </script>
53
+ <script>
54
+ jQuery(document).on('click', '.remove-this-variable', function(){
55
+ jQuery(this).closest('.caldera-config-group').remove();
56
+ jQuery('.set-system-variable').trigger('change');
57
+ if(!jQuery('#variable_entry_list').children().length){
58
+ jQuery('#variable_entry_list_none').show();
59
+ }
60
+ });
61
+ jQuery(document).on('click', '.caldera-add-variable', function(e){
62
+ e.preventDefault();
63
+ jQuery('#variable_entry_list_none').hide();
64
+ jQuery('#variable_entry_list').append( jQuery('#variable-fields-tmpl').html() );
65
+ rebind_field_bindings();
66
+ });
67
+ jQuery(document).on('change', '.set-system-variable', function(){
68
+ //set-system-variable
69
+ var variables = jQuery('.set-system-variable');
70
+
71
+ if(!variables.length){
72
+ system_values.variable = null;
73
+ return;
74
+ }
75
+ // set object
76
+ system_values.variable = {
77
+ tags : {
78
+ vars : []
79
+ },
80
+ type : "<?php echo __('Variables', 'caldera-forms'); ?>",
81
+ wrap : ['{','}']
82
+ };
83
+ // add values
84
+ for(var v = 0; v < variables.length; v++){
85
+ if(variables[v].value.length){
86
+ variables[v].value = variables[v].value.replace(/[^a-z0-9]/gi, '_').toLowerCase();
87
+ system_values.variable.tags.vars.push( 'variable:' + variables[v].value );
88
+ jQuery(variables[v]).closest('.caldera-config-group').find('.var-value').data('parent', variables[v].value);
89
+ }
90
+ }
91
+
92
+ rebind_field_bindings();
93
+ });
94
+
95
+ jQuery(function(){
96
+ jQuery('.set-system-variable').trigger('change');
97
+ });
98
+
99
+ </script>