From 008c5a8a7df36d8c96853ed9754e7065dfa4b99d Mon Sep 17 00:00:00 2001 From: Igor Date: Tue, 2 Nov 2010 13:05:06 +0300 Subject: tag --- README | 2 -- bibtex.php | 6 +----- syntax.php | 48 ++++++++++++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/README b/README index 38334ec..e71a2e5 100644 --- a/README +++ b/README @@ -21,8 +21,6 @@ no empty line are allowed before 2. Publications selected from by some attributes. -(Not implemented yet) - author = pashev year = 2005 diff --git a/bibtex.php b/bibtex.php index acda55a..9fd391f 100644 --- a/bibtex.php +++ b/bibtex.php @@ -132,7 +132,7 @@ class BibtexParser } if ($select) { - if (!!empty($entry['html'])) + if (empty($entry['html'])) { $entry['html'] = $this->format($entry); } @@ -544,10 +544,6 @@ class BibtexParserTeam extends BibtexParser class BibtexParserWorker extends BibtexParserTeam { - /* - * Compare entries for sorting - * - */ protected function cmp_entries(&$a, &$b) { // by entry type diff --git a/syntax.php b/syntax.php index c4f38f7..9bbd0ea 100644 --- a/syntax.php +++ b/syntax.php @@ -49,13 +49,15 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin switch ($state) { case DOKU_LEXER_ENTER : - $tag = substr($match, 1 ,6); // FIXME : Ugly! + preg_match('/<(\w+)>/', $match, $tmp); + $tag = $tmp[1]; + unset($tmp); return array($state, $tag, array()); case DOKU_LEXER_UNMATCHED : if ($tag === 'papers') // Parse ... { - $bibtex = new BibtexParserTeam(); + $bibtex = new BibtexParserWorker(); $bibtex->read_file(wikiFN($this->getConf('bibtex'))); $spec = array(); $fields = preg_split('/\s*\n\s*/u', $match); @@ -67,10 +69,11 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin } } $bibtex->select($spec); + unset($spec); $bibtex->sort(); return array($state, $tag, $bibtex); } - elseif ($this->tag === 'bibtex') + elseif ($tag === 'bibtex') // Parse ... { $bibtex = new BibtexParserTeam(); $bibtex->read_text($match); @@ -101,7 +104,7 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin } elseif ($tag === 'papers') { - $renderer->doc .= $this->format_bibtex($bibtex, true); + $renderer->doc .= $this->format_bibtex($bibtex, array('raw'=>true)); } break; @@ -118,7 +121,7 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin } - function format_bibtex(&$bibtex, $raw = false) + function format_bibtex(&$bibtex, $options = array()) { $res = ''; $year = ''; $year_prev = ''; @@ -126,25 +129,30 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin $in_list = false; foreach ($bibtex->SELECTION as &$entry) { - if (!$raw) + // tag results in just a list of papers + if (!isset($options['raw']) || $options['raw']) { - preg_match('/(\d{4})/u', $entry['year'], $matches); - $year = $matches[1]; - if ($year < $this->getConf('year_min')) - break; - - if ($year !== $year_prev) + // No 'Year' title for papers of a worker (team member) + if (!isset($options['year']) || $options['year']) { - if ($in_list) + preg_match('/(\d{4})/u', $entry['year'], $matches); + $year = $matches[1]; + if ($year < $this->getConf('year_min')) + break; + + if ($year !== $year_prev) { - $res .= "\n"; - $in_list = false; - } + if ($in_list) + { + $res .= "\n"; + $in_list = false; + } - $year_prev = $year; - $type_prev = ''; - $res .= "

$year " - . $this->getLang('year') . "

\n"; + $year_prev = $year; + $type_prev = ''; + $res .= "

$year " + . $this->getLang('year') . "

\n"; + } } $type = $entry['entry']; -- cgit v1.2.3