mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Fix stamp
This commit is contained in:
@@ -69,71 +69,42 @@ class recordutils_image extends recordutils
|
|||||||
* @param boolean $hd
|
* @param boolean $hd
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function stamp($bas, $rec, $hd = false)
|
public static function stamp(\media_subdef $subdef, $bas, $rec, $hd = false)
|
||||||
{
|
{
|
||||||
$registry = registry::get_instance();
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$debug = false;
|
$registry = $appbox->get_registry();
|
||||||
|
$base_id = $subdef->get_record()->get_base_id();
|
||||||
|
|
||||||
|
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
|
||||||
|
return $subdef->get_pathfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $subdef->is_physically_present()) {
|
||||||
|
return $subdef->get_pathfile();
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $registry->get('GV_imagick')) {
|
if ( ! $registry->get('GV_imagick')) {
|
||||||
return false;
|
return $subdef->get_pathfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
$sbas_id = phrasea::sbasFromBas($bas);
|
|
||||||
|
|
||||||
if ( ! isset($sbas_id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$connSbas = connection::getPDOConnection($sbas_id);
|
|
||||||
|
|
||||||
$sdname = 'preview';
|
|
||||||
if ($hd)
|
|
||||||
$sdname = 'document';
|
|
||||||
|
|
||||||
$sql = "SELECT path, file, s.mime, type, xml, prefs
|
|
||||||
FROM subdef s, record r, coll c
|
|
||||||
WHERE r.record_id = :record_id AND r.record_id = s.record_id
|
|
||||||
AND name = :name AND c.coll_id=r.coll_id";
|
|
||||||
|
|
||||||
$stmt = $connSbas->prepare($sql);
|
|
||||||
$stmt->execute(array(':record_id' => $rec, ':name' => $sdname));
|
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$sxprefs = $sxxml = $domprefs = FALSE;
|
|
||||||
|
|
||||||
if ($row) {
|
|
||||||
$domprefs = new DOMDocument();
|
$domprefs = new DOMDocument();
|
||||||
if ( ! ($domprefs->loadXML($row['prefs'])))
|
|
||||||
$domprefs = FALSE;
|
|
||||||
|
|
||||||
$sxxml = simplexml_load_string($row['xml']);
|
if (false === $domprefs->loadXML($subdef->get_record()->get_collection()->get_prefs())) {
|
||||||
$file = array(
|
return $subdef->get_pathfile();
|
||||||
'type' => $row['type']
|
|
||||||
, 'path' => p4string::addEndSlash($row['path'])
|
|
||||||
, 'file' => $row['file']
|
|
||||||
, 'mime' => $row['mime']
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($domprefs === FALSE || $sxxml === FALSE) {
|
if (false === $sxxml = simplexml_load_string($subdef->get_record()->get_caption()->serialize(caption_record::SERIALIZE_XML))) {
|
||||||
return false;
|
return $subdef->get_pathfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
$xpprefs = new DOMXPath($domprefs);
|
$xpprefs = new DOMXPath($domprefs);
|
||||||
|
|
||||||
$pathIn = $file['path'] . $file['file'];
|
$pathIn = $subdef->get_path() . $subdef->get_file();
|
||||||
$pathOut = $file['path'] . 'stamp_' . $file['file'];
|
$pathOut = $subdef->get_path() . 'stamp_' . $subdef->get_file();
|
||||||
$pathTmpStamp = $registry->get('GV_RootPath') . 'tmp/'
|
$pathTmpStamp = $registry->get('GV_RootPath') . 'tmp/' . time() . '-stamptmp_' . $subdef->get_file();
|
||||||
. time() . '-stamptmp_' . $file['file'];
|
|
||||||
|
|
||||||
if ( ! is_file($pathIn)) {
|
if ($xpprefs->query('/baseprefs/stamp')->length == 0) {
|
||||||
return false;
|
return $subdef->get_pathfile();
|
||||||
}
|
|
||||||
|
|
||||||
if ($file['type'] != 'image' ||
|
|
||||||
$xpprefs->query('/baseprefs/stamp')->length == 0) {
|
|
||||||
return $pathIn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$vars = $xpprefs->query('/baseprefs/stamp/*/var');
|
$vars = $xpprefs->query('/baseprefs/stamp/*/var');
|
||||||
@@ -145,7 +116,7 @@ class recordutils_image extends recordutils
|
|||||||
if ( ! ($format = $n->getAttribute('format')))
|
if ( ! ($format = $n->getAttribute('format')))
|
||||||
$format = 'Y/m/d H:i:s';
|
$format = 'Y/m/d H:i:s';
|
||||||
$varval = date($format);
|
$varval = date($format);
|
||||||
@unlink($pathOut); // since date is included, invalidate cache
|
@unlink($pathOut);
|
||||||
break;
|
break;
|
||||||
case 'RECORD_ID':
|
case 'RECORD_ID':
|
||||||
$varval = $rec;
|
$varval = $rec;
|
||||||
@@ -154,7 +125,6 @@ class recordutils_image extends recordutils
|
|||||||
$n->parentNode->replaceChild($domprefs->createTextNode($varval), $n);
|
$n->parentNode->replaceChild($domprefs->createTextNode($varval), $n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------- CACHING !
|
|
||||||
if (is_file($pathOut)) {
|
if (is_file($pathOut)) {
|
||||||
return $pathOut;
|
return $pathOut;
|
||||||
}
|
}
|
||||||
@@ -177,8 +147,6 @@ class recordutils_image extends recordutils
|
|||||||
|
|
||||||
$domprefs->normalizeDocument();
|
$domprefs->normalizeDocument();
|
||||||
|
|
||||||
$collname = phrasea::bas_names($bas);
|
|
||||||
|
|
||||||
if ( ! ($tailleimg = @getimagesize($pathIn))) {
|
if ( ! ($tailleimg = @getimagesize($pathIn))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -189,7 +157,7 @@ class recordutils_image extends recordutils
|
|||||||
$text_xpos = 0;
|
$text_xpos = 0;
|
||||||
$text_width = $image_width;
|
$text_width = $image_width;
|
||||||
|
|
||||||
$logofile = $registry->get('GV_RootPath') . 'config/stamp/' . $bas;
|
$logofile = $registry->get('GV_RootPath') . 'config/stamp/' . $base_id;
|
||||||
$logopos = null;
|
$logopos = null;
|
||||||
$imlogo = null; // gd image
|
$imlogo = null; // gd image
|
||||||
$logo_phywidth = $logo_phyheight = 0; // physical size
|
$logo_phywidth = $logo_phyheight = 0; // physical size
|
||||||
@@ -334,7 +302,7 @@ class recordutils_image extends recordutils
|
|||||||
return $pathOut;
|
return $pathOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return $subdef->get_pathfile();;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -488,11 +488,7 @@ class set_export extends set_abstract
|
|||||||
break;
|
break;
|
||||||
case 'document':
|
case 'document':
|
||||||
$subdef_export = true;
|
$subdef_export = true;
|
||||||
$path = recordutils_image::stamp(
|
$path = recordutils_image::stamp($sd[$name]);
|
||||||
$download_element->get_base_id()
|
|
||||||
, $download_element->get_record_id()
|
|
||||||
, true
|
|
||||||
);
|
|
||||||
$tmp_pathfile = array(
|
$tmp_pathfile = array(
|
||||||
'path' => $sd[$name]->get_path()
|
'path' => $sd[$name]->get_path()
|
||||||
, 'file' => $sd[$name]->get_file()
|
, 'file' => $sd[$name]->get_file()
|
||||||
|
Reference in New Issue
Block a user