diff options
author | Igor <pashev.igor@gmail.com> | 2010-11-08 23:23:51 +0300 |
---|---|---|
committer | Igor <pashev.igor@gmail.com> | 2010-11-08 23:23:51 +0300 |
commit | 8fce6c7d3d5a661b87ed21fe9f3ed6675ba74eb5 (patch) | |
tree | 6d7805b1ab02cf7706014f56eac5d7da551ca528 /bibtex.php | |
parent | ed6c3110af1f0c8b224d6806df52e0adfdaba023 (diff) | |
download | dokuwiki-plugin-papers-8fce6c7d3d5a661b87ed21fe9f3ed6675ba74eb5.tar.gz |
Added method to export sorted BiBTeX
Diffstat (limited to 'bibtex.php')
-rw-r--r-- | bibtex.php | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -185,6 +185,37 @@ class BibtexParser } + /* + * Export sorted BiBTeX. + * Do not use after $this->expand_years() + * + */ + public function export() + { + $res = ''; + $this->sort(); + foreach ($this->STRINGS as $key => $value) + { + $res .= '@STRING (' . $key . '="' . $value . '")' . "\n"; + } + + $res .= "\n\n"; + + foreach ($this->ENTRIES as $ent) + { + $res .= '@' . mb_strtoupper($ent['entry']) . ' {' . $ent['id'] . ",\n"; + $fields = array(); + foreach($ent as $key => $value) + { + // Skip our special fields + if (!in_array($key, array('id', 'entry'))) + $fields[] = mb_strtoupper($key) . '=' . $value; + } + $res .= implode(",\n", $fields); + $res .= "\n}\n\n"; + } + return $res; + } } |