Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
qiang.xue committed Nov 19, 2009
1 parent c11fafc commit 96788b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
13 changes: 5 additions & 8 deletions framework/web/CActiveDataProvider.php
Expand Up @@ -83,15 +83,14 @@ public function setCriteria($value)

/**
* Fetches the data from the persistent data storage.
* @param boolean whether this call is triggered by an explicit refresh
* @return array list of data items
*/
protected function fetchData($refresh)
protected function fetchData()
{
$criteria=clone $this->getCriteria();
if(($pagination=$this->getPagination())!==false)
{
$pagination->setItemCount($this->getTotalCount($refresh));
$pagination->setItemCount($this->getTotalCount(true));
$pagination->applyLimit($criteria);
}
if(($sort=$this->getSort())!==false)
Expand All @@ -109,15 +108,14 @@ protected function fetchData($refresh)

/**
* Fetches the data item keys from the persistent data storage.
* @param boolean whether this call is triggered by an explicit refresh
* @return array list of data item keys.
*/
protected function fetchKeys($refresh)
protected function fetchKeys()
{
$keys=array();
if($this->keyAttribute===null)
{
foreach($this->getData($refresh) as $i=>$data)
foreach($this->getData() as $i=>$data)
$keys[$i]=$data->getPrimaryKey();
}
else
Expand All @@ -130,10 +128,9 @@ protected function fetchKeys($refresh)

/**
* Calculates the total number of data items.
* @param boolean whether this call is triggered by an explicit refresh
* @return integer the total number of data items.
*/
protected function calculateTotalCount($refresh)
protected function calculateTotalCount()
{
$finder=CActiveRecord::model($this->modelClass);
if($this->with===null)
Expand Down
15 changes: 6 additions & 9 deletions framework/web/CDataProvider.php
Expand Up @@ -21,22 +21,19 @@ abstract class CDataProvider extends CComponent implements IDataProvider

/**
* Fetches the data from the persistent data storage.
* @param boolean whether this call is triggered by an explicit refresh
* @return array list of data items
*/
abstract protected function fetchData($refresh);
abstract protected function fetchData();
/**
* Fetches the data item keys from the persistent data storage.
* @param boolean whether this call is triggered by an explicit refresh
* @return array list of data item keys.
*/
abstract protected function fetchKeys($refresh);
abstract protected function fetchKeys();
/**
* Calculates the total number of data items.
* @param boolean whether this call is triggered by an explicit refresh
* @return integer the total number of data items.
*/
abstract protected function calculateTotalCount($refresh);
abstract protected function calculateTotalCount();

/**
* @return string the unique ID that uniquely identifies the data provider among all data providers.
Expand Down Expand Up @@ -122,7 +119,7 @@ public function setSort($value)
public function getData($refresh=false)
{
if($this->_data===null || $refresh)
$this->_data=$this->fetchData($refresh);
$this->_data=$this->fetchData();
return $this->_data;
}

Expand All @@ -143,7 +140,7 @@ public function setData($value)
public function getKeys($refresh=false)
{
if($this->_keys===null || $refresh)
$this->_keys=$this->fetchKeys($refresh);
$this->_keys=$this->fetchKeys();
return $this->_keys;
}

Expand All @@ -166,7 +163,7 @@ public function setKeys($value)
public function getTotalCount($refresh=false)
{
if($this->_totalCount===null || $refresh)
$this->_totalCount=$this->calculateTotalCount($refresh);
$this->_totalCount=$this->calculateTotalCount();
return $this->_totalCount;
}
}

0 comments on commit 96788b7

Please sign in to comment.