[xoops-cvslog 4951] CVS update: xoops2jp/html/modules/legacyRender/class

Zurück zum Archiv-Index

Minahito minah****@users*****
2006年 10月 12日 (木) 22:56:31 JST


Index: xoops2jp/html/modules/legacyRender/class/AbstractListAction.class.php
diff -u xoops2jp/html/modules/legacyRender/class/AbstractListAction.class.php:1.1.2.1 xoops2jp/html/modules/legacyRender/class/AbstractListAction.class.php:1.1.2.1.2.1
--- xoops2jp/html/modules/legacyRender/class/AbstractListAction.class.php:1.1.2.1	Mon Apr 24 16:31:08 2006
+++ xoops2jp/html/modules/legacyRender/class/AbstractListAction.class.php	Thu Oct 12 22:56:31 2006
@@ -2,41 +2,38 @@
 
 if (!defined('XOOPS_ROOT_PATH')) exit();
 
-require_once XOOPS_MODULE_PATH . "/legacyRender/class/PageNavigator.class.php";
+require_once XOOPS_ROOT_PATH . "/core/XCube_PageNavigator.class.php";
 
 class LegacyRender_AbstractListAction extends LegacyRender_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 LegacyRender_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 LEGACYRENDER_FRAME_VIEW_INDEX;
 	}
Index: xoops2jp/html/modules/legacyRender/class/AbstractFilterForm.class.php
diff -u xoops2jp/html/modules/legacyRender/class/AbstractFilterForm.class.php:1.1.2.2 xoops2jp/html/modules/legacyRender/class/AbstractFilterForm.class.php:1.1.2.2.2.1
--- xoops2jp/html/modules/legacyRender/class/AbstractFilterForm.class.php:1.1.2.2	Mon Jul 10 15:08:31 2006
+++ xoops2jp/html/modules/legacyRender/class/AbstractFilterForm.class.php	Thu Oct 12 22:56:31 2006
@@ -7,21 +7,50 @@
 	var $mSort = 0;
 	var $mSortKeys = array();
 	var $_mCriteria = null;
-	var $_mNavi = null;
-
-	function LegacyRender_AbstractFilterForm(&$navi)
+	var $mNavi = null;
+	
+	var $_mHandler = null;
+	
+	function LegacyRender_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;
 	}


xoops-cvslog メーリングリストの案内
Zurück zum Archiv-Index