Example #1
0
 public function actionIndex()
 {
     $game = Game::model()->with('movies')->findByTextId('wow');
     //        dump($game);
     //        dump(User\Role::model()->findByPk(1)->users);
     //        dump($_SESSION);
     //        echo '<hr>';
     //
     //        $movie = Movie::model()->with('game')->findByPk(1);
     //        d(simplexml_load_string(gzinflate($movie->mediaInfo->data)));
     //        echo '<hr>';
     //
     //        d($movie->images);
     //        echo '<hr>';
     //
     //        dump($movie->storage);
     //        echo '<hr>';
     //
     //        dump(Yii::getPathOfAlias('ext'));
     //        echo '<hr>';
     //
     //        echo date(DateTime::ATOM);
     //        echo '<hr>';
     //
     //        $this->render('/dummy');
     $this->render('index');
 }
Example #2
0
 public function setAttributesByPost($postData = array())
 {
     parent::setAttributesByPost($postData);
     if (!$this->gameId) {
         $game = Game::model()->findByAttributes(array('title' => $this->gameTitle));
         if ($game) {
             $this->gameId = $game->id;
         }
     }
 }
Example #3
0
 public function actionCreate($gameId = null)
 {
     $movie = new Movie();
     $game = Game::model()->findByPk($gameId) ?: new Game();
     $movieForm = new Form\Movie(self::SCENARIO_CREATE, array('movie' => $movie, 'game' => $game));
     $this->_tryAjaxValidation($movieForm);
     $backUrl = $this->_getBackUrl();
     if (Yii::app()->getRequest()->getIsPostRequest()) {
         $movieForm->setAttributesByPost();
         if ($movieForm->save()) {
             $this->redirect($backUrl);
         }
     }
     $this->render('create', array('movieForm' => $movieForm, 'backUrl' => $backUrl));
 }
 /**
  * @param string $search Поисковая строка
  * @param bool $expand Возвращать расширенные данные
  */
 public function actionGetGameList($search = '', $expand = false)
 {
     $search = $this->_prepareSearchString($search);
     $criteria = new CDbCriteria();
     $criteria->addSearchCondition('t.title', $search);
     // %search%
     $criteria->order = 't.title ASC';
     $games = Game::model()->findAll($criteria);
     $data = array();
     if ($expand) {
         foreach ($games as $game) {
             $data[] = array('title' => $game->title, 'id' => $game->id);
         }
     } else {
         foreach ($games as $game) {
             $data[] = $game->title;
         }
     }
     $this->_sendAnswer($data);
 }
Example #5
0
 private function _getModelById($id, $with = array())
 {
     $model = Game::model()->with($with)->findByPk($id);
     if (!$model) {
         // TODO: Сделать нормальное исключение
         throw new \CHttpException(404, 'Модель не найдена');
     }
     return $model;
 }