This commit is contained in:
rGaillard
2011-07-06 10:10:43 +00:00
parent 31d94236ac
commit d1a13007b9
4695 changed files with 0 additions and 339293 deletions
-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>watermark</name>
<displayName>Watermark</displayName>
<version>0.1</version>
<description>Protect image by watermark.</description>
<author>PrestaShop</author>
<tab>administration</tab>
<confirmUninstall>Are you sure you want to delete your details ?</confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
</module>
-29
View File
@@ -1,29 +0,0 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{watermark}prestashop>watermark_ee20bb60493f049175fc10c35acd2272'] = 'Wasserzeichen';
$_MODULE['<{watermark}prestashop>watermark_8d7c07bcea7e80d072308e4bd4cc37b0'] = 'Bild schützen durch ein Wasserzeichen';
$_MODULE['<{watermark}prestashop>watermark_fa214007826415a21a8456e3e09f999d'] = 'Sie sind sicher, dass Sie Ihre Daten löschen wollen?';
$_MODULE['<{watermark}prestashop>watermark_e7bbd7019d9f73bc63f406de1422d989'] = 'Wasserzeichen-Bild muss um hochgeladen werden, damit dieses Modul richtig funktioniert';
$_MODULE['<{watermark}prestashop>watermark_f26d820220f1db94ea35bb61d95a80f4'] = 'Transparenz ist erforderlich.';
$_MODULE['<{watermark}prestashop>watermark_78d0b1c450a31c9728488a6b0a893e8a'] = 'Transparenz ist nicht im zulässigen Bereich.';
$_MODULE['<{watermark}prestashop>watermark_d31c2d99614d8e16430d2d8c99c1f2b0'] = 'Y-Align ist erforderlich.';
$_MODULE['<{watermark}prestashop>watermark_8fe9c39f4bf87082caabcf3650970c71'] = 'Y-Align ist nicht im zulässigen Bereich.';
$_MODULE['<{watermark}prestashop>watermark_c2cf8e33c907a4cc689881dc8fa571c2'] = 'X-Align ist erforderlich.';
$_MODULE['<{watermark}prestashop>watermark_3a1f788dbe8957be92048606cf0d3fcb'] = 'X-Align ist nicht im zulässigen Bereich.';
$_MODULE['<{watermark}prestashop>watermark_a9cac4be0fa0b815376b96f49e1435d7'] = 'Es ist mindestens eine Bildart erforderlich.';
$_MODULE['<{watermark}prestashop>watermark_b670770ad59c1f8e7fb65f276074172b'] = 'Bild muss im GIF-Format sein';
$_MODULE['<{watermark}prestashop>watermark_444bcb3a3fcf8389296c49467f27e1d6'] = 'ok';
$_MODULE['<{watermark}prestashop>watermark_c888438d14855d7d96a2724ee9c306bd'] = 'Einstellungen aktualisiert';
$_MODULE['<{watermark}prestashop>watermark_c0275788cf97660b52ab23f1f8c7c8d7'] = 'Wasserzeichen-Details';
$_MODULE['<{watermark}prestashop>watermark_cc99ba657a4a5ecf9d2d7cb974d25596'] = 'Sobald Sie das Modul eingestellt haben, müssen Sie die Bilder mit Hilfe des Tools in Präferenzen> wieder herstellen. Das Wasserzeichen wird in jedem Fall automatisch zu den neuen Bildern hinzugefügt.';
$_MODULE['<{watermark}prestashop>watermark_c23549e174914e9796db47d27c49eb95'] = 'Noch kein Wasserzeichen hochgeladen';
$_MODULE['<{watermark}prestashop>watermark_c9519bff5a6fe31e0f26b1c52dad7ad8'] = 'Wasserzeichen-Datei';
$_MODULE['<{watermark}prestashop>watermark_ce4ca541df51a63fd8e78e0da29e1d44'] = 'Muss im GIF-Format sein';
$_MODULE['<{watermark}prestashop>watermark_3ccc25c1409aec574beb82bad14b5ebc'] = 'Wasserzeichen-Transparenz (0-100)';
$_MODULE['<{watermark}prestashop>watermark_acf0fa79a73731e7d70cb208a62c249a'] = 'Wasserzeichen X align';
$_MODULE['<{watermark}prestashop>watermark_489f2e730102b59aec48b5c27d2cbe1c'] = 'Wasserzeichen Y align';
$_MODULE['<{watermark}prestashop>watermark_8d92a725c5abead5353e60e0b2fc7d6d'] = 'Wählen Sie die Bildarten für den Wasserzeichenschutz';
$_MODULE['<{watermark}prestashop>watermark_b17f3f4dcf653a5776792498a9b44d6a'] = 'Einstellungen aktualisieren';
$_MODULE['<{watermark}prestashop>watermark_220d9102465c9223781b8f99af48c154'] = 'Das Wasserzeichen ist kein echtes gif, bitte UMKONVERTIEREN und nicht umbenennen';
-4
View File
@@ -1,4 +0,0 @@
<?php
global $_MODULE;
$_MODULE = array();
-29
View File
@@ -1,29 +0,0 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{watermark}prestashop>watermark_ee20bb60493f049175fc10c35acd2272'] = 'Marca de agua (filigrana)';
$_MODULE['<{watermark}prestashop>watermark_8d7c07bcea7e80d072308e4bd4cc37b0'] = 'Proteja la imagen por una marca de agua';
$_MODULE['<{watermark}prestashop>watermark_fa214007826415a21a8456e3e09f999d'] = '¿Está seguro de querer suprimir los detalles?';
$_MODULE['<{watermark}prestashop>watermark_e7bbd7019d9f73bc63f406de1422d989'] = 'La imagen de la Marca de agua (filigrana) tiene que ser cargada para que este módulo funcione correctamente';
$_MODULE['<{watermark}prestashop>watermark_f26d820220f1db94ea35bb61d95a80f4'] = 'La transparencia es obligatoria';
$_MODULE['<{watermark}prestashop>watermark_78d0b1c450a31c9728488a6b0a893e8a'] = 'La transparencia no esta en la gama permitida';
$_MODULE['<{watermark}prestashop>watermark_d31c2d99614d8e16430d2d8c99c1f2b0'] = 'Se necesita alineación Y';
$_MODULE['<{watermark}prestashop>watermark_8fe9c39f4bf87082caabcf3650970c71'] = 'Alineación Y no permitida.';
$_MODULE['<{watermark}prestashop>watermark_c2cf8e33c907a4cc689881dc8fa571c2'] = 'Se necesita alineación X';
$_MODULE['<{watermark}prestashop>watermark_3a1f788dbe8957be92048606cf0d3fcb'] = 'Alineación X no permitida.';
$_MODULE['<{watermark}prestashop>watermark_a9cac4be0fa0b815376b96f49e1435d7'] = 'Se requiere al menos un tipo de imagen.';
$_MODULE['<{watermark}prestashop>watermark_b670770ad59c1f8e7fb65f276074172b'] = 'La imagen debe ser en formato GIF';
$_MODULE['<{watermark}prestashop>watermark_444bcb3a3fcf8389296c49467f27e1d6'] = 'ok';
$_MODULE['<{watermark}prestashop>watermark_c888438d14855d7d96a2724ee9c306bd'] = 'Ajustes actualizados';
$_MODULE['<{watermark}prestashop>watermark_c0275788cf97660b52ab23f1f8c7c8d7'] = 'Detalles de la filigrana';
$_MODULE['<{watermark}prestashop>watermark_cc99ba657a4a5ecf9d2d7cb974d25596'] = 'Una vez que haya creado el módulo, tiene que regenerar las imágenes a utilizar en la herramienta Preferencias> Imágenes. Sin embargo, la filigrana se añadirá automáticamente en las nuevas imágenes.';
$_MODULE['<{watermark}prestashop>watermark_c23549e174914e9796db47d27c49eb95'] = 'La marca de agua no se ha subido';
$_MODULE['<{watermark}prestashop>watermark_c9519bff5a6fe31e0f26b1c52dad7ad8'] = 'Archivo de la filigrana';
$_MODULE['<{watermark}prestashop>watermark_ce4ca541df51a63fd8e78e0da29e1d44'] = 'Debe ser en formato GIF';
$_MODULE['<{watermark}prestashop>watermark_3ccc25c1409aec574beb82bad14b5ebc'] = 'Transparencia de la marca de agua (0-100)';
$_MODULE['<{watermark}prestashop>watermark_acf0fa79a73731e7d70cb208a62c249a'] = 'Alineación X de la marca de agua';
$_MODULE['<{watermark}prestashop>watermark_489f2e730102b59aec48b5c27d2cbe1c'] = 'Alineación Y de la marca de agua';
$_MODULE['<{watermark}prestashop>watermark_8d92a725c5abead5353e60e0b2fc7d6d'] = 'Elija el tipo de imagen para proteger la filigrana';
$_MODULE['<{watermark}prestashop>watermark_b17f3f4dcf653a5776792498a9b44d6a'] = 'Ajustes actualizados';
$_MODULE['<{watermark}prestashop>watermark_220d9102465c9223781b8f99af48c154'] = 'Su imagen filigrana no es un verdadero formato gif, conviértalo en lugar de renombrarlo';
-29
View File
@@ -1,29 +0,0 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{watermark}prestashop>watermark_ee20bb60493f049175fc10c35acd2272'] = 'Filigrane';
$_MODULE['<{watermark}prestashop>watermark_8d7c07bcea7e80d072308e4bd4cc37b0'] = 'Protégez vos images avec un filigrane';
$_MODULE['<{watermark}prestashop>watermark_fa214007826415a21a8456e3e09f999d'] = 'Êtes-vous sûr de vouloir tout supprimer ?';
$_MODULE['<{watermark}prestashop>watermark_e7bbd7019d9f73bc63f406de1422d989'] = 'Le filigrane doit être chargé pour que le module fonctionne correctement';
$_MODULE['<{watermark}prestashop>watermark_f26d820220f1db94ea35bb61d95a80f4'] = 'La transparence est requise';
$_MODULE['<{watermark}prestashop>watermark_78d0b1c450a31c9728488a6b0a893e8a'] = 'Valeur incorrecte pour la transparence';
$_MODULE['<{watermark}prestashop>watermark_d31c2d99614d8e16430d2d8c99c1f2b0'] = 'Alignement Y requis';
$_MODULE['<{watermark}prestashop>watermark_8fe9c39f4bf87082caabcf3650970c71'] = 'Valeur incorrecte pour l\'alignement en Y';
$_MODULE['<{watermark}prestashop>watermark_c2cf8e33c907a4cc689881dc8fa571c2'] = 'Alignement X requis';
$_MODULE['<{watermark}prestashop>watermark_3a1f788dbe8957be92048606cf0d3fcb'] = 'Valeur incorrecte pour l\'alignement en X';
$_MODULE['<{watermark}prestashop>watermark_a9cac4be0fa0b815376b96f49e1435d7'] = 'Au moins un type d\'image doit être selectionné';
$_MODULE['<{watermark}prestashop>watermark_b670770ad59c1f8e7fb65f276074172b'] = 'l\'image doit être au format GIF';
$_MODULE['<{watermark}prestashop>watermark_444bcb3a3fcf8389296c49467f27e1d6'] = 'OK';
$_MODULE['<{watermark}prestashop>watermark_c888438d14855d7d96a2724ee9c306bd'] = 'Paramètres sauvegardés';
$_MODULE['<{watermark}prestashop>watermark_c0275788cf97660b52ab23f1f8c7c8d7'] = 'Configuration du filigrane';
$_MODULE['<{watermark}prestashop>watermark_cc99ba657a4a5ecf9d2d7cb974d25596'] = 'Une fois que vous avez configuré le module, vous devez régénérer les images à l\'aide de l\'outil disponible dans Préférences > Images. Notez que le filigrane sera intégré automatiquement aux nouvelles images que vous ajouterez.';
$_MODULE['<{watermark}prestashop>watermark_c23549e174914e9796db47d27c49eb95'] = 'Aucun filigrane pour le moment';
$_MODULE['<{watermark}prestashop>watermark_c9519bff5a6fe31e0f26b1c52dad7ad8'] = 'Fichier du filigrane';
$_MODULE['<{watermark}prestashop>watermark_ce4ca541df51a63fd8e78e0da29e1d44'] = 'Doit être au format GIF';
$_MODULE['<{watermark}prestashop>watermark_3ccc25c1409aec574beb82bad14b5ebc'] = 'Transparence';
$_MODULE['<{watermark}prestashop>watermark_acf0fa79a73731e7d70cb208a62c249a'] = 'Alignement en X';
$_MODULE['<{watermark}prestashop>watermark_489f2e730102b59aec48b5c27d2cbe1c'] = 'Alignement en Y';
$_MODULE['<{watermark}prestashop>watermark_8d92a725c5abead5353e60e0b2fc7d6d'] = 'Choisissez les types d\'image pour lesquels le filigrane doit s\'appliquer';
$_MODULE['<{watermark}prestashop>watermark_b17f3f4dcf653a5776792498a9b44d6a'] = 'Sauvegarder';
$_MODULE['<{watermark}prestashop>watermark_220d9102465c9223781b8f99af48c154'] = 'votre image filigrane n\'est pas un vrai format gif, merci de le convertir au lieu de la renommer';
-29
View File
@@ -1,29 +0,0 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{watermark}prestashop>watermark_ee20bb60493f049175fc10c35acd2272'] = 'Filigrana';
$_MODULE['<{watermark}prestashop>watermark_8d7c07bcea7e80d072308e4bd4cc37b0'] = 'Proteggi immagine con la filigrana';
$_MODULE['<{watermark}prestashop>watermark_fa214007826415a21a8456e3e09f999d'] = 'Sei sicuro di voler cancellare i tuoi dati?';
$_MODULE['<{watermark}prestashop>watermark_e7bbd7019d9f73bc63f406de1422d989'] = 'L\'immagine filigrana deve essere caricata affinché questo modulo funzioni correttamente';
$_MODULE['<{watermark}prestashop>watermark_f26d820220f1db94ea35bb61d95a80f4'] = 'La trasparenza è richiesta.';
$_MODULE['<{watermark}prestashop>watermark_78d0b1c450a31c9728488a6b0a893e8a'] = 'La trasparenza non è nel range ammesso.';
$_MODULE['<{watermark}prestashop>watermark_d31c2d99614d8e16430d2d8c99c1f2b0'] = 'Y-Align è richiesto.';
$_MODULE['<{watermark}prestashop>watermark_8fe9c39f4bf87082caabcf3650970c71'] = 'Y-align non è nel range ammesso.';
$_MODULE['<{watermark}prestashop>watermark_c2cf8e33c907a4cc689881dc8fa571c2'] = 'X-Align è richiesto.';
$_MODULE['<{watermark}prestashop>watermark_3a1f788dbe8957be92048606cf0d3fcb'] = 'X-Align non è nel range ammesso.';
$_MODULE['<{watermark}prestashop>watermark_a9cac4be0fa0b815376b96f49e1435d7'] = 'Almeno un tipo di immagine è richiesto.';
$_MODULE['<{watermark}prestashop>watermark_b670770ad59c1f8e7fb65f276074172b'] = 'immagine deve essere in formato GIF';
$_MODULE['<{watermark}prestashop>watermark_444bcb3a3fcf8389296c49467f27e1d6'] = 'ok';
$_MODULE['<{watermark}prestashop>watermark_c888438d14855d7d96a2724ee9c306bd'] = 'Impostazioni aggiornate';
$_MODULE['<{watermark}prestashop>watermark_c0275788cf97660b52ab23f1f8c7c8d7'] = 'Dettagli filigrana';
$_MODULE['<{watermark}prestashop>watermark_cc99ba657a4a5ecf9d2d7cb974d25596'] = 'Una volta impostato il modulo, è necessario rigenerare le immagini usando lo strumento in Preferenze> Foto. Tuttavia, la filigrana verrà aggiunta automaticamente alle nuove immagini.';
$_MODULE['<{watermark}prestashop>watermark_c23549e174914e9796db47d27c49eb95'] = 'Nessuna filigrana ancora caricata';
$_MODULE['<{watermark}prestashop>watermark_c9519bff5a6fe31e0f26b1c52dad7ad8'] = 'File filigrana';
$_MODULE['<{watermark}prestashop>watermark_ce4ca541df51a63fd8e78e0da29e1d44'] = 'Deve essere in formato GIF';
$_MODULE['<{watermark}prestashop>watermark_3ccc25c1409aec574beb82bad14b5ebc'] = 'Trasparenza filigrana (0-100)';
$_MODULE['<{watermark}prestashop>watermark_acf0fa79a73731e7d70cb208a62c249a'] = 'Filigrana X align';
$_MODULE['<{watermark}prestashop>watermark_489f2e730102b59aec48b5c27d2cbe1c'] = 'Filigrana Y align';
$_MODULE['<{watermark}prestashop>watermark_8d92a725c5abead5353e60e0b2fc7d6d'] = 'Scegli i tipi di immagine per la protezione della filigrana';
$_MODULE['<{watermark}prestashop>watermark_b17f3f4dcf653a5776792498a9b44d6a'] = 'Aggiorna le impostazioni';
$_MODULE['<{watermark}prestashop>watermark_220d9102465c9223781b8f99af48c154'] = 'l\'immagine della filigrana non è un vero e proprio gif, per favore CONVERTI e non rinominarlo';
Binary file not shown.

Before

Width:  |  Height:  |  Size: 988 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

-261
View File
@@ -1,261 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_CAN_LOAD_FILES_'))
exit;
class Watermark extends Module
{
private $_html = '';
private $_postErrors = array();
private $xaligns = array('left', 'middle', 'right');
private $yaligns = array('top', 'middle', 'bottom');
private $yAlign;
private $xAlign;
private $transparency;
private $imageTypes = array();
private $watermarkTypes;
private $maxImageSize = 100000;
public function __construct()
{
$this->name = 'watermark';
$this->tab = 'administration';
$this->version = 0.1;
$this->author = 'PrestaShop';
parent::__construct();
$config = Configuration::getMultiple(array('WATERMARK_TYPES', 'WATERMARK_Y_ALIGN', 'WATERMARK_X_ALIGN', 'WATERMARK_TRANSPARENCY'));
if (!isset($config['WATERMARK_TYPES']))
$config['WATERMARK_TYPES'] = '';
$tmp = explode(',', $config['WATERMARK_TYPES']);
foreach (ImageType::getImagesTypes('products') as $type)
if (in_array($type['id_image_type'], $tmp))
$this->imageTypes[] = $type;
$this->yAlign = isset($config['WATERMARK_Y_ALIGN']) ? $config['WATERMARK_Y_ALIGN'] : '';
$this->xAlign = isset($config['WATERMARK_X_ALIGN']) ? $config['WATERMARK_X_ALIGN'] : '';
$this->transparency = isset($config['WATERMARK_TRANSPARENCY']) ? $config['WATERMARK_TRANSPARENCY'] : 60;
$this->displayName = $this->l('Watermark');
$this->description = $this->l('Protect image by watermark.');
$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
if (!isset($this->transparency) OR !isset($this->xAlign) OR !isset($this->yAlign))
$this->warning = $this->l('Watermark image must be uploaded in order for this module to work correctly.');
}
public function install()
{
if (!parent::install() OR !$this->registerHook('watermark'))
return false;
Configuration::updateValue('WATERMARK_TRANSPARENCY', 60);
Configuration::updateValue('WATERMARK_Y_ALIGN', 'bottom');
Configuration::updateValue('WATERMARK_X_ALIGN', 'right');
return true;
}
public function uninstall()
{
return (parent::uninstall()
AND Configuration::deleteByName('WATERMARK_TYPES')
AND Configuration::deleteByName('WATERMARK_TRANSPARENCY')
AND Configuration::deleteByName('WATERMARK_Y_ALIGN')
AND Configuration::deleteByName('WATERMARK_X_ALIGN'));
}
private function _postValidation()
{
$yalign = Tools::getValue('yalign');
$xalign = Tools::getValue('xalign');
$transparency = (int)(Tools::getValue('transparency'));
$image_types = Tools::getValue('image_types');
if (empty($transparency))
$this->_postErrors[] = $this->l('Transparency required.');
elseif($transparency < 0 || $transparency > 100)
$this->_postErrors[] = $this->l('Transparency is not in allowed range.');
if (empty($yalign))
$this->_postErrors[] = $this->l('Y-Align is required.');
elseif(!in_array($yalign, $this->yaligns))
$this->_postErrors[] = $this->l('Y-Align is not in allowed range.');
if (empty($xalign))
$this->_postErrors[] = $this->l('X-Align is required.');
elseif(!in_array($xalign, $this->xaligns))
$this->_postErrors[] = $this->l('X-Align is not in allowed range.');
if (empty($image_types))
$this->_postErrors[] = $this->l('At least one image type is required.');
if (isset($_FILES['PS_WATERMARK']['tmp_name']) AND !empty($_FILES['PS_WATERMARK']['tmp_name']))
{
if (!isPicture($_FILES['PS_WATERMARK'], array('image/gif')))
$this->_postErrors[] = $this->l('Image must be in GIF format.');
}
return !sizeof($this->_postErrors) ? true : false;
}
private function _postProcess(){
Configuration::updateValue('WATERMARK_TYPES', implode(',', Tools::getValue('image_types')));
Configuration::updateValue('WATERMARK_Y_ALIGN', Tools::getValue('yalign'));
Configuration::updateValue('WATERMARK_X_ALIGN', Tools::getValue('xalign'));
Configuration::updateValue('WATERMARK_TRANSPARENCY', Tools::getValue('transparency'));
//submited watermark
if (isset($_FILES['PS_WATERMARK']) AND !empty($_FILES['PS_WATERMARK']['tmp_name']))
{
/* Check watermark validity */
if ($error = checkImage($_FILES['PS_WATERMARK'], $this->maxImageSize))
$this->_errors[] = $error;
/* Copy new watermark */
elseif(!copy($_FILES['PS_WATERMARK']['tmp_name'], dirname(__FILE__).'/watermark.gif'))
$this->_errors[] = Tools::displayError('an error occurred while uploading watermark: '.$_FILES['PS_WATERMARK']['tmp_name'].' to '.$dest);
}
$this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('ok').'" /> '.$this->l('Settings updated').'</div>';
}
private function _displayForm()
{
$imageTypes = ImageType::getImagesTypes('products');
$this->_html .=
'<form action="'.$_SERVER['REQUEST_URI'].'" method="post" enctype="multipart/form-data">
<fieldset><legend><img src="../modules/'.$this->name.'/logo.gif" />'.$this->l('Watermark details').'</legend>
<p>'.$this->l('Once you have set up the module, regenerate the images using the "Images" tool in Preferences. However, the watermark will be added automatically to new images.').'</p>
<table border="0" width="500" cellpadding="0" cellspacing="0" id="form">
<tr>
<td />
<td>'.(file_exists(dirname(__FILE__).'/watermark.gif') ? '<img src="../modules/'.$this->name.'/watermark.gif?t='.time().'" />' : $this->l('No watermark uploaded.')).'</td>
</tr>
<tr>
<td>'.$this->l('Watermark file').'</td>
<td>
<input type="file" name="PS_WATERMARK" />
<p style="color:#7F7F7F; font-size:0.85em; margin:0; padding:0;">'.$this->l('Must be in GIF format').'</p>
</td>
</tr>
<tr>
<td width="270" style="height: 35px;">'.$this->l('Watermark transparency (0-100)').'</td>
<td><input type="text" name="transparency" value="'.Tools::getValue('transparency', Configuration::get('WATERMARK_TRANSPARENCY')).'" style="width: 30px;" /></td>
</tr>
<tr><td width="270" style="height: 35px;">'.$this->l('Watermark X align').'</td>
<td>
<select id="xalign" name = "xalign">';
foreach($this->xaligns as $align)
$this->_html .= '<option value="'.$align.'"'.(Tools::getValue('xalign', Configuration::get('WATERMARK_X_ALIGN')) == $align ? ' selected="selected"' : '' ).'>'.$this->l($align).'</option>';
$this->_html .= '</select>
</td>
</tr>
<tr><td width="270" style="height: 35px;">'.$this->l('Watermark Y align').'</td>
<td>
<select id="yalign" name = "yalign">';
foreach($this->yaligns as $align)
$this->_html .= '<option value="'.$align.'"'.(Tools::getValue('yalign', Configuration::get('WATERMARK_Y_ALIGN')) == $align ? ' selected="selected"' : '' ).'>'.$this->l($align).'</option>';
$this->_html .= '</select>
</td>
</tr>
<tr><td width="270" style="height: 35px;">'.$this->l('Choose image types for watermark protection.').'</td><td>';
$selected_types = explode(',', Configuration::get('WATERMARK_TYPES'));
foreach(ImageType::getImagesTypes('products') as $type)
{
$this->_html .= '<label style="float:none; ">
<input type="checkbox" value="'.$type['id_image_type'].'" name="image_types[]"'.
(in_array($type['id_image_type'], $selected_types) ? ' checked="checked"' : '').' />&nbsp;<span style="font-weight:bold;">'.$type['name'].'</span>
('.$type['width'].' x '.$type['height'].')</label><br />';
}
$this->_html .= '</td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2" align="center"><input class="button" name="btnSubmit" value="'.$this->l('Update settings').'" type="submit" /></td></tr>
</table>
</fieldset>
</form>';
}
public function getContent()
{
$this->_html = '<h2>'.$this->displayName.'</h2>';
if (!empty($_POST))
{
$this->_postValidation();
if (!sizeof($this->_postErrors))
$this->_postProcess();
else
foreach ($this->_postErrors AS $err)
$this->_html .= '<div class="alert error">'. $err .'</div>';
}
else
$this->_html .= '<br />';
$this->_displayForm();
return $this->_html;
}
//we assume here only jpg files
public function hookwatermark($params)
{
global $smarty;
$file = _PS_PROD_IMG_DIR_.$params['id_product'].'-'.$params['id_image'].'-watermark.jpg';
//first make a watermark image
$return = $this->watermarkByImage(_PS_PROD_IMG_DIR_.$params['id_product'].'-'.$params['id_image'].'.jpg', dirname(__FILE__).'/watermark.gif', $file, 23, 0, 0, 'right');
//go through file formats defined for watermark and resize them
foreach($this->imageTypes as $imageType)
{
$newFile = _PS_PROD_IMG_DIR_.$params['id_product'].'-'.$params['id_image'].'-'.stripslashes($imageType['name']).'.jpg';
if (!imageResize($file, $newFile, (int)($imageType['width']), (int)($imageType['height'])))
$return = false;
}
return $return;
}
private function watermarkByImage($imagepath, $watermarkpath, $outputpath)
{
$Xoffset = $Yoffset = $xpos = $ypos = 0;
if (!$image = imagecreatefromjpeg($imagepath))
return false;
if (!$imagew = imagecreatefromgif($watermarkpath))
die ($this->l('The watermark image is not a real gif, please CONVERT the image.'));
list($watermarkWidth, $watermarkHeight) = getimagesize($watermarkpath);
list($imageWidth, $imageHeight) = getimagesize($imagepath);
if ($this->xAlign == "middle") { $xpos = $imageWidth/2 - $watermarkWidth/2 + $Xoffset; }
if ($this->xAlign == "left") { $xpos = 0 + $Xoffset; }
if ($this->xAlign == "right") { $xpos = $imageWidth - $watermarkWidth - $Xoffset; }
if ($this->yAlign == "middle") { $ypos = $imageHeight/2 - $watermarkHeight/2 + $Yoffset; }
if ($this->yAlign == "top") { $ypos = 0 + $Yoffset; }
if ($this->yAlign == "bottom") { $ypos = $imageHeight - $watermarkHeight - $Yoffset; }
if (!imagecopymerge($image, $imagew, $xpos, $ypos, 0, 0, $watermarkWidth, $watermarkHeight, $this->transparency))
return false;
return imagejpeg($image, $outputpath, 100);
}
}