-
Notifications
You must be signed in to change notification settings - Fork 7
/
RCCWP_WritePostPage.php
executable file
·1587 lines (1310 loc) · 59 KB
/
RCCWP_WritePostPage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* This class content all type of fields for the panels
*/
class RCCWP_WritePostPage {
function ApplyCustomWritePanelAssignedCategories($content){
global $CUSTOM_WRITE_PANEL;
global $post,$title;
$assignedCategoryIds = RCCWP_CustomWritePanel::GetAssignedCategoryIds($CUSTOM_WRITE_PANEL->id);
$customThemePage = RCCWP_CustomWritePanel::GetThemePage($CUSTOM_WRITE_PANEL->name);
//hide all categories
$all = get_categories( "get=all" );
foreach($all as $al){
$toReplace = 'class="selectit"><input value="'.$al->term_id.'" type="checkbox" name="post_category[]" id="in-category-'.$al->term_id.'"';
$replacement = 'class="selectit" style="display:none;"><input value="'.$al->term_id.'" type="checkbox" name="post_category[]" id="in-category-'.$al->term_id.'"';
$content = str_replace($toReplace, $replacement, $content);
}
//display ony categories and child
$dos=$assignedCategoryIds;
foreach($assignedCategoryIds as $id){
$childs= get_categories( "child_of=".$id."&hierarchical=0&hide_empty=0" );
foreach($childs as $child){
array_unshift($dos, $child->term_id);
}
}
$dos=array_unique($dos);
foreach($dos as $do){
$toReplace = 'class="selectit" style="display:none;"><input value="'.$do.'" type="checkbox" name="post_category[]" id="in-category-'.$do.'"';
$replacement = 'class="selectit"><input value="'.$do.'" type="checkbox" name="post_category[]" id="in-category-'.$do.'"';
$content = str_replace($toReplace, $replacement, $content);
}
foreach ($assignedCategoryIds as $categoryId)
{
$toReplace = 'id="in-category-' . $categoryId . '"';
$replacement = $toReplace . ' checked="checked"';
$content = str_replace($toReplace, $replacement, $content);
}
//set default theme page
if($post->ID == 0){
$toReplace = "value='".$customThemePage."'";
$replacement = "value='".$customThemePage."'" . ' SELECTED"';
$content = str_replace($toReplace, $replacement, $content);
}
return $content;
}
function FormError(){
global $flutter_domain;
if (RCCWP_Application::InWritePostPanel()){
echo "<div id='flutter-publish-error-message' class='error' style='display:none;'><p><strong>".__("Post was not published - ",$flutter_domain)."</strong> ".__("You have errors in some fields, please check the fields below.",$flutter_domain)."</p></div>";
}
}
function CustomFieldsCSSScripts(){
?>
<link rel='stylesheet' href='<?php echo FLUTTER_URI?>css/epoch_styles.css' type='text/css' />
<link href="<?php echo FLUTTER_URI?>js/greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" />
<style type="text/css">
.freshout{
display: block;
margin-left: auto;
margin-right: auto ;
}
.photo_edit_link{
clear:both;
margin: 0px 0px 0px 0px;
width:150px;
text-align:center;
}
</style>
<!-- Live Query Jquery plugin -->
<script type="text/javascript" src="<?php echo FLUTTER_URI?>js/jquery.livequery.js"></script>
<script language="JavaScript" type="text/javascript" src="<?php echo FLUTTER_URI; ?>js/prototype.js"></script>
<!-- Calendar Control -->
<script type="text/javascript" src="<?php echo FLUTTER_URI?>js/epoch_classes.js"></script> <!--Epoch's Code-->
<!-- Calendar Control -->
<script type="text/javascript">
var GB_ROOT_DIR = "<?php echo FLUTTER_URI?>js/greybox/";
var flutter_path = "<?php echo FLUTTER_URI ?>" ;
var swf_authentication = "<?php if ( function_exists('is_ssl') && is_ssl() ) echo $_COOKIE[SECURE_AUTH_COOKIE]; else echo $_COOKIE[AUTH_COOKIE]; ?>" ;
var swf_nonce = "<?php echo wp_create_nonce('media-form'); ?>" ;
</script>
<script type="text/javascript" src="<?php echo FLUTTER_URI?>js/greybox/AJS.js"></script>
<script type="text/javascript" src="<?php echo FLUTTER_URI?>js/greybox/AJS_fx.js"></script>
<script type="text/javascript" src="<?php echo FLUTTER_URI?>js/greybox/gb_scripts.js"></script>
<script type="text/javascript" src="<?php echo FLUTTER_URI; ?>js/swfcallbacks.js" ></script>
<script type="text/javascript" src="<?php echo get_bloginfo('wpurl');?>/wp-includes/js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="<?php echo FLUTTER_URI?>js/groups.js"></script>
<script type="text/javascript">
function isset( ) {
// http://kevin.vanzonneveld.net
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: FremyCompany
// * example 1: isset( undefined, true);
// * returns 1: false
// * example 2: isset( 'Kevin van Zonneveld' );
// * returns 2: true
var a=arguments; var l=a.length; var i=0;
while ( i!=l ) {
if (typeof(a[i])=='undefined') {
return false;
} else {
i++;
}
}
return true;
}
// -------------
// Edit Photo functions
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function prepareUpdatePhoto(inputName){
document.getElementById(inputName+'_dorename').value = '1';
return true;
}
function exchangeValues(e, id)
{
//==== ¿? ====//
//document.getElementById(document.getElementById('parent_text_'+id.substring(10)).value).value = e;
//document.getElementById(document.getElementById('hidImgValue'+id.substring(10)).value).value = e;
}
// -------------
// Date Functions
var dp_cal = new Array(); // declare the calendars as global variables
function pickDate(inputName){
if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0]) document.getElementById('date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat('Y-m-d');
}
function InitializeDateObject(inputName, dateFormat, currentValue){
if (!Object.isElement($('display_date_field_' + inputName))) return;
dp_cal[inputName] = new Epoch('dp_cal_'+inputName,'popup',document.getElementById('display_date_field_'+inputName), false, 'pickDate', inputName, dateFormat);
var d = new Date();
if (currentValue.length > 0){
d.setYear(parseInt(currentValue.substr(0,4),10));
d.setMonth(parseInt(currentValue.substr(5,2),10)-1);
d.setDate(parseInt(currentValue.substr(8,2),10));
}
d.selected = true;
d.canSelect = true;
var tmpDatesArray = new Array(d);
dp_cal[inputName].selectDates(tmpDatesArray, true, true, true);
if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0])
document.getElementById('display_date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat(dateFormat);
}
function today_date(inputName, dateFormat){
var d = new Date();
var tmpDatesArray = new Array(d);
dp_cal[inputName].selectDates(tmpDatesArray, true, true, true);
if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0]){
document.getElementById('display_date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat(dateFormat);
document.getElementById('date_field_' + inputName).value = dp_cal[inputName].selectedDates[0].dateFormat('Y-m-d');
}
}
</script>
<?php
}
function ApplyCustomWritePanelHeader()
{
global $CUSTOM_WRITE_PANEL;
global $flutter_domain;
// Validate capability
require_once ('RCCWP_Options.php');
$assignToRole = RCCWP_Options::Get('assign-to-role');
$requiredPostsCap = 'edit_posts';
$requiredPagesCap = 'edit_pages';
if ($assignToRole == 1){
$requiredPostsCap = $CUSTOM_WRITE_PANEL->capability_name;
$requiredPagesCap = $CUSTOM_WRITE_PANEL->capability_name;
}
if ($CUSTOM_WRITE_PANEL->type == "post")
$requiredCap = $requiredPostsCap;
else
$requiredCap = $requiredPagesCap;
if (!current_user_can($requiredCap)) wp_die( __('You do not have sufficient permissions to access this custom write panel.',$flutter_domain) );
// --- Apply Flutter CSS and javascript
?>
<link rel='stylesheet' href='<?php echo FLUTTER_URI?>css/epoch_styles.css' type='text/css' />
<link href="<?php echo FLUTTER_URI?>js/greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" />
<style type="text/css">
.tr_inside{
background-color:transparent !important;
}
.freshout{
display: block;
margin-left: auto;
margin-right: auto ;
}
.photo_edit_link{
clear:both;
margin: 0px 0px 0px 0px;
width:150px;
text-align:center;
}
.error_msg_txt{
font-weight: bold;
overflow: auto;
}
.duplicate_button{
text-decoration:none;
font-weight:bold;
float:right
}
.duplicate_image{
vertical-align:middle;
padding-right:3px;
}
</style>
<script language="JavaScript" type="text/javascript" src="<?php echo FLUTTER_URI; ?>js/prototype.js"></script>
<script type="text/javascript">
var wp_root = "<?php echo get_bloginfo('wpurl');?>";
var GB_ROOT_DIR = "<?php echo FLUTTER_URI?>js/greybox/";
var flutter_path = "<?php echo FLUTTER_URI; ?>";
var flutter_relative = "<?php echo FLUTTER_URI_RELATIVE;?>";
var phpthumb = "<?php echo PHPTHUMB;?>";
var swf_authentication = "<?php if ( function_exists('is_ssl') && is_ssl() ) echo $_COOKIE[SECURE_AUTH_COOKIE]; else echo $_COOKIE[AUTH_COOKIE]; ?>" ;
var swf_nonce = "<?php echo wp_create_nonce('media-form'); ?>" ;
</script>
<script type="text/javascript" src="<?php echo FLUTTER_URI?>js/greybox/AJS.js"></script>
<script type="text/javascript" src="<?php echo FLUTTER_URI?>js/greybox/AJS_fx.js"></script>
<script type="text/javascript" src="<?php echo FLUTTER_URI?>js/greybox/gb_scripts.js"></script>
<script type="text/javascript" src="<?php echo FLUTTER_URI; ?>js/swfcallbacks.js" ></script>
<script type="text/javascript" src="<?php echo get_bloginfo('wpurl');?>/wp-includes/js/swfupload/swfupload.js"></script>
<script type="text/javascript">
function isset( ) {
// http://kevin.vanzonneveld.net
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: FremyCompany
// * example 1: isset( undefined, true);
// * returns 1: false
// * example 2: isset( 'Kevin van Zonneveld' );
// * returns 2: true
var a=arguments; var l=a.length; var i=0;
while ( i!=l ) {
if (typeof(a[i])=='undefined') {
return false;
} else {
i++;
}
}
return true;
}
function checkForm(event){
var stopPublish = false;
$$('input.field_required','textarea.field_required').each(
function(inputField){
if ($F(inputField) == "" &&
!(Object.isElement($(inputField.id+"_last")) && $F(inputField.id+"_last") != "") ){
stopPublish = true;
// Update row color
if (isset($("row_"+inputField.id).style))
$("row_"+inputField.id).style.backgroundColor = "#FFEBE8";
// Update iframe color if it exists
if (Object.isElement($("upload_internal_iframe_"+inputField.id))){
if ($("upload_internal_iframe_"+inputField.id).contentDocument) {
// For FF
$("upload_internal_iframe_"+inputField.id).contentDocument.body.style.backgroundColor = "#FFEBE8";
} else if ($("upload_internal_iframe_"+inputField.id).contentWindow) {
// For IE5.5 and IE6
$("upload_internal_iframe_"+inputField.id).contentWindow.document.body.style.backgroundColor = "#FFEBE8";
}
}
$("fieldcellerror_"+inputField.id).style.display = "";
$("fieldcellerror_"+inputField.id).innerHTML = "ERROR: Field can not be empty";
}
else{
$("fieldcellerror_"+inputField.id).style.display = "none";
if (isset($("row_"+inputField.id).style))
$("row_"+inputField.id).style.backgroundColor = "";
// Update iframe color if it exists
if (Object.isElement($("upload_internal_iframe_"+inputField.id))){
if ($("upload_internal_iframe_"+inputField.id).contentDocument) {
// For FF
$("upload_internal_iframe_"+inputField.id).contentDocument.body.style.backgroundColor = "#EAF3FA";
} else if ($("upload_internal_iframe_"+inputField.id).contentWindow) {
// For IE5.5 and IE6
$("upload_internal_iframe_"+inputField.id).contentWindow.document.body.style.backgroundColor = "#EAF3FA";
}
}
}
}
);
if (stopPublish){
$("flutter-publish-error-message").style.display = "";
Event.stop(event);
return false;
}
return true;
}
Event.observe(window, 'load', function() {
Event.observe('post', 'submit', checkForm);
});
// -------------
// Edit Photo functions
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function prepareUpdatePhoto(inputName){
document.getElementById(inputName+'_dorename').value = '1';
return true;
}
function exchangeValues(e, id)
{
//document.getElementById(document.getElementById('parent_text_'+id.substring(10)).value).value = e;
//document.getElementById(document.getElementById('hidImgValue'+id.substring(10)).value).value = e;
}
// -------------
// Date RCCPW_WritePostPage::Functions
var dp_cal = new Array(); // declare the calendars as global variables
function pickDate(inputName){
if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0]) document.getElementById('date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat('Y-m-d');
}
function InitializeDateObject(inputName, dateFormat, currentValue){
if (!Object.isElement($('display_date_field_' + inputName))) return;
dp_cal[inputName] = new Epoch('dp_cal_'+inputName,'popup',document.getElementById('display_date_field_'+inputName), false, 'pickDate', inputName, dateFormat);
var d = new Date();
if (currentValue.length > 0){
d.setYear(parseInt(currentValue.substr(0,4),10));
d.setMonth(parseInt(currentValue.substr(5,2),10)-1);
d.setDate(parseInt(currentValue.substr(8,2),10));
}
d.selected = true;
d.canSelect = true;
var tmpDatesArray = new Array(d);
dp_cal[inputName].selectDates(tmpDatesArray, true, true, true);
if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0])
document.getElementById('display_date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat(dateFormat);
}
function today_date(inputName, dateFormat){
var d = new Date();
var tmpDatesArray = new Array(d);
dp_cal[inputName].selectDates(tmpDatesArray, true, true, true);
if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0]){
document.getElementById('display_date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat(dateFormat);
document.getElementById('date_field_' + inputName).value = dp_cal[inputName].selectedDates[0].dateFormat('Y-m-d');
}
}
</script>
<?php
//change title
global $post,$title;
if($post->ID == 0){
$blu = RCCWP_CustomWritePanel::Get($CUSTOM_WRITE_PANEL->id);
if($post->post_type == "post"){ $name_title = "Post";}
else{$name_title = "Page";}
$title="Write ".$name_title." >> " .$blu->name;
}else{
$blu = RCCWP_CustomWritePanel::Get($CUSTOM_WRITE_PANEL->id);
if($post->post_type == "post"){ $name_title = "Post";}
else{$name_title = "Page";}
$title="Edit ".$name_title." >> " .$blu->name;
}
// Show/Hide Panel fields
global $STANDARD_FIELDS;
$standardFields = RCCWP_CustomWritePanel::GetStandardFields($CUSTOM_WRITE_PANEL->id);
$hideCssIds = array();
foreach($STANDARD_FIELDS as $standardField){
if (!in_array($standardField->id, $standardFields)){
foreach($standardField->cssId as $cssID)
array_push($hideCssIds, $cssID);
}
}
if (empty($hideCssIds))
return;
array_walk($hideCssIds, create_function('&$item1, $key', '$item1 = "#" . $item1;'));
$hideCssIdString = implode(', ', $hideCssIds);
?>
<style type="text/css">
<?php echo $hideCssIdString?> {display: none !important;}
</style>
<?php
}
function CustomFieldCollectionInterfaceRight(){
RCCWP_WritePostPage::CustomFieldCollectionInterface(true);
}
function CustomFieldCollectionInterface($rightOnly = false) {
global $flutter_domain;
global $CUSTOM_WRITE_PANEL;
global $wpdb;
global $post;
//if no exists the write panel returni
if (!isset($CUSTOM_WRITE_PANEL))
return;
$customGroups = RCCWP_CustomWritePanel::GetCustomGroups($CUSTOM_WRITE_PANEL->id);
foreach ($customGroups as $customGroup) {
//render the elements
$customFields = RCCWP_CustomGroup::GetCustomFields($customGroup->id);
//when will be edit the Post
if(isset( $_REQUEST['post'] ) && count($customFields) > 0){
//using the first field name we can know
//the order of the groups
$firstFieldName = $customFields[0]->name;
//$duplicates = RCCWP_CustomField::GetFieldGroupDuplicates($_REQUEST['post'], $firstFieldName);
$order = RCCWP_CustomField::GetOrderDuplicates($_REQUEST['post'],$firstFieldName);
//if ($duplicates < 1) $duplicates = 1;//for backward compatability
?>
<div class="write_panel_wrapper" id="write_panel_wrap_<?php echo $customGroup->id;?>"><?php
//build the group duplicates
foreach($order as $key => $element){
/*for($i= 1 ;$i<=$duplicates;$i++){
if($customGroup->name != "__default"){
//order the groups
$order_id = $wpdb->get_var('select order_id from '.RC_CWP_TABLE_POST_META.' where post_id = '.$post->ID.' and group_count = '.$i.' limit 1');
}else{
$order_id = 1;
}*/
?>
<?php RCCWP_WritePostPage::GroupDuplicate2($customGroup,$element,$key,false);?>
<?php
}
?>
<?php
//knowing what is the biggest duplicate group
if(!empty($order)){
$tmp = $order;
sort($tmp);
$top = $tmp[count($tmp) -1];
}else{
$top = 0;
}
?>
<input type='hidden' name='g<?php echo $customGroup->id?>counter' id='g<?php echo $customGroup->id?>counter' value='<?php echo $top ?>' />
<input type="hidden" name="rc-custom-write-panel-verify-key" id="rc-custom-write-panel-verify-key" value="<?php echo wp_create_nonce('rc-custom-write-panel')?>" />
<input type="hidden" name="rc-cwp-custom-write-panel-id" value="<?php echo $CUSTOM_WRITE_PANEL->id?>" />
</div>
<?php
}else{
if(count($customFields) > 0){
?>
<div class="write_panel_wrapper" id="write_panel_wrap_<?php echo $customGroup->id;?>">
<?php
RCCWP_WritePostPage::GroupDuplicate2($customGroup,1,1,false) ;
$gc = 1;
?>
<input type='hidden' name='g<?php echo $customGroup->id?>counter' id='g<?php echo $customGroup->id?>counter' value='<?php echo $gc?>' />
<input type='hidden' name="rc-custom-write-panel-verify-key" id="rc-custom-write-panel-verify-key" value="<?php echo wp_create_nonce('rc-custom-write-panel')?>" />
<input type='hidden' name="rc-cwp-custom-write-panel-id" value="<?php echo $CUSTOM_WRITE_PANEL->id?>" />
</div>
<?php
}
}
}
}
/**
* This method and groupduplicated will be merged in nexts commits
*
* @param object $customGroup
* @param integer $groupCounter
* @param boolean $fromAjax
*
*/
function GroupDuplicate2($customGroup, $groupCounter,$order,$fromAjax=true){
global $flutter_domain;
$counter = "";
if($groupCounter == 1){
$counter = "";
}else{
$tmp = $groupCounter ;
$counter = "(".$tmp.")";
}
//getting the custom fields
$customFields = RCCWP_CustomGroup::GetCustomFields($customGroup->id);
//if don't have fields then finish
if (count($customFields) == 0) return;
//¿?
if( $customGroup->duplicate == 0 && $groupCounter != 1 ) return ;
require_once("RC_Format.php");
if(empty($customGroup->name) || $customGroup->name == "__default"){
$title = "Flutter custom fields";
}else{
$title = $customGroup->name;
}
?>
<div id="freshpostdiv_group_<?php echo $customGroup->id.'_'.$groupCounter;?>" class="postbox1">
<div class="postbox">
<h3 class="hndle">
<span><?php echo $title;?> <?php echo $counter;?></span>
</h3>
<div class="inside">
<table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
<?php
foreach ($customFields as $field) {
// Render a row for each field in the group
//$customField = RCCWP_CustomField::Get($field->id);
$customFieldName = RC_Format::GetInputName(attribute_escape($field->name));
$customFieldTitle = attribute_escape($field->description);
$groupId = $customGroup->id;
$inputName = $field->id."_".$groupCounter."_1_".$groupId."_".$customFieldName;
if(isset($_REQUEST['post'])){
$fc = RCCWP_CustomField::GetFieldDuplicates($_REQUEST['post'],$field->name,$groupCounter);
$fields_order = RCCWP_CustomField::GetFieldsOrder($_REQUEST['post'],$field->name);
foreach($fields_order as $element){
//if($fc < 1) $fc = 1;
//for($i = 1;$i <= $fc;$i++){
RCCWP_WritePostPage::CustomFieldInterface($field->id,$groupCounter,$element,$customGroup->id);
}
}else{
RCCWP_WritePostPage::CustomFieldInterface($field->id,$groupCounter,1,$customGroup->id);
$fc = 1;
}
if(!empty($fields_order)){
$tmp = $fields_order;
sort($tmp);
$top = $tmp[count($tmp) -1];
}else{
$top = 1;
}
?>
<tr style="display:none" id="<?php echo "c".$inputName."Duplicate"?>">
<th valign="top" scope="row">
</th>
<td>
<img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/spinner.gif" alt=""/> <?php _e('Loading', $flutter_domain); ?> ...
<input type="text" name="c<?php echo $inputName ?>Counter" id="c<?php echo $inputName ?>Counter" value='<?php echo $top ?>' />
</td>
</tr>
<?php } ?>
</table>
<br />
<?php
if( $customGroup->duplicate != 0 ){
if($groupCounter != 1):?>
<a class ="delete_duplicate_button" href="javascript:void(0);" id="delete_duplicate-freshpostdiv_group_<?php echo $customGroup->id.'_'.$groupCounter; ?>">
<img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/delete.png" alt="<?php _e('Remove field duplicate', $flutter_domain); ?>"/><?php _e('Remove Group', $flutter_domain); ?>
</a>
<?php else:?>
<a class="duplicate_button" id="add_duplicate_<?php echo $customGroup->id."Duplicate"."_".$customGroup->id;?>" href="javascript:void(0);">
<img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/duplicate.png" alt="<?php _e('Add group duplicate', $flutter_domain); ?>"/> <?php _e('Duplicate Group', $flutter_domain); ?>
</a>
<?php endif;?>
<br style="height:2px"/>
<?php
}
?>
</div>
</div>
<input type="hidden" name="order_<?php echo $customGroup->id?>_<?php echo $groupCounter;?>" id="order_<?php echo $customGroup->id?>_<?php echo $groupCounter;?>" value="<?php echo $order?>" />
</div>
<?php
}
/**
* This function is for duplicate a group (When is clicked the button "Duplicate Group"
* @param object $customGroup
* @param integer $groupCounter
* @param boolean $fromAjax
*
*/
function GroupDuplicate($customGroup, $groupCounter, $fromAjax=true) {
global $flutter_domain;
//getting the custom fields
$customFields = RCCWP_CustomGroup::GetCustomFields($customGroup->id);
//if don't have any custom field then finish
if (count($customFields) == 0) return;
//if this group can't be duplicated and the group conter is != to 1 then finish
if( $customGroup->duplicate == 0 && $groupCounter != 1 ) return ;
//formating
require_once("RC_Format.php");
?>
<div id="freshpostdiv_group_<?php echo $customGroup->id.'_'.$groupCounter;?>" class="postbox1">
<div class="postbox">
<h3 onclick="jQuery(jQuery(this).parent().get(0)).toggleClass('closed');"> <a class="togbox">+</a>
<?php echo $customGroup->name." ($groupCounter)" ?>
</h3>
<div class="inside">
<table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5">
<?php
foreach ($customFields as $field){
// Render a row for each field in the group
$customField = RCCWP_CustomField::Get($field->id);
$customFieldName = RC_Format::GetInputName(attribute_escape($field->name));
$customFieldTitle = attribute_escape($customField->description);
$inputName = $field->id."_".$groupCounter."_1_".$customFieldName;
RCCWP_WritePostPage::CustomFieldInterface($field->id,$groupCounter,1,$customGroup->id);
}
?>
<tr style="display:none" id="<?php echo "c".$inputName."Duplicate"?>">
<th valign="top" scope="row">
</th>
<td>
<img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/spinner.gif" alt=""/> <?php _e('Loading', $flutter_domain); ?> ...
<input type="hidden" name="c<?php echo $inputName ?>Counter" id="c<?php echo $inputName ?>Counter" value='<?php echo $fc ?>' />
</td>
</tr>
</table>
</div>
<br />
<a class ="delete_duplicate_button" href="javascript:void(0);" id="delete_duplicate-freshpostdiv_group_<?php echo $customGroup->id.'_'.$groupCounter ?>">
<img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/delete.png" alt="<?php _e('Remove field duplicate', $flutter_domain); ?>"/><?php _e('Remove Group', $flutter_domain); ?>
</a>
<br style="height:2px"/>
</div>
<input type="hidden" name="order_<?php echo $customGroup->id?>_<?php echo $groupCounter;?>" id="order_<?php echo $customGroup->id?>_<?php echo $groupCounter;?>" value="0" />
</div>
<?php
}
function CustomFieldInterface($customFieldId, $groupCounter=1, $fieldCounter=1,$customGroup_id=0){
global $flutter_domain;
require_once("RC_Format.php");
$customField = RCCWP_CustomField::Get($customFieldId);
$customFieldName = RC_Format::GetInputName(attribute_escape($customField->name));
$customFieldTitle = attribute_escape($customField->description);
$groupId = $customGroup_id;
$inputName = $customFieldId."_".$groupCounter."_".$fieldCounter."_".$groupId."_".$customFieldName; // Create input tag name
if( $fieldCounter > 1 && $customField->duplicate == 0 ) return ;
if( $fieldCounter > 1) $titleCounter = " ($fieldCounter)";
$field_group = RCCWP_CustomGroup::Get($customField->group_id);
?>
<tr class="form-field" id="row_<?php echo $inputName?>">
<?php
// If the field is at right, put the header over the field
if ($field_group->at_right){
?>
<td>
<label style="font-weight:bold" for="<?php echo $inputName?>"><?php echo $customFieldTitle.$titleCounter?></label>
<br />
<?php
} else {
?>
<th valign="top" scope="row">
<label for="<?php echo $inputName?>"><?php echo $customFieldTitle.$titleCounter?></label>
</th>
<td>
<?php
}
?>
<p class="error_msg_txt" id="fieldcellerror_<?php echo $inputName?>" style="display:none"></p>
<?php
switch ($customField->type)
{
case 'Textbox' :
RCCWP_WritePostPage::TextboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Multiline Textbox' :
RCCWP_WritePostPage::MultilineTextboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Checkbox' :
RCCWP_WritePostPage::CheckboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Checkbox List' :
RCCWP_WritePostPage::CheckboxListInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Radiobutton List' :
RCCWP_WritePostPage::RadiobuttonListInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Dropdown List' :
RCCWP_WritePostPage::DropdownListInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Listbox' :
RCCWP_WritePostPage::ListboxInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'File' :
RCCWP_WritePostPage::FileInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Image' :
RCCWP_WritePostPage::PhotoInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Date' :
RCCWP_WritePostPage::DateInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Audio' :
RCCWP_WritePostPage::AudioInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Color Picker' :
RCCWP_WritePostPage::ColorPickerInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
case 'Slider' :
RCCWP_WritePostPage::SliderInterface($customField, $inputName, $groupCounter, $fieldCounter);
break;
default:
;
}
if($fieldCounter == 1)
{
?>
<?php if($customField->duplicate != 0 ){ ?>
<br />
<a class ="typeHandler" href="javascript:void(0);" id="type_handler-<?php echo $inputName ?>" >
<img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/duplicate.png" alt="<?php _e('Add field duplicate', $flutter_domain); ?>"/> <?php _e('Duplicate', $flutter_domain); ?>
</a>
<?php } ?>
<?php
}
else
{
?>
<br />
<a class ="delete_duplicate_field" href="javascript:void(0)" id="delete_field_repeat-<?php echo $inputName?>">
<img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/delete.png" alt="<?php _e('Remove field duplicate', $flutter_domain); ?> "/> <?php _e('Remove', $flutter_domain); ?>
</a>
<?php
}
?>
<input type="hidden" name="rc_cwp_meta_keys[]" value="<?php echo $inputName?>" />
</td>
</tr>
<?php
}
function CheckboxInterface($customField, $inputName, $groupCounter, $fieldCounter)
{
$customFieldId = '';
if (isset($_REQUEST['post']))
{
$customFieldId = $customField->id;
$value = RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter);
$checked = $value == 'true' ? 'checked="checked"' : '';
}
?>
<input type="hidden" name="<?php echo $inputName?>" value="false" />
<input tabindex="3" class="checkbox" name="<?php echo $inputName?>" value="true" id="<?php echo $inputName?>" type="checkbox" <?php echo $checked?> />
<?php
}
function CheckboxListInterface($customField, $inputName, $groupCounter, $fieldCounter)
{
$customFieldId = '';
$values = array();
if (isset($_REQUEST['post']))
{
$customFieldId = $customField->id;
$values = (array) RCCWP_CustomField::GetCustomFieldValues(false, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter);
}else{
$values = $customField->default_value;
}
?>
<?php
foreach ($customField->options as $option) :
$checked = in_array($option, (array)$values) ? 'checked="checked"' : '';
$option = attribute_escape(trim($option));
?>
<input tabindex="3" id="<?php echo $option?>" name="<?php echo $inputName?>[]" value="<?php echo $option?>" type="checkbox" <?php echo $checked?> style="width:40px;"/>
<label for="" class="selectit">
<?php echo attribute_escape($option)?>
</label><br />
<?php
endforeach;
?>
<?php
}
function DropdownListInterface($customField, $inputName, $groupCounter, $fieldCounter)
{
global $flutter_domain;
$customFieldId = '';
if (isset($_REQUEST['post']))
{
$customFieldId = $customField->id;
$value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter));
}
else
{
$value = $customField->default_value[0];
}
if ($customField->required_field) $requiredClass = "field_required";
?>
<select tabindex="3" class="<?php echo $requiredClass;?>" name="<?php echo $inputName?>">
<option value=""><?php _e('--Select--', $flutter_domain); ?></option>
<?php
foreach ($customField->options as $option) :
$selected = $option == $value ? 'selected="selected"' : '';
$option = attribute_escape(trim($option));
?>
<option value="<?php echo $option?>" <?php echo $selected?>><?php echo $option?></option>
<?php
endforeach;
?>
</select>
<?php
}
function ListboxInterface($customField, $inputName, $groupCounter, $fieldCounter) {
$customFieldId = '';
if (isset($_REQUEST['post'])){
$customFieldId = $customField->id;
$values = (array) RCCWP_CustomField::GetCustomFieldValues(false, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter);
}else{
$values = $customField->default_value;
}
$inputSize = (int)$customField->properties['size'];
$requiredClass = "flutter_listbox";
if ($customField->required_field) $requiredClass = "flutter_listbox field_required";
?>
<select class="<?php echo $requiredClass;?>" tabindex="3" id="<?php echo $inputName?>" name="<?php echo $inputName?>[]" multiple size="<?php echo $inputSize?>" style="height: 6em;">
<?php
foreach ($customField->options as $option) :
$selected = in_array($option, (array)$values) ? 'selected="selected"' : '';
$option = attribute_escape(trim($option));
?>
<option value="<?php echo $option?>" <?php echo $selected?>><?php echo $option?></option>
<?php
endforeach;
?>
</select>
<?php
}
function MultilineTextboxInterface($customField, $inputName, $groupCounter, $fieldCounter)
{
$customFieldId = '';
if (isset($_REQUEST['post']))
{
$customFieldId = $customField->id;
$value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter));
}else{
$value = $customField->value;
}
$inputHeight = (int)$customField->properties['height'];
$inputWidth = (int)$customField->properties['width'];
if ($customField->required_field) $requiredClass = "field_required";
?>
<?php
$hide_visual_editor = RCCWP_Options::Get('hide-visual-editor');
if ($hide_visual_editor == '' || $hide_visual_editor == 0){
?>
<script type="text/javascript">
//Event.observe(window, 'load', function() {
tinyMCE.execCommand('mceAddControl', false, "<?php echo $inputName?>");
//});
</script>
<?php } ?>
<textarea class="<?php echo $requiredClass;?>" tabindex="3" id="<?php echo $inputName?>" name="<?php echo $inputName?>" rows="<?php echo $inputHeight?>" cols="<?php echo $inputWidth?>"><?php echo $value?></textarea>
<?php
}
function TextboxInterface($customField, $inputName, $groupCounter, $fieldCounter)
{
$customFieldId = '';
if (isset($_REQUEST['post']))
{
$customFieldId = $customField->id;
$value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter));
}else{
$value = $customField->value;
}