add_help_tab( array( 'id' => 'tp_add_publication_help', 'title' => esc_html__('Create a new publication','teachpress'), 'content' => '

' . esc_html__('Required fields','teachpress') . '

' . esc_html__('The required fields for a new publication:','teachpress') . ' ' . esc_html__('title, author, bibtex key, tags','teachpress') . '

' . esc_html__('URL/Files','teachpress') . '

' . esc_html__('You can add one URL or file per line. Insert the name of the URL/file behind the address and separate it by a comma and a space. Example:', 'teachpress') . '
http://mywebsite.com/docs/readme.pdf, Basic Instructions

' ) ); } /** * New publication / edit publication * from show_publications.php (GET): * @param int $pub_id publication ID * @since 5.0.0 */ function tp_add_publication_page() { // WordPress current unser info $current_user = wp_get_current_user(); $user = $current_user->ID; $fields = get_tp_options('teachpress_pub','`setting_id` ASC', ARRAY_A); // form variables from add_publication.php $data = tp_get_default_structure(); $data['bibtex'] = isset( $_POST['bibtex'] ) ? htmlspecialchars($_POST['bibtex']) : ''; $data['type'] = isset( $_POST['type'] ) ? htmlspecialchars($_POST['type']) : ''; $data['award'] = isset( $_POST['award'] ) ? htmlspecialchars($_POST['award']) : ''; $data['title'] = isset( $_POST['tp_post_title'] ) ? htmlspecialchars($_POST['tp_post_title']) : ''; $data['author'] = isset( $_POST['author'] ) ? htmlspecialchars($_POST['author']) : ''; $data['editor'] = isset( $_POST['editor'] ) ? htmlspecialchars($_POST['editor']) : ''; $data['isbn'] = isset( $_POST['isbn'] ) ? htmlspecialchars($_POST['isbn']) : ''; $data['url'] = isset( $_POST['url'] ) ? htmlspecialchars($_POST['url']) : ''; $data['date'] = isset( $_POST['pubdate'] ) ? htmlspecialchars($_POST['pubdate']) : ''; $data['status'] = isset( $_POST['forthcoming'] ) ? 'forthcoming' : 'published'; $data['urldate'] = isset( $_POST['urldate'] ) ? htmlspecialchars($_POST['urldate']) : ''; $data['booktitle'] = isset( $_POST['booktitle'] ) ? htmlspecialchars($_POST['booktitle']) : ''; $data['issuetitle'] = isset( $_POST['issuetitle'] ) ? htmlspecialchars($_POST['issuetitle']) : ''; $data['journal'] = isset( $_POST['journal'] ) ? htmlspecialchars($_POST['journal']) : ''; $data['issue'] = isset( $_POST['issue'] ) ? htmlspecialchars($_POST['issue']) : ''; $data['volume'] = isset( $_POST['volume'] ) ? htmlspecialchars($_POST['volume']) : ''; $data['number'] = isset( $_POST['number'] ) ? htmlspecialchars($_POST['number']) : ''; $data['pages'] = isset( $_POST['pages'] ) ? htmlspecialchars($_POST['pages']) : ''; $data['publisher'] = isset( $_POST['publisher'] ) ? htmlspecialchars($_POST['publisher']) : ''; $data['address'] = isset( $_POST['address'] ) ? htmlspecialchars($_POST['address']) : ''; $data['edition'] = isset( $_POST['edition'] ) ? htmlspecialchars($_POST['edition']) : ''; $data['chapter'] = isset( $_POST['chapter'] ) ? htmlspecialchars($_POST['chapter']) : ''; $data['institution'] = isset( $_POST['institution'] ) ? htmlspecialchars($_POST['institution']) : ''; $data['organization'] = isset( $_POST['organization'] ) ? htmlspecialchars($_POST['organization']) : ''; $data['school'] = isset( $_POST['school'] ) ? htmlspecialchars($_POST['school']) : ''; $data['series'] = isset( $_POST['series'] ) ? htmlspecialchars($_POST['series']) : ''; $data['crossref'] = isset( $_POST['crossref'] ) ? htmlspecialchars($_POST['crossref']) : ''; $data['abstract'] = isset( $_POST['abstract'] ) ? htmlspecialchars($_POST['abstract']) : ''; $data['howpublished'] = isset( $_POST['howpublished'] ) ? htmlspecialchars($_POST['howpublished']) : ''; $data['key'] = isset( $_POST['key'] ) ? htmlspecialchars($_POST['key']) : ''; $data['techtype'] = isset( $_POST['techtype'] ) ? htmlspecialchars($_POST['techtype']) : ''; $data['comment'] = isset( $_POST['comment'] ) ? htmlspecialchars($_POST['comment']) : ''; $data['note'] = isset( $_POST['note'] ) ? htmlspecialchars($_POST['note']) : ''; $data['image_url'] = isset( $_POST['image_url'] ) ? htmlspecialchars($_POST['image_url']) : ''; $data['image_target'] = isset( $_POST['image_target'] ) ? htmlspecialchars($_POST['image_target']) : ''; $data['image_ext'] = isset( $_POST['image_ext'] ) ? htmlspecialchars($_POST['image_ext']) : ''; $data['doi'] = isset( $_POST['doi'] ) ? htmlspecialchars($_POST['doi']) : ''; $data['rel_page'] = isset( $_POST['rel_page'] ) ? intval($_POST['rel_page']) : ''; $data['is_isbn'] = isset( $_POST['is_isbn'] ) ? intval($_POST['is_isbn']) : ''; $tags = isset( $_POST['tags'] ) ? TP_Publication_Page::prepare_tags($_POST['tags']) : ''; $delbox = isset( $_POST['delbox'] ) ? $_POST['delbox'] : ''; $new_bookmarks = isset( $_POST['new_bookmarks'] ) ? $_POST['new_bookmarks'] : ''; $del_bookmarks = isset( $_POST['del_bookmarks'] ) ? $_POST['del_bookmarks'] : ''; // from show_publications.php $pub_id = isset( $_REQUEST['pub_id'] ) ? intval($_REQUEST['pub_id']) : 0; echo '
'; // headline if ( $pub_id === 0 ) { echo '

' . esc_html__('Add a new publication','teachpress') . '

'; } else { echo '

' . esc_html__('Edit publication','teachpress') . ' ' . esc_html__('Create','teachpress') . '

'; } echo '
'; wp_nonce_field( 'verify_teachpress_pub_edit', 'tp_nonce', true, true ); // create related content (post/page/...) if ( isset($_POST['create_rel_content']) ) { TP_Publication_Page::check_nonce_field(); $data['rel_page'] = tp_add_publication_as_post( $data['title'], $data['bibtex'], $data['date'], get_tp_option('rel_page_publications'), $tags, array(get_tp_option('rel_content_category')) ); } // create publication and related page if ( isset($_POST['create_pub']) ) { TP_Publication_Page::check_nonce_field(); $pub_id = TP_Publications::add_publication($data, $tags, $new_bookmarks); TP_DB_Helpers::prepare_meta_data($pub_id, $fields, $_POST, 'publications'); $message = esc_html__('Publication added','teachpress') . ' ' . esc_html__('Add new','teachpress') . ''; get_tp_message($message); } // save publication if ( isset($_POST['speichern']) ) { TP_Publication_Page::check_nonce_field(); TP_Publications::delete_pub_meta($pub_id); TP_Publications::change_publication($pub_id, $data, $tags, $delbox, $new_bookmarks, $del_bookmarks); TP_DB_Helpers::prepare_meta_data($pub_id, $fields, $_POST, 'publications'); get_tp_message( esc_html__('Saved') ); } // Default values if ( $pub_id != 0 ) { $pub_data = TP_Publications::get_publication($pub_id, ARRAY_A); $pub_meta = TP_Publications::get_pub_meta($pub_id); } else { $pub_data = tp_get_default_structure(); $pub_meta = array ( array('meta_key' => '', 'meta_value' => '') ); } // Check format of author/editor field if ( $pub_id != 0 && !isset($_POST['create_pub']) ) { $check = ( strpos($pub_data['author'], ',') !== false || strpos($pub_data['editor'], ',') !== false) ? true : false; if ( $check === true ) { get_tp_message( esc_html__('Please check the format of author/editor information and correct it to the following format: firstname1 lastname1 and firstname2 lastname 2. Example: Adam Smith and John M. Keynes','teachpress') , 'orange'); } } // input fields echo ''; if ( $pub_id != 0 ) { echo ''; } echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; TP_Publication_Page::get_general_box ($pub_id, $pub_data); TP_Publication_Page::get_main_box ($pub_id, $pub_data); TP_Publication_Page::get_comments_box ($pub_data); if ( count($fields) !== 0 ) { TP_Admin::display_meta_data($fields, $pub_meta); } echo '
'; echo '
'; echo '
'; TP_HTML::div_open('tp_postcontent_right'); TP_Publication_Page::get_publication_box($pub_id); TP_Publication_Page::get_bookmarks_box ($pub_id, $user); TP_Publication_Page::get_tags_box ($pub_id); TP_Publication_Page::get_image_box ($pub_data); TP_Publication_Page::get_rel_page_box ($pub_data); TP_HTML::div_close('tp_postcontent_right'); echo ''; TP_Publication_Page::print_scripts(); echo '
'; } /** * This class contains all funcitons for the add_publication_page * @package teachpress\admin\publications * @since 5.0.0 */ class TP_Publication_Page { public static function get_publication_box($pub_id) { TP_HTML::div_open('postbox'); TP_HTML::line('

' . esc_html__('Publications','teachpress') . '

'); // Add, Save, Reset buttons TP_HTML::line('
'); TP_HTML::line('
'); if ( $pub_id === 0 ) { TP_HTML::line(''); TP_HTML::line(''); } else { TP_HTML::line(''); } TP_HTML::line('
'); TP_HTML::line('
'); TP_HTML::div_close('postbox'); } /** * Gets the bookmarks box * @param int $pub_id The ID of the publication * @param int $user The ID of the current user * @since 5.0.0 */ public static function get_bookmarks_box ($pub_id, $user) { TP_HTML::div_open('postbox'); TP_HTML::line('

' . esc_html__('Bookmarks','teachpress') . '

'); TP_HTML::div_open('inside'); // Current Bookmarks self::get_current_bookmarks($pub_id, $user); // Add Bookmarks TP_HTML::line('

' . esc_html__('New','teachpress') . '

'); TP_HTML::line(''); TP_HTML::div_close('inside'); TP_HTML::div_close('postbox'); } /** * Gets the comment box * @param array $pub_data An associative array with publication data * @since 5.0.0 */ public static function get_comments_box ($pub_data) { TP_HTML::div_open('postbox'); TP_HTML::line('

' . esc_html__('Comments','teachpress') . '

'); TP_HTML::div_open('inside'); // comment TP_Admin::get_form_field( array( 'name' => 'comment', 'title' => esc_html__('A not vissible private comment','teachpress'), 'label' => esc_html__('Private comment','teachpress'), 'type' => 'textarea', 'value' => $pub_data['comment'], 'tabindex' => 31, 'display' => 'block', 'style' => 'width:95%; height: 75px;'), true ); // note TP_Admin::get_form_field( array( 'name' => 'note', 'title' => esc_html__('Additional information','teachpress'), 'label' => esc_html__('Note','teachpress'), 'type' => 'textarea', 'value' => $pub_data['note'], 'tabindex' => 32, 'display' => 'block', 'style' => 'width:95%; height: 75px;'), true ); TP_HTML::div_close('inside'); TP_HTML::div_close('postbox'); } /** * Gets the current tags of a publication * @param int $pub_id The ID of the publication * @since 5.0.0 * @access private */ private static function get_current_tags ( $pub_id ) { $current_tags = TP_Tags::get_tags( array('pub_id' => $pub_id) ); if ( count ($current_tags) === 0 ) { return; } TP_HTML::line('

' . esc_html__('Current','teachpress') . '

'); foreach ($current_tags as $row){ $id = $row->con_id; $label = stripslashes($row->name); $onclick = "teachpress_change_label_color('delbox_" . $id . "', 'delbox_label_" . $id . "')"; TP_HTML::line('
'); } } /** * Prints the current bookmarks list * @param int $pub_id * @param int $current_user_id * @since 8.1.0 * @access private */ private static function get_current_bookmarks ( $pub_id, $current_user_id ) { if ( $pub_id === 0 ) { return; } $bookmarks = TP_Bookmarks::get_bookmarks( array( 'pub_id' => $pub_id, 'output_type' => ARRAY_A ) ); TP_HTML::line('

' . esc_html__('Current','teachpress') . '

'); foreach ( $bookmarks as $row ) { $user_info = get_userdata($row['user']); // if there is no data if ($user_info === false) { continue; } // Print use name with checkbox $id = $row['bookmark_id']; $user_id = $user_info->ID; $name = $user_info->display_name; $icon = ( $user_id === $current_user_id ) ? ' ' : ''; $onclick = "teachpress_change_label_color('bookmark_" . $id . "', 'bookmark_label_" . $id . "')"; TP_HTML::line('
'); } } /** * Gets the general 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_general_box ($pub_id, $pub_data){ TP_HTML::div_open('postbox'); TP_HTML::line('

' . esc_html__('General information','teachpress') . '

'); TP_HTML::div_open('inside'); TP_HTML::line(''); TP_HTML::line(''); $tabindex = 1; // Publication type TP_HTML::line(''); // BibTex key TP_HTML::line(''); // Award of publication TP_HTML::line(''); TP_HTML::line(''); TP_HTML::line('
'); $title = esc_html__('The type of publication','teachpress'); TP_HTML::line('

'); $tabindex++; TP_HTML::line(''); TP_HTML::line('
'); $title = esc_html__('A simple unique key without spaces','teachpress'); TP_HTML::line('

'); $tabindex++; TP_HTML::line(''); TP_HTML::line(''); TP_HTML::line('
'); $title = esc_html__('Award','teachpress'); TP_HTML::line('

'); $tabindex++; TP_HTML::line(''); TP_HTML::line('
'); // author $tabindex++; TP_Admin::get_form_field( array( 'name' => 'author', 'title' => esc_html__('The names of the authors, separate by `and`. Example: Mark Twain and Albert Einstein','teachpress'), 'label' => esc_html__('Author(s)','teachpress'), 'type' => 'textarea', 'value' => $pub_data['author'], 'tabindex' => $tabindex, 'display' => 'block', 'style' => 'width:95%; height: 65px;'), true ); // editor $tabindex++; TP_Admin::get_form_field( array( 'name' => 'editor', 'title' => esc_html__('The names of the editors, separate by `and`. Example: Mark Twain and Albert Einstein','teachpress'), 'label' => esc_html__('Editor(s)','teachpress'), 'type' => 'textarea', 'value' => $pub_data['editor'], 'tabindex' => $tabindex, 'display' => 'block', 'style' => 'width:95%; height: 65px;'), true ); // pubdate $title = esc_html__('Date of publishing','teachpress'); $placeholder = esc_html__('YYYY-MM-DD','teachpress'); $value = ($pub_id != 0) ? $pub_data["date"] : $placeholder; $checked = ( $pub_data['status'] === 'forthcoming' ) ? 'checked="checked"' : ''; TP_HTML::line('

'); $tabindex++; TP_HTML::line(''); TP_HTML::line(''); TP_HTML::line(''); TP_HTML::div_close('inside'); TP_HTML::div_close('postbox'); } /** * Gets the image box * @param array $pub_data An associative array with publication data * @since 5.0.0 */ public static function get_image_box ($pub_data) { TP_HTML::div_open('postbox'); TP_HTML::line('

' . esc_html__('Image','teachpress') . '

'); TP_HTML::div_open('inside'); // Image URL if ( $pub_data["image_url"] != '' ) { TP_HTML::line('

' . $pub_data[

'); } $title = esc_html__('With the image field you can add an image to a publication. You can display images in all publication lists','teachpress'); TP_HTML::line('

'); TP_HTML::line(''); TP_HTML::line(''); // Image Link Target TP_HTML::line( '

'); TP_HTML::line( ''); // External Image Link TP_Admin::get_form_field( array( 'name' => 'image_ext', 'title' => esc_html__('If you choice an external link target for the image, then you can define the URL of this target here.','teachpress'), 'label' => esc_html__('External Image Link','teachpress'), 'type' => 'input', 'value' => $pub_data['image_ext'], 'tabindex' => 36, 'display' => 'block', 'style' => 'width:90%;'), true ); TP_HTML::div_close('inside'); TP_HTML::div_close('postbox'); } /** * Gets the related page box * @param array $pub_data An associative array with publication data * @since 7.1.0 */ public static function get_rel_page_box ($pub_data) { TP_HTML::div_open('postbox'); TP_HTML::line('

' . esc_html__('Related content','teachpress') . '

'); TP_HTML::div_open('inside'); TP_HTML::line('

'); TP_HTML::line('
'); // SELECT field 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('

' . esc_html__('Detailed information','teachpress') . ' | ' . esc_html__('Show all fields','teachpress') . '

'); 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('

'); $tabindex++; TP_HTML::line(''); TP_HTML::line(''); $tabindex++; TP_HTML::line(''); $tabindex++; TP_HTML::line(''); 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('

'); $tabindex++; TP_HTML::line(''); TP_HTML::div_close('div_urldate'); // url TP_HTML::div_open('div_url'); TP_HTML::line('

| '); 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('

'); 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(); ?>