[xoops-cvslog 1784] CVS update: xoops2jp/html/class

Back to archive index

Minahito minah****@users*****
2006年 1月 15日 (日) 21:11:11 JST


Index: xoops2jp/html/class/XCube_PageNavigator.class.php
diff -u xoops2jp/html/class/XCube_PageNavigator.class.php:1.1.2.6 xoops2jp/html/class/XCube_PageNavigator.class.php:1.1.2.7
--- xoops2jp/html/class/XCube_PageNavigator.class.php:1.1.2.6	Sun Dec 25 19:50:53 2005
+++ xoops2jp/html/class/XCube_PageNavigator.class.php	Sun Jan 15 21:11:11 2006
@@ -10,7 +10,10 @@
 {
 	var $mStart=0;
 	var $mTotal=0;
+
 	var $mPerpage = 20;
+	var $mPerpageFreeze = false;
+	
 	var $mUrl=null;
 	
 	var $mPrefix = null;
@@ -19,7 +22,7 @@
 	
 	var $mFlags=0;
 
-	function XCube_PageNavigator($url, $total, $flags=0)
+	function XCube_PageNavigator($url, $total=0, $flags=0)
 	{
 		$this->mUrl = $url;
 		$this->setTotal($total);
@@ -35,7 +38,7 @@
 			$this->mStart = intval($_REQUEST[$startKey]);
 		}
 
-		if ($this->mFlags & XCUBE_PAGENAVI_PERPAGE && isset($_REQUEST[$perpageKey])) {
+		if ($this->mFlags & XCUBE_PAGENAVI_PERPAGE && isset($_REQUEST[$perpageKey]) && !$this->mPerpageFreeze) {
 			$this->mPerpage = intval($_REQUEST[$perpageKey]);
 		}
 	}
@@ -45,43 +48,74 @@
 		$this->mExtra[$key]=$value;
 	}
 	
-	/**
-	 * Return url string for navigation. The return value is lose start value.
-	 * The user need to add start value. For example, It is "$navi->getRenderUrl().'20'".
-	 * This method name is bad. I must rename this.
-	 * @return string
-	 */
-	function getRenderUrl()
+	function removeExtra($key)
 	{
-		if(count($this->mExtra)) {
-			$url=$this->mUrl;
+		if ($this->mExtra[$key]) {
+			unset($this->mExtra[$key]);
+		}
+	}
+	
+	function getRenderBaseUrl($mask = null)
+	{
+		if ($mask == null) {
+			$mask = array();
+		}
+		if (!is_array($mask)) {
+			$mask = array($mask);
+		}
+		
+		if(count($this->mExtra) > 0) {
 			$tarr=array();
+			
 			foreach($this->mExtra as $key=>$value) {
-				$tarr[]=$key."=".urlencode($value);
-			}
-			if(strpos($this->mUrl,"?")!==false) {
-				return $this->mUrl."&".implode("&",$tarr)."&" . $this->getStartKey() . "=";
+				if (is_array($mask) && !isset($mask[$key])) {
+					$tarr[]=$key."=".urlencode($value);
+				}
 			}
-			else {
-				return $this->mUrl."?".implode("&",$tarr)."&" . $this->getStartKey() . "=";
+			
+			if (count($tarr)==0) {
+				return $this->mUrl;
 			}
-		}
-		else {
+			
 			if(strpos($this->mUrl,"?")!==false) {
-				return $this->mUrl."&" . $this->getStartKey() . "=";
+				return $this->mUrl."&".implode("&",$tarr);
 			}
 			else {
-				return $this->mUrl."?" . $this->getStartKey() . "=";
+				return $this->mUrl."?".implode("&",$tarr);
 			}
 		}
+		
+		return $this->mUrl;
+	}
+	
+	/**
+	 * Return url string for navigation. The return value is lose start value.
+	 * The user need to add start value. For example, It is "$navi->getRenderUrl().'20'".
+	 * This method name is bad. I must rename this.
+	 * @return string
+	 */
+	function getRenderUrl($mask = null)
+	{
+		if ($mask != null && is_array($mask)) {
+			$mask = array($mask);
+		}
+		
+		$demiliter = "?";
+		$url = $this->getRenderBaseUrl($mask);
+		
+		if(strpos($url,"?")!==false) {
+			$demiliter = "&";
+		}
+		
+		return $url . $demiliter . $this->getStartKey() . "=";
 	}
 	
 	/**
 	 * Return url string for sort. The return value is complete style.
 	 */
-	function renderSortUrl()
+	function renderSortUrl($mask = null)
 	{
-		return $this->getRenderUrl() . $this->mStart;
+		return $this->getRenderUrl($mask) . $this->mStart;
 	}
 
 	function setStart($start)
@@ -109,6 +143,11 @@
 		$this->mPerpage = intval($perpage);
 	}
 	
+	function freezePerpage()
+	{
+		$this->mPerpageFreeze = true;
+	}
+	
 	function getPerpage()
 	{
 		return $this->mPerpage;


xoops-cvslog メーリングリストの案内
Back to archive index