Skip to content

Commit

Permalink
Merge pull request #1547 from Ryadnov/1546-cdataprovider-bugfix
Browse files Browse the repository at this point in the history
CDataProvider bugfix
  • Loading branch information
samdark committed Oct 9, 2012
2 parents 7cc307d + 83c92d5 commit dcb7524
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
5 changes: 3 additions & 2 deletions framework/web/CActiveDataProvider.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ public function setCriteria($value)


/** /**
* Returns the sorting object. * Returns the sorting object.
* @param string $className the sorting object class name. Parameter is available since version 1.1.13.
* @return CSort the sorting object. If this is false, it means the sorting is disabled. * @return CSort the sorting object. If this is false, it means the sorting is disabled.
*/ */
public function getSort() public function getSort($className='CSort')
{ {
if(($sort=parent::getSort())!==false) if(($sort=parent::getSort($className))!==false)
$sort->modelClass=$this->modelClass; $sort->modelClass=$this->modelClass;
return $sort; return $sort;
} }
Expand Down
22 changes: 18 additions & 4 deletions framework/web/CDataProvider.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getPagination($className='CPagination')
* @param mixed $value the pagination to be used by this data provider. This could be a {@link CPagination} object * @param mixed $value the pagination to be used by this data provider. This could be a {@link CPagination} object
* or an array used to configure the pagination object. If this is false, it means the pagination should be disabled. * or an array used to configure the pagination object. If this is false, it means the pagination should be disabled.
* *
* You can configre this property same way as a component: * You can configure this property same way as a component:
* <pre> * <pre>
* array( * array(
* 'class' => 'MyPagination', * 'class' => 'MyPagination',
Expand All @@ -94,7 +94,14 @@ public function setPagination($value)
{ {
if(is_array($value)) if(is_array($value))
{ {
$pagination=isset($value['class']) ? $this->getPagination($value['class']) : $this->getPagination(); if(isset($value['class']))
{
$pagination=$this->getPagination($value['class']);
unset($value['class']);
}
else
$pagination=$this->getPagination();

foreach($value as $k=>$v) foreach($value as $k=>$v)
$pagination->$k=$v; $pagination->$k=$v;
} }
Expand Down Expand Up @@ -123,7 +130,7 @@ public function getSort($className='CSort')
* @param mixed $value the sorting to be used by this data provider. This could be a {@link CSort} object * @param mixed $value the sorting to be used by this data provider. This could be a {@link CSort} object
* or an array used to configure the sorting object. If this is false, it means the sorting should be disabled. * or an array used to configure the sorting object. If this is false, it means the sorting should be disabled.
* *
* You can configre this property same way as a component: * You can configure this property same way as a component:
* <pre> * <pre>
* array( * array(
* 'class' => 'MySort', * 'class' => 'MySort',
Expand All @@ -135,7 +142,14 @@ public function setSort($value)
{ {
if(is_array($value)) if(is_array($value))
{ {
$sort=isset($value['class']) ? $this->getSort($value['class']) : $this->getSort(); if(isset($value['class']))
{
$sort=$this->getSort($value['class']);
unset($value['class']);
}
else
$sort=$this->getSort();

foreach($value as $k=>$v) foreach($value as $k=>$v)
$sort->$k=$v; $sort->$k=$v;
} }
Expand Down

0 comments on commit dcb7524

Please sign in to comment.