Katalog sociálních služeb

Logo: Královéhradecký kraj

Úvodní stránka > Pomoc pro rodiny a děti

Pomoc pro rodiny a děti

* @version 0.1.0 */ class MyPaginator { /** * Total number of items * @var integer */ protected $TotalItemsCount; /** * Number of items displayed per page * @var integer */ protected $ItemsPerPage; /** * Number of currently displayed page * @var integer */ protected $CurrentPage; /** * Number of Index items in paginator: * example for IndexCount == 10 * Previous | 1 2 3 4 5 6 7 8 ... 18 | Next * 10 items + 2 for Previous and Next item * @var integer */ protected $IndexCount; /** * Total number of pages * @var integer */ protected $TotalPages; protected $Uri; /** * __construct() * @param integer $totalItemsCount * @param integer $itemsPerPage * @param integer $indexCount */ function __construct($totalItemsCount, $itemsPerPage, $indexCount = 20) { $this->CurrentPage = (int) array_key_exists('current_page', $_GET) ? $_GET['current_page'] : 0; $this->CurrentPage = $this->CurrentPage == 0 ? 1 : $this->CurrentPage; $this->TotalItemsCount = $totalItemsCount; $this->ItemsPerPage = $itemsPerPage; $this->TotalPages = ceil($this->TotalItemsCount / $this->ItemsPerPage); $this->IndexCount = $indexCount; $this->IndexCount = $this->IndexCount < $this->TotalPages ? $this->IndexCount : $this->TotalPages; } /** * PrintIndex() is used by {@link Render()} for generating links */ protected function PrintIndex($Page, $Text = null) { $Text = $Text == null ? (int) $Page : $Text; $Page = $Page <= 1 ? null : $Page; $Page = $Page > $this->TotalPages ? $this->TotalPages : $Page; $Page = $Page <= 1 ? null : $Page; $CurrentPage = $this->CurrentPage == 1 ? null : $this->CurrentPage; if($Page != $CurrentPage && $Page != null) { printf('%s ', $this->Uri, $Page, $Text); } else if($Page != $CurrentPage) { printf('%s ', $this->Uri, $Text); } else if(is_integer($Text)) { printf('%s ', $Text); } else { printf('%s ', $Text); } } /** * Render() is used to render paginator (output html) */ public function Render($cssClassName = null) { $cssClassName = $cssClassName == null ? 'paginator' : $cssClassName; printf('
', $cssClassName); $this->Uri = preg_replace('|(.*)\?current_page=\d*$|', '$1', $_SERVER['REQUEST_URI']); /** * First index item */ $this->PrintIndex($this->CurrentPage - 1, 'Pedchoz'); echo ' | '; $this->PrintIndex(1); /** * Second index item */ if($this->IndexCount >= 2) { if(($this->IndexCount >= 5 && $this->IndexCount < $this->TotalPages) && $this->CurrentPage > ceil($this->IndexCount / 2) && $this->CurrentPage != 2) { echo '... '; } else { $this->PrintIndex(2); } } /** * Middle index items */ if($this->IndexCount >= 5) { if($this->CurrentPage <= $this->TotalPages - $this->IndexCount / 2 && $this->CurrentPage > $this->IndexCount / 2) { // we are in middle $start = $this->CurrentPage - ceil(($this->IndexCount - 4) / 2) + 1; $end = $this->CurrentPage + floor(($this->IndexCount - 4) / 2 ); } else if($this->CurrentPage <= $this->IndexCount /2) { // we are in beginning $start = 3; $end = $this->IndexCount - 2; } else { // we are in the end $start = $this->TotalPages - $this->IndexCount + 3; $end = $this->TotalPages - 2; } for($i = $start; $i <= $end; $i++) { $this->PrintIndex($i); } } /** * The last but one index item */ if($this->IndexCount >= 4) { if(($this->IndexCount >= 5 && $this->IndexCount < $this->TotalPages) && $this->CurrentPage < $this->TotalPages - $this->IndexCount / 2) { echo '... '; } else { $this->PrintIndex($this->TotalPages - 1); } } /** * Last index item */ if($this->IndexCount >= 3) { $this->PrintIndex($this->TotalPages); } echo ' | '; $this->PrintIndex($this->CurrentPage + 1, 'Dalš'); echo '
'; } public function __get($str) { switch($str) { case 'Offset': return $this->ItemsPerPage * ($this->CurrentPage - 1); case 'ItemsPerPage': return $this->ItemsPerPage; case 'CurrentPage': return $this->CurrentPage; case 'TotalPages': return $this->TotalPages; case 'TotalItemsCount': return $this->TotalItemsCount; } } } ?>

| Zobraz vybraná zařízení  |  Zrušit výběr |


Upřesněte území:  
Upozornění: Po kliknutí na název zařízení se otevře karta zařízení s detailními informacemi v novém okně!

\n"; echo "
\n"; echo "

Celkový počet vyhledaných záznamů: ".$total."

\n"; $i=0; while ( $data=mysql_fetch_array($select)) { $okr=""; $c_okresu =""; $i=$i+1; $c_okresu = $data['CountyNumber']; if ($c_okresu == "CZ0521") { $okr="HK";} if ($c_okresu == "CZ0522") { $okr="JC";} if ($c_okresu == "CZ0523") { $okr="NA";} if ($c_okresu == "CZ0524") { $okr="RK";} if ($c_okresu == "CZ0525") { $okr="TU";} $b[] = "".$i."".$okr."".str_convert($data['City'], "iso")."".str_convert($data['Name'], "iso")." ".str_convert($data['SocialServiceType'], "iso")." "; } //--------------vypis------------------------- $paginator = new MyPaginator($i, 20); $paginator->Render(); for($j = 0; $j < $paginator->ItemsPerPage; $j++) { if ($j == 0) { echo "

\n"; echo "\n"; } //printf ($data['Name'], $objPaginator->Offset, $objPaginator->ItemsPerPage ); echo $b[$paginator->Offset+$j] . "\n"; if ($j == 19) {echo "
č.okresObecNázev zařízeníDruh služby
\n";} } $paginator->Render(); ?>