本文整理汇总了PHP中Books::get_all_books方法的典型用法代码示例。如果您正苦于以下问题:PHP Books::get_all_books方法的具体用法?PHP Books::get_all_books怎么用?PHP Books::get_all_books使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Books
的用法示例。
在下文中一共展示了Books::get_all_books方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: allAction
public function allAction()
{
$requestParams = $this->_request->getParams();
$host = App_Config::getHost();
$frontendOptions = array('lifetime' => 72000, 'automatic_serialization' => true);
$backendOptions = array('cache_dir' => './bookdata/');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
$requestURI = $this->_request->getRequestUri();
// for testing
$requestURI = str_replace("/", "_", $requestURI);
$requestURI = str_replace(".", "_", $requestURI);
if (isset($requestParams["callback"])) {
$requestURI = str_replace("?", "", $requestURI);
$requestURI = str_replace("callback=" . $requestParams["callback"], "", $requestURI);
}
$cache_id = $requestURI;
if (isset($requestParams['avar'])) {
$aVar = $requestParams['avar'];
if ($aVar == ".json") {
$books = new Books();
$books->get_all_books();
$outputArray = $books->bookData;
unset($books);
$output = Zend_Json::encode($outputArray);
$this->_helper->viewRenderer->setNoRender();
if (isset($requestParams["callback"])) {
header('Content-Type: application/javascript; charset=utf8');
$output = $requestParams["callback"] . "(" . $output . ");";
echo $output;
} else {
header('Content-Type: application/json; charset=utf8');
header("Access-Control-Allow-Origin: *");
echo $output;
//outputs JSON of a given book's word cloud
}
} elseif (is_numeric($aVar)) {
$book = $aVar;
if (isset($requestParams['bvar'])) {
if ($requestParams['bvar'] == "words.json") {
if (!($cache_result = $cache->load($cache_id))) {
$bookObj = new Book();
$bookObj->initialize($book);
$bookObj->book = $book;
$bookObj->get_book_meta();
$bookObj->getBookWordData();
$outputArray = $bookObj->wordSummary;
$output = Zend_Json::encode($outputArray);
$cache->save($output, $cache_id);
} else {
$output = $cache_result;
}
$this->_helper->viewRenderer->setNoRender();
if (isset($requestParams["callback"])) {
header('Content-Type: application/javascript; charset=utf8');
$output = $requestParams["callback"] . "(" . $output . ");";
echo $output;
} else {
header('Content-Type: application/json; charset=utf8');
header("Access-Control-Allow-Origin: *");
echo $output;
//outputs JSON of a given book's word cloud
}
} elseif ($requestParams['bvar'] == "page") {
$failPageRequest = true;
if (isset($requestParams['cvar'])) {
if (stristr($requestParams['cvar'], ".json")) {
$page = str_replace(".json", "", $requestParams['cvar']);
if (is_numeric($page)) {
$failPageRequest = false;
$bookObj = new Book();
$bookObj->initialize($book);
$bookObj->book = $book;
$bookObj->page = $page;
$bookObj->get_book_meta();
$bookObj->getBookPageData();
$outputArray = $bookObj->pageOutput;
$output = Zend_Json::encode($outputArray);
$this->_helper->viewRenderer->setNoRender();
if (isset($requestParams["callback"])) {
header('Content-Type: application/javascript; charset=utf8');
$output = $requestParams["callback"] . "(" . $output . ");";
echo $output;
} else {
header('Content-Type: application/json; charset=utf8');
header("Access-Control-Allow-Origin: *");
echo $output;
//outputs JSON of a given book's word cloud
}
}
}
}
if ($failPageRequest) {
$this->view->requestURI = $this->_request->getRequestUri();
return $this->render('404error');
}
}
} else {
$bookObj = new Book();
$bookObj->initialize($book);
$bookObj->get_book_meta();
//.........这里部分代码省略.........