-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscreens.php
2016 lines (1914 loc) · 82.9 KB
/
screens.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
/**
* Screen display functions.
*
* @package HumCORE
* @subpackage Deposits
*/
/**
* Output the deposits search form.
*/
function humcore_deposits_search_form() {
$default_search_value = bp_get_search_default_text( 'humcore_deposits' );
$search_value = '';
if ( ! empty( $_REQUEST['s'] ) ) {
$search_value = stripslashes( $_REQUEST['s'] ); }
$search_form_html = '
<div id="deposits-dir-search" class="dir-search" role="search">
<form action="" method="post" id="search-deposits-form">
<label>
<input type="text" name="s" id="search-deposits-term" value="' . esc_attr( $search_value ) . '" placeholder="' . esc_attr( $default_search_value ) . '" />
</label>
<input type="hidden" name="facets" id="search-deposits-facets" />
<input type="hidden" name="field" id="search-deposits-field" />
<input type="submit" id="search-deposits-submit" name="search_deposits_submit" value="' . __( 'Search', 'humcore_domain' ) . '" />
</form>
</div><!-- #deposits-dir-search -->
';
echo apply_filters( 'humcore_deposits_search_form', $search_form_html ); // XSS OK.
}
/**
* Prepare the content for deposits/item/new.
*/
function humcore_new_deposit_form() {
if ( ! empty( $_POST ) ) {
//check nonce
$deposit_id = humcore_deposit_file();
if ( $deposit_id ) {
$review_url = sprintf( '/deposits/item/%1$s/review/', $deposit_id );
wp_redirect( $review_url );
exit();
}
}
ob_end_flush(); // We've been capturing output.
if ( ! humcore_check_externals() ) {
echo '<h3>New <em>CORE</em> Deposit</h3>';
echo "<p>We're so sorry, but one of the components of <em>CORE</em> is currently down and it can't accept deposits just now. We're working on it (and we're delighted that you want to share your work) so please come back and try again later.</p>";
$wp_referer = wp_get_referer();
printf(
'<a href="%1$s" class="button white" style="line-height: 1.2em;">Go Back</a>',
( ! empty( $wp_referer ) && ! strpos( $wp_referer, 'item/new' ) ) ? $wp_referer : '/deposits/'
);
return;
}
if ( ! humanities_commons::hcommons_vet_user() ) {
echo '<h3>New <em>CORE</em> Deposit</h3>';
echo "<p>We're sorry, but uploading to <em>CORE</em> is currently unavailable. We're we're delighted that you want to share your work so please come back and try again later.</p>";
$wp_referer = wp_get_referer();
printf(
'<a href="%1$s" class="button white" style="line-height: 1.2em;">Go Back</a>',
( ! empty( $wp_referer ) && ! strpos( $wp_referer, 'item/new' ) ) ? $wp_referer : '/deposits/'
);
return;
}
if ( ! Humanities_Commons::hcommons_user_in_current_society() && ! is_super_admin() ) {
$society_name = Humanities_Commons::society_name();
echo '<h3>New <em>CORE</em> Deposit</h3>';
echo "<br/>";
echo "<p>Only members of $society_name can upload CORE deposits on this network.</p>";
return;
}
$current_group_id = '';
preg_match( '~.*?/groups/(.*[^/]?)/deposits/~i', wp_get_referer(), $slug_match );
if ( ! empty( $slug_match ) ) {
$current_group_id = BP_Groups_Group::get_id_from_slug( $slug_match[1] );
}
$user_id = bp_loggedin_user_id();
$user_login = get_the_author_meta( 'user_login', $user_id );
$user_firstname = get_the_author_meta( 'first_name', $user_id );
$user_lastname = get_the_author_meta( 'last_name', $user_id );
$prev_val = array();
if ( ! empty( $_POST ) ) {
$prev_val = $_POST;
} else {
$prev_val['deposit-author-role'] = 'author';
}
humcore_display_deposit_form( $current_group_id, $user_id, $user_login, $user_firstname, $user_lastname, $prev_val, 'new' );
}
/**
* Prepare the content for deposits/item/edit.
*/
function humcore_edit_deposit_form() {
global $solr_client, $wp;
if ( ! empty( $_POST ) ) {
//check nonce
$deposit_id = humcore_deposit_edit_file();
if ( $deposit_id ) {
$review_url = sprintf( '/deposits/item/%1$s/review/', $deposit_id );
wp_redirect( $review_url );
exit();
}
}
ob_end_flush(); // We've been capturing output.
if ( ! humcore_check_externals() ) {
echo '<h3>Edit <em>CORE</em> Deposit</h3>';
echo "<p>We're so sorry, but one of the components of <em>CORE</em> is currently down and it can't accept deposits just now. We're working on it (and we're delighted that you want to edit your work) so please come back and try again later.</p>";
$wp_referer = wp_get_referer();
printf(
'<a href="%1$s" class="button white" style="line-height: 1.2em;">Go Back</a>',
( ! empty( $wp_referer ) && ! strpos( $wp_referer, 'item/edit' ) ) ? $wp_referer : '/deposits/'
);
return;
}
$current_group_id = '';
preg_match( '~.*?/groups/(.*[^/]?)/deposits/~i', wp_get_referer(), $slug_match );
if ( ! empty( $slug_match ) ) {
$current_group_id = BP_Groups_Group::get_id_from_slug( $slug_match[1] );
}
$deposit_id = $wp->query_vars['deposits_item'];
$item_found = humcore_has_deposits( 'include=' . $deposit_id );
humcore_the_deposit();
$record_identifier = humcore_get_deposit_record_identifier();
$record_location = explode( '-', $record_identifier );
// handle legacy MLA Commons value
if ( $record_location[0] === $record_identifier ) {
$record_location[0] = '1';
$record_location[1] = $record_identifier;
}
//Switch blog not needed here, current blog already checked.
$post_data = get_post( $record_location[1] );
$post_metadata = json_decode( get_post_meta( $record_location[1], '_deposit_metadata', true ), true );
$prev_val = humcore_prepare_edit_page_metadata( $post_metadata );
$file_metadata = json_decode( get_post_meta( $record_location[1], '_deposit_file_metadata', true ), true );
$full_tempname = pathinfo( $file_metadata['files'][0]['fileloc'], PATHINFO_BASENAME );
$tempname = str_replace( '.' . $file_metadata['files'][0]['filename'], '', $full_tempname );
$prev_val['selected_temp_name'] = $tempname;
$prev_val['selected_file_name'] = $file_metadata['files'][0]['filename'];
$prev_val['selected_file_type'] = $file_metadata['files'][0]['filetype'];
$prev_val['selected_file_size'] = $file_metadata['files'][0]['filesize'];
if ( 'yes' == $prev_val['deposit-on-behalf-flag'] || 'yes' == $prev_val['deposit-for-others-flag'] ) {
$user = get_user_by( 'ID', sanitize_text_field( $prev_val['submitter'] ) );
} else {
$user = get_user_by( 'login', $prev_val['deposit-author-uni'] );
}
$user_id = $user->ID;
$user_login = $prev_val['deposit-author-uni'];
$user_firstname = $prev_val['deposit-author-first-name'];
$user_lastname = $prev_val['deposit-author-last-name'];
/*
* Maybe get file data and load prev_val
* in deposit check for type and if found we need to do edit - maybe a whole new file shoud be used.
*/
if ( ! empty( $_POST ) ) {
$prev_val = $_POST;
}
humcore_display_deposit_form( $current_group_id, $user_id, $user_login, $user_firstname, $user_lastname, $prev_val, 'edit' );
}
/**
* Render the content for deposits/item/new and deposits/item/edit.
*/
function humcore_display_deposit_form( $current_group_id, $user_id, $user_login, $user_firstname, $user_lastname, $prev_val, $form_type ) {
$deposit_button_label = ( 'new' === $form_type ) ? 'Deposit' : 'Update';
?>
<script type="text/javascript">
var MyAjax = {
ajaxurl : '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
flash_swf_url : '<?php echo esc_url( includes_url( '/js/plupload/Moxie.swf' ) ); ?>',
silverlight_xap_url : '<?php echo esc_url( includes_url( '/js/plupload/Moxie.xap' ) ); ?>',
_ajax_nonce : '<?php echo esc_attr( wp_create_nonce( 'file-upload' ) ); ?>',
};
</script>
<h3><?php echo ucfirst( $form_type ); ?> CORE</em> Deposit</h3>
<form id="deposit-form" name="deposit-form" class="standard-form" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" id="action" value="deposit_file" />
<?php wp_nonce_field( 'new_core_deposit', 'new_core_deposit_nonce' ); ?>
<input type="hidden" name="selected_temp_name" id="selected_temp_name"
<?php
if ( ! empty( $prev_val['selected_temp_name'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['selected_temp_name'] ) . '" '; }
?>
/>
<input type="hidden" name="selected_file_name" id="selected_file_name"
<?php
if ( ! empty( $prev_val['selected_file_name'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['selected_file_name'] ) . '" '; }
?>
/>
<input type="hidden" name="selected_file_type" id="selected_file_type"
<?php
if ( ! empty( $prev_val['selected_file_type'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['selected_file_type'] ) . '" '; }
?>
/>
<input type="hidden" name="selected_file_size" id="selected_file_size"
<?php
if ( ! empty( $prev_val['selected_file_type'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['selected_file_size'] ) . '" '; }
?>
/>
<input type="hidden" name="deposit-form-type" id="deposit-form-type" value="<?php echo $form_type; ?>" />
<input type="hidden" name="deposit_blog_id" id="deposit_blog_id"
<?php
if ( ! empty( $prev_val['deposit_blog_id'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit_blog_id'] ) . '" '; }
?>
/>
<input type="hidden" name="deposit_post_id" id="deposit_post_id"
<?php
if ( ! empty( $prev_val['deposit_post_id'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit_post_id'] ) . '" '; }
?>
/>
<div id="deposit-file-entry">
<br />
<label for="deposit-file">Select the file you wish to upload and deposit. *</label>
<div id="container">
<button id="pickfile">Select File</button>
<?php
$wp_referer = wp_get_referer();
printf(
'<a href="%1$s" class="button white" style="line-height: 1.2em;">Cancel</a>',
( ! empty( $wp_referer ) && ! strpos( $wp_referer, 'item/new' ) ) ? $wp_referer : '/deposits/'
);
?>
</div>
</div>
<div id="deposit-file-entries">
<div id="filelist">Your browser doesn't have Flash, Silverlight or HTML5 support.</div>
<div id="progressbar">
<div id="indicator"></div>
</div>
<div id="console"></div>
</div>
<div id="deposit-published-entry">
<label for="deposit-published">Has this item been previously published?</label>
<input type="radio" name="deposit-published" value="published"
<?php
if ( ! empty( $prev_val['deposit-published'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-published'] ), 'published' ); }
?>
>Published
<input type="radio" name="deposit-published" value="not-published"
<?php
if ( ! empty( $prev_val['deposit-published'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-published'] ), 'not-published' );
} else {
echo 'checked="checked"'; }
?>
>Not published
</div>
<div id="deposit-metadata-entries">
<div id="lookup-doi-entry">
<br />
<label for="lookup-doi">Retrieve information</label>
<span class="description">Use <a onclick="target='_blank'" href="http://www.sherpa.ac.uk/romeo/">SHERPA/RoMEO</a> to check a journal’s open access policies.</span><br />
<span class="description">Enter a publisher DOI to automatically retrieve information about your item.</span> <br />
<input type="text" id="lookup-doi" name="lookup-doi" class="long" value="" placeholder="Enter the publisher DOI for this item." />
<button onClick="javascript:retrieveDOI(); return false;">Retrieve</button>
<div id="lookup-doi-message"></div>
</div>
</div>
<div id="deposit-title-entry">
<br />
<label for="deposit-title">Title</label>
<input type="text" id="deposit-title-unchanged" name="deposit-title-unchanged" size="75" maxlength="255" class="long"
<?php
if ( ! empty( $prev_val['deposit-title-unchanged'] ) ) {
echo ' value="' . wp_kses(
stripslashes( $prev_val['deposit-title-unchanged'] ), array(
'b' => array(),
'em' => array(),
'strong' => array(),
)
) . '" '; }
?>
/>
<span class="description">*</span>
</div>
<label for="deposit-genre">Item Type</label>
<div id="deposit-genre-entry">
<select name="deposit-genre" id="deposit-genre" class="js-basic-single-required" data-placeholder="Select an item type">
<option class="level-0" value=""></option>
<?php
$genre_list = humcore_deposits_genre_list();
$posted_genre = '';
if ( ! empty( $prev_val['deposit-genre'] ) ) {
$posted_genre = sanitize_text_field( $prev_val['deposit-genre'] );
}
foreach ( $genre_list as $genre_key => $genre_value ) {
printf(
' <option class="level-0" %1$s value="%2$s">%3$s</option>' . "\n",
( $genre_key == $posted_genre ) ? 'selected="selected"' : '',
$genre_key,
$genre_value
);
}
?>
</select>
<span class="description">*</span>
</div>
<div id="deposit-conference-entries">
<div id="deposit-conference-title-entry">
<label for="deposit-conference-title-entry-list">Conference Title</label>
<input type="text" name="deposit-conference-title" size="75" class="text"
<?php
if ( ! empty( $prev_val['deposit-conference-title'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-conference-title'] ) . '" '; }
?>
/>
</div>
<div id="deposit-conference-organization-entry">
<label for="deposit-conference-organization-entry-list">Conference Host Organization</label>
<input type="text" name="deposit-conference-organization" size="60" class="text"
<?php
if ( ! empty( $prev_val['deposit-conference-organization'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-conference-organization'] ) . '" '; }
?>
/>
</div>
<div id="deposit-conference-location-entry">
<label for="deposit-conference-location-entry-list">Conference Location</label>
<input type="text" name="deposit-conference-location" size="75" class="text"
<?php
if ( ! empty( $prev_val['deposit-conference-location'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-conference-location'] ) . '" '; }
?>
/>
</div>
<div id="deposit-conference-date-entry">
<label for="deposit-conference-date-entry-list">Conference Date</label>
<input type="text" name="deposit-conference-date" size="75" class="text"
<?php
if ( ! empty( $prev_val['deposit-conference-date'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-conference-date'] ) . '" '; }
?>
/>
</div>
</div>
<div id="deposit-meeting-entries">
<div id="deposit-meeting-title-entry">
<label for="deposit-meeting-title-entry-list">Meeting Title</label>
<input type="text" name="deposit-meeting-title" size="75" class="text"
<?php
if ( ! empty( $prev_val['deposit-meeting-title'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-meeting-title'] ) . '" '; }
?>
/>
</div>
<div id="deposit-meeting-organization-entry">
<label for="deposit-meeting-organization-entry-list">Meeting Host Organization</label>
<input type="text" name="deposit-meeting-organization" size="60" class="text"
<?php
if ( ! empty( $prev_val['deposit-meeting-organization'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-meeting-organization'] ) . '" '; }
?>
/>
</div>
<div id="deposit-meeting-location-entry">
<label for="deposit-meeting-location-entry-list">Meeting Location</label>
<input type="text" name="deposit-meeting-location" size="75" class="text"
<?php
if ( ! empty( $prev_val['deposit-meeting-location'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-meeting-location'] ) . '" '; }
?>
/>
</div>
<div id="deposit-meeting-date-entry">
<label for="deposit-meeting-date-entry-list">Meeting Date</label>
<input type="text" name="deposit-meeting-date" size="75" class="text"
<?php
if ( ! empty( $prev_val['deposit-meeting-date'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-meeting-date'] ) . '" '; }
?>
/>
</div>
</div>
<div id="deposit-institution-entries">
<div id="deposit-institution-entry">
<label for="deposit-institution-entry-list">Name of Institution</label>
<input type="text" name="deposit-institution" size="60" class="text"
<?php
if ( ! empty( $prev_val['deposit-institution'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-institution'] ) . '" '; }
?>
/>
</div>
</div>
<div id="deposit-abstract-entry">
<label for="deposit-abstract">Description or Abstract</label>
<textarea class="abstract_area" rows="12" autocomplete="off" cols="80" name="deposit-abstract-unchanged" id="deposit-abstract-unchanged">
<?php
if ( ! empty( $prev_val['deposit-abstract-unchanged'] ) ) {
echo wp_kses(
stripslashes( $prev_val['deposit-abstract-unchanged'] ), array(
'b' => array(),
'em' => array(),
'strong' => array(),
)
); }
?>
</textarea>
<span class="description">*</span>
<div class="character-count"></div>
</div>
<p>Depositor</p>
<div id="deposit-for-others-flag-entry">
<?php
$can_deposit_for_others = humcore_deposits_can_deposit_for_others( $user_id );
if ( ! $can_deposit_for_others ) {
?>
<input type="hidden" name="deposit-for-others-flag" id="deposit-for-others-flag" value="" />
<?php } else { ?>
<span class="description">Is this deposit authored by others?</span>
<input type="radio" name="deposit-for-others-flag" value="yes"
<?php
if ( ! empty( $prev_val['deposit-for-others-flag'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-for-others-flag'] ), 'yes' ); }
?>
>Yes
<input type="radio" name="deposit-for-others-flag" value="no"
<?php
if ( ! empty( $prev_val['deposit-for-others-flag'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-for-others-flag'] ), 'no' );
} else {
echo 'checked="checked"'; }
?>
>No
<?php
}
?>
</div>
<div id="deposit-on-behalf-flag-entry">
<?php
$committee_list = humcore_deposits_user_committee_list( $user_id );
if ( empty( $committee_list ) ) {
?>
<input type="hidden" name="deposit-on-behalf-flag" id="deposit-on-behalf-flag" value="" />
<?php } else { ?>
<span class="description">Is this deposit authored by a group?</span>
<input type="radio" name="deposit-on-behalf-flag" value="yes"
<?php
if ( ! empty( $prev_val['deposit-on-behalf-flag'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-on-behalf-flag'] ), 'yes' ); }
?>
>Yes
<input type="radio" name="deposit-on-behalf-flag" value="no"
<?php
if ( ! empty( $prev_val['deposit-on-behalf-flag'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-on-behalf-flag'] ), 'no' );
} else {
echo 'checked="checked"'; }
?>
>No
<?php
}
?>
</div>
<div id="deposit-committee-entry">
<?php
if ( empty( $committee_list ) ) {
?>
<input type="hidden" name="deposit-committee" id="deposit-committee" value="" />
<?php } else { ?>
<label for="deposit-committee">Deposit Group</label>
<select name="deposit-committee" id="deposit-committee" class="js-basic-single-optional" data-placeholder="Select group">
<option class="level-0" selected value=""></option>
<?php
$posted_committee = '';
if ( ! empty( $prev_val['deposit-committee'] ) ) {
$posted_committee = sanitize_text_field( $prev_val['deposit-committee'] ); }
foreach ( $committee_list as $committee_key => $committee_value ) {
printf(
' <option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n",
( $committee_key == $posted_committee ) ? 'selected="selected"' : '',
$committee_key,
$committee_value
);
}
?>
</select>
<?php
}
?>
</div>
<div id="deposit-other-authors-entry">
<label for="deposit-other-authors-entry-list">Contributors</label>
<span class="description">Add any contributors in addition to yourself.</span>
<div id="deposit-other-authors-entry-list">
<table id="deposit-other-authors-entry-table"><tbody>
<tr><td class="noBorderTop" style="width:205px;">
Given Name
</td><td class="noBorderTop" style="width:205px;">
Family Name
</td><td class="noBorderTop">
Role
</td><td class="noBorderTop">
<input type="button" id="deposit-insert-other-author-button" class="button add_author" value="Add a Contributor">
</td></tr>
<tr id="deposit-author-display"><td class="borderTop" style="width:205px;">
<?php echo esc_html( $user_firstname ); ?>
<input type="hidden" name="deposit-author-first-name" id="deposit-author-first-name" value="<?php echo esc_html( $user_firstname ); ?>" />
</td><td class="borderTop" style="width:205px;">
<?php echo esc_html( $user_lastname ); ?>
<input type="hidden" name="deposit-author-last-name" id="deposit-author-last-name" value="<?php echo esc_html( $user_lastname ); ?>" />
</td><td class="borderTop" style="width:230px;">
<span style="white-space: nowrap;"><input type="radio" name="deposit-author-role" class="styled" value="author"
<?php
if ( ! empty( $prev_val['deposit-author-role'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-author-role'] ), 'author' ); }
?>
>Author </span>
<span style="white-space: nowrap;"><input type="radio" name="deposit-author-role" class="styled" value="contributor"
<?php
if ( ! empty( $prev_val['deposit-author-role'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-author-role'] ), 'contributor' ); }
?>
>Contributor </span>
<span style="white-space: nowrap;"><input type="radio" name="deposit-author-role" class="styled" value="editor"
<?php
if ( ! empty( $prev_val['deposit-author-role'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-author-role'] ), 'editor' ); }
?>
>Editor </span>
<?php if ( humcore_deposits_can_deposit_for_others( $user_id) ) : ?>
<span style="white-space: nowrap;"><input type="radio" name="deposit-author-role" class="styled" value="submitter"
<?php
if ( ! empty( $prev_val['deposit-author-role'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-author-role'] ), 'submitter' ); }
?>
>Submitter </span>
<?php endif; ?>
<span style="white-space: nowrap;"><input type="radio" name="deposit-author-role" class="styled" value="translator"
<?php
if ( ! empty( $prev_val['deposit-author-role'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-author-role'] ), 'translator' ); }
?>
>Translator </span>
<input type="hidden" name="deposit-author-uni" id="deposit-author-uni"
<?php
if ( 'new' === $form_type ) {
echo ' value="' . $user_login . '" ';
} elseif ( ! empty( $prev_val['deposit-author-uni'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-author-uni'] ) . '" ';
}
?>
/>
</td><td class="borderTop">
</td></tr>
<?php
if ( ! empty( $prev_val['deposit-other-authors-first-name'] ) && ! empty( $prev_val['deposit-other-authors-last-name'] ) ) {
$other_authors = array_map(
function ( $first_name, $last_name, $role, $uni ) {
return array(
'first_name' => sanitize_text_field( $first_name ),
'last_name' => sanitize_text_field( $last_name ),
'role' => sanitize_text_field( $role ),
'uni' => sanitize_text_field( $uni ),
); },
$prev_val['deposit-other-authors-first-name'],
$prev_val['deposit-other-authors-last-name'],
$prev_val['deposit-other-authors-role'],
$prev_val['deposit-other-authors-uni']
);
$row_counter = 0;
foreach ( $other_authors as $author_array ) {
if ( ! empty( $author_array['first_name'] ) && ! empty( $author_array['last_name'] ) ) {
?>
<tr><td class="borderTop" style="width:205px;">
<input type="text" name="deposit-other-authors-first-name[<?php echo $row_counter; ?>]" class="text" value="<?php echo $author_array['first_name']; ?>" />
</td><td class="borderTop" style="width:205px;">
<input type="text" name="deposit-other-authors-last-name[<?php echo $row_counter; ?>]" class="text deposit-other-authors-last-name" value="<?php echo $author_array['last_name']; ?>" />
</td><td class="borderTop" style="width:230px; vertical-align: top;">
<span style="white-space: nowrap;"><input type="radio" name="deposit-other-authors-role[<?php echo $row_counter; ?>]" class="styled" style="margin-top: 12px;" value="author"
<?php
if ( ! empty( $author_array['role'] ) ) {
checked( sanitize_text_field( $author_array['role'] ), 'author' ); }
?>
>Author </span>
<span style="white-space: nowrap;"><input type="radio" name="deposit-other-authors-role[<?php echo $row_counter; ?>]" class="styled" style="margin-top: 12px;" value="contributor"
<?php
if ( ! empty( $author_array['role'] ) ) {
checked( sanitize_text_field( $author_array['role'] ), 'contributor' ); }
?>
>Contributor </span>
<span style="white-space: nowrap;"><input type="radio" name="deposit-other-authors-role[<?php echo $row_counter; ?>]" class="styled" style="margin-top: 12px;" value="editor"
<?php
if ( ! empty( $author_array['role'] ) ) {
checked( sanitize_text_field( $author_array['role'] ), 'editor' ); }
?>
>Editor </span>
<span style="white-space: nowrap;"><input type="radio" name="deposit-other-authors-role[<?php echo $row_counter; ?>]" class="styled" style="margin-top: 12px;" value="translator"
<?php
if ( ! empty( $author_array['role'] ) ) {
checked( sanitize_text_field( $author_array['role'] ), 'translator' ); }
?>
>Translator </span>
<input type="hidden" name="deposit-other-authors-uni[<?php echo $row_counter; ?>]" value="<?php echo $author_array['uni']; ?>" />
</td><td class="borderTop">
</td></tr>
<?php
}
$row_counter++;
}
}
?>
</tbody></table>
</div>
</div>
<div id="deposit-group-entry">
<label for="deposit-group">Groups</label>
<span class="description">Share this item with up to five groups that you are a member of.<br />Selecting a group will notify members of that group about your deposit.</span><br />
<select name="deposit-group[]" id="deposit-group[]" class="js-basic-multiple" multiple="multiple" data-placeholder="Select groups">
<?php
$group_list = humcore_deposits_group_list( $user_id );
$posted_group_list = array();
if ( ! empty( $prev_val['deposit-group'] ) ) {
$posted_group_list = array_map( 'sanitize_text_field', $prev_val['deposit-group'] ); }
foreach ( $group_list as $group_key => $group_value ) {
printf(
' <option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n",
( $current_group_id == $group_key || in_array( $group_key, $posted_group_list ) ) ? 'selected="selected"' : '',
$group_key,
$group_value
);
}
?>
</select>
</div>
<div id="deposit-subject-entry">
<label for="deposit-subject">Subjects</label>
<span class="description">Assign up to ten subject fields to your item.
<!-- FAST subjects -->
<select
name="deposit-subject[]"
id="deposit-subject[]"
class="js-basic-multiple-fast-subjects"
data-placeholder="Pick a FAST subject heading"
multiple="multiple"
data-allow-clear="false"
data-width="75%"
data-theme="default"
data-dir="ltr"
data-minimum-input-length="2"
data-maximum-selection-length="10"
data-close-on-select="true"
data-disabled="false"
data-debug="false"
data-delay="250"
>
<?php
$posted_subject_list = array();
if ( ! empty( $prev_val['deposit-subject'] ) ) {
$posted_subject_list = array_map( 'sanitize_text_field', $prev_val['deposit-subject'] );
}
foreach ( $posted_subject_list as $subject ) {
printf(
' <option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n",
'selected="selected"',
$subject,
$subject
);
}
?>
</select>
</div>
<div id="deposit-keyword-entry">
<label for="deposit-keyword">Tags</label>
<span class="description">Enter up to ten tags to further categorize this item.</span><br />
<select
name="deposit-keyword[]"
id="deposit-keyword[]"
class="js-basic-multiple-keywords"
multiple="multiple"
data-placeholder="Enter tags">
<?php
$posted_keyword_list = array();
if ( ! empty( $prev_val['deposit-keyword'] ) ) {
$posted_keyword_list = array_map( 'sanitize_text_field', $prev_val['deposit-keyword'] );
}
foreach ( $posted_keyword_list as $keyword_value ) {
printf(
' <option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n",
'selected="selected"',
$keyword_value,
$keyword_value
);
}
?>
</select>
</div>
<label for="deposit-resource-type">File Type</label>
<div id="deposit-resource-type-entry">
<select name="deposit-resource-type" id="deposit-resource-type" class="js-basic-single-optional" data-placeholder="Select a file type" data-allowClear="true">
<option class="level-0" selected="selected" value=""></option>
<?php
$resource_type_list = humcore_deposits_resource_type_list();
$posted_resource_type = '';
if ( ! empty( $prev_val['deposit-resource-type'] ) ) {
$posted_resource_type = sanitize_text_field( $prev_val['deposit-resource-type'] );
}
foreach ( $resource_type_list as $resource_key => $resource_value ) {
printf(
' <option class="level-0" %1$s value="%2$s">%3$s</option>' . "\n",
( $resource_key == $posted_resource_type ) ? 'selected="selected"' : '',
$resource_key,
$resource_value
);
}
?>
</select>
</div>
<label for="deposit-language">Language</label>
<div id="deposit-language-entry">
<select name="deposit-language" id="deposit-language" class="js-basic-single-optional" data-placeholder="Select a language" data-allowClear="true">
<option class="level-0" selected="selected" value=""></option>
<?php
$language_list = humcore_deposits_language_list();
$posted_language = '';
if ( ! empty( $prev_val['deposit-language'] ) ) {
$posted_language = sanitize_text_field( $prev_val['deposit-language'] );
}
foreach ( $language_list as $language_key => $language_value ) {
printf(
' <option class="level-0" %1$s value="%2$s">%3$s</option>' . "\n",
( $language_key == $posted_language ) ? 'selected="selected"' : '',
$language_key,
$language_value
);
}
?>
</select>
</div>
<div id="deposit-notes-entry">
<label for="deposit-notes">Notes or Background</label>
<span class="description">Any additional information about your item?</span><br />
<textarea name="deposit-notes-unchanged" class="the-notes" id="deposit-notes-unchanged">
<?php
if ( ! empty( $prev_val['deposit-notes-unchanged'] ) ) {
echo wp_kses(
stripslashes( $prev_val['deposit-notes-unchanged'] ), array(
'b' => array(),
'em' => array(),
'strong' => array(),
)
); }
?>
</textarea>
<div class="character-count"></div>
</div>
<div id="deposit-publication-type-entry">
<label for="deposit-publication-type">Publication Type</label>
<div id="deposit-publication-type-entries">
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="book"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'book' ); }
?>
>Book </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="book-chapter"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'book-chapter' ); }
?>
>Book chapter </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="book-review"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'book-review' ); }
?>
>Book review </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="book-section"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'book-section' ); }
?>
>Book section </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="proceedings-article"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'proceedings-article' ); }
?>
>Conference proceeding </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="journal-article"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'journal-article' ); }
?>
>Journal article </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="magazine-section"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'magazine-section' ); }
?>
>Magazine section </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="monograph"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'monograph' ); }
?>
>Monograph </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="newspaper-article"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'newspaper-article' ); }
?>
>Newspaper article </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="online-publication"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'online-publication' ); }
?>
>Online publication </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="podcast"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'podcast' ); }
?>
>Podcast </span>
<span style="white-space:nowrap;"><input type="radio" name="deposit-publication-type" value="none"
<?php
if ( ! empty( $prev_val['deposit-publication-type'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-publication-type'] ), 'none' );
} else {
echo 'checked="checked"'; }
?>
>Not published </span>
</div>
</div>
<br />
<?php format_book_input( $prev_val ); ?>
<?php format_book_chapter_input( $prev_val ); ?>
<?php format_book_review_input( $prev_val ); ?>
<?php format_book_section_input( $prev_val ); ?>
<?php format_journal_article_input( $prev_val ); ?>
<?php format_magazine_section_input( $prev_val ); ?>
<?php format_monograph_input( $prev_val ); ?>
<?php format_newspaper_article_input( $prev_val ); ?>
<?php format_online_publication_input( $prev_val ); ?>
<?php format_podcast_input( $prev_val ); ?>
<?php format_proceedings_article_input( $prev_val ); ?>
<div id="deposit-non-published-entries">
<div id="deposit-non-published-date-entry">
<label for="deposit-non-published-date">Date of Creation</label>
<input type="text" id="deposit-non-published-date" name="deposit-non-published-date" class="text"
<?php
if ( ! empty( $prev_val['deposit-non-published-date'] ) ) {
echo ' value="' . sanitize_text_field( $prev_val['deposit-non-published-date'] ) . '" '; }
?>
/>
</div>
</div>
<div id="deposit-license-type-entry">
<label for="deposit-license-type">Creative Commons License</label>
<span class="description">By default, and in accordance with section 2 of the <em>Commons</em> terms of service, no one may reuse this content in any way. Should you wish to allow others to distribute, display, modify, or otherwise reuse your content, please attribute it with the appropriate Creative Commons license from the drop-down menu below. See <a onclick="target='_blank'" href="http://creativecommons.org/licenses/">this page</a> for more information about the different types of Creative Commons licenses.</span><br /><br />
<select name="deposit-license-type" id="deposit-license-type" class="js-basic-single-required">
<?php
$license_type_list = humcore_deposits_license_type_list();
$posted_license_type = '';
if ( ! empty( $prev_val['deposit-license-type'] ) ) {
$posted_license_type = sanitize_text_field( $prev_val['deposit-license-type'] );
}
foreach ( $license_type_list as $license_key => $license_value ) {
printf(
' <option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n",
( $license_key == $posted_license_type ) ? 'selected="selected"' : '',
$license_key,
$license_value
);
}
?>
</select>
<span class="description">*</span>
</div>
<div id="deposit-embargoed-entry">
<label for="deposit-embargoed-flag">Embargo this deposit?</label>
<input type="radio" name="deposit-embargoed-flag" value="yes"
<?php
if ( ! empty( $prev_val['deposit-embargoed-flag'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-embargoed-flag'] ), 'yes' ); }
?>
>Yes
<input type="radio" name="deposit-embargoed-flag" value="no"
<?php
if ( ! empty( $prev_val['deposit-embargoed-flag'] ) ) {
checked( sanitize_text_field( $prev_val['deposit-embargoed-flag'] ), 'no' );
} else {
echo 'checked="checked"'; }
?>
>No
</div>
<div id="deposit-embargoed-entries">
<label for="deposit-embargo-length">Embargo Length</label>
<div id="deposit-embargo-length-entry">
<span class="description">Use <a onclick="target='_blank'" href="http://www.sherpa.ac.uk/romeo/">SHERPA/RoMEO</a> to check a journal’s open access policies.</span><br />
<span class="description">Enter the length of time (up to two years from now) after which this item should become available.</span> <br />
<select name="deposit-embargo-length" id="deposit-embargo-length" class="js-basic-single-required" data-placeholder="Select the embargo length." data-allowClear="true">
<option class="level-0" selected="selected" value=""></option>
<?php
$embargo_length_list = humcore_deposits_embargo_length_list();
$posted_embargo_length = '';
if ( ! empty( $prev_val['deposit-embargo-length'] ) ) {
$posted_embargo_length = sanitize_text_field( $prev_val['deposit-embargo-length'] );
}
foreach ( $embargo_length_list as $embargo_key => $embargo_value ) {
printf(
' <option class="level-0" %1$s value="%2$s">%3$s</option>' . "\n",
( $embargo_key == $posted_embargo_length ) ? 'selected="selected"' : '',
$embargo_key,
$embargo_value
);
}
?>
</select>
<span class="description">*</span>
</div>
</div>
<br />
<input id="deposit-submit" name="deposit-submit" type="submit" value="<?php echo ucfirst( $deposit_button_label ); ?>" />
<?php
$wp_referer = wp_get_referer();
printf(
'<a id="deposit-cancel" href="%1$s" class="button white">Cancel</a>',
( ! empty( $wp_referer ) && ! strpos( $wp_referer, 'item/new' ) ) ? $wp_referer : '/deposits/'
);
?>
</div>
</form>
<br /><span class="description">Required fields are marked *.</span><br />
<br />
<div id="deposit-warning-dialog">
</div>
<div id="deposit-error-dialog">
</div>
<?php
}
/**
* Output deposits list entry html.
*/
function humcore_deposits_list_entry_content() {
$metadata = (array) humcore_get_current_deposit();
$authors = array_filter( $metadata['authors'] );
$authors_list = implode( ', ', $authors );
$item_url = sprintf( '%1$s/deposits/item/%2$s', HC_SITE_URL, $metadata['pid'] );
?>
<ul class="deposits-item">
<li>