Example #1
0
 public function actionCreate()
 {
     $video = new Video();
     $video->loadDefaultValues();
     $video->videoId = '146751001';
     $video->mobileLink = "https://player.vimeo.com/external/146751001.mobile.mp4?s=0b43d0d45d443d1850e290c950ab621e977d5cb2&profile_id=116";
     $video->sdLink = "https://player.vimeo.com/external/146751001.sd.mp4?s=ae3d3e9818788730b24d5aafa31fd10d6cee87b0&profile_id=112";
     $video->hlsLink = "https://player.vimeo.com/external/146751001.m3u8?p=high,standard,mobile&s=5100ac376ddb43addfe9e185b93075eb83ffd519";
     $video->embed = "<iframe src=\"https://player.vimeo.com/video/146751001?title=0&byline=0&portrait=0&badge=0&autopause=0&player_id=0\" width=\"854\" height=\"480\" frameborder=\"0\" title=\"EVAW LoRes\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
     $video->duration = 221;
     $video->poster = "https://i.vimeocdn.com/video/545226406_640x360.jpg?r=pad";
     $video->size = 10;
     $video->created_by = 7;
     $video->updated_by = 7;
     $video->save();
     $cb = new CodeBankCampaign();
     $cb->loadDefaultValues();
     $cb->name = 'Violence Against Women';
     $cb->modelClass = 'Video';
     $cb->objectId = $video->id;
     $cb->codeBank_code = 'EVAW';
     $cb->created_by = 7;
     $cb->updated_by = 7;
     $cb->save();
     echo "Done\n";
 }
Example #2
0
 /**
  * Displays profile homepage.
  *
  * @return mixed
  */
 public function actionIndex($code = null)
 {
     $codes = Yii::$app->user->identity->availableCodes;
     $allCodes = array_merge($codes, Yii::$app->user->identity->availableGroupCodes);
     $campaigns = CodeBankCampaign::find()->where(['codeBank_code' => $allCodes])->all();
     $model = CodeBank::find()->where(['code' => $codes])->all();
     return $this->render('index', ['model' => $model, 'roleOptions' => $this->roleOptions, 'allCodes' => $allCodes, 'selectedCode' => $code, 'campaigns' => $campaigns]);
 }
Example #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CodeBankCampaign::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'objectId' => $this->objectId, 'startDate' => $this->startDate, 'endDate' => $this->endDate, 'active' => $this->active, 'codeBank_code' => $this->codeBank_code]);
     //        $query->andFilterWhere(['like', 'codeBank_code', $this->codeBank_code])
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'modelClass', $this->modelClass]);
     return $dataProvider;
 }
Example #4
0
 public function actionStep()
 {
     $model = new Question();
     $answers = [];
     $count = count(Yii::$app->request->post('Answer', []));
     $codeBankCampaign = new CodeBankCampaign();
     $codeBankCampaign->load(Yii::$app->request->post());
     if (Yii::$app->request->isPost && $model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($count > 0) {
             if ($model->qType === '1') {
                 $temp = Yii::$app->request->post('Answer', []);
                 $count = count($temp['answer']);
                 for ($i = 0; $i < $count; $i++) {
                     $answer = new Answer();
                     $answer->scenario = 'objective';
                     $answer->answer = $temp['answer'][$i];
                     $answer->correctObjective = $temp['correctObjective'][$i];
                     $answer->validate();
                     $answers[] = $answer;
                 }
             }
         }
     }
     return $this->render('step', ['model' => $model, 'codeBankCampaign' => $codeBankCampaign, 'answers' => $answers]);
 }
Example #5
0
 public function actionConfirmed()
 {
     $codeBankCampaign = new CodeBankCampaign();
     $codeBankCampaign->loadDefaultValues();
     $video = new Video();
     $video->loadDefaultValues();
     $request = Yii::$app->request;
     if ($request->isPost) {
         $lib = new Vimeo(Yii::$app->params['vimeoClientId'], Yii::$app->params['vimeoSecret'], Yii::$app->params['vimeoAccessToken']);
         if ($codeBankCampaign->load($request->post()) && $video->load($request->post())) {
             $response = $lib->request('/me/videos/' . $video->videoId, [], 'GET');
             $video->duration = $response['body']['duration'];
             $video->embed = $response['body']['embed']['html'];
             $video->poster = $response['body']['pictures']['sizes'][3]['link'];
             $files = $response['body']['files'];
             foreach ($files as $key => $value) {
                 switch ($value['quality']) {
                     case 'mobile':
                         $video->mobileLink = $value['link'];
                         break;
                     case 'sd':
                         $video->sdLink = $value['link'];
                         break;
                     case 'hls':
                         $video->hlsLink = $value['link'];
                         break;
                 }
             }
             if (isset($codeBankCampaign->codeBank_code)) {
                 $video->confirmed = 1;
             }
             $video->save();
             $codeBankCampaign->objectId = $video->id;
             $codeBankCampaign->save();
             //                $view = $this->getView();
             //                $view->title = 'Step 3: Editing Video Information for Hyrizy Code ' . Html::tag('label',$codeBankCampaign->codeBank_code,['class'=>'label label-primary']);
             //                return $this->render('update',['model'=>$video]);
             return $this->redirect(['/campaign/view', 'id' => $codeBankCampaign->id]);
         }
     }
 }
Example #6
0
 public function actionConfirmed()
 {
     $codeBankCampaign = new CodeBankCampaign();
     $codeBankCampaign->loadDefaultValues();
     $review = new Review();
     $review->loadDefaultValues();
     $request = Yii::$app->request;
     if ($request->isPost && $codeBankCampaign->load($request->post()) && $review->load($request->post())) {
         $isValid = $codeBankCampaign->validate();
         $isValid = $review->validate() && $isValid;
         if ($isValid) {
             if ($review->save()) {
                 $codeBankCampaign->objectId = $review->id;
                 $codeBankCampaign->save();
                 return $this->redirect(['/campaign/index']);
             }
         }
     }
     return $this->render('step', ['model' => $review, 'codeBankCampaign' => $codeBankCampaign]);
 }
Example #7
0
 /**
  * Finds the CodeBankCampaign model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CodeBankCampaign the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CodeBankCampaign::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }