Beispiel #1
0
 protected function read($id)
 {
     $id = explode(",", $id);
     if ($storyData = $this->model->getStory($id[0], @$id[1])) {
         $story = $id[0];
         if (empty($id[1]) and $storyData['chapters'] > 1) {
             $id[1] = "toc";
         }
         if (isset($id[1]) and $id[1] == "reviews") {
             $content = "*No reviews found";
             $tocData = $this->model->getMiniTOC($story);
             if ($reviewData = $this->model->loadReviews($story)) {
                 $content = \View\Story::buildReviews($reviewData);
             }
         } elseif (isset($id[1]) and $id[1] == "toc" and $storyData['chapters'] > 1) {
             $tocData = $this->model->getTOC($story);
             $content = \View\Story::buildTOC($tocData, $storyData);
         } else {
             if (empty($id[1]) or !is_numeric($id[1])) {
                 $id[1] = 1;
             }
             $chapter = $id[1] = max(1, min($id[1], $storyData['chapters']));
             $tocData = $this->model->getMiniTOC($story);
             \Base::instance()->set('bigscreen', TRUE);
             $content = ($content = $this->model->getChapter($story, $chapter)) ?: "Error";
             $storyData['reviewData'] = $this->model->loadReviews($story, $storyData['chapid']);
         }
         $dropdown = \View\Story::dropdown($tocData, $id[1]);
         $view = \View\Story::buildStory($storyData, $content, $dropdown);
         $this->buffer($view);
     } else {
         $this->buffer("Error, not found");
     }
 }