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

This commit is contained in:
Markus Jochim
2014-12-04 22:41:33 +01:00
committed by Martin Monperrus
parent 02a3df6fed
commit 19a3335597
+31 -6
View File
@@ -2457,9 +2457,13 @@ 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) {
$href = makeHref(array($queryKey => $key)); if ($queryKey === 'year') {
echo '<a '. $href .' target="'.BIBTEXBROWSER_MENU_TARGET.'">'. $item ."</a>\n"; $href = makeHref(array($queryKey => __($item)));
echo "<div class=\"mini_se\"></div>\n"; } else {
$href = makeHref(array($queryKey => $key));
}
echo '<a '. $href .' target="'.BIBTEXBROWSER_MENU_TARGET.'">'. $item ."</a>\n";
echo "<div class=\"mini_se\"></div>\n";
} }
$index++; $index++;
} }
@@ -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"); $year = strtolower($bib->getYearRaw());
$result[$year] = $year; $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;
} }