/** * Tests */ public function testShouldDisplayPage() { $request = new NeechyRequest(); $page = Page::find_by_title('NeechyPage'); $handler = new PageHandler($request, $page); $response = $handler->handle(); $this->assertEquals(200, $response->status); $this->assertContains('<div class="tab-pane page active" id="read">', $response->body); # TODO: Figure out why this doesn't pass as expected. #$this->assertContains($page->body_to_html(), $response->body); }
} else { throw new Exception("template doesn't exist"); } } /* * Function to change Detectlanguage, Boolean */ public function setDetectTemplate($bool) { $this->detectTemplate = $bool; } /* * Function to detect language * Will check for cookie first else if in the "HTTP_ACCEPT_LANGUAGE" else default "EN" * Will also check GET to check for a language. */ private function detectTemplate() { if (isset($_COOKIE["template"])) { $this->setTemplate($_COOKIE["template"]); } if (isset($_GET["template"])) { $this->setTemplate($_GET["template"]); setcookie("template", $_GET["template"], time() + 60 * 60 * 24 * 360); } } } //Step 3: load the process $instance = new PageHandler(); $instance->setDetectTemplate(true); $instance->buildPage($_GET["page"]);
while ($file = readdir($pages)) { if (preg_match("/.phtml\$/", $file)) { $files[] = preg_replace("/.phtml\$/", "", $file); } } closedir($pages); return $this->files = $files; } public function CheckPageExists() { if (empty($this->files)) { header("Location: news.php"); } if (!$this->page || !in_array($this->page, $this->files)) { header("Location: news.php"); } } public function GetButtons() { foreach ($this->files as $file => $value) { echo "<div class=\"button\" onclick=\"navigate('./?page=" . $this->files[$file] . "')\"><span>" . ucfirst($this->files[$file]) . "</span></div>\n"; if (empty($this->files[$file + 1])) { break; } else { echo "\t\t\t"; } } } } $pagehandler = new PageHandler(); $pagehandler->init();
<?php /** * Created by Andrew sampson * User: Andrew * Date: 5/19/14 * Time: 5:26 AM */ header('Content-Type: application/json'); if (!empty($_GET["hash"])) { $debug = FALSE; if (!empty($_GET["debug"])) { $debug = TRUE; } $hashes = urldecode($_GET["hash"]); require_once "PageHandler.php"; $api = new PageHandler($hashes, $debug); $api->getPage(); } else { http_response_code(404); $error = '{"statuscode":404,"message":"Please enter a hash."}'; die($error); }