Permalink
Browse files

Merge pull request #1547 from Ryadnov/1546-cdataprovider-bugfix

CDataProvider bugfix
  • Loading branch information...
2 parents 7cc307d + 83c92d5 commit dcb752416e7b197adb0322860fc88b384a69bbae @samdark samdark committed Oct 9, 2012
Showing with 21 additions and 6 deletions.
  1. +3 −2 framework/web/CActiveDataProvider.php
  2. +18 −4 framework/web/CDataProvider.php
@@ -106,11 +106,12 @@ public function setCriteria($value)
/**
* 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.
*/
- public function getSort()
+ public function getSort($className='CSort')
{
- if(($sort=parent::getSort())!==false)
+ if(($sort=parent::getSort($className))!==false)
$sort->modelClass=$this->modelClass;
return $sort;
}
@@ -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
* 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>
* array(
* 'class' => 'MyPagination',
@@ -94,7 +94,14 @@ public function setPagination($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)
$pagination->$k=$v;
}
@@ -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
* 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>
* array(
* 'class' => 'MySort',
@@ -135,7 +142,14 @@ public function setSort($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)
$sort->$k=$v;
}

0 comments on commit dcb7524

Please sign in to comment.