Changeset 18729


Ignore:
Timestamp:
10/23/12 22:19:57 (7 years ago)
Author:
rvelices
Message:
  • navigation bar urls are always on the number of images per page boundaries (fix rare case when the admin changer the number of thumbs per page for guests, and then google bot fetches almost all start-xx pages)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r18629 r18729  
    510510    $formated_date.= ' '.$lang['month'][(int)$ymdhms[1]]; 
    511511  } 
    512    
     512 
    513513  $formated_date.= ' '.$ymdhms[0]; 
    514514  if ($show_time and count($ymdhms)>=5 ) 
     
    533533      $tok = strtok('- :'); 
    534534    } 
    535      
     535 
    536536    if ($ymdhms[0] < 1970) return false; 
    537537    if (!isset($ymdhms[3])) $ymdhms[3] = 12; 
     
    540540    $original = mktime($ymdhms[3],$ymdhms[4],$ymdhms[5],$ymdhms[1],$ymdhms[2],$ymdhms[0]); 
    541541  } 
    542    
     542 
    543543  // array of time period chunks 
    544544  $chunks = array( 
     
    551551    'second' => 1, 
    552552  ); 
    553    
     553 
    554554  $today = time(); /* Current unix time  */ 
    555555  $since = abs($today - $original); 
    556    
     556 
    557557  $print = null; 
    558558  foreach ($chunks as $name => $seconds) 
     
    569569  } 
    570570 
    571   if ($today > $original)  
     571  if ($today > $original) 
    572572  { 
    573573    $print = sprintf(l10n('%s ago'), $print); 
     
    577577    $print = sprintf(l10n('%s in the future'), $print); 
    578578  } 
    579    
     579 
    580580  return $print; 
    581581} 
     
    14221422  if ($nb_element > $nb_element_page) 
    14231423  { 
    1424     $cur_page = ceil($start / $nb_element_page) + 1; 
     1424    $url_start = $url.$start_str; 
     1425 
     1426    $cur_page = $navbar['CURRENT_PAGE'] = $start / $nb_element_page + 1; 
    14251427    $maximum = ceil($nb_element / $nb_element_page); 
     1428 
     1429    $start = $nb_element_page * round( $start / $nb_element_page ); 
    14261430    $previous = $start - $nb_element_page; 
    14271431    $next = $start + $nb_element_page; 
    14281432    $last = ($maximum - 1) * $nb_element_page; 
    14291433 
    1430     $navbar['CURRENT_PAGE'] = $cur_page; 
    1431  
    14321434    // link to first page and previous page? 
    14331435    if ($cur_page != 1) 
    14341436    { 
    14351437      $navbar['URL_FIRST'] = $url; 
    1436       $navbar['URL_PREV'] = $url.($previous > 0 ? $start_str.$previous : ''); 
     1438      $navbar['URL_PREV'] = $previous > 0 ? $url_start.$previous : $url; 
    14371439    } 
    14381440    // link on next page and last page? 
    14391441    if ($cur_page != $maximum) 
    14401442    { 
    1441       $navbar['URL_NEXT'] = $url.$start_str.$next; 
    1442       $navbar['URL_LAST'] = $url.$start_str.$last; 
     1443      $navbar['URL_NEXT'] = $url_start.($next < $last ? $next : $last); 
     1444      $navbar['URL_LAST'] = $url_start.$last; 
    14431445    } 
    14441446 
     
    14461448    $navbar['pages'] = array(); 
    14471449    $navbar['pages'][1] = $url; 
    1448     $navbar['pages'][$maximum] = $url.$start_str.$last; 
    1449  
    1450     for ($i = max($cur_page - $pages_around , 2), $stop = min($cur_page + $pages_around + 1, $maximum); 
     1450    for ($i = max( floor($cur_page) - $pages_around , 2), $stop = min( ceil($cur_page) + $pages_around + 1, $maximum); 
    14511451         $i < $stop; $i++) 
    14521452    { 
    14531453      $navbar['pages'][$i] = $url.$start_str.(($i - 1) * $nb_element_page); 
    14541454    } 
    1455     ksort($navbar['pages']); 
     1455    $navbar['pages'][$maximum] = $url_start.$last; 
    14561456  } 
    14571457  return $navbar; 
Note: See TracChangeset for help on using the changeset viewer.