/** * Liefert ein Array mit den YumpuEpapers */ public static function getAll() { global $wpdb; $table_name = $wpdb->prefix . 'yumpu_documents'; $items = array(); $qry = "SELECT id FROM " . $table_name; $result = $wpdb->get_results($qry); foreach ($result as $data) { $items[] = YumpuEpaper_repository::loadById($data->id); } return $items; }
private function handle_publish() { $status = false; $message = ""; $filename = $_POST['pub_filename']; if (file_exists($filename)) { try { $id = YumpuEpaper_repository::create($filename, $_POST['title']); } catch (YumpuEpaper_repository_exception $e) { $status = "error"; $message = $e->getMessage(); } } else { $status = "error"; $message = "file not found"; } echo json_encode(array('status' => $status, 'message' => $message, 'id' => $id)); }
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(); }
public function shortcode_embed($attr, $content = null, $code) { $document_id = (int) $attr['epaper_id']; $document_width = isset($attr['width']) ? (int) $attr['width'] : 512; $document_height = isset($attr['height']) ? (int) $attr['height'] : 384; if (!isset($attr['epaper_id'])) { return $content . '<p>misconfigured shortcode</p>'; } try { $ePaper = YumpuEpaper_repository::loadById($document_id); if ($ePaper->getStatus() == "progress") { $ret = $content . '<div style="position:relative; width:' . $document_width . 'px;height:' . $document_height . 'px; background:#233039;margin-bottom:10px;"><p style="text-align:center;padding-top:' . ($document_height / 2 - 30) . 'px;color:#ffffff;font-weight:normal;font-size:1.5em;">ePaper in progress <br><span style="color:#93A8B7;font-size:0.7em;">Powered by Yumpu.com</span></p>'; $ret .= '<a class="yumpuLink" target="yumpu" href="http://www.yumpu.com/de/"><img src="' . plugins_url('misc/images/yumpu_logo_trans.png', __FILE__) . '"></a>'; $ret .= '</div>'; $ret .= '<style>'; $ret .= '.yumpuLink img { opacity:0.5;filter:alpha(opacity=50);width:75px;bottom:10px;right:10px;position:absolute; }'; $ret .= '.yumpuLink:hover img { opacity:0.8;filter:alpha(opacity=80);width:75px;bottom:10px;right:10px;position:absolute; }'; $ret .= '</style>'; return $ret; } /** * ePaper nun hier anzeigen. */ $output = $ePaper->getEmbed_code(); if (isset($_SERVER["HTTPS"])) { // IFrame muss via HTTPS aufgerufen werden. $output = preg_replace('#http\\://#i', "https://", $output); } $output = preg_replace('/width:(.*?)px/i', "width:" . $document_width . "px", $output); $output = preg_replace('/height:(.*?)px/i', "height:" . $document_height . "px", $output); $output = preg_replace('/width="(.*?)px"/i', "width=\"" . $document_width . "px\"", $output); $output = preg_replace('/height="(.*?)px"/i', "height=\"" . $document_height . "px\"", $output); return $content . $output; } catch (YumpuEpaper_repository_exception $e) { return '<div style="width:' . $document_width . 'px;height:' . $document_height . 'px"><p>ePaper not found</p></div>'; } }