Merge pull request #151 from romainneutron/Fixes

Multiple fixes
This commit is contained in:
Romain Neutron
2012-06-26 03:41:09 -07:00
6 changed files with 37 additions and 45 deletions

View File

@@ -36,7 +36,7 @@ return call_user_func(
$pathIn = $pathOut = $file->get_pathfile();
if ($watermark === true && $file->get_type() === \media_subdef::TYPE_IMAGE) {
$pathOut = \recordutils_image::watermark($record->get_base_id(), $record->get_record_id());
$pathOut = \recordutils_image::watermark($file);
} elseif ($stamp === true && $file->get_type() === \media_subdef::TYPE_IMAGE) {
$pathOut = \recordutils_image::stamp($record->get_base_id(), $record->get_record_id());
}

View File

@@ -168,7 +168,7 @@ class PDF
if ( ! $user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
&& $subdef->get_type() == \media_subdef::TYPE_IMAGE) {
$fimg = \recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id());
$fimg = \recordutils_image::watermark($subdef);
}
$wimg = $himg = $ImgSize;
@@ -436,7 +436,7 @@ class PDF
if ( ! $user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
&& $subdef->get_type() == \media_subdef::TYPE_IMAGE)
$f = \recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id());
$f = \recordutils_image::watermark($subdef);
$wimg = $himg = 150; // preview dans un carre de 150 mm
if ($subdef->get_width() > 0 && $subdef->get_height() > 0) {

View File

@@ -339,47 +339,30 @@ class recordutils_image extends recordutils
/**
*
* @param int $bas
* @param int $rec
* @param boolean $hd
* @return string
* @param \media_subdef $subdef
* @return boolean|string
*/
public static function watermark($bas, $rec, $hd = false)
public static function watermark(\media_subdef $subdef)
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry();
$base_id = $subdef->get_record()->get_base_id();
$sbas_id = phrasea::sbasFromBas($bas);
if ( ! isset($sbas_id)) {
return false;
if ($subdef->get_name() !== 'preview') {
return $subdef->get_pathfile();
}
$connSbas = connection::getPDOConnection($sbas_id);
$sql = "SELECT s.path, s.file, s.mime, r.type, r.xml
FROM subdef s, record r
WHERE r.record_id = :record_id AND r.record_id = s.record_id AND name='preview'";
$stmt = $connSbas->prepare($sql);
$stmt->execute(array(':record_id' => $rec));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if ( ! $row) {
return false;
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
return $subdef->get_pathfile();
}
$file = array(
'type' => $row['type']
, 'path' => p4string::addEndSlash($row['path'])
, 'file' => $row['file']
, 'mime' => $row['mime']
);
if ( ! $subdef->is_physically_present()) {
return $subdef->get_pathfile();
}
$pathIn = $file['path'] . $file['file'];
$pathIn = $subdef->get_path() . $subdef->get_file();
$pathOut = $file['path'] . 'watermark_' . $file['file'];
$pathOut = $subdef->get_path() . 'watermark_' . $subdef->get_file();
if ( ! is_file($pathIn)) {
return false;
@@ -390,9 +373,9 @@ class recordutils_image extends recordutils
}
if ($registry->get('GV_pathcomposite') &&
file_exists($registry->get('GV_RootPath') . 'config/wm/' . $bas)) { // si il y a un WM
file_exists($registry->get('GV_RootPath') . 'config/wm/' . $base_id)) { // si il y a un WM
$cmd = $registry->get('GV_pathcomposite') . " ";
$cmd .= $registry->get('GV_RootPath') . 'config/wm/' . $bas . " ";
$cmd .= $registry->get('GV_RootPath') . 'config/wm/' . $base_id . " ";
$cmd .= " \"" . $pathIn . "\" "; # <<-- la preview original
$cmd .= " -strip -watermark 90% -gravity center ";
$cmd .= " \"" . $pathOut . "\""; # <-- la preview temporaire
@@ -414,7 +397,7 @@ class recordutils_image extends recordutils
$return_value = proc_close($process);
}
} elseif ($registry->get('GV_imagick')) {
$collname = phrasea::bas_names($bas);
$collname = phrasea::bas_names($base_id);
$cmd = $registry->get('GV_imagick');
$tailleimg = @getimagesize($pathIn);
$max = ($tailleimg[0] > $tailleimg[1] ? $tailleimg[0] : $tailleimg[1]);

View File

@@ -356,7 +356,7 @@ class searchEngine_options implements Serializable
public function set_min_date($min_date)
{
if ( ! is_null($min_date) && trim($min_date) !== '') {
$this->date_min = DateTime::createFromFormat('d/m/Y H:i:s', $min_date . ' 00:00:00');
$this->date_min = DateTime::createFromFormat('Y/m/d H:i:s', $min_date . ' 00:00:00');
}
return $this;
@@ -379,7 +379,7 @@ class searchEngine_options implements Serializable
public function set_max_date($max_date)
{
if ( ! is_null($max_date) && trim($max_date) !== '') {
$this->date_max = DateTime::createFromFormat('d/m/Y H:i:s', $max_date . ' 23:59:59');
$this->date_max = DateTime::createFromFormat('Y/m/d H:i:s', $max_date . ' 23:59:59');
}
return $this;

View File

@@ -516,10 +516,7 @@ class set_export extends set_abstract
if ( ! $user->ACL()->has_right_on_base($download_element->get_base_id(), "nowatermark")
&& ! $user->ACL()->has_preview_grant($download_element)
&& $sd[$name]->get_type() == media_subdef::TYPE_IMAGE) {
$path = recordutils_image::watermark(
$download_element->get_base_id()
, $download_element->get_record_id()
);
$path = recordutils_image::watermark($sd[$name]);
if (file_exists($path)) {
$tmp_pathfile = array(
'path' => dirname($path)

View File

@@ -178,8 +178,18 @@
<div id="thesaurus_tab" class="PNB ui-tabs-panel ui-tabs-hide" style="top:52px;">
<div id="THPD_tabs">
<ul>
<li><a href="#THPD_T"><span>{% trans 'prod::thesaurusTab:thesaurus' %}</span></a></li>
<li><a href="#THPD_C"><span>{% trans 'prod::thesaurusTab:candidats' %}</span></a></li>
<li>
<a href="#THPD_T">
<span>{% trans 'prod::thesaurusTab:thesaurus' %}</span>
</a>
</li>
{% if user.ACL().has_access_to_module('thesaurus') %}
<li>
<a href="#THPD_C">
<span>{% trans 'prod::thesaurusTab:candidats' %}</span>
</a>
</li>
{% endif %}
</ul>
<div class="ui-tabs-panels-container">
<div id="THPD_T">
@@ -215,6 +225,7 @@
</div>
</div>
</div>
{% if user.ACL().has_access_to_module('thesaurus') %}
<div id="THPD_C">
<div id='THPD_C_treeBox' class="searchZone">
<div onclick="Xclick(event);return(false);" ondblclick="CXdblClick(event);">
@@ -232,6 +243,7 @@
</div>
</div>
</div>
{% endif %}
</div>
</div>
<div style="display:none" id="THPD_confirm_del_dlg">
@@ -435,7 +447,7 @@
<select name="datefield" class="input-medium">
{% for field_id, field in search_datas['dates'] %}
<option onchange="checkFilters(true);"
class="field_switch field_{{field['sbas']|implode(' field_')}}" value="{{field_id}}">{{field['fieldname']}}</option>
class="field_switch field_{{field['sbas']|implode(' field_')}}" value="{{ field['fieldname'] }}">{{field['fieldname']}}</option>
{% endfor %}
<option value="{{search_datas['dates']|array_keys|implode('|')}}" selected="selected">
{% trans 'rechercher dans tous les champs' %}