[CLASS] pagination class Oracle 27 ოქტ 2013, 17:40 Me agixsnit tu rogor gaaketot saitze martivad da lamazad pagination-i magalitistvis First | Prev | 2 | 3 | [4] | 5 | 6 | Next | Last vqmnit fails saxelad class.pagination.php an rac gindat is daarqvit da sshignit vwert [php] '', 'perpage' => '', 'page' => '', 'total' => '', 'numlinks' => '', 'firsttext' => 'First', 'nexttext' => 'Next', 'prevtext' => 'Previous', 'lasttext' => 'Last', 'focusedclass' => 'imp', 'delimiter' => ', ', 'nextprev' => '0' ); function set($who,$what){ $this->output = ''; $this->options[$who] = $what; } function checkValues(){ $errors = array(); if($this->options['perpage']=='') $errors[] = 'Invalid perpage value'; if($this->options['page']=='') $errors[] = 'Invalid page value'; if($this->options['total']=='') $errors[] = 'Invalid total value'; if($this->options['numlinks']=='') $errors[] = 'Invalid numlinks value'; } function display($return = false){ $this->checkValues(); if($this->output=='') $this->generateOutput(); if(!$return) echo $this->output; else return $this->output; } function generateOutput(){ $elements = array(); $num_pages = ceil($this->options['total']/$this->options['perpage']); $front_links = ceil($this->options['numlinks']/2); $end_links = floor($this->options['numlinks']/2); if($this->options['page'] > $num_pages){ $this->set('page',1); } $start_page = max(1,($this->options['page']-$front_links+1)); $end_page = min($this->options['numlinks'] + $start_page-1,$num_pages); if($this->options['page'] > 2){ $elements[] = $this->generate_link(1,$this->options['firsttext']); } if(($this->options['page'] > 1) && ($this->options['nextprev'] !='0')){ $elements[] = $this->generate_link($this->options['page']-1,$this->options['prevtext']); } for($i=$start_page;$i<=$end_page;$i++){ $elements[] = $this->generate_link($i); } if(($this->options['page'] < $num_pages) && ($this->options['nextprev'] !='0')){ $elements[] = $this->generate_link($this->options['page']+1,$this->options['nexttext']); } if($this->options['page'] < ($num_pages -1)){ $elements[] = $this->generate_link($num_pages,$this->options['lasttext']); } $this->output = implode($this->options['delimiter'],$elements); } function generate_link($page,$label=''){ $url = str_replace('%page%',$page,$this->options['urlscheme']); if($label=='') $label=$page; $html=($page == $this->options['page']) ? "options['focusedclass']}\">[$label]\n":"{$label}\n"; return $html; } } ?> [/php] shemdeg sadac gvinda gavaketot es vsvamt aset kods vtqvat index.phpshi tavshi vsvamt [php] [/php] da sasurvel adgilas [php] set('urlscheme','class.pagination.php?page=%page%'); $paging->set('perpage',10); $paging->set('page',15); $paging->set('total',3000); $paging->set('nexttext','Next Page'); $paging->set('prevtext','Previous Page'); $paging->set('focusedclass','selected'); $paging->set('delimiter',''); $paging->set('numlinks',9); $paging->display(); ?> [/php] gadaaketet survilisamebr --------------- Oracle 27 ოქტ 2013, 17:53 cudat chans temashi da gadaweret es faili https://spaceshipcollaborative.googlecode.com/files/class.pagination.php ---------------