Browse Source

Now also applies graceful ordering and i18n of non-string year-values to yearIndex()

pull/25/head
Markus Jochim 11 years ago
committed by Martin Monperrus
parent
commit
19a3335597
  1. 31
      bibtexbrowser.php

31
bibtexbrowser.php

@ -2457,7 +2457,11 @@ else $page = 1;
$index = 0; $index = 0;
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
if ($index >= $startIndex && $index < $endIndex) { if ($index >= $startIndex && $index < $endIndex) {
if ($queryKey === 'year') {
$href = makeHref(array($queryKey => __($item)));
} else {
$href = makeHref(array($queryKey => $key)); $href = makeHref(array($queryKey => $key));
}
echo '<a '. $href .' target="'.BIBTEXBROWSER_MENU_TARGET.'">'. $item ."</a>\n"; echo '<a '. $href .' target="'.BIBTEXBROWSER_MENU_TARGET.'">'. $item ."</a>\n";
echo "<div class=\"mini_se\"></div>\n"; echo "<div class=\"mini_se\"></div>\n";
} }
@ -3203,10 +3207,31 @@ class BibDataBase {
$result = array(); $result = array();
foreach ($this->bibdb as $bib) { foreach ($this->bibdb as $bib) {
if (!$bib->hasField("year")) continue; if (!$bib->hasField("year")) continue;
$year = $bib->getField("year");
$result[$year] = $year;
$year = strtolower($bib->getYearRaw());
$yearInt = (int) $year;
// Allow for ordering of non-string values ('in press' etc.)
switch ($year) {
case (string) $yearInt: // Sorry for this hacky type-casting
$key = $year;
break;
case Q_YEAR_INPRESS:
$key = PHP_INT_MAX + ORDER_YEAR_INPRESS;
break;
case Q_YEAR_ACCEPTED:
$key = PHP_INT_MAX + ORDER_YEAR_ACCEPTED;
break;
case Q_YEAR_SUBMITTED:
$key = PHP_INT_MAX + ORDER_YEAR_SUBMITTED;
break;
default:
$key = PHP_INT_MAX + ORDER_YEAR_OTHERNONINT;
} }
arsort($result);
$result[$key] = $year;
}
krsort($result);
return $result; return $result;
} }

Loading…
Cancel
Save