/** * * @url POST /?settings */ function updateSettings($data) { //check if new logo is submitted if (isset($_FILES['file'])) { $file = $_FILES['file']; try { uploadFile($file['tmp_name'], DIR_LOGO_FILE, $file['name']); } catch (Exception $e) { throw new RestException(400, $e->getMessage()); return; } $_POST['logo'] = DIR_LOGO_FILE . '/' . $file['name']; $db = new SettingsDatabase(); $result = $db->updateSettings($_POST); return arrayToUtf8($result); } $db = new SettingsDatabase(); $result = $db->updateSettings($data); return arrayToUtf8($result); }
// list all topics echo "<h2>ALL TOPICS</h2>"; $rows = $db->listTopics(); var_dump($rows); echo "<h2>DELETE TOPIC</h2>"; $db->deleteTopic(4); $rows = $db->listTopics(); var_dump($rows); echo "<h2>DELETED 5th DOCUMENT</h2>"; $db->deleteDocument(5); $rows = $db->listDocuments(); var_dump($rows); echo "<h2>GET THIRD DOCUMENT</h2>"; $rows = $db->getDocument(3); var_dump($rows); echo "<h2>CHANGE TITLE</h2>"; $db->insertDocument(array("id" => 1, "title" => "The Hitchhikers Guide to the Galaxy (2)", "author" => "Adams, Douglas", "description" => "Aenean varius quam at quam convallis, id porta nulla luctus. Nullam a tincidunt odio, sit amet mollis elit. Pellentesque et tristique enim. Aliquam vel dolor et lectus venenatis varius at aliquam nulla. Integer vehicula nibh justo, aliquet feugiat ex maximus et. Curabitur ex velit, commodo", "keywords" => "scifi fantasy comedy", "topic_id" => 42, "published" => 1979, "language" => "German", "file" => "hitchhiker.pdf")); $rows = $db->getDocument(1); var_dump($rows); echo "<h1>SETTINGS DB</h1>"; $db = new SettingsDatabase(); $db->create(); echo "<h2>GET SETTINGS</h2>"; $rows = $db->getSettings(); var_dump($rows); echo "<h2>CHANGE SETTINGS</h2>"; $db->updateSettings(array("about_text" => "-", "footer_text" => "Powered By OfflineLibrary.", "logo" => "images/logo.png", "header_color" => 0, "content_color" => 0)); $rows = $db->getSettings(); var_dump($rows); ?> </body>