');
// SELECT field
TP_HTML::line('
');
$post_type = get_tp_option('rel_page_publications');
get_tp_wp_pages("menu_order", "ASC", $pub_data["rel_page"], $post_type, 0, 0);
TP_HTML::line(' ');
// New related content link
TP_HTML::line('
');
$value = ( get_tp_option('rel_content_auto') == '1' ) ? '1' : '0';
TP_Admin::get_checkbox('create_rel_content', esc_html__('Create related content','teachpress'), $value, false, true);
TP_HTML::line('
');
TP_HTML::div_close();
TP_HTML::div_close('inside');
TP_HTML::div_close('postbox');
}
/**
* Gets the main box
* @param int $pub_id The ID of the publication
* @param array $pub_data An associative array with publication data
* @since 5.0.0
*/
public static function get_main_box ($pub_id, $pub_data) {
// teachPress Publication Types
global $tp_publication_types;
$publication_types = $tp_publication_types->get();
if ( isset( $publication_types[ $pub_data['type'] ]['default_fields'] ) ) {
$default_fields = $publication_types[ $pub_data['type'] ]['default_fields'];
}
else {
$default_fields = $publication_types['article']['default_fields'];
}
TP_HTML::div_open('postbox');
TP_HTML::line('
');
TP_HTML::div_open('inside');
$tabindex = 8;
// booktitle
TP_Admin::get_form_field(
array(
'name' => 'booktitle',
'title' => esc_html__('The title of a book','teachpress'),
'label' => esc_html__('Booktitle','teachpress'),
'type' => 'textarea',
'value' => $pub_data['booktitle'],
'tabindex' => $tabindex,
'display' => ( in_array('booktitle', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%; height: 58px;'),
true );
// issuetitle
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'issuetitle',
'title' => esc_html__('The subtitle of a periodical publication','teachpress'),
'label' => esc_html__('Issuetitle','teachpress'),
'type' => 'textarea',
'value' => $pub_data['issuetitle'],
'tabindex' => $tabindex,
'display' => ( in_array('issuetitle', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%; height: 58px;'),
true );
// journal
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'journal',
'title' => esc_html__('The title of a journal','teachpress'),
'label' => esc_html__('Journal','teachpress'),
'type' => 'input',
'value' => $pub_data['journal'],
'tabindex' => $tabindex,
'display' => ( in_array('journal', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;'),
true );
// volume
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'volume',
'title' => esc_html__('The volume of a journal or book','teachpress'),
'label' => esc_html__('Volume','teachpress'),
'type' => 'input',
'value' => $pub_data['volume'],
'tabindex' => $tabindex,
'display' => ( in_array('volume', $default_fields) ) ? 'block' : 'none'),
true );
// volume
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'issue',
'title' => esc_html__('The issue of a journal','teachpress'),
'label' => esc_html__('Issue','teachpress'),
'type' => 'input',
'value' => $pub_data['issue'],
'tabindex' => $tabindex,
'display' => ( in_array('issue', $default_fields) ) ? 'block' : 'none'),
true );
// number
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'number',
'title' => esc_html__('The number of a book, journal or work in a series','teachpress'),
'label' => esc_html__('Number','teachpress'),
'type' => 'input',
'value' => $pub_data['number'],
'tabindex' => $tabindex,
'display' => ( in_array('number', $default_fields) ) ? 'block' : 'none'),
true );
// pages
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'pages',
'title' => esc_html__('The page you are referring to.','teachpress'),
'label' => esc_html__('Pages','teachpress'),
'type' => 'input',
'value' => $pub_data['pages'],
'tabindex' => $tabindex,
'display' => ( in_array('pages', $default_fields) ) ? 'block' : 'none'),
true );
// publisher
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'publisher',
'title' => esc_html__('The names of publisher','teachpress'),
'label' => esc_html__('Publisher','teachpress'),
'type' => 'input',
'value' => $pub_data['publisher'],
'tabindex' => $tabindex,
'display' => ( in_array('publisher', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;'),
true );
// address
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'address',
'title' => esc_html__('The address of the publisher or the place of confernece','teachpress'),
'label' => esc_html__('Address','teachpress'),
'type' => 'input',
'value' => $pub_data['address'],
'tabindex' => $tabindex,
'display' => ( in_array('address', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;'),
true);
// edition
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'edition',
'title' => esc_html__('The edition of a book','teachpress'),
'label' => esc_html__('Edition','teachpress'),
'type' => 'input',
'value' => $pub_data['edition'],
'tabindex' => $tabindex,
'display' => ( in_array('edition', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;'),
true);
// chapter
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'chapter',
'title' => esc_html__('The chapter or the section number','teachpress'),
'label' => esc_html__('Chapter','teachpress'),
'type' => 'input',
'value' => $pub_data['chapter'],
'tabindex' => $tabindex,
'display' => ( in_array('chapter', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;'),
true);
// institution
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'institution',
'title' => esc_html__('The name of a sponsoring institution','teachpress'),
'label' => esc_html__('Institution','teachpress'),
'type' => 'input',
'value' => $pub_data['institution'],
'tabindex' => $tabindex,
'display' => ( in_array('institution', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;'),
true);
// organization
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'organization',
'title' => esc_html__('The names of a sponsoring organization','teachpress'),
'label' => esc_html__('Organization','teachpress'),
'type' => 'input',
'value' => $pub_data['organization'],
'tabindex' => $tabindex,
'display' => ( in_array('organization', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;'),
true );
// school
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'school',
'title' => esc_html__('The names of the academic instituion where a thesis was written','teachpress'),
'label' => esc_html__('School','teachpress'),
'type' => 'input',
'value' => $pub_data['school'],
'tabindex' => $tabindex,
'display' => ( in_array('school', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;'),
true );
// series
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'series',
'title' => esc_html__('The name of a series','teachpress'),
'label' => esc_html__('Series','teachpress'),
'type' => 'input',
'value' => $pub_data['series'],
'tabindex' => $tabindex,
'display' => ( in_array('series', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;' ),
true );
// crossref
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'crossref',
'title' => esc_html__('The BibTeX key this work is referring to','teachpress'),
'label' => esc_html__('Crossref','teachpress'),
'type' => 'input',
'value' => $pub_data['crossref'],
'tabindex' => $tabindex,
'display' => ( in_array('crossref', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;' ),
true );
// abstract
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'abstract',
'title' => esc_html__('A short summary of the publication','teachpress'),
'label' => esc_html__('Abstract','teachpress'),
'type' => 'textarea',
'value' => $pub_data['abstract'],
'tabindex' => $tabindex,
'display' => 'block',
'style' => 'width:95%; height: 150px;'),
true );
// howpublished
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'howpublished',
'title' => esc_html__('An unusual method for publishing','teachpress'),
'label' => esc_html__('Howpublished','teachpress'),
'type' => 'input',
'value' => $pub_data['howpublished'],
'tabindex' => $tabindex,
'display' => ( in_array('howpublished', $default_fields) ) ? 'block' : 'none',
'style' => 'width:95%;'),
true );
// key
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'key',
'title' => esc_html__('If there is no author or editor given, so this field is used for the sorting.','teachpress'),
'label' => esc_html__('Key','teachpress'),
'type' => 'input',
'value' => $pub_data['key'],
'tabindex' => $tabindex,
'display' => 'block',
'style' => ''),
true );
// techtype
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'techtype',
'title' => esc_html__('The type of a technical report, thesis, incollection or inbook.','teachpress'),
'label' => esc_html__('Type'),
'type' => 'input',
'value' => $pub_data['techtype'],
'tabindex' => $tabindex,
'display' => ( in_array('techtype', $default_fields) ) ? 'block' : 'none',
'style' => ''),
true );
// isbn
$checked_1 = ( $pub_data["is_isbn"] == '1' || $pub_id === 0 ) ? 'checked="checked"' : '';
$checked_2 = ($pub_data["is_isbn"] == '0') ? 'checked="checked"' : '';
TP_HTML::div_open('div_isbn');
TP_HTML::line('
' . esc_html__('ISBN/ISSN','teachpress') . '
');
$tabindex++;
TP_HTML::line('
');
TP_HTML::line('
');
$tabindex++;
TP_HTML::line(' ' . esc_html__('ISBN','teachpress') . ' ');
$tabindex++;
TP_HTML::line(' ' . esc_html__('ISSN','teachpress') . ' ');
TP_HTML::line(' ');
TP_HTML::div_close('div_isbn');
// doi
$tabindex++;
TP_Admin::get_form_field(
array(
'name' => 'doi',
'title' => esc_html__('DOI number','teachpress'),
'label' => esc_html__('DOI number','teachpress'),
'type' => 'input',
'value' => $pub_data['doi'],
'tabindex' => $tabindex,
'display' => 'block',
'style' => 'width:95%;'),
true );
// urldate
$display = ($pub_data["type"] === 'online' || $pub_data["type"] === 'periodical') ? 'style="display:block;"' : 'style="display:none;"';
$title = esc_html__('The date you have visited the online resource','teachpress');
$placeholder = esc_html__('YYYY-MM-DD','teachpress');
$value = ($pub_id != 0) ? $pub_data["date"] : $placeholder;
TP_HTML::line('
');
TP_HTML::line('
' . esc_html__('Urldate','teachpress') . '
');
$tabindex++;
TP_HTML::line('
');
TP_HTML::div_close('div_urldate');
// url
TP_HTML::div_open('div_url');
TP_HTML::line('
' . esc_html__('URL/Files', 'teachpress') . ' | ');
TP_HTML::line(' ' . esc_html__('Add/Upload','teachpress') . '
');
TP_HTML::line('
');
$tabindex++;
TP_HTML::line('
');
TP_HTML::div_close('div_url');
TP_HTML::div_close('inside');
TP_HTML::div_close('postbox');
}
/**
* Gets the tags box
* @param int $pub_id The ID of the publication
* @since 5.0.0
*/
public static function get_tags_box ($pub_id) {
TP_HTML::div_open('postbox');
TP_HTML::line('
' . esc_html__('Tags') . ' ');
TP_HTML::div_open('inside');
if ($pub_id != 0) {
TP_Publication_Page::get_current_tags ( $pub_id );
}
// New tags field
TP_HTML::line('
' . esc_html__('New','teachpress') . '
');
TP_HTML::line('
');
$tags = TP_Tags::get_tags( array('group_by' => true, 'output_type' => ARRAY_A) );
foreach ($tags as $row) {
TP_HTML::line('' . $row['name'] . ' ');
}
TP_HTML::line(' ');
TP_HTML::div_close('inside');
TP_HTML::div_close('postbox');
}
/**
* Convert $tags array to a comma separate string
* @param array $tags
* @return string
*/
public static function prepare_tags($tags) {
$end = '';
foreach ( $tags as $element ) {
$end = ( $end === '' ) ? $element : $end . ',' . $element;
}
return $end;
}
/**
* Checks the nonce field of the form. If the check fails wp_die() will be executed
* @since 9.0.5
*/
public static function check_nonce_field () {
if ( ! isset( $_POST['tp_nonce'] )
|| ! wp_verify_nonce( $_POST['tp_nonce'], 'verify_teachpress_pub_edit' )
) {
wp_die('teachPress error: This request could not be verified!');
exit;
}
}
/**
* Gets the javascripts for this page
* @since 5.0.0
*/
public static function print_scripts () {
global $tp_publication_types;
$publication_types = $tp_publication_types->get();
?>