Example #1
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'));
 }
Example #2
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.');
     }
 }