private function handle_upload() { $id = null; if (isset($_FILES['Filedata']) && !empty($_FILES['Filedata']['tmp_name']) && !empty($_POST['title'])) { $FileAPI = new FileAPI(array('pdf')); try { $imported_filename = $FileAPI->import($_FILES['Filedata']['tmp_name'], $_FILES['Filedata']['name']); //Upload war erfolgreich und die Datei wurde korrekt abgelegt. //$id = YumpuEpaper_repository::create($imported_filename, $_POST['title']); $status = "success"; } catch (FileAPI_exception $e) { $status = "error"; $message = $e->getMessage(); } catch (YumpuEpaper_repository_exception $e) { /** * Wenn möglich sollten wir die importierte Datei direkt entfernen. */ $FileAPI->delete($_FILES['yc_file']['name']); $status = "error"; $message = $e->getMessage(); } } else { $status = "error"; $message = "no input file"; } $upload_response = json_encode(array('status' => $status, 'message' => $message, 'id' => $id, 'filename' => addslashes($imported_filename))); $HB = new HtmlBuilder('admin_upload_response.php', $this->plugin_path . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR); $HB->assign('upload_response', $upload_response); echo $HB->get_data(); }
private function display() { if (WP_Yumpu::$API_TOKEN === null) { echo ''; return; } $HB = new HtmlBuilder('admin_files.php', $this->plugin_path . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR); $yumpu_action = isset($_REQUEST['yumpu_action']) ? $_REQUEST['yumpu_action'] : null; switch ($yumpu_action) { case "create_epaper": if (isset($_FILES['yc_file']) && !empty($_FILES['yc_file']['tmp_name']) && !empty($_POST['yc_title'])) { $FileAPI = new FileAPI(array('pdf')); try { $imported_filename = $FileAPI->import($_FILES['yc_file']['tmp_name'], $_FILES['yc_file']['name']); //Upload war erfolgreich und die Datei wurde korrekt abgelegt. YumpuEpaper_repository::create($imported_filename, $_POST['yc_title'], $_POST['yc_description']); $HB->assign('yumpu_success_message', 'upload successfull'); } catch (FileAPI_exception $e) { $HB->assign('yumpu_error_message', $e->getMessage()); } catch (YumpuEpaper_repository_exception $e) { /** * Wenn möglich sollten wir die importierte Datei direkt entfernen. */ $FileAPI->delete($_FILES['yc_file']['name']); $HB->assign('yumpu_error_message', $e->getMessage()); } } else { $HB->assign('yumpu_error_message', 'no input file or title missing'); } break; } /** * Hier Liste der gesmaten Dokumenten auflisten. */ $ePapers = YumpuEpaper_repository::getAll(); $HB->assign('epapers', $ePapers); echo $HB->get_data(); }
private function display() { $HB = new HtmlBuilder('admin_settings.php', $this->plugin_path . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR); $HB->assign('API_TOKEN', WP_Yumpu::$API_TOKEN); echo $HB->get_data(); }