diff --git a/lib/Alchemy/Phrasea/Out/Module/PDF.php b/lib/Alchemy/Phrasea/Out/Module/PDF.php index 54bf76487b..aa03f03b5e 100644 --- a/lib/Alchemy/Phrasea/Out/Module/PDF.php +++ b/lib/Alchemy/Phrasea/Out/Module/PDF.php @@ -340,7 +340,7 @@ class PDF $RIGHT_IMG = NULL; $LEFT__IMG = $registry->get('GV_RootPath') . "config/minilogos/logopdf_" - . $rec->get_sbas_id() . ".jpg"; + . $rec->get_sbas_id() . ""; if ( ! is_file($LEFT__IMG)) { $databox = $rec->get_databox(); diff --git a/lib/classes/appbox.class.php b/lib/classes/appbox.class.php index e324a42bb8..cdc2fe4681 100644 --- a/lib/classes/appbox.class.php +++ b/lib/classes/appbox.class.php @@ -96,23 +96,28 @@ class appbox extends base public function write_collection_pic(collection $collection, SymfoFile $pathfile = null, $pic_type) { $core = \bootstrap::getCore(); + $filename = null; if ( ! is_null($pathfile)) { if ( ! in_array(mb_strtolower($pathfile->getMimeType()), array('image/gif', 'image/png', 'image/jpeg', 'image/jpg', 'image/pjpeg'))) { throw new \InvalidArgumentException('Invalid file format'); } + $filename = $pathfile->getPathname(); //resize collection logo $imageSpec = new ImageSpecification(); $imageSpec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO); $imageSpec->setDimensions(120, 24); + $tmp = tempnam(sys_get_temp_dir(), 'tmpdatabox').'.jpg'; + try { $core['media-alchemyst'] ->open($pathfile->getPathname()) - ->turninto($pathfile->getPathname(), $imageSpec) + ->turninto($tmp, $imageSpec) ->close(); + $filename = $tmp; } catch (\MediaAlchemyst\Exception $e) { } @@ -147,12 +152,12 @@ class appbox extends base $core['file-system']->remove($target); } - if (null === $target || null === $pathfile) { + if (null === $target || null === $filename) { continue; } $core['file-system']->mkdir(dirname($target), 0750); - $core['file-system']->copy($pathfile->getPathname(), $target, true); + $core['file-system']->copy($filename, $target, true); $core['file-system']->chmod($target, 0760); } @@ -162,10 +167,11 @@ class appbox extends base public function write_databox_pic(databox $databox, SymfoFile $pathfile = null, $pic_type) { $core = \bootstrap::getCore(); + $filename = null; if ( ! is_null($pathfile)) { - if ( ! in_array(mb_strtolower($pathfile->getMimeType()), array('image/jpeg', 'image/jpg', 'image/pjpeg'))) { + if ( ! in_array(mb_strtolower($pathfile->getMimeType()), array('image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png', 'image/gif'))) { throw new \InvalidArgumentException('Invalid file format'); } } @@ -174,6 +180,27 @@ class appbox extends base throw new \InvalidArgumentException('unknown pic_type'); } + if($pathfile) { + + $filename = $pathfile->getPathname(); + + $imageSpec = new ImageSpecification(); + $imageSpec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO); + $imageSpec->setDimensions(120, 35); + + $tmp = tempnam(sys_get_temp_dir(), 'tmpdatabox').'.jpg'; + + try { + $core['media-alchemyst'] + ->open($pathfile->getPathname()) + ->turninto($tmp, $imageSpec) + ->close(); + $filename = $tmp; + } catch (\MediaAlchemyst\Exception $e) { + + } + } + $registry = $databox->get_registry(); $file = $registry->get('GV_RootPath') . 'config/minilogos/' . $pic_type . '_' . $databox->get_sbas_id(); $custom_path = $registry->get('GV_RootPath') . 'www/custom/minilogos/' . $pic_type . '_' . $databox->get_sbas_id(); @@ -184,12 +211,12 @@ class appbox extends base $core['file-system']->remove($target); } - if (is_null($pathfile)) { + if (is_null($filename)) { continue; } $core['file-system']->mkdir(dirname($target)); - $core['file-system']->copy($pathfile->getRealPath(), $target); + $core['file-system']->copy($filename, $target); $core['file-system']->chmod($target, 0760); } diff --git a/www/admin/database.php b/www/admin/database.php index e74ad21eaf..fac724f0a0 100644 --- a/www/admin/database.php +++ b/www/admin/database.php @@ -42,14 +42,20 @@ $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) { switch ($parm["act"]) { case "SENDLOGOPDF": - if (isset($_FILES['newLogoPdf']) && $_FILES['newLogoPdf']['error'] == UPLOAD_ERR_OK) { - if ($_FILES['newLogoPdf']['size'] < 65536) { - $appbox->write_databox_pic($databox, new SymfoFile($_FILES['newLogoPdf']["tmp_name"]), databox::PIC_PDF); - unlink($_FILES['newLogoPdf']["tmp_name"]); + try { + if (isset($_FILES['newLogoPdf']) && $_FILES['newLogoPdf']['error'] == UPLOAD_ERR_OK) { + if ($_FILES['newLogoPdf']['size'] < 65536) { + $appbox->write_databox_pic($databox, new SymfoFile($_FILES['newLogoPdf']["tmp_name"]), \databox::PIC_PDF); + unlink($_FILES['newLogoPdf']["tmp_name"]); + } else { + $printLogoUploadMsg = _('forms::erreur lors de l\'envoi du fichier'); + } } else { $printLogoUploadMsg = _('forms::erreur lors de l\'envoi du fichier'); } - } else { + } catch (\InvalidArgumentException $e) { + $printLogoUploadMsg = _('Invalid file format'); + } catch (\Exception $e) { $printLogoUploadMsg = _('forms::erreur lors de l\'envoi du fichier'); } break; @@ -100,230 +106,230 @@ if ($parm['act']) { } ?> - function sendLogopdf() - { - document.forms["flpdf"].target = ""; - document.forms["flpdf"].act.value = "SENDLOGOPDF"; - document.forms["flpdf"].submit(); - } - function deleteLogoPdf() - { - if(confirm("")) - { - $.ajax({ - type: "POST", - url: "/admin/adminFeedback.php", - dataType: 'json', - data: { action:"DELLOGOPDF", p0:}, - success: function(data){ - $("#printLogoDIV_OK").hide(); - $("#printLogoDIV_NONE").show(); - } - }); - } - } - function reindex() - { - if(confirm('')) - { - $.ajax({ - type: "POST", - url: "/admin/adminFeedback.php", - dataType: 'json', - data: { action:"REINDEX", sbas_id:}, - success: function(data){ - } - }); - } - } - - function makeIndexable(el) + function sendLogopdf() + { + document.forms["flpdf"].target = ""; + document.forms["flpdf"].act.value = "SENDLOGOPDF"; + document.forms["flpdf"].submit(); + } + function deleteLogoPdf() + { + if(confirm("")) { $.ajax({ type: "POST", url: "/admin/adminFeedback.php", dataType: 'json', - data: { action:"MAKEINDEXABLE", sbas_id:, INDEXABLE:(el.checked?'1':'') }, + data: { action:"DELLOGOPDF", p0:}, success: function(data){ + $("#printLogoDIV_OK").hide(); + $("#printLogoDIV_NONE").show(); } }); } - - var __viewname = ""; // global will be updated by refreshContent - function chgViewName() - { - if( (newAlias = prompt(" :", __viewname)) != null) - { - $.ajax({ - type: "POST", - url: "/admin/adminFeedback.php", - dataType: 'json', - data: { action:"CHGVIEWNAME", sbas_id:, viewname:newAlias}, - success: function(data){ - } - }); - } - } - - function emptyBase() - { - if(confirm("")) - { - $.ajax({ - type: "POST", - url: "/admin/adminFeedback.php?action=EMPTYBASE", - dataType: 'json', - data: { sbas_id: }, - success: function(data){ - alert(data.message); - } - }); - } - } - - function refreshContent() + } + function reindex() + { + if(confirm('')) { $.ajax({ type: "POST", url: "/admin/adminFeedback.php", dataType: 'json', - data: { action:"P_BAR_INFO", sbas_id:""}, + data: { action:"REINDEX", sbas_id:}, success: function(data){ - __viewname = data.viewname; // global - if(data.viewname == '') - $("#viewname").html(""); - else - $("#viewname").html(""+data.viewname+""); - $("#nrecords").text(data.records); - $("#is_indexable").attr('checked', data.indexable); - $("#xml_indexed").text(data.xml_indexed); - $("#thesaurus_indexed").text(data.thesaurus_indexed); - if(data.records > 0) - { - var p; - p = 100*data.xml_indexed/data.records; - $("#xml_indexed_bar").width(Math.round(2*p)); // 0..200px - $("#xml_indexed_percent").text((Math.round(p*100)/100)+" %"); - p = 100*data.thesaurus_indexed/data.records; - $("#thesaurus_indexed_bar").width(Math.round(2*p)); - $("#thesaurus_indexed_percent").text((Math.round(p*100)/100)+" %"); - } - if(data.printLogoURL) - { - $("#printLogo").attr("src", data.printLogoURL); - $("#printLogoDIV_NONE").hide(); - $("#printLogoDIV_OK").show(); - } - else - { - $("#printLogoDIV_OK").hide(); - $("#printLogoDIV_NONE").show(); - } - } - }); - setTimeout("refreshContent();", 6000); - } - - function deleteBase() - { - $.ajax({ - type: "POST", - url: "/admin/adminFeedback.php", - dataType: 'json', - data: { action:"P_BAR_INFO", sbas_id: }, - success: function(data){ - if(data.records > 0) - { - alert(""); - } - else - { - if(confirm("")) - { - $.ajax({ - type: "POST", - url: "/admin/adminFeedback.php", - dataType: 'json', - data: { action:"DELETEBASE", sbas_id: }, - success: function(data){ - if(data.err == 0) // ok - { - parent.$("#TREE_DATABASES").trigger('click'); - parent.reloadTree("bases"); - } - else - { - if(data.errmsg) - alert(data.errmsg); - } - } - }); - } - } } }); } - function clearAllLog() - { - if(confirm("")) - { - $.ajax({ - type: "POST", - url: "/admin/adminFeedback.php", - dataType: 'json', - data: { action:"CLEARALLLOG", sbas_id: - }, - success: function(data){ - } - }); + } + + function makeIndexable(el) + { + $.ajax({ + type: "POST", + url: "/admin/adminFeedback.php", + dataType: 'json', + data: { action:"MAKEINDEXABLE", sbas_id:, INDEXABLE:(el.checked?'1':'') }, + success: function(data){ } - } - - function mountColl() - { - $('#mount_coll').toggle(); - } - - function activateColl() - { - $('#activate_coll').toggle(); - } - - function umountBase() - { - if(confirm("")) - { - $.ajax({ - type: "POST", - url: "/admin/adminFeedback.php", - dataType: 'json', - data: { action:"UNMOUNTBASE", sbas_id: - }, - success: function(data){ - parent.$("#TREE_DATABASES").trigger('click'); - } - }); - } - } - - function showDetails(sta) - { - document.forms["manageDatabase"].target = ""; - document.forms["manageDatabase"].act.value = ""; - document.forms["manageDatabase"].sta.value = sta; - document.forms["manageDatabase"].submit(); - } - function chgOrd(srt) - { - document.forms["manageDatabase"].target = ""; - document.forms["manageDatabase"].act.value = ""; - document.forms["manageDatabase"].sta.value = "1"; - document.forms["manageDatabase"].srt.value = srt; - document.forms["manageDatabase"].submit(); - } - $(document).ready(function(){ - refreshContent(); }); + } + + var __viewname = ""; // global will be updated by refreshContent + function chgViewName() + { + if( (newAlias = prompt(" :", __viewname)) != null) + { + $.ajax({ + type: "POST", + url: "/admin/adminFeedback.php", + dataType: 'json', + data: { action:"CHGVIEWNAME", sbas_id:, viewname:newAlias}, + success: function(data){ + } + }); + } + } + + function emptyBase() + { + if(confirm("")) + { + $.ajax({ + type: "POST", + url: "/admin/adminFeedback.php?action=EMPTYBASE", + dataType: 'json', + data: { sbas_id: }, + success: function(data){ + alert(data.message); + } + }); + } + } + + function refreshContent() + { + $.ajax({ + type: "POST", + url: "/admin/adminFeedback.php", + dataType: 'json', + data: { action:"P_BAR_INFO", sbas_id:""}, + success: function(data){ + __viewname = data.viewname; // global + if(data.viewname == '') + $("#viewname").html(""); + else + $("#viewname").html(""+data.viewname+""); + $("#nrecords").text(data.records); + $("#is_indexable").attr('checked', data.indexable); + $("#xml_indexed").text(data.xml_indexed); + $("#thesaurus_indexed").text(data.thesaurus_indexed); + if(data.records > 0) + { + var p; + p = 100*data.xml_indexed/data.records; + $("#xml_indexed_bar").width(Math.round(2*p)); // 0..200px + $("#xml_indexed_percent").text((Math.round(p*100)/100)+" %"); + p = 100*data.thesaurus_indexed/data.records; + $("#thesaurus_indexed_bar").width(Math.round(2*p)); + $("#thesaurus_indexed_percent").text((Math.round(p*100)/100)+" %"); + } + if(data.printLogoURL) + { + $("#printLogo").attr("src", data.printLogoURL); + $("#printLogoDIV_NONE").hide(); + $("#printLogoDIV_OK").show(); + } + else + { + $("#printLogoDIV_OK").hide(); + $("#printLogoDIV_NONE").show(); + } + } + }); + setTimeout("refreshContent();", 6000); + } + + function deleteBase() + { + $.ajax({ + type: "POST", + url: "/admin/adminFeedback.php", + dataType: 'json', + data: { action:"P_BAR_INFO", sbas_id: }, + success: function(data){ + if(data.records > 0) + { + alert(""); + } + else + { + if(confirm("")) + { + $.ajax({ + type: "POST", + url: "/admin/adminFeedback.php", + dataType: 'json', + data: { action:"DELETEBASE", sbas_id: }, + success: function(data){ + if(data.err == 0) // ok + { + parent.$("#TREE_DATABASES").trigger('click'); + parent.reloadTree("bases"); + } + else + { + if(data.errmsg) + alert(data.errmsg); + } + } + }); + } + } + } + }); + } + function clearAllLog() + { + if(confirm("")) + { + $.ajax({ + type: "POST", + url: "/admin/adminFeedback.php", + dataType: 'json', + data: { action:"CLEARALLLOG", sbas_id: + }, + success: function(data){ + } + }); + } + } + + function mountColl() + { + $('#mount_coll').toggle(); + } + + function activateColl() + { + $('#activate_coll').toggle(); + } + + function umountBase() + { + if(confirm("")) + { + $.ajax({ + type: "POST", + url: "/admin/adminFeedback.php", + dataType: 'json', + data: { action:"UNMOUNTBASE", sbas_id: + }, + success: function(data){ + parent.$("#TREE_DATABASES").trigger('click'); + } + }); + } + } + + function showDetails(sta) + { + document.forms["manageDatabase"].target = ""; + document.forms["manageDatabase"].act.value = ""; + document.forms["manageDatabase"].sta.value = sta; + document.forms["manageDatabase"].submit(); + } + function chgOrd(srt) + { + document.forms["manageDatabase"].target = ""; + document.forms["manageDatabase"].act.value = ""; + document.forms["manageDatabase"].sta.value = "1"; + document.forms["manageDatabase"].srt.value = srt; + document.forms["manageDatabase"].submit(); + } + $(document).ready(function(){ + refreshContent(); + });