/**
  * 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;
 }
 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>';
     }
 }