diff options
author | Igor <pashev.igor@gmail.com> | 2010-11-02 09:19:48 +0300 |
---|---|---|
committer | Igor <pashev.igor@gmail.com> | 2010-11-02 09:19:48 +0300 |
commit | 7583f905dd04b309169be6eb796890891b9ee8e8 (patch) | |
tree | 297ef4c4e3516f0ebfd707f52711b1c00e1058f5 | |
parent | b660da13aca216d0fa3598208b7bfa656771cf39 (diff) | |
download | dokuwiki-plugin-papers-7583f905dd04b309169be6eb796890891b9ee8e8.tar.gz |
Rename class and new class
-rw-r--r-- | bibtex.php | 54 |
1 files changed, 53 insertions, 1 deletions
@@ -176,7 +176,7 @@ class BibtexParser * Example class for very special purpose * */ -class BibtexParserGoga extends BibtexParser +class BibtexParserTeam extends BibtexParser { protected $entry; @@ -541,5 +541,57 @@ class BibtexParserGoga extends BibtexParser } } + +class BibtexParserWorker extends BibtexParserTeam +{ + /* + * Compare entries for sorting + * + */ + protected function cmp_entries(&$a, &$b) + { + // by entry type + $type = array ( + 'article' => 10, + 'book' => 20, + 'inbook' => 30, + 'booklet' => 40, + 'inproceedings' => 50, + 'grant' => 1000, // for grants, not for publications ;-) + 'misc' => 999999, // We use misc for articles in non-reviewed journals + ); + $x = $type[$a['entry']]; // FIXME : other entry type if needed + $y = $type[$b['entry']]; + if ($x < $y) {return -1;}; + if ($x > $y) {return 1;}; + + // by year (if range - by last year) + $x = preg_match('/.*([0-9]{4})/ui', $a['year'], $matches) ? $matches[1] : 0; + $y = preg_match('/.*([0-9]{4})/ui', $b['year'], $matches) ? $matches[1] : 0; + // die ("$x < $y"); + if ($x > $y) {return -1;}; + if ($x < $y) {return 1;}; + + + // by journal importance, + // which is defined by order of @STRING commands for BiBTeX + // (strings are stored in $this->STRINGS) + $x = empty($a['journal']) ? 'NONE' : $a['journal']; + $y = empty($b['journal']) ? 'NONE' : $b['journal']; + // Not a journal. Maybe grant? + if (($x === 'NONE') && ($y === 'NONE')) + { // 'organization' is my (Igor's) extention + $x = empty($a['organization']) ? 'NONE' : $a['organization']; + $y = empty($b['organization']) ? 'NONE' : $b['organization']; + } + $x = empty($this->STRINGS_o[$x]) ? 999999 : $this->STRINGS_o[$x]; + $y = empty($this->STRINGS_o[$y]) ? 999999 : $this->STRINGS_o[$y]; + if ($x < $y) {return -1;}; + if ($x > $y) {return 1;}; + + return 0; + } +} + ?> |