Exemple #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Story::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]);
     $query->andFilterWhere(['like', 'story_name', $this->story_name]);
     return $dataProvider;
 }
Exemple #2
0
 public function actionIndex($id)
 {
     $story = Story::findOne(['id' => $id]);
     $jsonScenes = ['panels' => 20, 'scenes' => []];
     $panels = 0;
     foreach ($story->scenes as $scene) {
         $jsonScenes['scenes'][] = ['duration' => 5, 'start' => $panels, 'chars' => array_map(function ($v) {
             return intval($v);
         }, json_decode($scene->chars)), 'id' => $scene->id - 1, 'scene_name' => $scene->scene_name];
         $panels += 5;
     }
     $jsonScenes['panels'] = $panels;
     // echo '<pre>', print_r($jsonScenes);
     // die;
     $xmlCharacter = '<characters>';
     foreach ($story->characters as $char) {
         $xmlCharacter .= '<character group="' . $char->group_id . '" id="' . $char->id . '" name="' . $char->char_name . '" />';
     }
     $xmlCharacter .= '</characters>';
     $jsonScenes = json_encode($jsonScenes);
     // echo $jsonScenes;
     // die;
     return $this->render('index', compact('jsonScenes', 'xmlCharacter'));
 }
Exemple #3
0
 /**
  * Finds the Story model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Story the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Story::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #4
0
echo $form->field($model, 'scene_name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'start')->textInput();
?>

    <?php 
echo $form->field($model, 'duration')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'chars')->label('Character')->widget(Select2::classname(), ['addon' => ['prepend' => ['content' => '<span class="fa fa-flag" aria-hidden="true"></span> Character']], 'data' => ArrayHelper::map(Character::find()->all(), 'id', 'char_name'), 'options' => ['placeholder' => 'Select Character ...', 'multiple' => true]]);
?>

    <?php 
echo $form->field($model, 'story_id')->label('Story')->widget(Select2::classname(), ['addon' => ['prepend' => ['content' => '<span class="fa fa-flag" aria-hidden="true"></span> Story']], 'data' => ArrayHelper::map(Story::find()->all(), 'id', 'story_name'), 'options' => ['placeholder' => 'Select Story ...']]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>