From 008c5a8a7df36d8c96853ed9754e7065dfa4b99d Mon Sep 17 00:00:00 2001 From: Igor Date: Tue, 2 Nov 2010 13:05:06 +0300 Subject: tag --- syntax.php | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'syntax.php') 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