/** * Manages all models. */ public function actionAdmin() { $model = new AdminGenreModel('search'); $model->unsetAttributes(); if (isset($_GET['AdminGenreModel'])) { $model->setAttributes($_GET['AdminGenreModel']); } $this->render('admin', array('model' => $model)); }
public function actionAddItems() { $channelId = Yii::app()->request->getParam('channel_id', 0); $type = AdminRadioModel::model()->findByPk($channelId)->type; $flag = true; if (Yii::app()->getRequest()->ispostRequest) { $flag = false; $collInRadio = AdminRadioCollectionModel::model()->findAll("radio_id=:radio_id", array(':radio_id' => $channelId)); $collData = CHtml::listData($collInRadio, 'id', 'collection_id'); $contentId = Yii::app()->request->getParam('cid'); for ($i = 0; $i < count($contentId); $i++) { if (!in_array($contentId[$i], $collData)) { $model = new AdminRadioCollectionModel(); $model->collection_id = $contentId[$i]; $model->radio_id = $channelId; $model->created_time = date('Y-m-d H:i:s'); $model->save(); } } //AdminAlbumModel::model()->updateTotalSong($albumId); } if ($flag) { Yii::app()->user->setState('pageSize', 20); if ($type == 'artist') { //artist $CollModel = new AdminArtistModel('search'); $CollModel->unsetAttributes(); if (isset($_GET['AdminArtistModel'])) { $CollModel->attributes = $_GET['AdminArtistModel']; } $CollModel->setAttribute("status", 1); Yii::app()->clientScript->scriptMap['jquery.js'] = false; $this->renderPartial('_addItemsArtist', array('CollModel' => $CollModel, 'channelId' => $channelId), false, true); } elseif ($type == 'genre') { //genre $CollModel = new AdminGenreModel('search'); $CollModel->unsetAttributes(); if (isset($_GET['AdminSongModel'])) { $CollModel->attributes = $_GET['AdminSongModel']; } $CollModel->setAttribute("status", 1); Yii::app()->clientScript->scriptMap['jquery.js'] = false; $this->renderPartial('_addItemsArtist', array('CollModel' => $CollModel, 'channelId' => $channelId), false, true); } elseif ($type == 'playlist') { $CollModel = new AdminPlaylistModel('search'); $CollModel->unsetAttributes(); if (isset($_GET['AdminPlaylistModel'])) { $CollModel->attributes = $_GET['AdminPlaylistModel']; } $CollModel->setAttribute("status", 1); Yii::app()->clientScript->scriptMap['jquery.js'] = false; $this->renderPartial('_addItemsPlaylist', array('CollModel' => $CollModel, 'channelId' => $channelId), false, true); } elseif ($type == 'album') { $CollModel = new AdminAlbumModel('search'); $CollModel->unsetAttributes(); if (isset($_GET['AdminAlbumModel'])) { $CollModel->attributes = $_GET['AdminAlbumModel']; } $CollModel->setAttribute("status", 1); Yii::app()->clientScript->scriptMap['jquery.js'] = false; $this->renderPartial('_addItemsAlbum', array('CollModel' => $CollModel, 'channelId' => $channelId), false, true); } else { //channel $CollModel = new AdminCollectionModel('newsearch'); $CollModel->unsetAttributes(); if (isset($_GET['AdminSongModel'])) { $CollModel->attributes = $_GET['AdminSongModel']; } $CollModel->setAttribute("status", 1); $CollModel->_onlySong = true; Yii::app()->clientScript->scriptMap['jquery.js'] = false; $this->renderPartial('_addItems', array('CollModel' => $CollModel, 'channelId' => $channelId), false, true); } } }