[xoops-cvslog 4946] CVS update: xoops2jp/html/modules/base/class

Back to archive index

Minahito minah****@users*****
2006年 10月 12日 (木) 20:03:16 JST


Index: xoops2jp/html/modules/base/class/AbstractFilterForm.class.php
diff -u xoops2jp/html/modules/base/class/AbstractFilterForm.class.php:1.1.2.6 xoops2jp/html/modules/base/class/AbstractFilterForm.class.php:1.1.2.6.2.1
--- xoops2jp/html/modules/base/class/AbstractFilterForm.class.php:1.1.2.6	Wed Aug  2 18:46:08 2006
+++ xoops2jp/html/modules/base/class/AbstractFilterForm.class.php	Thu Oct 12 20:03:16 2006
@@ -7,21 +7,50 @@
 	var $mSort = 0;
 	var $mSortKeys = array();
 	var $_mCriteria = null;
-	var $_mNavi = null;
-
-	function Legacy_AbstractFilterForm(&$navi)
+	var $mNavi = null;
+	
+	var $_mHandler = null;
+	
+	function Legacy_AbstractFilterForm(&$navi, &$handler)
 	{
-		$this->_mNavi =& $navi;
+		$this->mNavi =& $navi;
+		$this->_mHandler =& $handler;
+		
 		$this->_mCriteria =& new CriteriaCompo();
+		
+		$this->mNavi->mGetTotalItems->add(array(&$this, 'getTotalItems'));
+	}
+	
+	function getDefaultSortKey()
+	{
+	}
+	
+	function getTotalItems(&$total)
+	{
+		$total = $this->_mHandler->getCount($this->getCriteria());
+	}
+	
+	function fetchSort()
+	{
+		$root =& XCube_Root::getSingleton();
+		$this->mSort = intval($root->mContext->mRequest->getRequest('sort'));
+		
+		if (!isset($this->mSortKeys[abs($this->mSort)])) {
+			$this->mSort = $this->getDefaultSortKey();
+		}
+		
+		$this->mNavi->mSort['sort'] = $this->mSort;
 	}
 
 	function fetch()
 	{
+		$this->mNavi->fetch();
+		$this->fetchSort();
 	}
-
+	
 	function getSort()
 	{
-		$sortkey = abs($this->mSort);
+		$sortkey = abs($this->mNavi->mSort['sort']);
 		return isset($this->mSortKeys[$sortkey]) ? $this->mSortKeys[$sortkey] : null;
 	}
 
@@ -30,12 +59,15 @@
 		return ($this->mSort < 0) ? "DESC" : "ASC";
 	}
 
-	function getCriteria($start = 0, $limit = 0)
+	function getCriteria($start = null, $limit = null)
 	{
+		$t_start = ($start === null) ? $this->mNavi->getStart() : intval($start);
+		$t_limit = ($limit === null) ? $this->mNavi->getPerpage() : intval($limit);
+		
 		$criteria = $this->_mCriteria;
 		
-		$criteria->setStart($start);
-		$criteria->setLimit($limit);
+		$criteria->setStart($t_start);
+		$criteria->setLimit($t_limit);
 		
 		return $criteria;
 	}
Index: xoops2jp/html/modules/base/class/AbstractListAction.class.php
diff -u xoops2jp/html/modules/base/class/AbstractListAction.class.php:1.1.2.2 xoops2jp/html/modules/base/class/AbstractListAction.class.php:1.1.2.2.2.1
--- xoops2jp/html/modules/base/class/AbstractListAction.class.php:1.1.2.2	Tue Mar 28 22:29:21 2006
+++ xoops2jp/html/modules/base/class/AbstractListAction.class.php	Thu Oct 12 20:03:16 2006
@@ -7,36 +7,34 @@
 class Legacy_AbstractListAction extends Legacy_Action
 {
 	var $mObjects = array();
+	
 	var $mFilter = null;
-	var $mNavi = null;
 
 	function &_getHandler()
 	{
 	}
 
-	function &_getFilterForm(&$navi)
+	function &_getFilterForm()
 	{
 	}
 
 	function _getBaseUrl()
 	{
 	}
+	
+	function &_getPageNavi()
+	{
+		$navi =& new XCube_PageNavigator($this->_getBaseUrl(), XCUBE_PAGENAVI_START);
+		return $navi;
+	}
 
 	function getDefaultView(&$controller, &$xoopsUser)
 	{
-		$this->mNavi =& new Legacy_PageNavigator($this->_getBaseUrl(), 0, XCUBE_PAGENAVI_START | XCUBE_PAGENAVI_PERPAGE);
-		
-		$this->mFilter =& $this->_getFilterForm($this->mNavi);
+		$this->mFilter =& $this->_getFilterForm();
 		$this->mFilter->fetch();
-		$handler =& $this->_getHandler();
 		
-		$total = $handler->getCount($this->mFilter->getCriteria());
-		
-		$this->mNavi->setTotal($total);
-		$this->mNavi->fetch();
-		
-		$criteria = $this->mFilter->getCriteria($this->mNavi->getStart(), $this->mNavi->getPerpage());
-		$this->mObjects =& $handler->getObjects($criteria);
+		$handler =& $this->_getHandler();
+		$this->mObjects =& $handler->getObjects($this->mFilter->getCriteria());
 		
 		return LEGACY_FRAME_VIEW_INDEX;
 	}


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