/** * The function for the head of the HTML catalog * @dataProvider providerTemplate */ public function testGenerateHeader($templateName) { $_SERVER["HTTP_USER_AGENT"] = "Firefox"; global $config; $headcontent = file_get_contents(dirname(__FILE__) . '/../templates/' . $templateName . '/file.html'); $template = new doT(); $tpl = $template->template($headcontent, NULL); $data = array("title" => $config['cops_title_default'], "version" => VERSION, "opds_url" => $config['cops_full_url'] . "feed.php", "customHeader" => "", "template" => $templateName, "server_side_rendering" => useServerSideRendering(), "current_css" => getCurrentCss(), "favico" => $config['cops_icon'], "getjson_url" => "getJSON.php?" . addURLParameter(getQueryString(), "complete", 1)); $head = $tpl($data); $this->assertContains("<head>", $head); $this->assertContains("</head>", $head); }
public function InitializeContent() { $this->title = localize("customize.title"); $this->entryArray = array(); $ignoredBaseArray = array(PageQueryResult::SCOPE_AUTHOR, PageQueryResult::SCOPE_TAG, PageQueryResult::SCOPE_SERIES, PageQueryResult::SCOPE_PUBLISHER, PageQueryResult::SCOPE_RATING, "language"); $content = ""; array_push($this->entryArray, new Entry("Template", "", "<span style='cursor: pointer;' onclick='\$.cookie(\"template\", \"bootstrap\", { expires: 365 });window.location=\$(\".headleft\").attr(\"href\");'>Click to switch to Bootstrap</span>", "text", array())); if (!preg_match("/(Kobo|Kindle\\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { $content .= '<select id="style" onchange="updateCookie (this);">'; foreach ($this->getStyleList() as $filename) { $content .= "<option value='{$filename}' " . $this->isSelected("style", $filename) . ">{$filename}</option>"; } $content .= '</select>'; } else { foreach ($this->getStyleList() as $filename) { $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; } } array_push($this->entryArray, new Entry(localize("customize.style"), "", $content, "text", array())); if (!useServerSideRendering()) { $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked("use_fancyapps") . ' />'; array_push($this->entryArray, new Entry(localize("customize.fancybox"), "", $content, "text", array())); } $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />'; array_push($this->entryArray, new Entry(localize("customize.paging"), "", $content, "text", array())); $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption("email") . '" />'; array_push($this->entryArray, new Entry(localize("customize.email"), "", $content, "text", array())); $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked("html_tag_filter") . ' />'; array_push($this->entryArray, new Entry(localize("customize.filter"), "", $content, "text", array())); $content = ""; foreach ($ignoredBaseArray as $key) { $keyPlural = preg_replace('/(ss)$/', 's', $key . "s"); $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked("ignored_categories", $key) . ' > ' . localize("{$keyPlural}.title") . '</input> '; } array_push($this->entryArray, new Entry(localize("customize.ignored"), "", $content, "text", array())); }
// Access the database ASAP to be sure it's readable, redirect if that's not the case. // It has to be done before any header is sent. Base::checkDatabaseAvailability(); if ($config['cops_fetch_protect'] == "1") { session_start(); if (!isset($_SESSION['connected'])) { $_SESSION['connected'] = 0; } } header("Content-Type:text/html;charset=utf-8"); $data = array("title" => $config['cops_title_default'], "version" => VERSION, "opds_url" => $config['cops_full_url'] . "feed.php", "customHeader" => "", "template" => getCurrentTemplate(), "server_side_rendering" => useServerSideRendering(), "current_css" => getCurrentCss(), "favico" => $config['cops_icon'], "getjson_url" => "getJSON.php?" . addURLParameter(getQueryString(), "complete", 1)); if (preg_match("/Kindle/", $_SERVER['HTTP_USER_AGENT'])) { $data["customHeader"] = '<style media="screen" type="text/css"> html { font-size: 75%; -webkit-text-size-adjust: 75%; -ms-text-size-adjust: 75%; }</style>'; } $headcontent = file_get_contents('templates/' . getCurrentTemplate() . '/file.html'); $template = new doT(); $dot = $template->template($headcontent, NULL); echo $dot($data); ?> <body> <?php if (useServerSideRendering()) { // Get the data require_once "JSON_renderer.php"; $data = JSONRenderer::getJson(true); echo serverSideRender($data); } ?> </body> </html>
public static function addCompleteArray($in) { global $config; $out = $in; $out["c"] = array("version" => VERSION, "i18n" => array("coverAlt" => localize("i18n.coversection"), "authorsTitle" => localize("authors.title"), "bookwordTitle" => localize("bookword.title"), "tagsTitle" => localize("tags.title"), "seriesTitle" => localize("series.title"), "customizeTitle" => localize("customize.title"), "aboutTitle" => localize("about.title"), "previousAlt" => localize("paging.previous.alternate"), "nextAlt" => localize("paging.next.alternate"), "searchAlt" => localize("search.alternate"), "sortAlt" => localize("sort.alternate"), "homeAlt" => localize("home.alternate"), "cogAlt" => localize("cog.alternate"), "permalinkAlt" => localize("permalink.alternate"), "publisherName" => localize("publisher.name"), "pubdateTitle" => localize("pubdate.title"), "languagesTitle" => localize("language.title"), "contentTitle" => localize("content.summary"), "sortorderAsc" => localize("search.sortorder.asc"), "sortorderDesc" => localize("search.sortorder.desc"), "customizeEmail" => localize("customize.email")), "url" => array("detailUrl" => "index.php?page=13&id={0}&db={1}", "coverUrl" => "fetch.php?id={0}&db={1}", "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"), "config" => array("use_fancyapps" => $config["cops_use_fancyapps"], "max_item_per_page" => $config['cops_max_item_per_page'], "kindleHack" => "", "server_side_rendering" => useServerSideRendering(), "html_tag_filter" => $config['cops_html_tag_filter'])); if ($config['cops_thumbnail_handling'] == "1") { $out["c"]["url"]["thumbnailUrl"] = $out["c"]["url"]["coverUrl"]; } else { if (!empty($config['cops_thumbnail_handling'])) { $out["c"]["url"]["thumbnailUrl"] = $config['cops_thumbnail_handling']; } } if (preg_match("/./", $_SERVER['HTTP_USER_AGENT'])) { $out["c"]["config"]["kindleHack"] = 'style="text-decoration: none !important;"'; } return $out; }