package com.tarena.oss.util;

public class PageParameter {
public static final int CNT_EACH_PAGE = 4; 
	
	public static String pageNavigator(int currentPage, int totalPages, String url){
		StringBuffer sb = new StringBuffer();
		sb.append("第").append(currentPage).append("页/共");
		sb.append(totalPages).append("页&nbsp;&nbsp;<a href='");
		sb.append(url);
		
		String pageStr = "";
		if (url.indexOf("?") == -1 )
			pageStr = "?page=";
		else
			pageStr = "&page=";
		
		sb.append(pageStr).append(1).append("'>|第一页</a>|<a href='");
		sb.append(url).append(pageStr).append(currentPage-1<=0 ? 1 : currentPage-1);
		sb.append("'>上一页</a>|<a href='");
		sb.append(url).append(pageStr).append(currentPage+1 >= totalPages ? totalPages : currentPage+1);
		sb.append("'>下一页</a>|<a href='");
		sb.append(url).append(pageStr).append(totalPages);
		sb.append("'>最后一页</a>|");
		
		return sb.toString();
	}
}
