>"; var $nr_links_stanga = 5; var $nr_links_dreapta = 5; var $file; var $total_records; var $query_string; var $lnk_stg; var $lnk_dr; function execute($sql, $db, $type = "mysql") { global $total_records, $row, $numtoshow; $numtoshow = $this->numrowsperpage; if (!isset($row)) $row = 0; $start = $row * $numtoshow; if ($type == "mysql") { $result = mysql_db_query($db,$sql); $total_records = mysql_num_rows($result); $sql .= " LIMIT $start, $numtoshow"; $result = mysql_db_query($db,$sql); } elseif ($type == "pgsql") { $result = pg_Exec($db, $sql); $this->total_records = pg_NumRows($result); $sql .= " LIMIT $numtoshow, $start"; $result = pg_Exec($db, $sql); } return $result; } function build_geturl() { //global $REQUEST_URI, $REQUEST_METHOD, $_GET, $_POST; $query_string=""; list($fullfile, $voided) = explode("?", $_SERVER['REQUEST_URI']); $this->file = $fullfile; $cgi = $_SERVER['REQUEST_METHOD'] == 'GET' ? $_GET : $_POST; reset ($cgi); while (list($key, $value) = each($cgi)) { if ($key != "row") $query_string .= "&" . $key . "=" . $value; } return $query_string; } // $option parameter (default to "all") : // . "all" - return every navigation link // . "pages" - return only the page numbering links // . "sides" - return only the 'Next' and / or 'Previous' links // // $show_blank parameter (default to "off") : // . "off" - don't show the "Next" or "Previous" when it is not needed // . "on" - show the "Next" or "Previous" strings as plain text when it is not needed function getlinks() { global $total_records, $row, $numtoshow; $lnk_stg=""; $lnk_dr=""; $extra_vars = $this->build_geturl(); $file = $this->file; $number_of_pages = ceil($total_records / $numtoshow); $explozia=explode("&",$extra_vars); $rez=sizeof($explozia)-1; switch ($rez){ case "0" : if (!isset($row)) $row=0; $start = (($row-$this->nr_links_stanga)<0) ? 0 : $row-$this->nr_links_stanga ; for ($i=$start;$i<=$row;$i++) if ($i>0) $lnk_stg .= '' . ($i) . ''." "; for ($i=$row+1;$i<=$row+$this->nr_links_dreapta;$i++) if (($i>0) && ($i<$number_of_pages)) $lnk_dr .= '' . ($i+1) . ''." "; $inapoi = ($row>0) ? '' . $this->str_previous . ''." " : ""; $inainte = ($row < $number_of_pages-1) ? '' . $this->str_next . ''." " : ""; $centru = "".($row+1).""; $links = $inapoi." ".$lnk_stg." ".$centru." ".$lnk_dr." ".$inainte; return $links; break; case "1": $explod=explode("=",$explozia[2]); $xplod=explode("=",$explozia[1]); if (!isset($row)) $row=0; $start = (($row-$this->nr_links_stanga)<0) ? 0 : $row-$this->nr_links_stanga ; for ($i=$start;$i<=$row;$i++) if ($i>0) $lnk_stg .= '' . ($i) . ''." "; for ($i=$row+1;$i<=$row+$this->nr_links_dreapta;$i++) if (($i>0) && ($i<$number_of_pages)) $lnk_dr .= '' . ($i+1) . ''." "; $inapoi = ($row>0) ? '' . $this->str_previous . ''." " : ""; $inainte = ($row < $number_of_pages-1) ? '' . $this->str_next . ''." " : ""; $centru = "".($row+1).""; $links = $inapoi." ".$lnk_stg." ".$centru." ".$lnk_dr." ".$inainte; return $links; break; case "2": $explod=explode("=",$explozia[2]); $xplod=explode("=",$explozia[1]); if (!isset($row)) $row=0; $start = (($row-$this->nr_links_stanga)<0) ? 0 : $row-$this->nr_links_stanga ; for ($i=$start;$i<=$row;$i++) if ($i>0) $lnk_stg .= '' . ($i) . ''." "; for ($i=$row+1;$i<=$row+$this->nr_links_dreapta;$i++) if (($i>0) && ($i<$number_of_pages)) $lnk_dr .= '' . ($i+1) . ''." "; $inapoi = ($row>0) ? '' . $this->str_previous . ''." " : ""; $inainte = ($row < $number_of_pages-1) ? '' . $this->str_next . ''." " : ""; $centru = "".($row+1).""; $links = $inapoi." ".$lnk_stg." ".$centru." ".$lnk_dr." ".$inainte; return $links; break; case "3": $explod=explode("=",$explozia[2]); $xplod=explode("=",$explozia[1]); if (!isset($row)) $row=0; $start = (($row-$this->nr_links_stanga)<0) ? 0 : $row-$this->nr_links_stanga ; for ($i=$start;$i<=$row;$i++) if ($i>0) $lnk_stg .= '' . ($i) . ''." "; for ($i=$row+1;$i<=$row+$this->nr_links_dreapta;$i++) if (($i>0) && ($i<$number_of_pages)) $lnk_dr .= '' . ($i+1) . ''." "; $inapoi = ($row>0) ? '' . $this->str_previous . ''." " : ""; $inainte = ($row < $number_of_pages-1) ? '' . $this->str_next . ''." " : ""; $centru = "".($row+1).""; $links = $inapoi." ".$lnk_stg." ".$centru." ".$lnk_dr." ".$inainte; return $links; break; case "4": if (!isset($row)) $row=0; $start = (($row-$this->nr_links_stanga)<0) ? 0 : $row-$this->nr_links_stanga ; for ($i=$start;$i<=$row;$i++) if ($i>0) $lnk_stg .= '' . ($i) . ''." "; for ($i=$row+1;$i<=$row+$this->nr_links_dreapta;$i++) if (($i>0) && ($i<$number_of_pages)) $lnk_dr .= '' . ($i+1) . ''." "; $inapoi = ($row>0) ? '' . $this->str_previous . ''." " : ""; $inainte = ($row < $number_of_pages-1) ? '' . $this->str_next . ''." " : ""; $centru = "".($row+1).""; $links = $inapoi." ".$lnk_stg." ".$centru." ".$lnk_dr." ".$inainte; return $links; break; case "5": if (!isset($row)) $row=0; $start = (($row-$this->nr_links_stanga)<0) ? 0 : $row-$this->nr_links_stanga ; for ($i=$start;$i<=$row;$i++) if ($i>0) $lnk_stg .= '' . ($i) . ''." "; for ($i=$row+1;$i<=$row+$this->nr_links_dreapta;$i++) if (($i>0) && ($i<$number_of_pages)) $lnk_dr .= '' . ($i+1) . ''." "; $inapoi = ($row>0) ? '' . $this->str_previous . ''." " : ""; $inainte = ($row < $number_of_pages-1) ? '' . $this->str_next . ''." " : ""; $centru = "".($row+1).""; $links = $inapoi." ".$lnk_stg." ".$centru." ".$lnk_dr." ".$inainte; return $links; break; } //for ($i = 0; $i < $number_of_pages; $i++) { //if ($row == ($i+1)) $current = $i+1; //$array[0] = '' . $this->str_previous . ''; }} ?>