Exemple #1
0
/**
 * Render the content for deposits/item/new.
 */
function humcore_deposit_form()
{
    if (!empty($_POST)) {
        $deposit_id = humcore_deposit_file();
        if ($deposit_id) {
            $review_url = sprintf('/deposits/item/%1$s/review/', $deposit_id);
            wp_redirect($review_url);
            exit;
        }
    }
    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;
    }
    $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_firstname = get_the_author_meta('first_name', $user_id);
    $user_lastname = get_the_author_meta('last_name', $user_id);
    ?>

<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>New CORE Deposit</h3>
<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">Select the file you wish to upload and deposit. *</div>

<div id="container">
	<button id="pickfile">Select File</button> 
<!--    <button id="uploadfile">Upload</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>

<script type='text/javascript' src='/js/retrieveDOI.js'></script>

<form id="deposit-form" class="standard-form" method="post" action="" 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" value="<?php 
    if (!empty($_POST['selected_temp_name'])) {
        echo sanitize_text_field($_POST['selected_temp_name']);
    }
    ?>
" />
        <input type="hidden" name="selected_file_name" id="selected_file_name" value="<?php 
    if (!empty($_POST['selected_file_name'])) {
        echo sanitize_text_field($_POST['selected_file_name']);
    }
    ?>
" />
        <input type="hidden" name="selected_file_type" id="selected_file_type" value="<?php 
    if (!empty($_POST['selected_file_type'])) {
        echo sanitize_text_field($_POST['selected_file_type']);
    }
    ?>
" />
        <input type="hidden" name="selected_file_size" id="selected_file_size" value="<?php 
    if (!empty($_POST['selected_file_type'])) {
        echo sanitize_text_field($_POST['selected_file_size']);
    }
    ?>
" />

	<div id="deposit-metadata-entries">

	<div id="deposit-title-entry">
		<label for="deposit-title">Title</label>
		<input type="text" id="deposit-title-unchanged" name="deposit-title-unchanged" size="75" class="long" value="<?php 
    if (!empty($_POST['deposit-title-unchanged'])) {
        echo wp_kses(stripslashes($_POST['deposit-title-unchanged']), array('b' => array(), 'em' => array(), 'strong' => array()));
    }
    ?>
" />
		<span class="description">*</span>
	</div>
	<p>
	<div id="deposit-genre-entry">
		<label for="deposit-genre">Item Type</label>
		<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($_POST['deposit-genre'])) {
        $posted_genre = sanitize_text_field($_POST['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>
	</p>
	<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" value="<?php 
    if (!empty($_POST['deposit-conference-title'])) {
        echo sanitize_text_field($_POST['deposit-conference-title']);
    }
    ?>
" />
	</div>

	<div id="deposit-organization-entry">
		<label for="deposit-organization-entry-list">Conference Host Organization</label>
		<input type="text" name="deposit-organization" size="60" class="text" value="<?php 
    if (!empty($_POST['deposit-organization'])) {
        echo sanitize_text_field($_POST['deposit-organization']);
    }
    ?>
" />
	</div>

	<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" value="<?php 
    if (!empty($_POST['deposit-institution'])) {
        echo sanitize_text_field($_POST['deposit-institution']);
    }
    ?>
" />
	</div>
	<p>
	<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($_POST['deposit-abstract-unchanged'])) {
        echo wp_kses(stripslashes($_POST['deposit-abstract-unchanged']), array('b' => array(), 'em' => array(), 'strong' => array()));
    }
    ?>
</textarea>
		<span class="description">*</span>
	<div class="character-count"></div>
	</div>
	</p>
	<p>
	<div id="deposit-on-behalf-flag-entry">
<?php 
    $committee_list = humcore_deposits_user_committee_list(bp_loggedin_user_id());
    $committee_list = '';
    //disable for now
    if (empty($committee_list)) {
        ?>
        <input type="hidden" name="deposit-on-behalf-flag" id="deposit-on-behalf-flag" value="" />
<?php 
    } else {
        ?>
		<label for="deposit-on-behalf-flag-list">Depositor</label>
		<span class="description">Is this deposit being made on behalf of a committee?</span>
			<input type="radio" name="deposit-on-behalf-flag" value="yes" <?php 
        if (!empty($_POST['deposit-on-behalf-flag'])) {
            checked(sanitize_text_field($_POST['deposit-on-behalf-flag']), 'yes');
        }
        ?>
>Yes &nbsp;
			<input type="radio" name="deposit-on-behalf-flag" value="no" <?php 
        if (!empty($_POST['deposit-on-behalf-flag'])) {
            checked(sanitize_text_field($_POST['deposit-on-behalf-flag']), 'no');
        } else {
            echo 'checked="checked"';
        }
        ?>
>No &nbsp;
<?php 
    }
    ?>
	</div>
	</p>
	<p>
	<div id="deposit-other-authors-entry">
		<label for="deposit-other-authors-entry-list">Authors</label>
		<span class="description">Add any authors in addition to yourself.</span>
		<ul id="deposit-other-authors-entry-list">
		<li>
		<table id="deposit-other-authors-entry-table"><tbody>
		<tr><td class="noBorderTop" style="width:205px;">
		First Name
		</td><td class="noBorderTop" style="width:205px;">
		Last Name
		</td><td class="noBorderTop">
		</td><td class="noBorderTop">
		</td></tr>
		<tr><td class="borderTop" style="width:205px;">
		<?php 
    echo esc_html($user_firstname);
    ?>
		</td><td class="borderTop" style="width:205px;">
		<?php 
    echo esc_html($user_lastname);
    ?>
		</td><td class="borderTop">
		<input type="button" id="deposit-insert-other-author-button" class="button add_author" value="Add Another">
		</td></tr>

<?php 
    if (!empty($_POST['deposit-other-authors-first-name']) && !empty($_POST['deposit-other-authors-last-name'])) {
        $other_authors = array_map(function ($first_name, $last_name) {
            return array('first_name' => sanitize_text_field($first_name), 'last_name' => sanitize_text_field($last_name));
        }, $_POST['deposit-other-authors-first-name'], $_POST['deposit-other-authors-last-name']);
        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[]" 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[]" class="text deposit-other-authors-last-name" value="<?php 
                echo $author_array['last_name'];
                ?>
" />
		</td><td class="borderTop">
		</td></tr>
<?php 
            }
        }
    }
    ?>
		</tbody></table>
		</li>
		</ul>
	</div>
	</p>
	<p>
	<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">Committee</label>
		<select name="deposit-committee" id="deposit-committee" class="js-basic-single-optional" data-placeholder="Select committee">
			<option class="level-0" selected value=""></option>
<?php 
        $posted_committee = '';
        if (!empty($_POST['deposit-committee'])) {
            $posted_committee = sanitize_text_field($_POST['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>
	</p>
	<p>
	<div id="deposit-subject-entry">
		<label for="deposit-subject">Subjects</label>
		<span class="description">Assign up to five subject fields to your item.<br />Please let us know if you would like to <a href="mailto:commons@mla.org?subject=CORE" target="_blank">suggest additional subject
 fields</a>.</span><br />
		<select name="deposit-subject[]" id="deposit-subject[]" class="js-basic-multiple" multiple="multiple" data-placeholder="Select subjects">
<?php 
    $subject_list = humcore_deposits_subject_list();
    $posted_subject_list = array();
    if (!empty($_POST['deposit-subject'])) {
        $posted_subject_list = array_map('sanitize_text_field', $_POST['deposit-subject']);
    }
    foreach ($subject_list as $subject_key => $subject_value) {
        printf('			<option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n", in_array($subject_key, $posted_subject_list) ? 'selected="selected"' : '', $subject_key, $subject_value);
    }
    ?>
		</select>
	</div>
	</p>
	<p>
	<div id="deposit-group-entry">
		<label for="deposit-group">Forums</label>
		<span class="description">Share this item with up to five <em>MLA Commons</em> forums.</span><br />
		<select name="deposit-group[]" id="deposit-group[]" class="js-basic-multiple" multiple="multiple" data-placeholder="Select forums">
<?php 
    $group_list = humcore_deposits_group_list();
    $posted_group_list = array();
    if (!empty($_POST['deposit-group'])) {
        $posted_group_list = array_map('sanitize_text_field', $_POST['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>
	</p>
	<p>
	<div id="deposit-keyword-entry">
		<label for="deposit-keyword">Tags</label>
		<span class="description">Enter up to five tags to further categorize this item.</span><br />
		<select name="deposit-keyword[]" id="deposit-keyword[]" class="js-basic-multiple-tags" multiple="multiple" data-placeholder="Enter tags">
<?php 
    $keyword_list = humcore_deposits_keyword_list();
    $posted_keyword_list = array();
    if (!empty($_POST['deposit-keyword'])) {
        $posted_keyword_list = array_map('sanitize_text_field', $_POST['deposit-keyword']);
    }
    foreach ($keyword_list as $keyword_key => $keyword_value) {
        printf('			<option class="level-1" %1$s value="%2$s">%3$s</option>' . "\n", in_array($keyword_key, $posted_keyword_list) ? 'selected="selected"' : '', $keyword_key, $keyword_value);
    }
    ?>
		</select>
	</div>
	</p>
	<p>
	<div id="deposit-resource-type-entry">
		<label for="deposit-resource-type">File Type</label>
		<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 value=""></option>
<?php 
    $resource_type_list = humcore_deposits_resource_type_list();
    $posted_resource_type = '';
    if (!empty($_POST['deposit-resource-type'])) {
        $posted_resource_type = sanitize_text_field($_POST['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>
	</p>
	<p>
	<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($_POST['deposit-notes-unchanged'])) {
        echo wp_kses(stripslashes($_POST['deposit-notes-unchanged']), array('b' => array(), 'em' => array(), 'strong' => array()));
    }
    ?>
</textarea>
	<div class="character-count"></div>
	</div>
	</p>
	<p>
	<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>MLA 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($_POST['deposit-license-type'])) {
        $posted_license_type = sanitize_text_field($_POST['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>
	</p>
	<p>
	<div id="deposit-publication-type-entry">
		<label for="deposit-publication-type">Published?</label>
		<span class="description">Check journal or publisher open access policies at <a onclick="target='_blank'" href="http://www.sherpa.ac.uk/romeo/">SHERPA/RoMEO</a> for previously published work.</span><br /><br />
			<input type="radio" name="deposit-publication-type" value="book" <?php 
    if (!empty($_POST['deposit-publication-type'])) {
        checked(sanitize_text_field($_POST['deposit-publication-type']), 'book');
    }
    ?>
>Book &nbsp;
			<input type="radio" name="deposit-publication-type" value="journal-article" <?php 
    if (!empty($_POST['deposit-publication-type'])) {
        checked(sanitize_text_field($_POST['deposit-publication-type']), 'journal-article');
    }
    ?>
>Journal &nbsp;
			<input type="radio" name="deposit-publication-type" value="conference-proceeding" <?php 
    if (!empty($_POST['deposit-publication-type'])) {
        checked(sanitize_text_field($_POST['deposit-publication-type']), 'conference-proceeding');
    }
    ?>
>Conference proceeding &nbsp;
			<input type="radio" name="deposit-publication-type" value="none" <?php 
    if (!empty($_POST['deposit-publication-type'])) {
        checked(sanitize_text_field($_POST['deposit-publication-type']), 'none');
    } else {
        echo 'checked="checked"';
    }
    ?>
>Not published &nbsp;
	</div>
	</p>
	<div id="deposit-book-entries">

		<div id="deposit-book-doi-entry">
			<label for="deposit-book-doi">Publisher DOI</label>
			<input type="text" id="deposit-book-doi" name="deposit-book-doi" class="long" value="<?php 
    if (!empty($_POST['deposit-book-doi'])) {
        echo sanitize_text_field($_POST['deposit-book-doi']);
    }
    ?>
" />
		</div>

		<div id="deposit-book-publisher-entry">
			<label for="deposit-book-publisher">Publisher</label>
			<input type="text" id="deposit-book-publisher" name="deposit-book-publisher" size="40" class="long" value="<?php 
    if (!empty($_POST['deposit-book-publisher'])) {
        echo sanitize_text_field($_POST['deposit-book-publisher']);
    }
    ?>
" />
		</div>

		<div id="deposit-book-publish-date-entry">
			<label for="deposit-book-publish-date">Pub Date</label>
			<input type="text" id="deposit-book-publish-date" name="deposit-book-publish-date" class="text" value="<?php 
    if (!empty($_POST['deposit-book-publish-date'])) {
        echo sanitize_text_field($_POST['deposit-book-publish-date']);
    }
    ?>
" />
		</div>

		<div id="deposit-book-title-entry">
			<label for="deposit-book-title">Book Title</label>
			<input type="text" id="deposit-book-title" name="deposit-book-title" size="60" class="long" value="<?php 
    if (!empty($_POST['deposit-book-title'])) {
        echo sanitize_text_field($_POST['deposit-book-title']);
    }
    ?>
" />
		</div>

		<div id="deposit-book-author-entry">
			<label for="deposit-book-author">Book Author or Editor</label>
			<input type="text" id="deposit-book-author" name="deposit-book-author" class="long" value="<?php 
    if (!empty($_POST['deposit-book-author'])) {
        echo sanitize_text_field($_POST['deposit-book-author']);
    }
    ?>
" />
		</div>

		<div id="deposit-book-chapter-entry">
			<label for="deposit-book-chapter">Chapter</label>
			<input type="text" id="deposit-book-chapter" name="deposit-book-chapter" class="text" value="<?php 
    if (!empty($_POST['deposit-book-chapter'])) {
        echo sanitize_text_field($_POST['deposit-book-chapter']);
    }
    ?>
" />
		</div>

		<div id="deposit-book-pages-entry">
			<label for="deposit-book-start-page"><span>Start Page</span>
			<input type="text" id="deposit-book-start-page" name="deposit-book-start-page" size="5" class="text" value="<?php 
    if (!empty($_POST['deposit-book-start-page'])) {
        echo sanitize_text_field($_POST['deposit-book-start-page']);
    }
    ?>
" />
			</label>
			<label for="deposit-book-end-page"><span>End Page</span>
			<input type="text" id="deposit-book-end-page" name="deposit-book-end-page" size="5" class="text" value="<?php 
    if (!empty($_POST['deposit-book-end-page'])) {
        echo sanitize_text_field($_POST['deposit-book-end-page']);
    }
    ?>
" />
			</label>
			<br style='clear:both'>
		</div>

		<div id="deposit-book-isbn-entry">
			<label for="deposit-book-isbn">ISBN</label>
			<input type="text" id="deposit-book-isbn" name="deposit-book-isbn" class="text" value="<?php 
    if (!empty($_POST['deposit-book-isbn'])) {
        echo sanitize_text_field($_POST['deposit-book-isbn']);
    }
    ?>
" />
		</div>

	</div>

	<div id="deposit-journal-entries">

		<div id="deposit-journal-doi-entry">
			<label for="deposit-journal-doi">Publisher DOI</label>
			<input type="text" id="deposit-journal-doi" name="deposit-journal-doi" class="long" value="<?php 
    if (!empty($_POST['deposit-journal-doi'])) {
        echo sanitize_text_field($_POST['deposit-journal-doi']);
    }
    ?>
" />
		</div>

		<div id="deposit-journal-publisher-entry">
			<label for="deposit-journal-publisher">Publisher</label>
			<input type="text" id="deposit-journal-publisher" name="deposit-journal-publisher" size="40" class="long" value="<?php 
    if (!empty($_POST['deposit-journal-publisher'])) {
        echo sanitize_text_field($_POST['deposit-journal-publisher']);
    }
    ?>
" />
		</div>

		<div id="deposit-journal-publish-date-entry">
			<label for="deposit-journal-publish-date">Pub Date</label>
			<input type="text" id="deposit-journal-publish-date" name="deposit-journal-publish-date" class="text" value="<?php 
    if (!empty($_POST['deposit-journal-publish-date'])) {
        echo sanitize_text_field($_POST['deposit-journal-publish-date']);
    }
    ?>
" />
		</div>

		<div id="deposit-journal-title-entry">
			<label for="deposit-journal-title">Journal Title</label>
			<input type="text" id="deposit-journal-title" name="deposit-journal-title" size="75" class="long" value="<?php 
    if (!empty($_POST['deposit-journal-title'])) {
        echo sanitize_text_field($_POST['deposit-journal-title']);
    }
    ?>
" />
		</div>

		<div id="deposit-journal-volume-entry">
			<label for="deposit-journal-volume"><span>Volume</span>
			<input type="text" id="deposit-journal-volume" name="deposit-journal-volume" class="text" value="<?php 
    if (!empty($_POST['deposit-journal-volume'])) {
        echo sanitize_text_field($_POST['deposit-journal-volume']);
    }
    ?>
" />
			</label>
			<label for="deposit-journal-issue"><span>Issue</span>
			<input type="text" id="deposit-journal-issue" name="deposit-journal-issue" class="text" value="<?php 
    if (!empty($_POST['deposit-journal-volume'])) {
        echo sanitize_text_field($_POST['deposit-journal-volume']);
    }
    ?>
" />
			</label>
			<br style='clear:both'>
		</div>

		<div id="deposit-journal-pages-entry">
			<label for="deposit-journal-start-page"><span>Start Page</span>
			<input type="text" id="deposit-journal-start-page" name="deposit-journal-start-page" size="5" class="text" value="<?php 
    if (!empty($_POST['deposit-journal-start-page'])) {
        echo sanitize_text_field($_POST['deposit-journal-start-page']);
    }
    ?>
" />
			</label>
			<label for="deposit-journal-end-page"><span>End Page</span>
			<input type="text" id="deposit-journal-end-page" name="deposit-journal-end-page" size="5" class="text" value="<?php 
    if (!empty($_POST['deposit-journal-start-page'])) {
        echo sanitize_text_field($_POST['deposit-journal-start-page']);
    }
    ?>
" />
			</label>
			<br style='clear:both'>
		</div>

		<div id="deposit-journal-issn-entry">
			<label for="deposit-journal-issn">ISSN</label>
			<input type="text" id="deposit-journal-issn" name="deposit-journal-issn" class="text" value="<?php 
    if (!empty($_POST['deposit-journal-issn'])) {
        echo sanitize_text_field($_POST['deposit-journal-issn']);
    }
    ?>
" />
		</div>

	</div>

	<div id="deposit-conference-proceedings">

		<div id="deposit-proceeding-doi-entry">
			<label for="deposit-proceeding-doi">Publisher DOI</label>
			<input type="text" id="deposit-proceeding-doi" name="deposit-proceeding-doi" class="long" value="<?php 
    if (!empty($_POST['deposit-proceeding-doi'])) {
        echo sanitize_text_field($_POST['deposit-proceeding-doi']);
    }
    ?>
" />
		</div>

		<div id="deposit-proceeding-publisher-entry">
			<label for="deposit-proceeding-publisher">Publisher</label>
			<input type="text" id="deposit-proceeding-publisher" name="deposit-proceeding-publisher" size="40" class="long" value="<?php 
    if (!empty($_POST['deposit-proceeding-publisher'])) {
        echo sanitize_text_field($_POST['deposit-proceeding-publisher']);
    }
    ?>
" />
		</div>

		<div id="deposit-proceeding-publish-date-entry">
			<label for="deposit-proceeding-publish-date">Pub Date</label>
			<input type="text" id="deposit-proceeding-publish-date" name="deposit-proceeding-publish-date" class="text" value="<?php 
    if (!empty($_POST['deposit-proceeding-publish-date'])) {
        echo sanitize_text_field($_POST['deposit-proceeding-publish-date']);
    }
    ?>
" />
		</div>

		<div id="deposit-proceeding-title-entry">
			<label for="deposit-proceeding-title">Proceeding Title</label>
			<input type="text" id="deposit-proceeding-title" name="deposit-proceeding-title" size="75" class="long" value="<?php 
    if (!empty($_POST['deposit-proceeding-title'])) {
        echo sanitize_text_field($_POST['deposit-proceeding-title']);
    }
    ?>
" />
		</div>

		<div id="deposit-proceeding-pages-entry">
			<label for="deposit-proceeding-start-page"><span>Start Page</span>
			<input type="text" id="deposit-proceeding-start-page" name="deposit-proceeding-start-page" size="5" class="text" value="<?php 
    if (!empty($_POST['deposit-proceeding-start-page'])) {
        echo sanitize_text_field($_POST['deposit-proceeding-start-page']);
    }
    ?>
" />
			</label>
			<label for="deposit-proceeding-end-page"><span>End Page</span>
			<input type="text" id="deposit-proceeding-end-page" name="deposit-proceeding-end-page" size="5" class="text" value="<?php 
    if (!empty($_POST['deposit-proceeding-start-page'])) {
        echo sanitize_text_field($_POST['deposit-proceeding-start-page']);
    }
    ?>
" />
			</label>
			<br style='clear:both'>
		</div>

	</div>

	<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" value="<?php 
    if (!empty($_POST['deposit-non-published-date'])) {
        echo sanitize_text_field($_POST['deposit-non-published-date']);
    }
    ?>
" />
		</div>

	</div>

	<input id="submit" name="submit" type="submit" value="Deposit" />
	<?php 
    $wp_referer = wp_get_referer();
    printf('<a 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 />

<?php 
}
/**
 * Display the humcore_deposit custom post metadata.
 */
function humcore_deposit_metabox($post)
{
    // Noncename needed to verify where the data originated.
    echo '<input type="hidden" name="deposit_metabox_noncename" id="deposit_metabox_noncename" value="' . esc_attr(wp_create_nonce('humcore_deposit_metabox')) . '" />';
    // Get the metadata.
    $aggregator_metadata = json_decode(get_post_meta($post->ID, '_deposit_metadata', true), true);
    if (!empty($aggregator_metadata)) {
        if (empty($aggregator_metadata['title_unchanged'])) {
            $aggregator_metadata['title_unchanged'] = $aggregator_metadata['title'];
        }
        if (empty($aggregator_metadata['abstract_unchanged'])) {
            $aggregator_metadata['abstract_unchanged'] = $aggregator_metadata['abstract'];
        }
        if (empty($aggregator_metadata['notes_unchanged'])) {
            $aggregator_metadata['notes_unchanged'] = $aggregator_metadata['notes'];
        }
        // Echo out the array.
        ?>
	<div class="width_full p_box">
		<!-- <?php 
        print_r($aggregator_metadata);
        ?>
 -->

		<p>
			<label>ID<br>
				<input type="hidden" name="aggregator_id" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['id']);
        ?>
">
				<input type="text" name="aggregator_id_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['id']);
        ?>
">
			</label>
		</p>
		<p>
			<label>PID<br>
				<input type="hidden" name="aggregator_pid" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['pid']);
        ?>
">
				<input type="text" name="aggregator_pid_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['pid']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Creator<br>
				<input type="hidden" name="aggregator_creator" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['creator']);
        ?>
">
				<input type="text" name="aggregator_creator_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['creator']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Title<br>
				<input type="text" name="aggregator_title_unchanged" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['title_unchanged']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Abstract<br>
				<textarea name="aggregator_abstract_unchanged" class="widefat"><?php 
        echo esc_attr($aggregator_metadata['abstract_unchanged']);
        ?>
</textarea>
			</label>
		</p>
		<p>
			<label>Genre<br>
			<select name="aggregator_genre">
			<option class="level-0" selected value=""></option>
<?php 
        $genre_list = humcore_deposits_genre_list();
        $posted_genre = '';
        if (!empty($aggregator_metadata['genre'])) {
            $posted_genre = esc_attr($aggregator_metadata['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>
			</label>
		</p>
		<p>
			<label>Organization<br>
				<input type="text" name="aggregator_organization" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['organization']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Institution<br>
				<input type="text" name="aggregator_institution" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['institution']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Conference Title<br>
				<input type="text" name="aggregator_conference_title" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['conference_title']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Conference Organization<br>
				<input type="text" name="aggregator_conference_organization" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['conference_organization']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Committee Deposit<br>
				<input type="hidden" name="aggregator_committee_deposit" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['committee_deposit']);
        ?>
">
				<input type="text" name="aggregator_committee_deposit_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['committee_deposit']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Committee ID<br>
				<input type="hidden" name="aggregator_committee_id" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['committee_id']);
        ?>
">
				<input type="text" name="aggregator_committee_id_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['committee_id']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Submitter<br>
				<input type="hidden" name="aggregator_submitter" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['submitter']);
        ?>
">
				<input type="text" name="aggregator_submitter_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['submitter']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Author(s)<br>
			<?php 
        foreach ($aggregator_metadata['authors'] as $author) {
            ?>
				<label>Given: 
				<input type="text" name="aggregator_author_given[]" class="widefat" value="<?php 
            echo esc_attr($author['given']);
            ?>
">
				</label>
				<label>Family: 
				<input type="text" name="aggregator_author_family[]" class="widefat" value="<?php 
            echo esc_attr($author['family']);
            ?>
">
				</label>
				<label>Full Name: 
				<input type="text" name="aggregator_author_fullname[]" class="widefat" value="<?php 
            echo esc_attr($author['fullname']);
            ?>
">
				</label>
				<label>UNI: 
				<input type="text" name="aggregator_author_uni[]" class="widefat" value="<?php 
            echo esc_attr($author['uni']);
            ?>
">
				</label>
				<label>Role: 
				<input type="text" name="aggregator_author_role[]" class="widefat" value="<?php 
            echo esc_attr($author['role']);
            ?>
">
				</label>
				<label>Affiliation: 
				<input type="text" name="aggregator_author_affiliation[]" class="widefat" value="<?php 
            echo esc_attr($author['affiliation']);
            ?>
">
				</label>
			<?php 
        }
        ?>
				<label>Given: 
				<input type="text" name="aggregator_author_given[]" class="widefat" value="">
				</label>
				<label>Family: 
				<input type="text" name="aggregator_author_family[]" class="widefat" value="">
				</label>
				<label>Full Name: 
				<input type="text" name="aggregator_author_fullname[]" class="widefat" value="">
				</label>
				<label>UNI: 
				<input type="text" name="aggregator_author_uni[]" class="widefat" value="">
				</label>
				<label>Role: 
				<input type="text" name="aggregator_author_role[]" class="widefat" value="">
				</label>
				<label>Affiliation: 
				<input type="text" name="aggregator_author_affiliation[]" class="widefat" value="">
				</label>
			</label>
		</p>
		<p>
			<label>Author Info<br>
				<input type="hidden" name="aggregator_author_info" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['author_info']);
        ?>
">
				<input type="text" name="aggregator_author_info_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['author_info']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Group(s)<br>
			<select name="aggregator_group[]" multiple size="10">
			<option class="level-0" value="">(No groups)</option>
<?php 
        $group_list = humcore_deposits_group_list();
        $posted_group_list = array();
        if (!empty($aggregator_metadata['group'])) {
            foreach ($aggregator_metadata['group_ids'] as $group_id) {
                if (!empty($group_id)) {
                    $posted_group_list[] = $group_id;
                }
            }
        }
        foreach ($group_list as $group_key => $group_value) {
            printf('			<option class="level-0" %1$s value="%2$s">%3$s</option>' . "\n", in_array($group_key, $posted_group_list) ? 'selected="selected"' : '', $group_key, $group_value);
        }
        ?>
			</select>
			</label>
		</p>
		<p>
			<label>Subject(s)<br>
			<select name="aggregator_subject[]" multiple size="10">
			<option class="level-0" value="">(No subjects)</option>
<?php 
        $subject_list = humcore_deposits_subject_list();
        $posted_subject_list = array();
        if (!empty($aggregator_metadata['subject'])) {
            foreach ($aggregator_metadata['subject_ids'] as $subject_id) {
                $term = get_term_by('term_taxonomy_id', $subject_id, 'humcore_deposit_subject');
                $posted_subject_list[] = sanitize_text_field(stripslashes($term->name));
            }
        }
        foreach ($subject_list as $subject_key => $subject_value) {
            printf('			<option class="level-0" %1$s value="%2$s">%3$s</option>' . "\n", in_array($subject_key, $posted_subject_list) ? 'selected="selected"' : '', $subject_key, $subject_value);
        }
        ?>
			</select>
			</label>
		</p>
		<p>
			<label>Tag(s)<br>
			<select name="aggregator_keyword[]" multiple size="10">
			<option class="level-0" value="">(No keywords)</option>
<?php 
        $keyword_list = humcore_deposits_keyword_list();
        $posted_keyword_list = array();
        if (!empty($aggregator_metadata['keyword'])) {
            foreach ($aggregator_metadata['keyword_ids'] as $keyword_id) {
                $term = get_term_by('term_taxonomy_id', $keyword_id, 'humcore_deposit_tag');
                $posted_keyword_list[] = sanitize_text_field(stripslashes($term->name));
            }
        }
        foreach ($keyword_list as $keyword_key => $keyword_value) {
            printf('			<option class="level-0" %1$s value="%2$s">%3$s</option>' . "\n", in_array($keyword_key, $posted_keyword_list) ? 'selected="selected"' : '', $keyword_key, $keyword_value);
        }
        ?>
			</select>
			</label>
		</p>
		<p>
			<label>Type of Resource<br>
			<select name="aggregator_type_of_resource">
			<option class="level-0" selected value=""></option>
<?php 
        $resource_type_list = humcore_deposits_resource_type_list();
        $posted_resource_type = '';
        if (!empty($aggregator_metadata['type_of_resource'])) {
            $posted_resource_type = esc_attr($aggregator_metadata['type_of_resource']);
        }
        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>
			</label>
		</p>
		<p>
			<label>Language<br>
				<input type="text" name="aggregator_language" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['language']);
        ?>
">

			</label>
		</p>
		<p>
			<label>Notes<br>
				<textarea name="aggregator_notes_unchanged" class="widefat"><?php 
        echo esc_attr($aggregator_metadata['notes_unchanged']);
        ?>
</textarea>
			</label>
		</p>
		<p>
			<label>Creative Commons License<br>
			<select name="aggregator_type_of_license">
<?php 
        $license_type_list = humcore_deposits_license_type_list();
        $posted_license_type = '';
        if (!empty($aggregator_metadata['type_of_license'])) {
            $posted_license_type = esc_attr($aggregator_metadata['type_of_license']);
        }
        foreach ($license_type_list as $license_key => $license_value) {
            printf('			<option class="level-0" %1$s value="%2$s">%3$s</option>' . "\n", $license_key == $posted_license_type ? 'selected="selected"' : '', $license_key, $license_value);
        }
        ?>
			</select>
			</label>
		</p>
		<p>
			<label>Record Content Source<br>
				<input type="hidden" name="aggregator_record_content_source" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['record_content_source']);
        ?>
">
				<input type="text" name="aggregator_record_content_source_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['record_content_source']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Record Creation Date<br>
				<input type="hidden" name="aggregator_record_creation_date" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['record_creation_date']);
        ?>
">
				<input type="text" name="aggregator_record_creation_date_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['record_creation_date']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Member Of<br>
				<input type="hidden" name="aggregator_member_of" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['member_of']);
        ?>
">
				<input type="text" name="aggregator_member_of_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['member_of']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Publication Type<br>
			<input type="radio" name="aggregator_publication-type" class="widefat" value="book" <?php 
        if (!empty($aggregator_metadata['publication-type'])) {
            checked(sanitize_text_field($aggregator_metadata['publication-type']), 'book');
        }
        ?>
>Book &nbsp;
			<input type="radio" name="aggregator_publication-type" class="widefat" value="journal-article" <?php 
        if (!empty($aggregator_metadata['publication-type'])) {
            checked(sanitize_text_field($aggregator_metadata['publication-type']), 'journal-article');
        }
        ?>
>Journal &nbsp;
			<input type="radio" name="aggregator_publication-type" class="widefat" value="conference-proceeding" <?php 
        if (!empty($aggregator_metadata['publication-type'])) {
            checked(sanitize_text_field($aggregator_metadata['publication-type']), 'conference-proceeding');
        }
        ?>
>Conference proceeding &nbsp;
			<input type="radio" name="aggregator_publication-type" class="widefat" value="none" <?php 
        if (!empty($aggregator_metadata['publication-type'])) {
            checked(sanitize_text_field($aggregator_metadata['publication-type']), 'none');
        }
        ?>
>Not published &nbsp;
			</label>
		</p>
		<p>
			<label>Publisher<br>
				<input type="text" name="aggregator_publisher" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['publisher']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Date<br>
				<input type="text" name="aggregator_date" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['date']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Date Issued<br>
				<input type="text" name="aggregator_date_issued" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['date_issued']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Publisher DOI<br>
				<input type="text" name="aggregator_doi" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['doi']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Book, Journal or Proceeding Title<br>
				<input type="text" name="aggregator_book_journal_title" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['book_journal_title']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Author or Editor<br>
				<input type="text" name="aggregator_book_author" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['book_author']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Chapter<br>
				<input type="text" name="aggregator_chapter" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['chapter']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Volume<br>
				<input type="text" name="aggregator_volume" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['volume']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Issue<br>
				<input type="text" name="aggregator_issue" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['issue']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Start Page<br>
				<input type="text" name="aggregator_start_page" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['start_page']);
        ?>
">
			</label>
		</p>
		<p>
			<label>End Page<br>
				<input type="text" name="aggregator_end_page" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['end_page']);
        ?>
">
			</label>
		</p>
		<p>
			<label>ISBN<br>
				<input type="text" name="aggregator_isbn" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['isbn']);
        ?>
">
			</label>
		</p>
		<p>
			<label>ISSN<br>
				<input type="text" name="aggregator_issn" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['issn']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Handle<br>
				<input type="text" name="aggregator_handle" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['handle']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Deposit DOI<br>
				<input type="text" name="aggregator_deposit_doi" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['deposit_doi']);
        ?>
">
			</label>
		</p>
		<p>
			<label>Record Identifier<br>
				<input type="hidden" name="aggregator_record_identifier" class="widefat" value="<?php 
        echo esc_attr($aggregator_metadata['record_identifier']);
        ?>
">
				<input type="text" name="aggregator_record_identifier_display" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($aggregator_metadata['record_identifier']);
        ?>
">
			</label>
		</p>

	 </div>
<?php 
    }
    // Get the file metadata.
    $resource_file_metadata = json_decode(get_post_meta($post->ID, '_deposit_file_metadata', true), true);
    if (!empty($resource_file_metadata)) {
        $resource_pid = $resource_file_metadata['files'][0]['pid'];
        $resource_datastream_id = $resource_file_metadata['files'][0]['datastream_id'];
        $resource_filename = $resource_file_metadata['files'][0]['filename'];
        $resource_filetype = $resource_file_metadata['files'][0]['filetype'];
        $resource_filesize = $resource_file_metadata['files'][0]['filesize'];
        $resource_fileloc = $resource_file_metadata['files'][0]['fileloc'];
        // Echo out the fields.
        ?>
	<p />
	<div class="width_full p_box">
		<p>
			<label><strong>Resource Metadata Fields</strong><br>
				<hr />
			</label>
		</p>
		<p>
			<label>Resource PID<br>
				<input type="text" name="resource_pid" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($resource_pid);
        ?>
">
			</label>
		</p>
		<p>
			<label>Resource Datastream ID<br>
				<input type="text" name="resource_datastream_id" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($resource_datastream_id);
        ?>
">
			</label>
		</p>
		<p>
			<label>File Name<br>
				<input type="text" name="resource_filename" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($resource_filename);
        ?>
">
			</label>
		</p>
		<p><label>Mime Type<br>
				 <input type="text" name="resource_filetype" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($resource_filetype);
        ?>
">
			</label>
		</p>
		<p><label>File Size<br>
				<input type="text" name="resource_filesize" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($resource_filesize);
        ?>
">
			</label>
		</p>
		<p><label>File Location<br>
				<input type="text" name="resource_fileloc" class="widefat" disabled="disabled" value="<?php 
        echo esc_attr($resource_fileloc);
        ?>
">
			</label>
		</p>
	</div>
<?php 
    }
}