function get_notice_by_meta($name, $filename) { global $pmb_keyword_sep; global $pmb_type_audit; global $webdav_current_user_name, $webdav_current_user_id; \create_tableau_mimetype(); $mimetype = \trouve_mimetype($filename, extension_fichier($name)); //on commence avec la gymnatisque des métas... if ($mimetype == "application/epub+zip") { //pour les ebook, on gère ca directement ici ! $epub = new \epubData(realpath($filename)); $metas = $epub->metas; $img = imagecreatefromstring($epub->getCoverContent()); $file = tempnam(sys_get_temp_dir(), "vign"); imagepng($img, $file); $metas['thumbnail_content'] = file_get_contents($file); unlink($file); } else { $metas = \extract_metas(realpath($filename), $mimetype); } if ($this->config['metasMapper_class']) { $className = "Sabre\\PMB\\" . $this->config['metasMapper_class']; if (class_exists($className)) { $metasMapper = new $className($this->config, $metas, $mimetype, $name); } } if (!is_object($metasMapper)) { $metasMapper = new metasMapper($this->config, $metas, $mimetype, $name); } return $metasMapper->get_notice_id(); }
function get_notice_by_meta($name, $filename) { \create_tableau_mimetype(); $mimetype = \trouve_mimetype($filename, extension_fichier($name)); //on commence avec la gymnatisque des métas... if ($mimetype == "application/epub+zip") { //pour les ebook, on gère ca directement ici ! $epub = new \epubData(realpath($filename)); $metas = $epub->metas; $img = imagecreatefromstring($epub->getCoverContent()); $file = tempnam(sys_get_temp_dir(), "vign"); imagepng($img, $file); $metas['thumbnail_content'] = file_get_contents($file); unlink($file); } else { $metas = \extract_metas(realpath($filename), $mimetype); } $metasMapper = $this->load_metas_mapper(); return $metasMapper->get_notice_id($metas, $mimetype, $name); }
function calculate_vignette() { error_reporting(null); global $base_path, $include_path, $class_path; $path = $this->get_document_in_tmp(); if ($path) { switch ($this->mimetype) { case "application/bnf+zip": require_once $class_path . "/docbnf_zip.class.php"; $doc = new docbnf_zip($path); $this->vignette = construire_vignette($doc->getCover()); break; case "application/epub+zip": require_once $class_path . "/epubData.class.php"; $doc = new epubData($path); file_put_contents($path, $doc->getCoverContent()); $this->vignette = construire_vignette($path); break; default: $this->vignette = construire_vignette($path); break; } unlink($path); } }
/** * @param $name : file name * @param $filename : file name with path * @return Array : le tableau des métadonnées du fichier */ static function getMetadata($filename, $name) { \create_tableau_mimetype(); $mimetype = \trouve_mimetype($filename, extension_fichier($name)); if ($mimetype == "application/epub+zip") { //récupération de l'image $epub = new \epubData(realpath($filename)); //TODO : Vérifier la récupération des métadonnées d'un epub avec \extract_metas(), sinon rétablir les commentaires ici et le else plus bas // $tmp=array(); // $tmp=$epub->metas; // foreach($tmp as $key=>$val){ // $metas[strtoupper(substr($key,0,1)).substr($key,1)]=$val; // } $img = imagecreatefromstring($epub->getCoverContent()); $file = tempnam(sys_get_temp_dir(), "vign"); imagepng($img, $file); $entry['thumbnail_url'] = 'data:image/png;base64,' . base64_encode(file_get_contents($file)); unlink($file); } // else{ return \extract_metas(realpath($filename), $mimetype); // } }
function get_notice_by_meta($name, $filename) { global $pmb_keyword_sep; global $pmb_type_audit; global $webdav_current_user_name, $webdav_current_user_id; \create_tableau_mimetype(); $mimetype = \trouve_mimetype($filename, extension_fichier($name)); $notice_id = 0; $title = $cplt = $code = $pages = $year = $keywords = $url = $thumbnail_content = ""; //on commence avec la gymnatisque des métas... if ($mimetype == "application/epub+zip") { //pour les ebook, on gère ca directement ici ! $epub = new \epubData(realpath($filename)); $title = $epub->metas['title'][0]; $authors = $epub->metas['creator']; $co_authors = $epub->metas['contributor']; if ($epub->metas['identifier']['isbn']) { $code = \formatISBN($epub->metas['identifier']['isbn'], 13); } else { if ($epub->metas['identifier']['ean']) { $code = \EANtoISBN($epub->metas['identifier']['ean']); $code = \formatISBN($code, 13); } } if ($epub->metas['identifier']['uri']) { $url = \clean_string($epub->metas['identifier']['uri']); } $publisher = $epub->metas['publisher'][0]; $year = $epub->metas['date'][0]['value']; if (strlen($year) && strlen($year) != 4) { $year = \formatdate(detectFormatDate($year)); } $lang = $epub->metas['language']; $resume = implode("\n", $epub->metas['description']); $keywords = implode($pmb_keyword_sep, $epub->metas['subject']); //jouons à et si on trouvait a vignette... $img = imagecreatefromstring($epub->getCoverContent()); $file = tempnam(sys_get_temp_dir(), "vign"); imagepng($img, $file); $thumbnail_content = file_get_contents($file); unlink($file); } else { $metas = \extract_metas(realpath($filename), $mimetype); if ($metas['Title'] && $metas['Author'] && $metas['Subject']) { $title = $metas['Title']; $author = $metas['Author']; $cplt = $metas['Subject']; } else { // métas non fiable, on regarde avec le titre... $title = $name; } //date de création... if ($metas["CreateDate"]) { $year = substr($metas["CreateDate"], 0, 4); } //pages if ($metas['PageCount']) { $pages = $metas['PageCount']; } //keywords if ($metas['Keywords']) { foreach ($metas['Keywords'] as $keyword) { if ($keywords != "") { $keywords .= $pmb_keyword_sep; } $keywords .= $keyword; } } } $query = "select notice_id from notices where tit1 = '" . addslashes($title) . "'"; $result = mysql_query($query); if (mysql_num_rows($result)) { $notice_id = mysql_result($result, 0, 0); } if (!$notice_id) { //en cas d'une leture moyenne des infos, on s'assure d'avoir au moins un titre.... if (!$title) { $title = $name; } if ($publisher) { $ed_1 = \editeur::import(array('name' => $publisher)); } else { $ed_1 = 0; } $ind_wew = $title . " " . $cplt; $ind_sew = \strip_empty_words($ind_wew); $query = "insert into notices set \n\t\t\t\ttit1 = '" . addslashes($title) . "'," . ($code ? "code='" . $code . "'," : "") . "ed1_id = '" . $ed_1 . "'," . ($cplt ? "tit4 = '" . addslashes($cplt) . "'," : "") . ($pages ? "npages = '" . addslashes($pages) . "'," : "") . ($keywords ? "index_l = '" . addslashes($keywords) . "'," : "") . "\n\t\t\t\tyear = '" . $year . "',\n\t\t\t\tniveau_biblio='m', \n\t\t\t\tniveau_hierar='0',\n\t\t\t\tstatut = '" . $this->config['default_statut'] . "',\n\t\t\t\tindex_wew = '" . $ind_wew . "',\n\t\t\t\tindex_sew = '" . $ind_sew . "',\n\t\t\t\tn_resume = '" . addslashes($resume) . "',\n\t\t\t\tlien = '" . addslashes($url) . "',\n\t\t\t\tindex_n_resume = '" . \strip_empty_words($resume) . "'," . ($thumbnail_content ? "thumbnail_url = 'data:image/png;base64," . base64_encode($thumbnail_content) . "'," : "") . "create_date = sysdate(), \n\t\t\t\tupdate_date = sysdate()"; mysql_query($query); $notice_id = mysql_insert_id(); $sign = new \notice_doublon(); mysql_query("update notices set signature = '" . $sign->gen_signature($notice_id) . "' where notice_id = " . $notice_id); //traitement audit if ($pmb_type_audit) { $query = "INSERT INTO audit SET "; $query .= "type_obj='1', "; $query .= "object_id='{$notice_id}', "; $query .= "user_id='{$webdav_current_user_id}', "; $query .= "user_name='{$webdav_current_user_name}', "; $query .= "type_modif=1 "; $result = @mysql_query($query); } if (count($authors)) { $i = 0; foreach ($authors as $author) { $aut = array(); if ($author['file-as']) { $infos = explode(",", $author['file-as']); $aut = array('name' => $infos[0], 'rejete' => $infos[1], 'type' => 70); } if (!$aut['name']) { $aut = array('name' => $author['value'], 'type' => 70); } $aut_id = \auteur::import($aut); if ($aut_id) { $query = "insert into responsability set \n\t\t\t\t\t\t\tresponsability_author = '" . $aut_id . "',\n\t\t\t\t\t\t\tresponsability_notice = '" . $notice_id . "',\n\t\t\t\t\t\t\tresponsability_type = '0'"; mysql_query($query); $i++; } } } if (count($co_authors)) { foreach ($co_authors as $author) { $aut = array(); if ($author['file-as']) { $infos = explode(",", $author['file-as']); $aut = array('name' => $infos[0], 'rejete' => $infos[1], 'type' => 70); } if (!$aut['name']) { $aut = array('name' => $author['value'], 'type' => 70); } $aut_id = \auteur::import($aut); if ($aut_id) { $query = "insert into responsability set \n\t\t\t\t\t\t\tresponsability_author = '" . $aut_id . "',\n\t\t\t\t\t\t\tresponsability_notice = '" . $notice_id . "',\n\t\t\t\t\t\t\tresponsability_type = '0',\n\t\t\t\t\t\t\trepsonsability_ordre = '" . $i . "'"; mysql_query($query); $i++; } } } } return $notice_id; }