Skip to content

Commit

Permalink
Update bibtexParse integration
Browse files Browse the repository at this point in the history
Part of #147
  • Loading branch information
winkm89 committed Feb 15, 2021
1 parent 9f340d2 commit 5993fed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
7 changes: 2 additions & 5 deletions core/class-bibtex-import.php
Expand Up @@ -30,9 +30,8 @@ public static function init ($input, $settings, $test = false) {
$import_id = ( $test === false ) ? tp_publication_imports::add_import() : 0;

// Init bibtexParse
global $PARSEENTRIES;
$input = tp_bibtex::convert_bibtex_to_utf8($input);
$parse = NEW PARSEENTRIES();
$parse = NEW BIBTEXPARSE();
$parse->expandMacro = TRUE;
$array = array('RMP' => 'Rev., Mod. Phys.');
$parse->loadStringMacro($array);
Expand Down Expand Up @@ -258,16 +257,14 @@ public static function init ($entry, $key, $mode) {

/**
* This function can detect the name format automatically
* @global class $PARSECREATORS
* @param array $entry
* @param string $key
* @return string
* @since 6.0.0
* @access private
*/
private static function dynamic_mode ($entry, $key) {
global $PARSECREATORS;
$creator = new PARSECREATORS();
$creator = new BIBTEXCREATORPARSE();
$creatorArray = $creator->parse( $entry[$key] );
// print_r($creatorArray);
$string = '';
Expand Down
9 changes: 3 additions & 6 deletions core/class-bibtex.php
Expand Up @@ -396,14 +396,12 @@ public static function explode_url ($url_string) {

/**
* The function splits a author/editor name and returns the lastname or NULL if there is no name was found
* @global $PARSECREATORS
* @param string $input A name of an author or editor
* @return string
* @since 5.0.0
*/
public static function get_lastname ($input) {
global $PARSECREATORS;
$creator = new PARSECREATORS();
$creator = new BIBTEXCREATORPARSE();
$creatorArray = $creator->parse($input);
if ( isset( $creatorArray[0][2] ) ) {
return trim($creatorArray[0][2]);
Expand Down Expand Up @@ -446,11 +444,10 @@ public static function parse_author ($input, $separator, $mode = '') {
* @return string
* @since 5.0.0
* @access public
* @uses PARSECREATORS() This class is a part of bibtexParse
* @uses BIBTEXCREATORPARSE() This class is a part of bibtexParse
*/
public static function parse_author_default ($input, $separator = ';', $mode = 'initials') {
global $PARSECREATORS;
$creator = new PARSECREATORS();
$creator = new BIBTEXCREATORPARSE();
$creatorArray = $creator->parse($input);
$all_authors = '';
$max = count($creatorArray);
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Expand Up @@ -70,7 +70,7 @@ The plugin saves course documents in your WordPress upload directory under /teac

== Credits ==

Copyright 2008-2020 by Michael Winkler
Copyright 2008-2021 by Michael Winkler

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -87,7 +87,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

= Licence information of external resources =
* bibtexParse by Mark Grimshaw & Guillaume Gardey (Licence: GPL)
* Wikindx bibtex import classes (bibtexParse) by Mark Grimshaw-Aagaard & Stéphane Aulery (Licence: ISC License)
* Font Awesome Free 5.10.1 by fontawesome (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Academicons 1.8.6 by James Walsh (Font: SIL OFL 1.1, CSS: MIT License)
* jquery-ui-icons.png by The jQuery Foundation (License: MIT)
Expand Down Expand Up @@ -123,6 +123,9 @@ Please note the [teachPress 6.0 Upgrade Information](https://mtrv.wordpress.com/

== Changelog ==

= x.x.x =
* Changed: Update bibtexParse to v2.5

= 7.1.3 (04.11.2020) =
* Bugfix: Adding image URL no longer working with WordPress 5.5

Expand Down
8 changes: 4 additions & 4 deletions teachpress.php
Expand Up @@ -92,10 +92,10 @@
include_once("admin/show-students.php");
}

// BibTeX Parse
if ( !class_exists( 'PARSEENTRIES' ) ) {
include_once("includes/bibtexParse/PARSEENTRIES.php");
include_once("includes/bibtexParse/PARSECREATORS.php");
// BibTeX Parse v2.5
if ( !class_exists( 'BIBTEXPARSE' ) ) {
include_once("includes/bibtexParse/BIBTEXPARSE.php");
include_once("includes/bibtexParse/BIBTEXCREATORPARSE.php");
}

/*********/
Expand Down

0 comments on commit 5993fed

Please sign in to comment.