public function fetchBook($rqbook, $rqchapter, $startverse = null, $endverse = null) { $texts = array(); $book = Bible::getBook($this->app, $rqbook); $verses = array(array('start' => $startverse, 'end' => $endverse, 'context' => 0)); foreach ($this->versions as $version) { $bible = new Bible($this->app, $version); $bible->load(); $bible->Active = true; $bible->get($rqbook, $rqchapter ? $rqchapter : 1, $verses); $texts[] = $bible; } $encoders = array(new JsonEncoder()); $normalizers = array(new ObjectNormalizer()); $serializer = new Serializer($normalizers, $encoders); $json = $serializer->serialize($texts, 'json'); return $json; }
/** * TODO: Function Description * @param Var Description */ public function byBookChapter($rqbook, $rqchapter, $startverse = null, $endverse = null) { $texts = array(); $this->search = $rqbook . " " . $rqchapter; $verses = array(array('start' => $startverse, 'end' => $endverse, 'context' => 0)); $book = Bible::getBook($this->app, $rqbook); foreach ($this->versions as $version) { $bible = new Bible($this->app, $version); $bible->load(); $bible->Active = true; $bible->get($rqbook, $rqchapter ? $rqchapter : 1, $verses); $texts[] = $bible; } if (count($texts)) { $this->search = $book->Names['dutch'] . " " . $rqchapter; } if ($startverse) { $this->search .= ":" . $startverse; } if ($startverse && $endverse) { $this->search .= "-" . $endverse; } $this->setCurUrl(); //Add vars that can be json_encoded $this->response->addVars(array('title' => $book->Names['dutch'] . " " . $rqchapter, 'current_url' => "/" . $book->Names['dutch'] . "/" . $rqchapter)); //Render Html $this->response->render('index.twig', array('rqbook' => $book, 'rqchapter' => $rqchapter, 'search' => $this->search, 'texts' => $texts, 'books' => Bible::getAllBooks($this->app, $bible), 'versions' => Bible::getVersions($this->app, $this->versions))); }
/** * TODO: Function Description * @param Var Description */ public function get($book, $chapter, $verses = "*") { $book = Bible::getBook($this->app, $book, $this); $book->Active = true; if ($verses == "*") { $book->LoadChapter($chapter); } else { if (is_array($verses) && !empty($verses)) { foreach ($verses as $verseRange) { $book->LoadVerses($chapter, $verseRange['start'], $verseRange['end'], $verseRange['context']); } } } $this->Books[$book->Id] = $book; }