aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor <pashev.igor@gmail.com>2010-11-02 13:05:06 +0300
committerIgor <pashev.igor@gmail.com>2010-11-02 13:05:06 +0300
commit008c5a8a7df36d8c96853ed9754e7065dfa4b99d (patch)
treed313f275f9e8683488b62ca434a0e57e037308db
parent7583f905dd04b309169be6eb796890891b9ee8e8 (diff)
downloaddokuwiki-plugin-papers-008c5a8a7df36d8c96853ed9754e7065dfa4b99d.tar.gz
<papers> tag
-rw-r--r--README2
-rw-r--r--bibtex.php6
-rw-r--r--syntax.php48
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 </bibtex>
2. Publications selected from <bibtex> by some attributes.
-(Not implemented yet)
-
<papers>
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 <papers>...</papers>
{
- $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>...</bibtex>
{
$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)
+ // <papers> 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 .= "</ol>\n";
- $in_list = false;
- }
+ if ($in_list)
+ {
+ $res .= "</ol>\n";
+ $in_list = false;
+ }
- $year_prev = $year;
- $type_prev = '';
- $res .= "<h2 class=\"sectionedit2\">$year "
- . $this->getLang('year') . "</h2>\n";
+ $year_prev = $year;
+ $type_prev = '';
+ $res .= "<h2 class=\"sectionedit2\">$year "
+ . $this->getLang('year') . "</h2>\n";
+ }
}
$type = $entry['entry'];