Changeset 363


Ignore:
Timestamp:
May 21, 2008, 8:01:32 AM (16 years ago)
Author:
george
Message:

Úprava kodu funkce PagesList. Doplnění parametru.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • global.php

    r358 r363  
    245245
    246246// Zobrazení èíselný seznamu stránek
    247 function PagesList($URL,$Page,$TotalCount,$CountPerPage)
    248 {
    249   $Count = ceil($TotalCount/$CountPerPage);
    250   $Around = 10;
     247function PagesList($URL, $Page, $TotalCount, $CountPerPage, $Around = 10)
     248{
     249  $Count = ceil($TotalCount / $CountPerPage);
    251250  $Result = '';
    252   if($Count>1)
    253   {
    254     if($Page>0)
    255     {
    256       $Result.= '<a href="'.$URL.'0">&lt;&lt;</a> ';
    257       $Result.= '<a href="'.$URL.($Page-1).'">&lt;</a> ';
    258     }
    259     $PagesMax = $Count-1;
     251  if($Count > 1)
     252  {
     253    if($Page > 0)
     254    {
     255      $Result .= '<a href="'.$URL.'0">&lt;&lt;</a> ';
     256      $Result .= '<a href="'.$URL.($Page-1).'">&lt;</a> ';
     257    }
     258    $PagesMax = $Count - 1;
    260259    $PagesMin = 0;
    261     if($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;
    262     if($PagesMin<($Page-$Around))
     260    if($PagesMax > ($Page + $Around)) $PagesMax = $Page + $Around;
     261    if($PagesMin < ($Page - $Around))
    263262    {
    264263      $Result.= ' .. ';
    265       $PagesMin = $Page-$Around;
    266     }
    267     for($i=$PagesMin;$i<=$PagesMax;$i++)
    268     {
    269       if($i==$Page) $Result.= '<strong>';
    270       $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';
    271       if($i==$Page) $Result.= '</strong>';
     264      $PagesMin = $Page - $Around;
     265    }
     266    for($i = $PagesMin; $i <= $PagesMax; $i++)
     267    {
     268      if($i == $Page) $Result .= '<strong>';
     269      $Result .= '<a href="'.$URL.$i.'">'.($i + 1).'</a> ';
     270      if($i == $Page) $Result .= '</strong>';
    272271    }
    273     if($PagesMax<($Count-1)) $Result .= ' .. ';
    274     if($Page<($Count-1))
    275     {
    276       $Result.= '<a href="'.$URL.($Page+1).'">&gt;</a> ';
    277       $Result.= '<a href="'.$URL.($Count-1).'">&gt;&gt;</a>';
     272    if($PagesMax < ($Count - 1)) $Result .= ' .. ';
     273    if($Page < ($Count - 1))
     274    {
     275      $Result .= '<a href="'.$URL.($Page + 1).'">&gt;</a> ';
     276      $Result .= '<a href="'.$URL.($Count - 1).'">&gt;&gt;</a>';
    278277    }
    279278  }
Note: See TracChangeset for help on using the changeset viewer.