mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 13:33:14 +00:00
Fix PDF logos
This commit is contained in:
@@ -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();
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -42,9 +42,10 @@ $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":
|
||||
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);
|
||||
$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');
|
||||
@@ -52,6 +53,11 @@ if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
} else {
|
||||
$printLogoUploadMsg = _('forms::erreur lors de l\'envoi du fichier');
|
||||
}
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$printLogoUploadMsg = _('Invalid file format');
|
||||
} catch (\Exception $e) {
|
||||
$printLogoUploadMsg = _('forms::erreur lors de l\'envoi du fichier');
|
||||
}
|
||||
break;
|
||||
case 'MOUNT':
|
||||
$appbox->get_connection()->beginTransaction();
|
||||
@@ -681,8 +687,14 @@ if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
</div>
|
||||
|
||||
<div id='printLogoDIV_NONE' style='margin:0 0 5px 0; display:none'>
|
||||
<?php echo(_('admin::base:collection: aucun fichier (minilogo, watermark ...)')) ?>
|
||||
|
||||
<?php
|
||||
if ( ! file_exists($registry->get('GV_RootPath') . 'config/minilogos/logopdf_' . $databox->get_sbas_id())) {
|
||||
echo(_('admin::base:collection: aucun fichier (minilogo, watermark ...)'));
|
||||
} else {
|
||||
echo '<img style="margin:5px;" src="/custom/minilogos/logopdf_1"/>';
|
||||
}
|
||||
?>
|
||||
<form method="post" name="flpdf" action="./database.php" target="???" onsubmit="return(false);" ENCTYPE="multipart/form-data">
|
||||
<input type="hidden" name="p0" value="<?php echo($parm["p0"]); ?>" />
|
||||
<input type="hidden" name="sta" value="\" />
|
||||
|
Reference in New Issue
Block a user