Non-initialized variable fix.
[openlib.git] / www / getJSON.php
1 <?php\r
2 /**\r
3  * COPS (Calibre OPDS PHP Server) HTML main script\r
4  *\r
5  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)\r
6  * @author     Sébastien Lucas <sebastien@slucas.fr>\r
7  *\r
8  */\r
9  \r
10     require_once ("config.php");\r
11     require_once ("base.php");\r
12     require_once ("author.php");\r
13     require_once ("serie.php");\r
14     require_once ("tag.php");\r
15     require_once ("language.php");\r
16     require_once ("book.php");\r
17     \r
18     header ("Content-Type:application/json;charset=utf-8");\r
19     $page = getURLParam ("page", Base::PAGE_INDEX);\r
20     $query = getURLParam ("query");\r
21     $qid = getURLParam ("id");\r
22     $n = getURLParam ("n", "1");\r
23     \r
24     $currentPage = Page::getPage ($page, $qid, $query, $n);\r
25     $currentPage->InitializeContent ();\r
26     \r
27     $out = array ( "title" => $currentPage->title);\r
28     $entries = array ();\r
29     foreach ($currentPage->entryArray as $entry) {\r
30         array_push ($entries, $entry->getContentArray ());\r
31     }\r
32     if (!is_null ($currentPage->book)) {\r
33         $out ["book"] = $currentPage->book->getFullContentArray ();\r
34     }\r
35     $out ["page"] = $page;\r
36     $out ["entries"] = $entries;\r
37     $out ["isPaginated"] = 0;\r
38     if ($currentPage->isPaginated ()) {\r
39         $prevLink = $currentPage->getPrevLink ();\r
40         $nextLink = $currentPage->getNextLink ();\r
41         $out ["isPaginated"] = 1;\r
42         $out ["prevLink"] = "";\r
43         if (!is_null ($prevLink)) {\r
44             $out ["prevLink"] = $prevLink->hrefXhtml ();\r
45         }\r
46         $out ["nextLink"] = "";\r
47         if (!is_null ($nextLink)) {\r
48             $out ["nextLink"] = $nextLink->hrefXhtml ();\r
49         }\r
50         $out ["maxPage"] = $currentPage->getMaxPage ();\r
51         $out ["currentPage"] = $currentPage->n;\r
52     }\r
53     if (!is_null (getURLParam ("complete"))) { \r
54         $out ["const"] = array ("version" => VERSION, "i18n" => array (\r
55                        "coverAlt" => localize("i18n.coversection"),\r
56                        "authorsTitle" => localize("authors.title"),\r
57                        "bookwordTitle" => localize("bookword.title"),\r
58                        "tagsTitle" => localize("tags.title"),\r
59                        "seriesTitle" => localize("series.title"),\r
60                        "customizeTitle" => localize ("customize.title"),\r
61                        "aboutTitle" => localize ("about.title"),\r
62                        "previousAlt" => localize ("paging.previous.alternate"),\r
63                        "nextAlt" => localize ("paging.next.alternate"),\r
64                        "searchAlt" => localize ("search.alternate"),\r
65                        "sortAlt" => localize ("sort.alternate"),\r
66                        "homeAlt" => localize ("home.alternate"),\r
67                        "settingsAlt" => localize ("settings.alternate"),\r
68                        "permalinkAlt" => localize ("permalink.alternate"),\r
69                        "pubdateTitle" => localize("pubdate.title"),\r
70                        "languagesTitle" => localize("language.title"),\r
71                        "contentTitle" => localize("content.summary"),\r
72                        "sortorderAsc" => localize("search.sortorder.asc"),\r
73                        "sortorderDesc" => localize("search.sortorder.desc"),\r
74                        "customizeEmail" => localize("customize.email")),\r
75                    "url" => array (\r
76                        "detailUrl" => "index.php?page=".Base::PAGE_BOOK_DETAIL."&id={0}",\r
77                        "coverUrl" => "fetch.php?id={0}",\r
78                        "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}"),\r
79                    "config" => array (\r
80                        "use_fancyapps" => $config ["cops_use_fancyapps"],\r
81                        "max_item_per_page" => $config['cops_max_item_per_page'],\r
82                        "html_tag_filter" => $config['cops_html_tag_filter']));\r
83    }\r
84 \r
85     $out ["containsBook"] = 0;\r
86     if ($currentPage->containsBook ()) {\r
87         $out ["containsBook"] = 1;\r
88     }\r
89     \r
90     $out["abouturl"] = "index.php?page=".Base::PAGE_ABOUT;\r
91     \r
92     if ($page == Base::PAGE_ABOUT) {\r
93         $out ["fullhtml"] = file_get_contents('about.html');\r
94     }\r
95     \r
96     $out ["homeurl"] = "index.php";\r
97     \r
98     echo json_encode ($out);\r
99 \r