' . chr(13) . chr(10); echo '' . chr(13) . chr(10); echo ' ' . get_bloginfo('name') . ' ' . get_bloginfo('url') . ' ' . get_bloginfo('description') . ' ' . get_bloginfo('language') . ' daily 1 ' . get_bloginfo('name') . ' ' . date('r') . ' ' . get_bloginfo('name') . '' . chr(13) . chr(10); $row = TP_Publications::get_publications( array('user' => $id, 'tag' => $tag, 'limit' => '0,30', 'output_type' => ARRAY_A) ); foreach ($row as $row) { // prepare url if ( $row['doi'] != '') { $item_link = "https://dx.doi.org/" . $row['doi']; } elseif ( $row['url'] != '' ) { $new = explode(', ', $row['url']); $item_link = $new[0]; } elseif ($row['rel_page'] != '') { $item_link = get_bloginfo('url') . '/?page=' . $row['rel_page']; } else { $item_link = get_bloginfo('url'); } // prepare author name if ( $row['type'] === 'collection' || ( $row['author'] === '' && $row['editor'] !== '' ) ) { $all_authors = str_replace(' and ', ', ', TP_HTML::convert_special_chars( $row['editor'] ) ) . ' (' . __('Ed.','teachpress') . ')'; } else { $all_authors = str_replace(' and ', ', ', TP_HTML::convert_special_chars( $row['author'] ) ); } $row['title'] = TP_HTML::convert_special_chars($row['title']); $item_link = str_replace( array("\r\n", "\r", "\n"), ',', TP_HTML::convert_special_chars($item_link) ); $item_link1 = explode(',', $item_link); $settings = array( 'editor_name' => 'simple', 'editor_separator' => ',', 'style' => 'simple', 'meta_label_in' => __('In','teachpress') . ': ', 'use_span' => false ); echo ' <![CDATA[' . TP_HTML::prepare_title($row['title'], 'replace') . ']]> ' . stripslashes($all_authors) . ' ' . get_bloginfo('url') . '?publication=' . $row['pub_id'] . ' ' . date('r', strtotime($row['date'])) . ' ' . chr(13) . chr(10); } echo '' . chr(13) . chr(10); echo ''; } /** * Generates the BibTeX publication feed * @since 6.0.0 */ function tp_pub_bibtex_feed_func () { $id = isset( $_GET['id'] ) ? intval($_GET['id']) : 0; $tag = isset( $_GET['tag'] ) ? intval($_GET['tag']) : 0; $use_bibtool = isset( $_GET['use_bibtool'] ) ? true : false; header('Content-Type: text/plain; charset=utf-8;'); $convert_bibtex = ( get_tp_option('convert_bibtex') == '1' ) ? true : false; $row = TP_Publications::get_publications(array('user' => $id, 'tag' => $tag, 'output_type' => ARRAY_A)); $result = ''; foreach ($row as $row) { $tags = TP_Tags::get_tags(array('pub_id' => $row['pub_id'], 'output_type' => ARRAY_A)); // if you want to use bibtool if ( $use_bibtool === true ) { $result .= TP_Bibtex::get_single_publication_bibtex($row, $tags, $convert_bibtex); } // the general way else { echo TP_Bibtex::get_single_publication_bibtex($row, $tags, $convert_bibtex); } } if ( $use_bibtool === true ) { $trimmed = trim(preg_replace('/\s+/', ' ', $result)); passthru('echo ' . escapeshellarg($trimmed) . ' | bibtool -f "%-2n(author)_%-3T(title)_%2d(year)" -q '); } } /** * Generates the export stream * @since 6.0.0 */ function tp_export_feed_func() { $key = isset ( $_GET['key'] ) ? $_GET['key'] : ''; // Export single publication if ( $key != '' ) { header('Content-Type: text/plain; charset=utf-8' ); $filename = preg_replace('/[^a-zA-Z0-9]/', '_', $key); header("Content-Disposition: attachment; filename=" . $filename . ".bib"); TP_Export::get_publication_by_key($key); } elseif ( is_user_logged_in() && current_user_can('use_teachpress') ) { $type = isset ( $_GET['type'] ) ? htmlspecialchars($_GET['type']) : ''; $course_id = isset ( $_GET['course_id'] ) ? intval($_GET['course_id']) : 0; $user_id = isset ( $_GET['tp_user'] ) ? intval($_GET['tp_user']) : 0; $format = isset ( $_GET['tp_format'] ) ? htmlspecialchars($_GET['tp_format']) : ''; $sel = isset ( $_GET['tp_sel'] ) ? htmlspecialchars($_GET['tp_sel']) : ''; $filename = 'teachpress_course_' . $course_id . '_' . date('dmY'); // Export courses if ( $type === "xls" && $course_id != 0 ) { header("Content-type: application/vnd-ms-excel; charset=utf-8"); header("Content-Disposition: attachment; filename=" . $filename . ".xls"); TP_Export::get_course_xls($course_id); } if ( $type === 'csv' && $course_id != 0 ) { header('Content-Type: text/x-csv'); header("Content-Disposition: attachment; filename=" . $filename . ".csv"); TP_Export::get_course_csv($course_id); } // Export publication lists if ( $type === 'pub' ) { $filename = 'teachpress_pub_' . date('dmY'); $encoding = ( get_tp_option('convert_bibtex') == '1' ) ? 'Cp1252' : 'UTF-8'; if ( $format === 'bib' ) { header('Content-Type: text/plain; charset=utf-8' ); header("Content-Disposition: attachment; filename=" . $filename . ".bib"); echo '% This file was created with teachPress ' . get_tp_version() . chr(13) . chr(10); echo '% Encoding: ' . $encoding . chr(13) . chr(10) . chr(13) . chr(10); if ( $sel == '' ) { TP_Export::get_publications($user_id); } else { TP_Export::get_selected_publications($sel); } } if ( $format === 'txt' ) { header('Content-Type: text/plain; charset=utf-8' ); header("Content-Disposition: attachment; filename=" . $filename . ".txt"); TP_Export::get_publications($user_id,'bibtex'); } if ( $format === 'rtf' ) { header('Content-Type: text/plain; charset=utf-8' ); header("Content-Disposition: attachment; filename=" . $filename . ".rtf"); TP_Export::get_publications($user_id,'rtf'); } if ( $format === 'rss' ) { if ( $user_id == 0 ) { header("Location: " . home_url() . '?feed=tp_pub_rss'); exit; } else { header("Location: " . home_url() . "?feed=tp_pub_rss&id=$user_id"); exit; } } } else { // return a plain text with nothing header('Content-Type: text/plain; charset=utf-8' ); return; } } else { // return a plain text with nothing header('Content-Type: text/plain; charset=utf-8' ); return; } }