Пример #1
0
 public function testResolveSortFromStickyData()
 {
     list($sortAttribute, $sortDescending) = SearchUtil::resolveSortFromStickyData('testing', 'testId');
     $this->assertEquals(null, $sortAttribute);
     $this->assertFalse($sortDescending);
     $_GET['testing_sort'] = 'name';
     list($sortAttribute, $sortDescending) = SearchUtil::resolveSortFromStickyData('testing', 'testId');
     $this->assertEquals('name', $sortAttribute);
     $this->assertFalse($sortDescending);
     $_GET = array();
     list($sortAttribute, $sortDescending) = SearchUtil::resolveSortFromStickyData('testing', 'testId');
     $this->assertEquals('name', $sortAttribute);
     $this->assertFalse($sortDescending);
     $_GET['testing_sort'] = 'other.desc';
     list($sortAttribute, $sortDescending) = SearchUtil::resolveSortFromStickyData('testing', 'testId');
     $this->assertEquals('other', $sortAttribute);
     $this->assertTrue($sortDescending);
     $_GET = array();
     list($sortAttribute, $sortDescending) = SearchUtil::resolveSortFromStickyData('testing', 'testId');
     $this->assertEquals('other', $sortAttribute);
     $this->assertTrue($sortDescending);
 }
Пример #2
0
 protected function makeDataProviderBySearchAttributeData($searchAttributeData)
 {
     assert('is_array($searchAttributeData)');
     list($sortAttribute, $sortDescending) = SearchUtil::resolveSortFromStickyData($this->modelClassName, $this->uniqueLayoutId);
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('dashboardListPageSize');
     $redBeanModelDataProvider = new RedBeanModelDataProvider($this->modelClassName, $sortAttribute, $sortDescending, $searchAttributeData, array('pagination' => array('pageSize' => $pageSize)));
     $sort = new RedBeanSort($redBeanModelDataProvider->modelClassName);
     $sort->sortVar = $redBeanModelDataProvider->getId() . '_sort';
     $sort->route = 'default/index';
     $redBeanModelDataProvider->setSort($sort);
     return $redBeanModelDataProvider;
 }
Пример #3
0
 protected function makeDataProviderBySearchAttributeData($searchAttributeData)
 {
     assert('is_array($searchAttributeData)');
     list($sortAttribute, $sortDescending) = SearchUtil::resolveSortFromStickyData($this->modelClassName, $this->uniqueLayoutId);
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('dashboardListPageSize');
     if ($sortAttribute === null) {
         $sortAttribute = $this->getSortAttributeForDataProvider();
         $sortDescending = $this->resolveSortDescendingForDataProvider();
     }
     $redBeanModelDataProvider = new RedBeanModelDataProvider($this->modelClassName, $sortAttribute, $sortDescending, $searchAttributeData, array('pagination' => array('pageSize' => $pageSize)));
     $sort = new RedBeanSort($redBeanModelDataProvider->modelClassName);
     $sort->sortVar = $redBeanModelDataProvider->getId() . '_sort';
     $sort->route = 'defaultPortlet/myListDetails';
     $sort->params = array_merge(GetUtil::getData(), array('portletId' => $this->params['portletId']));
     $redBeanModelDataProvider->setSort($sort);
     return $redBeanModelDataProvider;
 }