Skip to content

Commit

Permalink
Merge branch 'feature/fix-a128ce3'
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Jan 11, 2017
2 parents 97fbe92 + d5837c2 commit 1643e03
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions public_html/directory.php
Expand Up @@ -383,31 +383,23 @@ function DIR_displayYear($template, $dir_topic, $year)
$mResult = DB_query($monthSql);
$numMonths = DB_numRows($mResult);

// The above query returns records with duplicate months. So, let's sort them out.
if ($numMonths > 0) {
$items = array();
$lastMonth = 1;
for ($j = 0; $j < $numMonths; $j++) {
$M = DB_fetchArray($mResult);

for (; $lastMonth < $M['month']; $lastMonth++) {
$items[] = DIR_monthLink($dir_topic, $year, $lastMonth, 0);
}
$lastMonth = $M['month'] + 1;
$numArticles = array_fill(1, 12, 0);

$items[] = DIR_monthLink($dir_topic, $year, $M['month'], $M['cnt']);
while (($M = DB_fetchArray($mResult, false)) !== false) {
$month = (int) $M['month'];
$cnt = (int) $M['cnt'];
$numArticles[$month] += $cnt;
}

if ($year == $currentYear) {
$fillMonth = $currentMonth;
} else {
$fillMonth = 12;
}
$items = array();
$lastMonth = ($year == $currentYear) ? $currentMonth : 12;

if ($lastMonth <= $fillMonth) {
for (; $lastMonth <= $fillMonth; $lastMonth++) {
$items[] = DIR_monthLink($dir_topic, $year, $lastMonth, 0);
}
for ($month = 1; $month <= $lastMonth; $month++) {
$items[] = DIR_monthLink($dir_topic, $year, $month, $numArticles[$month]);
}

$retval .= COM_makeList($items);
} else {
if (TEMPLATE_EXISTS) {
Expand Down

0 comments on commit 1643e03

Please sign in to comment.