Пример #1
0
/**
 * Output deposits single item review page html.
 */
function humcore_deposit_item_review_content()
{
    $metadata = (array) humcore_get_current_deposit();
    if (!empty($metadata['group'])) {
        $groups = array_filter($metadata['group']);
    }
    if (!empty($groups)) {
        $group_list = implode(', ', array_map('esc_html', $groups));
    }
    if (!empty($metadata['subject'])) {
        $subjects = array_filter($metadata['subject']);
    }
    if (!empty($subjects)) {
        $subject_list = implode(', ', array_map('esc_html', $subjects));
    }
    if (!empty($metadata['keyword'])) {
        $keywords = array_filter($metadata['keyword']);
    }
    if (!empty($keywords)) {
        $keyword_list = implode(', ', array_map('esc_html', $keywords));
    }
    $authors = array_filter($metadata['authors']);
    $author_uni = humcore_deposit_parse_author_info($metadata['author_info'][0], 1);
    $author_type = humcore_deposit_parse_author_info($metadata['author_info'][0], 3);
    $authors_list = implode(', ', array_map('esc_html', $authors));
    $deposit_post_id = $metadata['record_identifier'];
    $post_data = get_post($deposit_post_id);
    $post_metadata = json_decode(get_post_meta($deposit_post_id, '_deposit_metadata', true), true);
    $file_metadata = json_decode(get_post_meta($deposit_post_id, '_deposit_file_metadata', true), true);
    $downloads_meta_key = sprintf('_total_downloads_%s_%s', $file_metadata['files'][0]['datastream_id'], $file_metadata['files'][0]['pid']);
    $total_downloads = get_post_meta($deposit_post_id, $downloads_meta_key, true);
    $views_meta_key = sprintf('_total_views_%s', $metadata['pid']);
    $total_views = get_post_meta($deposit_post_id, $views_meta_key, true) + 1;
    // Views counted at item page level.
    if ($post_data->post_author != bp_loggedin_user_id()) {
        $post_meta_ID = update_post_meta($deposit_post_id, $views_meta_key, $total_views);
    }
    $download_url = sprintf('/deposits/download/%s/%s/%s/', $file_metadata['files'][0]['pid'], $file_metadata['files'][0]['datastream_id'], $file_metadata['files'][0]['filename']);
    $view_url = sprintf('/deposits/view/%s/%s/%s/', $file_metadata['files'][0]['pid'], $file_metadata['files'][0]['datastream_id'], $file_metadata['files'][0]['filename']);
    $metadata_url = sprintf('/deposits/download/%s/%s/%s/', $metadata['pid'], 'descMetadata', 'xml');
    $file_type_data = wp_check_filetype($file_metadata['files'][0]['filename'], wp_get_mime_types());
    $file_type_icon = sprintf('<img class="deposit-icon" src="%s" alt="%s" />', plugins_url('assets/' . esc_attr($file_type_data['ext']) . '-icon-48x48.png', __FILE__), esc_attr($file_type_data['ext']));
    if (!empty($file_metadata['files'][0]['thumb_filename'])) {
        $thumb_url = sprintf('<img class="deposit-thumb" src="/deposits/view/%s/%s/%s/" alt="%s" />', $file_metadata['files'][0]['pid'], $file_metadata['files'][0]['thumb_datastream_id'], $file_metadata['files'][0]['thumb_filename'], 'thumbnail');
    } else {
        $thumb_url = '';
    }
    ?>

<div class="bp-group-documents-meta">
<dl class='defList'>
<dt><?php 
    _e('Title:', 'humcore_domain');
    ?>
</dt>
<dd><span><?php 
    echo $metadata['title_unchanged'];
    // XSS OK.
    ?>
</span></dd>
<dt><?php 
    _e('Item Type:', 'humcore_domain');
    ?>
</dt>
<dd><?php 
    echo esc_html($metadata['genre']);
    ?>
</dd>
<!-- //new stuff -->
<?php 
    if ('Conference paper' == $metadata['genre'] || 'Conference proceeding' == $metadata['genre']) {
        ?>
<dt><?php 
        _e('Conf. Title:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($post_metadata['conference_title'])) {
            ?>
<dd><span><?php 
            echo $post_metadata['conference_title'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Conf. Org.:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($post_metadata['conference_organization'])) {
            ?>
<dd><span><?php 
            echo $post_metadata['conference_organization'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
    } elseif ('Dissertation' == $metadata['genre'] || 'Thesis' == $metadata['genre'] || 'Technical Report' == $metadata['genre']) {
        ?>
<dt><?php 
        _e('Institution:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($post_metadata['institution'])) {
            ?>
<dd><span><?php 
            echo $post_metadata['institution'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
    }
    ?>
<dt><?php 
    _e('Abstract:', 'humcore_domain');
    // Google Scholar wants Abstract.
    ?>
</dt>
<dd><?php 
    echo $metadata['abstract_unchanged'];
    ?>
</dd>
<?php 
    if ('yes' === $metadata['committee_deposit']) {
        // Do not show unless this is a committee deposit.
        ?>
<dt><?php 
        _e('Deposit Type:', 'humcore_domain');
        ?>
</dt>
<dd><span><?php 
        echo 'Committee';
        ?>
</span></dd>
<?php 
    }
    ?>
<dt><?php 
    _e('Author(s):', 'humcore_domain');
    ?>
</dt>
<dd><?php 
    echo $authors_list;
    // XSS OK.
    ?>
</dd>
<dt><?php 
    _e('Subject(s):', 'humcore_domain');
    ?>
</dt>
<?php 
    if (!empty($subjects)) {
        ?>
<dd><?php 
        echo $subject_list;
        // XSS OK.
        ?>
</dd>
<?php 
    } else {
        ?>
<dd>&nbsp;</dd>
<?php 
    }
    ?>
<dt><?php 
    _e('Forum(s):', 'humcore_domain');
    ?>
</dt>
<?php 
    if (!empty($groups)) {
        ?>
<dd><?php 
        echo $group_list;
        // XSS OK.
        ?>
</dd>
<?php 
    } else {
        ?>
<dd>&nbsp;</dd>
<?php 
    }
    ?>
<dt><?php 
    _e('Tag(s):', 'humcore_domain');
    ?>
</dt>
<?php 
    if (!empty($keywords)) {
        ?>
<dd><?php 
        echo $keyword_list;
        // XSS OK.
        ?>
</dd>
<?php 
    } else {
        ?>
<dd>&nbsp;</dd>
<?php 
    }
    ?>
<dt><?php 
    _e('File Type:', 'humcore_domain');
    ?>
</dt>
<dd><?php 
    echo esc_html($metadata['type_of_resource']);
    ?>
</dd>
<dt><?php 
    _e('Notes:', 'humcore_domain');
    ?>
</dt>
<?php 
    if (!empty($metadata['notes_unchanged'])) {
        ?>
<dd><?php 
        echo $metadata['notes_unchanged'];
        ?>
</dd>
<?php 
    } else {
        ?>
<dd>( None )</dd>
<?php 
    }
    if (!empty($post_metadata['type_of_license'])) {
        ?>
<dt><?php 
        _e('License:', 'humcore_domain');
        ?>
</dt>
<dd><?php 
        echo humcore_linkify_license($post_metadata['type_of_license']);
        ?>
</dd>
<?php 
    }
    if ('journal-article' == $post_metadata['publication-type']) {
        ?>
<dt><?php 
        _e('Pub. Type:', 'humcore_domain');
        ?>
</dt>
<dd><span><?php 
        echo 'Journal Article';
        // XSS OK.
        ?>
</span></dd>
<dt><?php 
        _e('Pub. DOI:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['doi'])) {
            ?>
<dd><span><?php 
            echo $metadata['doi'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Publisher:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['publisher'])) {
            ?>
<dd><span><?php 
            echo $metadata['publisher'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Pub. Date:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['date'])) {
            ?>
<dd><span><?php 
            echo $metadata['date'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Journal:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['book_journal_title'])) {
            ?>
<dd><span><?php 
            echo $metadata['book_journal_title'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Volume:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['volume'])) {
            ?>
<dd><span><?php 
            echo $metadata['volume'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Issue:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['issue'])) {
            ?>
<dd><span><?php 
            echo $metadata['issue'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Start Page:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['start_page'])) {
            ?>
<dd><span><?php 
            echo $metadata['start_page'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('End Page:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['end_page'])) {
            ?>
<dd><span><?php 
            echo $metadata['end_page'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('ISSN:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['issn'])) {
            ?>
<dd><span><?php 
            echo $metadata['issn'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
    } elseif ('book' == $post_metadata['publication-type']) {
        ?>
<dt><?php 
        _e('Pub. Type:', 'humcore_domain');
        ?>
</dt>
<dd><span><?php 
        echo 'Book';
        // XSS OK.
        ?>
</span></dd>
<dt><?php 
        _e('Pub. DOI:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['doi'])) {
            ?>
<dd><span><?php 
            echo $metadata['doi'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Publisher:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['publisher'])) {
            ?>
<dd><span><?php 
            echo $metadata['publisher'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Pub. Date:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['date'])) {
            ?>
<dd><span><?php 
            echo $metadata['date'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Author/Editor:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['book_author'])) {
            ?>
<dd><span><?php 
            echo $metadata['book_author'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Book Title:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['book_journal_title'])) {
            ?>
<dd><span><?php 
            echo $metadata['book_journal_title'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Chapter:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['chapter'])) {
            ?>
<dd><span><?php 
            echo $metadata['chapter'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Start Page:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['start_page'])) {
            ?>
<dd><span><?php 
            echo $metadata['start_page'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('End Page:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['end_page'])) {
            ?>
<dd><span><?php 
            echo $metadata['end_page'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('ISBN:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['isbn'])) {
            ?>
<dd><span><?php 
            echo $metadata['isbn'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
    } elseif ('conference-proceeding' == $post_metadata['publication-type']) {
        ?>
<dt><?php 
        _e('Pub. Type:', 'humcore_domain');
        ?>
</dt>
<dd><span><?php 
        echo 'Conference Proceeding';
        // XSS OK.
        ?>
</span></dd>
<dt><?php 
        _e('Pub. DOI:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['doi'])) {
            ?>
<dd><span><?php 
            echo $metadata['doi'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Publisher:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['publisher'])) {
            ?>
<dd><span><?php 
            echo $metadata['publisher'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Pub. Date:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['date'])) {
            ?>
<dd><span><?php 
            echo $metadata['date'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Proceeding:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['book_journal_title'])) {
            ?>
<dd><span><?php 
            echo $metadata['book_journal_title'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('Start Page:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['start_page'])) {
            ?>
<dd><span><?php 
            echo $metadata['start_page'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
        ?>
<dt><?php 
        _e('End Page:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['end_page'])) {
            ?>
<dd><span><?php 
            echo $metadata['end_page'];
            // XSS OK.
            ?>
</span></dd>
<?php 
        } else {
            ?>
<dd>&nbsp;</dd>
<?php 
        }
    } elseif (empty($post_metadata['publication-type']) || 'none' == $post_metadata['publication-type']) {
        ?>
<dt><?php 
        _e('Pub. Type:', 'humcore_domain');
        ?>
</dt>
<dd><span><?php 
        echo 'None';
        // XSS OK.
        ?>
</span></dd>
<dt><?php 
        _e('Creation Date:', 'humcore_domain');
        ?>
</dt>
<?php 
        if (!empty($metadata['date'])) {
            ?>
<dd><?php 
            echo esc_html($metadata['date']);
            ?>
</dd>
<?php 
        } else {
            ?>
<dd>( None entered )</dd>
<?php 
        }
    }
    ?>
<dt><?php 
    _e('File Name:', 'humcore_domain');
    ?>
</dt>
<dd><?php 
    echo esc_html($file_metadata['files'][0]['filename']);
    ?>
</dd>
<dt><?php 
    _e('File Size:', 'humcore_domain');
    ?>
</dt>
<dd><?php 
    echo number_format($file_metadata['files'][0]['filesize']), " bytes";
    ?>
</dd>
</dl>
</div>
<br style='clear:both'>
<a onclick="target='_blank'" class="bp-deposits-view button white" title="View" href="<?php 
    echo esc_url($view_url);
    ?>
"><?php 
    _e('View your Deposit', 'humcore_domain');
    ?>
</a>
<?php 
}
Пример #2
0
/**
 * Format the page head meta fields.
 */
function humcore_deposit_item_search_meta()
{
    while (humcore_deposits()) {
        humcore_the_deposit();
    }
    // Should fetch one record.
    $metadata = (array) humcore_get_current_deposit();
    printf('<meta name="description" content="%1$s">' . "\n\r", htmlentities($metadata['abstract']));
    printf('<meta name="citation_title" content="%1$s">' . "\n\r", htmlentities($metadata['title']));
    printf('<meta name="citation_publication_date" content="%1$s">' . "\n\r", htmlentities($metadata['date']));
    // Format date yyyy/mm/dd.
    if (!empty($metadata['publisher'])) {
        printf('<meta name="citation_publisher" content="%1$s">' . "\n\r", htmlentities($metadata['publisher']));
    }
    foreach ($metadata['authors'] as $author) {
        printf('<meta name="citation_author" content="%1$s">' . "\n\r", htmlentities($author));
    }
    if (!empty($metadata['genre']) && in_array($metadata['genre'], array('Dissertation', 'Technical Report', 'Thesis')) && !empty($metadata['institution'][0])) {
        printf('<meta name="citation_dissertation_institution" content="%1$s">' . "\n\r", htmlentities($metadata['institution'][0]));
    }
    if (!empty($metadata['genre']) && 'Technical report' == $metadata['genre'] && !empty($metadata['institution'])) {
        printf('<meta name="citation_technical_report_institution" content="%1$s">' . "\n\r", htmlentities($metadata['institution']));
    }
    if (!empty($metadata['genre']) && ('Conference paper' == $metadata['genre'] || 'Conference proceeding' == $metadata['genre']) && !empty($metadata['conference_title'])) {
        printf('<meta name="citation_conference_title" content="%1$s">' . "\n\r", htmlentities($metadata['conference_title']));
    }
    if (!empty($metadata['book_journal_title'])) {
        printf('<meta name="citation_journal_title" content="%1$s">' . "\n\r", htmlentities($metadata['book_journal_title']));
    }
    if (!empty($metadata['volume'])) {
        printf('<meta name="citation_volume" content="%1$s">' . "\n\r", htmlentities($metadata['volume']));
    }
    if (!empty($metadata['issue'])) {
        printf('<meta name="citation_issue" content="%1$s">' . "\n\r", htmlentities($metadata['issue']));
    }
    if (!empty($metadata['start_page'])) {
        printf('<meta name="citation_firstpage" content="%1$s">' . "\n\r", htmlentities($metadata['start_page']));
    }
    if (!empty($metadata['end_page'])) {
        printf('<meta name="citation_lastpage" content="%1$s">' . "\n\r", htmlentities($metadata['end_page']));
    }
    if (!empty($metadata['doi'])) {
        printf('<meta name="citation_doi" content="%1$s">' . "\n\r", htmlentities($metadata['doi']));
    }
    if (!empty($metadata['handle'])) {
        printf('<meta name="citation_handle_id" content="%1$s">' . "\n\r", htmlentities($metadata['handle']));
    }
    if (!empty($metadata['issn'])) {
        printf('<meta name="citation_issn" content="%1$s">' . "\n\r", htmlentities($metadata['issn']));
    }
    if (!empty($metadata['chapter'])) {
        printf('<meta name="citation_chapter" content="%1$s">' . "\n\r", htmlentities($metadata['chapter']));
    }
    if (!empty($metadata['isbn'])) {
        printf('<meta name="citation_isbn" content="%1$s">' . "\n\r", htmlentities($metadata['isbn']));
    }
    if (!empty($metadata['subject'])) {
        $full_subject_list = $metadata['subject'];
        foreach ($full_subject_list as $subject) {
            printf('<meta name="citation_keywords" content="%1$s">' . "\n\r", htmlentities($subject));
        }
    }
    printf('<meta name="citation_abstract_html_url" content="%1$s/deposits/item/%2$s/">' . "\n\r", bp_get_root_domain(), htmlentities($metadata['pid']));
    $post_metadata = json_decode(get_post_meta($metadata['record_identifier'], '_deposit_file_metadata', true), true);
    printf('<meta name="citation_pdf_url" content="%1$s/deposits/download/%2$s/%3$s/%4$s/">' . "\n\r", bp_get_root_domain(), htmlentities($post_metadata['files'][0]['pid']), htmlentities($post_metadata['files'][0]['datastream_id']), htmlentities($post_metadata['files'][0]['filename']));
}