aboutsummaryrefslogtreecommitdiff
path: root/bibtex.php
diff options
context:
space:
mode:
authorIgor <pashev.igor@gmail.com>2010-12-28 22:34:13 +0300
committerIgor <pashev.igor@gmail.com>2010-12-28 22:34:13 +0300
commit9cc9ed16fadeead0d846b2b43ef961791c74fe05 (patch)
tree875932736a0b43a5078881554ba97bf1dbd5b331 /bibtex.php
parent902d6ec2f5208a799feff916fa9cd739807453cb (diff)
downloaddokuwiki-plugin-papers-9cc9ed16fadeead0d846b2b43ef961791c74fe05.tar.gz
Fixed export; example added
Diffstat (limited to 'bibtex.php')
-rw-r--r--bibtex.php69
1 files changed, 37 insertions, 32 deletions
diff --git a/bibtex.php b/bibtex.php
index 6979855..9fe5294 100644
--- a/bibtex.php
+++ b/bibtex.php
@@ -185,38 +185,6 @@ class BibtexParser
return $res;
}
-
- /*
- * 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;
- }
}
@@ -301,6 +269,43 @@ class BibtexParserTeam extends BibtexParser
usort($this->SELECTION, array($this, 'cmp_entries'));
}
+ public function sort_all()
+ {
+ usort($this->ENTRIES, array($this, 'cmp_entries'));
+ }
+
+ /*
+ * Export sorted BiBTeX.
+ * Do not use after $this->expand_years()
+ *
+ */
+ public function export()
+ {
+ $res = '';
+ $this->sort_all();
+ 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;
+ }
+
protected function format_field_default($field)
{
$this->entry[$field] = $this->latex2html(