public static function getRecentItems() { if (!isset(self::$_recentItems)) { // inefficient, but n is small self::$_recentItems = User::model()->getRecentItems(function ($item) { return in_array($item['type'], array('a', 'b', 'c', 'l', 'o', 'q', 'r', 's')); }); foreach (self::$_recentItems as &$item) { // satisfy CListView by adding key field $item['id'] = $item['model']->id; } } return self::$_recentItems; }
public function getRecentItems($pageSize = 1) { $dataProvider = MobileRecentItems::getDataProvider($pageSize); $data = array_map(function ($record) { $item = new RecentItemPanelItem(); $item->model = $record['model']; return $item; }, $dataProvider->getData()); if (count($data) < count(MobileRecentItems::getRecentItems())) { $item = new RecentItemPanelItem(); $item->model = 'more'; $data[] = $item; } return $data; }
public function actionRecentItems() { $recentItems = MobileRecentItems::getDataProvider(null); $this->render('recentItems', array('dataProvider' => $recentItems)); }