Location: PHPKode > scripts > Price Comparison Shopping by DataFeedFile > price-comparison-shopping-by-datafeedfile/include/DFF_paging.func.php
<?php
/**************************************************************
*
* DataFeedFile.com (DFF) Framework API
* Copyright (c) 2008 DataFeedFile.com
*
* DFF Framework API uses CreativeCommons.org by-sa license.
* This license lets others remix, tweak, and build upon your work even for commercial reasons,
* as long as they CREDIT DataFeedFile.com and license their new creations under the identical terms.
* This license is often compared to open source software licenses.
* All new works based on yours will carry the same license, so any derivatives will also allow commercial use.
* Please read our license.txt file for more detail.
*
**************************************************************/
/*
* Input $params_array:
*  url_base = URL string
* 	total_page = (integer)
*	current_page = (integer)
*	first_link_enabled = TRUE / FALSE
*	first_link_text = string (default: first page number) (optional)
*	first_link_class = string (css class)
*	prev_link_enabled = TRUE / FALSE
*	prev_link_text = string (example: <<)
*	prev_link_class = string (css class)
*	page_link_to_show = (integer) (must be even number of 2 or greater)
*	page_link_class = string (css class)
*	page_link_active_class = string
*	next_link_enabled = TRUE / FALSE
*	next_link_text = string (example: >>)
*	next_link_class = string (css class)
*	end_link_enabled = TRUE / FALSE
*	end_link_text = string (default: last page number) (optional)
*	end_link_class = string (css class)
*/	
function DFF_create_paging($params_array){
  global $DFF_config;
  //exit('Total page:'.$params_array['total_page'].'<br>');
  preg_match('/([^?]+)\?*/',$_SERVER['REQUEST_URI'],$matches);
  $this_url = $params_array['url_base'].$matches[sizeof($matches)-1];
  $offset_left = $params_array['current_page']-($params_array['page_link_to_show']/2);
  $offset_right = $params_array['current_page']+($params_array['page_link_to_show']/2);
  if($offset_left < 2){
    $offset_left = 2;  
  }
  if($offset_right > $params_array['total_page']-1){
    $offset_right = $params_array['total_page']-1;
  }
  parse_str($_SERVER['QUERY_STRING'],$_GET); 
  $DFF_qs = new DFF_QueryString($_GET);     
  //$output_str .= "Page: ";
  if($params_array['current_page'] == 1){
    $output_str .= '<span class="'.$params_array['page_link_active_class'].'">1</span>';
  }else{
    $DFF_qs->add("dff_page",1);
    $output_str .= '<a class="'.$params_array['page_link_class'].'" href="'.$this_url.$DFF_qs->toString().'">1</a>';
  }
  
  if($offset_left > 2 ){
    $output_str .= "&nbsp;...&nbsp;";
  }
   
  for($i=$offset_left;$i<=$offset_right;$i++){
    if($i==$params_array['current_page']){
      $output_str .= ' <span class="'.$params_array['page_link_active_class'].'">'.$i.'</span>'; 
    }else{
    	$DFF_qs->add("dff_page",$i);
    	$output_str .= ' <a class="'.$params_array['page_link_class'].'" href="'.$this_url.$DFF_qs->toString().'">'.$i.'</a>';
    }    
  }
    
  if($offset_right < ($params_array['total_page']-1) ){
    $output_str .= "&nbsp;...&nbsp;";
  }
     
  if($params_array['total_page'] > 1){
    if($params_array['total_page'] == $params_array['current_page']){
      $output_str .= ' <span class="'.$params_array['page_link_active_class'].'">'.$params_array['total_page'].'</span>';
    }else{
      $DFF_qs->add("dff_page",$params_array['total_page']);
      $output_str .= ' <a class="'.$params_array['page_link_class'].'" href="'.$this_url. $DFF_qs->toString().'">'.$params_array['total_page'].'</a>';
    }
  }
  if($params_array['current_page'] > 1){
    $DFF_qs->add("dff_page",$params_array['current_page'] - 1);
    $output_str = '<a href="'.$this_url.$DFF_qs->toString() .'" class="'.$params_array['prev_link_class'].'"> '.$params_array['prev_link_text'].'</a>&nbsp;'.$output_str;
  }    
  if($params_array['current_page'] < $params_array['total_page']){
    $DFF_qs->add("dff_page",$params_array['current_page'] + 1);    
    $output_str .= '&nbsp;<a href="'.$this_url .$DFF_qs->toString() .'" class="'.$params_array['next_link_class'].'">'.$params_array['next_link_text'] .' </a>';  
  }else{
   // $output_str .= ' <span style="color:#888888">| Next</span>';  
  }
  //$output_str =  ;
  $output_str = '<span class="'.$classname.'">'. $output_str.'</span>';
  return $output_str;
  	
}

?>
Return current item: Price Comparison Shopping by DataFeedFile