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();
|
||||
@@ -358,8 +364,8 @@ $out = "";
|
||||
|
||||
<div style='margin:3px 0 3px 10px;'>
|
||||
<?php echo(_('admin::base: Alias')) ?> : <span id="viewname"></span>
|
||||
<?php
|
||||
if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
<?php
|
||||
if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
?>
|
||||
<img src='/skins/icons/edit_0.gif' onclick="chgViewName();return(false);" style='vertical-align:middle'/>
|
||||
<?php
|
||||
@@ -511,7 +517,7 @@ if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
<div id='INDEX_P_BAR'>
|
||||
<div style='height:30px;'>
|
||||
<div>
|
||||
<?php echo(_('admin::base: document indexes en utilisant la fiche xml')); ?> :
|
||||
<?php echo(_('admin::base: document indexes en utilisant la fiche xml')); ?> :
|
||||
<span id='xml_indexed'></span>
|
||||
</div>
|
||||
<div id='xml_indexed_bar' style='position:absolute;width:0px;height:15px;background:#d4d0c9;z-index:6;'>
|
||||
@@ -521,7 +527,7 @@ if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
</div>
|
||||
<div style='height:30px;'>
|
||||
<div>
|
||||
<?php echo(_('admin::base: document indexes en utilisant le thesaurus')); ?> :
|
||||
<?php echo(_('admin::base: document indexes en utilisant le thesaurus')); ?> :
|
||||
<span id='thesaurus_indexed'></span>
|
||||
</div>
|
||||
<div id='thesaurus_indexed_bar' style='position:absolute;width:0px;height:15px;background:#d4d0c9;z-index:6;'>
|
||||
@@ -530,8 +536,8 @@ if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
<?php
|
||||
if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
?>
|
||||
<div style='margin:15px 5px 0px 0px;'>
|
||||
<input type='checkbox' id='is_indexable' onclick='makeIndexable(this)'/>
|
||||
@@ -655,8 +661,8 @@ if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- minilogo pour print pdf -->
|
||||
<div class='logo_boxes'>
|
||||
@@ -676,21 +682,27 @@ if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
<?php echo(_('admin::base:collection: supprimer le logo')) ?>
|
||||
</a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
}
|
||||
?>
|
||||
</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="\" />
|
||||
<input type="hidden" name="srt" value="" />
|
||||
<input type="hidden" name="act" value="" />
|
||||
<input type="hidden" name="tid" value="" />
|
||||
<?php
|
||||
if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
<?php
|
||||
if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_manage')) {
|
||||
?>
|
||||
<input name="newLogoPdf" type="file" />
|
||||
<input type='button' value='<?php echo(_('boutton::envoyer')); ?>' onclick='sendLogopdf();'/>
|
||||
|
Reference in New Issue
Block a user