Minahito
minah****@users*****
2006年 4月 11日 (火) 15:12:15 JST
Index: xoops2jp/html/class/criteria.php diff -u xoops2jp/html/class/criteria.php:1.2.8.5 xoops2jp/html/class/criteria.php:1.2.8.6 --- xoops2jp/html/class/criteria.php:1.2.8.5 Tue Apr 11 14:28:48 2006 +++ xoops2jp/html/class/criteria.php Tue Apr 11 15:12:15 2006 @@ -1,5 +1,5 @@ <?php -// $Id: criteria.php,v 1.2.8.5 2006/04/11 05:28:48 minahito Exp $ +// $Id: criteria.php,v 1.2.8.6 2006/04/11 06:12:15 minahito Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -69,12 +69,12 @@ * Sort order * @var string */ - var $order = 'ASC'; + var $order = array(); /** * @var string */ - var $sort = ''; + var $sort = array(); /** * Number of records to retrieve @@ -159,30 +159,83 @@ */ /** * @param string $sort + * @param string $order */ - function setSort($sort) + function setSort($sort, $order = null) { - $this->sort = $sort; + $this->sort[0] = $sort; + $this->order[0] = 'ASC'; + if ($order != null) { + if (strtoupper($order) == 'ASC') { + $this->order[0] = 'ASC'; + } + elseif (strtoupper($order) == 'DESC') { + $this->order[0] = 'DESC'; + } + } } + + /** + * Add sort and order condition to this object. + */ + function addSort($sort, $order = 'ASC') + { + $this->sort[] = $sort; + if (strtoupper($order) == 'ASC') { + $this->order[] = 'ASC'; + } + elseif (strtoupper($order) == 'DESC') { + $this->order[] = 'DESC'; + } + } /** * @return string */ function getSort() { - return $this->sort; + if (isset($this->sort[0])) { + return $this->sort[0]; + } + else { + return ''; + } } + /** + * Return sort and order condition as hashmap array. + * + * @return hashmap 'sort' ... sort string/key'order' order string. + */ + function getSorts() + { + $ret = array(); + $max = count($this->sort); + + for ($i = 0; $i < $max; $i++) { + $ret[$i]['sort'] = $this->sort[$i]; + if (isset($this->order[$i])) { + $ret[$i]['order'] = $this->order[$i]; + } + else { + $ret[$i]['order'] = 'ASC'; + } + } + + return $ret; + } + /** * @param string $order + * @deprecated */ function setOrder($order) { if (strtoupper($order) == 'ASC') { - $this->order = 'ASC'; + $this->order[0] = 'ASC'; } elseif (strtoupper($order) == 'DESC') { - $this->order = 'DESC'; + $this->order[0] = 'DESC'; } } @@ -191,7 +244,12 @@ */ function getOrder() { - return $this->order; + if (isset($this->order[0])) { + return $this->order[0]; + } + else { + return 'ASC'; + } } /**