'.getPreinstallXmlLang($field, 'label').' : ';
if ($field->type == 'text' || $field->type == 'password')
echo '
size) ? 'size="'.$field->size.'"' : '').' value="'.(isset($_GET[trim($field->key)]) ? $_GET[trim($field->key)] : $field->default).'" />';
elseif ($field->type == 'radio')
@@ -99,7 +99,7 @@
if ($_GET['request'] == 'send')
{
- $context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 5)));
+ $stream_context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 5)));
$url = 'http://www.prestashop.com/partner/preactivation/actions.php?version=1.0&partner='.addslashes($_GET['partner']);
// Protect fields
@@ -111,7 +111,7 @@
foreach ($_GET as $key => $val)
$url .= '&'.$key.'='.urlencode($val);
$url .= '&security='.md5($_GET['email']._COOKIE_IV_);
- $content = @file_get_contents($url, false, $context);
+ $content = @file_get_contents($url, false, $stream_context);
if ($content)
echo $content;
else
diff --git a/install-dev/sql/db_settings_lite.sql b/install-dev/sql/db_settings_lite.sql
index 2a7dafeb7..2db213592 100644
--- a/install-dev/sql/db_settings_lite.sql
+++ b/install-dev/sql/db_settings_lite.sql
@@ -202,7 +202,8 @@ INSERT INTO `PREFIX_configuration` (`id_configuration`, `name`, `value`, `date_a
(131, 'PS_PNG_QUALITY', '7', NOW(), NOW()),
(132, 'PS_JPEG_QUALITY', '90', NOW(), NOW()),
(133, 'PS_COOKIE_LIFETIME_FO', '480', NOW(), NOW()),
-(134, 'PS_COOKIE_LIFETIME_BO', '480', NOW(), NOW());
+(134, 'PS_COOKIE_LIFETIME_BO', '480', NOW(), NOW()),
+(135, 'PS_RESTRICT_DELIVERED_COUNTRIES', '0', NOW(), NOW());
INSERT INTO `PREFIX_configuration_lang` (`id_configuration`, `id_lang`, `value`, `date_upd`) VALUES
(36, 1, 'IN', NOW()),(36, 2, 'FA', NOW()),(36, 3, 'CU', NOW()),(36, 4, 'FA', NOW()),(36, 5, 'FA', NOW()),
@@ -740,7 +741,7 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
(1, 12, 'Addresses'),(1, 13, 'Statuses'),(1, 14, 'Vouchers'),(1, 15, 'Currencies'),(1, 16, 'Taxes'),(1, 17, 'Carriers'),(1, 18, 'Countries'),
(1, 19, 'Zones'),(1, 20, 'Price Ranges'),(1, 21, 'Weight Ranges'),(1, 22, 'Positions'),(1, 23, 'Database'),(1, 24, 'E-mail'),(1, 26, 'Image'),
(1, 27, 'Products'),(1, 28, 'Contacts'),(1, 29, 'Employees'),(1, 30, 'Profiles'),(1, 31, 'Permissions'),(1, 32, 'Languages'),(1, 33, 'Translations'),
-(1, 34, 'Suppliers'),(1, 35, 'Tabs'),(1, 36, 'Features'),(1, 37, 'Quick Access'),(1, 38, 'Appearance'),(1, 39, 'Contact Information'),(1, 40, 'Alias Research'),
+(1, 34, 'Suppliers'),(1, 35, 'Tabs'),(1, 36, 'Features'),(1, 37, 'Quick Access'),(1, 38, 'Appearance'),(1, 39, 'Contact Information'),(1, 40, 'Aliases'),
(1, 41, 'Import'),(1, 42, 'Invoices'),(1, 43, 'Search'),(1, 44, 'Localization'),(1, 46, 'States'),(1, 47, 'Merchandise Returns'),(1, 48, 'PDF'),
(1, 49, 'Credit Slips'),(1, 51, 'Settings'),(1, 52, 'Subdomains'),(1, 53, 'DB backup'),(1, 54, 'Order Messages'),
(1, 55, 'Delivery Slips'),(1, 56, 'SEO & URLs'),(1, 57, 'CMS'),(1, 58, 'Image Mapping'),(1, 59, 'Customer Messages'),(1, 60, 'Tracking'),
@@ -755,7 +756,7 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
(2, 14, 'Bons de réduction'),(2, 15, 'Devises'),(2, 16, 'Taxes'),(2, 17, 'Transporteurs'),(2, 18, 'Pays'),(2, 19, 'Zones'),(2, 20, 'Tranches de prix'),
(2, 21, 'Tranches de poids'),(2, 22, 'Positions'),(2, 23, 'Base de données'),(2, 24, 'Emails'),(2, 26, 'Images'),(2, 27, 'Produits'),(2, 28, 'Contacts'),
(2, 29, 'Employés'),(2, 30, 'Profils'),(2, 31, 'Permissions'),(2, 32, 'Langues'),(2, 33, 'Traductions'),(2, 34, 'Fournisseurs'),(2, 35, 'Onglets'),
-(2, 36, 'Caractéristiques'),(2, 37, 'Accès rapide'),(2, 38, 'Apparence'),(2, 39, 'Coordonnées'),(2, 40, 'Alias de recherche'),(2, 41, 'Import'),(2, 42, 'Factures'),
+(2, 36, 'Caractéristiques'),(2, 37, 'Accès rapide'),(2, 38, 'Apparence'),(2, 39, 'Coordonnées'),(2, 40, 'Alias'),(2, 41, 'Import'),(2, 42, 'Factures'),
(2, 43, 'Recherche'),(2, 44, 'Localisation'),(2, 46, 'Etats'),(2, 47, 'Retours produits'),(2, 48, 'PDF'),(2, 49, 'Avoirs'),
(2, 51, 'Configuration'),(2, 52, 'Sous domaines'),(2, 53, 'Sauvegarde BDD'),(2, 54, 'Messages prédéfinis'),(2, 55, 'Bons de livraison'),
(2, 56, 'SEO & URLs'),(2, 57, 'CMS'),(2, 58, 'Scènes'),(2, 59, 'Messages clients'),(2, 60, 'Suivi'),(2, 61, 'Moteurs de recherche'),
@@ -770,7 +771,7 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
(3, 13, 'Estados'),(3, 14, 'Vales de descuento'),(3, 15, 'Divisas'),(3, 16, 'Impuestos'),(3, 17, 'Transportistas'),(3, 18, 'Países'),(3, 19, 'Zonas'),
(3, 20, 'Franja de precios'),(3, 21, 'Franja de pesos'),(3, 22, 'Posiciones'),(3, 23, 'Base de datos'),(3, 24, 'Emails'),(3, 26, 'Imágenes'),
(3, 27, 'Productos'),(3, 28, 'Contactos'),(3, 29, 'Empleados'),(3, 30, 'Perfiles'),(3, 31, 'Permisos'),(3, 32, 'Idiomas'),(3, 33, 'Traducciones'),
-(3, 34, 'Proveedores'),(3, 35, 'Pestañas'),(3, 36, 'Características'),(3, 37, 'Acceso rápido'),(3, 38, 'Aspecto'),(3, 39, 'Datos'),(3, 40, 'Alias de Investigación'),
+(3, 34, 'Proveedores'),(3, 35, 'Pestañas'),(3, 36, 'Características'),(3, 37, 'Acceso rápido'),(3, 38, 'Aspecto'),(3, 39, 'Datos'),(3, 40, 'Alias'),
(3, 41, 'Importar'),(3, 42, 'Facturas'),(3, 43, 'Búsqueda'),(3, 44, 'Ubicación'),(3, 46, 'Estados'),(3, 47, 'Devolución productos'),(3, 48, 'PDF'),
(3, 49, 'Vales'),(3, 51, 'Configuración'),(3, 52, 'Subcampos'),(3, 53, 'Copia de seguridad'),(3, 54, 'Mensajes de Orden'),
(3, 55, 'Albaranes de entrega'),(3, 56, 'SEO & URLs'),(3, 57, 'CMS'),(3, 58, 'Mapeo de la imagen'),(3, 59, 'Mensajes del cliente'),(3, 60, 'Rastreo'),
@@ -784,7 +785,7 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
(4, 12, 'Adressen'),(4, 13, 'Status'),(4, 14, 'Gutscheine'),(4, 15, 'Währungen'),(4, 16, 'Steuern'),(4, 17, 'Lieferanten'),(4, 18, 'Länder'),
(4, 19, 'Zonen'),(4, 20, 'Preislagen'),(4, 21, 'Gewichtsklassen'),(4, 22, 'Positionen'),(4, 23, 'Datenbank'),(4, 24, 'E-Mail'),(4, 26, 'Bild'),
(4, 27, 'Produkte'),(4, 28, 'Kontakte'),(4, 29, 'Mitarbeiter'),(4, 30, 'Profile'),(4, 31, 'Berechtigungen'),(4, 32, 'Sprachen'),(4, 33, 'Übersetzungen'),
-(4, 34, 'Zulieferer'),(4, 35, 'Tabs'),(4, 36, 'Funktionen'),(4, 37, 'Schnellzugriff'),(4, 38, 'Aussehen'),(4, 39, 'Kontaktinformation'),(4, 40, 'Suchname'),
+(4, 34, 'Zulieferer'),(4, 35, 'Tabs'),(4, 36, 'Funktionen'),(4, 37, 'Schnellzugriff'),(4, 38, 'Aussehen'),(4, 39, 'Kontaktinformation'),(4, 40, 'Alias'),
(4, 41, 'Import'),(4, 42, 'Rechnungen'),(4, 43, 'Suche'),(4, 44, 'Lokalisierung'),(4, 46, 'Staaten'),(4, 47, 'Warenrücksendungen'),(4, 48, 'PDF'),
(4, 49, 'Gutscheine'),(4, 51, 'Einstellungen'),(4, 52, 'Subdomains'),(4, 53, 'DB-Backup'),(4, 54, 'Bestellnachrichten'),
(4, 55, 'Lieferscheine'),(4, 56, 'SEO & URLs'),(4, 57, 'CMS'),(4, 58, 'Image Mapping'),(4, 59, 'Kundennachrichten'),(4, 60, 'Tracking'),
@@ -799,7 +800,7 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
(5, 12, 'Indirizzi'),(5, 13, 'Status'),(5, 14, 'Voucher'),(5, 15, 'Valute'),(5, 16, 'Tasse'),(5, 17, 'Corrieri'),(5, 18, 'Nazioni'),
(5, 19, 'Zone'),(5, 20, 'Fasce di prezzo'),(5, 21, 'Fasce di peso'),(5, 22, 'Posizioni'),(5, 23, 'Database'),(5, 24, 'E-mail'),(5, 26, 'Immagine'),
(5, 27, 'Prodotti'),(5, 28, 'Contatti'),(5, 29, 'Impiegati'),(5, 30, 'Profili'),(5, 31, 'Permessi'),(5, 32, 'Lingue'),(5, 33, 'Traduzioni'),
-(5, 34, 'Fornitori'),(5, 35, 'Tab'),(5, 36, 'Caratteristiche'),(5, 37, 'Accesso rapido'),(5, 38, 'Aspetto'),(5, 39, 'Informazioni di contatto'),(5, 40, 'Alias di ricerca'),
+(5, 34, 'Fornitori'),(5, 35, 'Tab'),(5, 36, 'Caratteristiche'),(5, 37, 'Accesso rapido'),(5, 38, 'Aspetto'),(5, 39, 'Informazioni di contatto'),(5, 40, 'Alias'),
(5, 41, 'Importa'),(5, 42, 'Fatture'),(5, 43, 'Cerca'),(5, 44, 'Localizzazione'),(5, 46, 'Stati'),(5, 47, 'Resi merci'),(5, 48, 'PDF'),
(5, 49, 'Note di credito'),(5, 51, 'Impostazioni'),(5, 52, 'Sottodomini'),(5, 53, 'DB backup'),(5, 54, 'Messaggi ordine'),
(5, 55, 'Note di consegna'),(5, 56, 'SEO & URLs'),(5, 57, 'CMS'),(5, 58, 'Mappatura immagine'),(5, 59, 'Messaggi cliente'),(5, 60, 'Rintracciare'),
diff --git a/install-dev/sql/upgrade/1.4.5.0.sql b/install-dev/sql/upgrade/1.4.5.0.sql
new file mode 100644
index 000000000..0f3d8270a
--- /dev/null
+++ b/install-dev/sql/upgrade/1.4.5.0.sql
@@ -0,0 +1,14 @@
+SET NAMES 'utf8';
+
+INSERT IGNORE INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VALUES
+('PS_RESTRICT_DELIVERED_COUNTRIES', '0', NOW(), NOW());
+
+UPDATE `PREFIX_country_lang`
+SET `name` = 'United States'
+WHERE `name` = 'United State'
+AND `id_lang` = (
+ SELECT `id_lang`
+ FROM `PREFIX_lang`
+ WHERE `iso_code` = 'en'
+ LIMIT 1
+);
\ No newline at end of file
diff --git a/install-dev/view.css b/install-dev/view.css
index 09810edd1..b56d05d1b 100644
--- a/install-dev/view.css
+++ b/install-dev/view.css
@@ -126,6 +126,7 @@ h1 {font-size:24px;}
h2 {
padding-bottom:20px;
font-size:18px;
+ line-height:20px;
}
h3 {
padding-bottom:20px;
@@ -161,6 +162,7 @@ input.button {
padding:0 30px;
height:31px;
line-height:31px;
+ font-weight:bold;
color:#fff;
text-shadow:0 1px 0 #0d7903;
background:#039701 url(img/bt.png) repeat-x 0 0;
@@ -191,7 +193,7 @@ input.text {
padding:0 6px;
height:22px;
width:218px;/* 230 */
- background:#fff img(img/bg-input-text.png) repeat-x 0 0;
+ background:#fff url(img/bg_input_button.png) repeat-x 0 0;
border:1px solid #ccc;
}
select {
@@ -316,6 +318,7 @@ ol#tabs{
color:#adadad;
}
ol#tabs li.selected{
+ font-weight: bold;
color:#000;
background : url(img/bg-li-tabs.png) no-repeat 1px 15px;
}
@@ -380,6 +383,8 @@ ul#footer a:link, ul#footer a:active, ul#footer a:visited {
}
.sheet .contentTitle .stepList li.ok {background-position:0 -50px;}
.sheet .contentTitle .stepList li.ko {background-position:0 -100px;}
+ .sheet .contentTitle h1 {text-shadow:0 1px 0 #fff;}
+ .sheet .contentTitle ul {list-style-type:none;}
li.title {
margin:0;
@@ -472,8 +477,7 @@ ul#optional {list-style-type:none;}
#mailPart .userInfos {
padding-left:18px;
- font-size:11px;
- font-style:italic;
+ font: 11px Georgia, Arial, Sans-serif italic;
color:#999;
}
diff --git a/install-dev/xml/checkShopInfos.php b/install-dev/xml/checkShopInfos.php
index c125e7296..9f20a132d 100644
--- a/install-dev/xml/checkShopInfos.php
+++ b/install-dev/xml/checkShopInfos.php
@@ -199,8 +199,8 @@ if (isFormValid())
require_once(dirname(__FILE__).'/../../classes/LocalizationPack.php');
- $context = stream_context_create(array('http' => array('timeout' => 5)));
- $localization_file = @Tools::file_get_contents('http://www.prestashop.com/download/localization_pack.php?country='.$_GET['countryName'], false, $context);
+ $stream_context = stream_context_create(array('http' => array('timeout' => 5)));
+ $localization_file = @Tools::file_get_contents('http://www.prestashop.com/download/localization_pack.php?country='.$_GET['countryName'], false, $stream_context);
if (!$localization_file AND file_exists(dirname(__FILE__).'/../../localization/'.strtolower($_GET['countryName']).'.xml'))
$localization_file = @file_get_contents(dirname(__FILE__).'/../../localization/'.strtolower($_GET['countryName']).'.xml');
if ($localization_file)
diff --git a/modules/blockcustomerprivacy/es.php b/modules/blockcustomerprivacy/es.php
new file mode 100644
index 000000000..64c3a7def
--- /dev/null
+++ b/modules/blockcustomerprivacy/es.php
@@ -0,0 +1,13 @@
+blockcustomerprivacy_0cec62d1bea02fbb1484d55d14f493dd'] = 'Bloque de privacidad de datos de los clientes';
+$_MODULE['<{blockcustomerprivacy}prestashop>blockcustomerprivacy_3a32ec2dbd8d955f6240d95d6004557c'] = 'Agrega un bloque para mostrar un mensaje respecto a la privacidad de los datos.';
+$_MODULE['<{blockcustomerprivacy}prestashop>blockcustomerprivacy_20015706a8cbd457cbb6ea3e7d5dc9b3'] = 'Configuración actualizada';
+$_MODULE['<{blockcustomerprivacy}prestashop>blockcustomerprivacy_b75fe4f32f17eb695f145704a8909146'] = 'Mensaje sobre la privacidad de datos de los clientes';
+$_MODULE['<{blockcustomerprivacy}prestashop>blockcustomerprivacy_03e6791c07164957bb87bfad5030f846'] = 'Mensaje que se mostrará en el formulario de creación de la cuenta.';
+$_MODULE['<{blockcustomerprivacy}prestashop>blockcustomerprivacy_2d4e74ab9c95452f5948cd959d186b6d'] = 'Sugerencias: Recuerde que si el texto es demasiado largo para ser escrito directamente en el formulario, puede añadir un enlace a una de sus páginas creadas a través de la ficha de la CMS.';
+$_MODULE['<{blockcustomerprivacy}prestashop>blockcustomerprivacy_c9cc8cce247e49bae79f15173ce97354'] = 'Guardar';
+$_MODULE['<{blockcustomerprivacy}prestashop>blockcustomerprivacy_ffeb523df77567c7fad7faf8af5f7e46'] = 'Por favor, acepte el acuerdo sobre la privacidad de los datos de los clientes marcando la casilla de abajo.';
+$_MODULE['<{blockcustomerprivacy}prestashop>blockcustomerprivacy_fb0440f9ca32a8b49eded51b09e70821'] = 'Privacidad de los datos de los clientes';
diff --git a/modules/blocklayered/es.php b/modules/blocklayered/es.php
index a5dc11e7f..304b8ae04 100644
--- a/modules/blocklayered/es.php
+++ b/modules/blocklayered/es.php
@@ -4,32 +4,55 @@ global $_MODULE;
$_MODULE = array();
$_MODULE['<{blocklayered}prestashop>blocklayered_84241e458cdd5162745500a59a3680f3'] = 'Bloque navegación por facetas';
$_MODULE['<{blocklayered}prestashop>blocklayered_2d08fa8e157fe3f1875402cbd98aee1b'] = 'Muestra un bloque con los filtros de la navegación por facetas';
+$_MODULE['<{blocklayered}prestashop>blocklayered_1b90c001d668d0ec894392d8e6695054'] = 'Debe habilitar la extensión cURL en el servidor si desea utilizar un link corto.';
$_MODULE['<{blocklayered}prestashop>blocklayered_7ad3f384bcf30d783b5a6f6c810b4762'] = 'La base de datos por niveles de navegación se ha iniciado con éxito';
+$_MODULE['<{blocklayered}prestashop>blocklayered_817c37b9c1f5cd4a450dad384e63e6c7'] = 'Su filtro';
+$_MODULE['<{blocklayered}prestashop>blocklayered_3185cefd67b575e582063148e4f15860'] = 'se ha actualizado correctamente.';
+$_MODULE['<{blocklayered}prestashop>blocklayered_7ccab4d8de5d6b9bb61e99c7bba343ab'] = 'se ha añadido correctamente.';
$_MODULE['<{blocklayered}prestashop>blocklayered_6e7db02664c13dd5b517a12eafab88b1'] = 'El nombre de usuario Bit.ly está vacío';
$_MODULE['<{blocklayered}prestashop>blocklayered_f5da5c32121b39bb2100b9b63ccf4c4c'] = 'Api_key Bit.ly está vacía';
$_MODULE['<{blocklayered}prestashop>blocklayered_fe016d3b990c2a9dd72ab6b45892f2ae'] = 'Configuración guardada con éxito';
$_MODULE['<{blocklayered}prestashop>blocklayered_bb291cb01196158549fba8f6fe636d4a'] = 'Los ajustes no se guardan';
+$_MODULE['<{blocklayered}prestashop>blocklayered_4ad0f0fe31d93e0d8dd7a7fc69a72784'] = 'Filtros de plantilla borrados, categorías actualizadas (modelo por defecto aplicado).';
+$_MODULE['<{blocklayered}prestashop>blocklayered_91e77d047f2496b7ba8c9def96d03324'] = 'Plantilla de filtros que no se encuentran';
$_MODULE['<{blocklayered}prestashop>blocklayered_09da2b6f1217055bb22caa6ea08d9b80'] = 'Capas de navegación';
-$_MODULE['<{blocklayered}prestashop>blocklayered_382a0cf3c7ea26e9c7d0642d6d0ec07d'] = 'Este módulo se encuentra en versión beta y se mejorará';
-$_MODULE['<{blocklayered}prestashop>blocklayered_016d6031144c99f759b36c5e00c79e91'] = '10 mejoras futuras';
-$_MODULE['<{blocklayered}prestashop>blocklayered_b77ae7b3f227f97fdbfbaee819c048d6'] = 'Actualizar en tiempo real de la tabla de caché';
-$_MODULE['<{blocklayered}prestashop>blocklayered_3cd881c5805a5564b080022968081652'] = 'Filtros adicionales (precios, peso)';
-$_MODULE['<{blocklayered}prestashop>blocklayered_f67587ba40eff59a15796352c9037ddf'] = 'Capacidad de gestión de filtros por categoría en la configuración del módulo';
-$_MODULE['<{blocklayered}prestashop>blocklayered_559175435fec02f846564385b20b98e2'] = 'Capacidad de ocultar los grupos de filtro sin valores y los valores con 0 productos';
-$_MODULE['<{blocklayered}prestashop>blocklayered_abb461f7d4d8271a12ceead064d13cd0'] = 'Estadísticas y análisis';
-$_MODULE['<{blocklayered}prestashop>blocklayered_6af4dd46928a781eda42b940d3394ca6'] = 'Administrar tipo de productos y paginación';
-$_MODULE['<{blocklayered}prestashop>blocklayered_b4ecb2bd1ea5153550669329db53277d'] = 'Añadir un cheque a la tabla categoría_grupo';
-$_MODULE['<{blocklayered}prestashop>blocklayered_d99bf479cc40101e28f1f0ba1bfb6150'] = 'Los links SEO y la construcción de URL en tiempo real (capacidad de dar la dirección a alguien)';
-$_MODULE['<{blocklayered}prestashop>blocklayered_27c7b93d882068a1137a9350c7f1a132'] = 'Añadir más opciones en la configuración del módulo';
-$_MODULE['<{blocklayered}prestashop>blocklayered_fb8082696a8d7a40fa62ea0e89b18c32'] = 'Ejecución mejoras';
-$_MODULE['<{blocklayered}prestashop>blocklayered_7263de0a10ad25dfdadc44791c44fb1f'] = 'Inicialización de caché';
-$_MODULE['<{blocklayered}prestashop>blocklayered_d15ce73cbadfe1e806ee7abd08a7fe4d'] = 'Antes de usar este módulo por primera vez tiene que inicializar el caché';
-$_MODULE['<{blocklayered}prestashop>blocklayered_2875534393f5ef32e42d92c30e9dfda5'] = 'Advertencia: Esto puede tardar varios minutos.';
-$_MODULE['<{blocklayered}prestashop>blocklayered_15aa842a19af51c2cf1ec631cdf8337a'] = 'Si no lo hace, esta tabla caché podría ser cada vez más grande ( y ser menos eficaz), y sus visitantes no tendrán acceso a todas las nuevas opciones (atributos, características).';
-$_MODULE['<{blocklayered}prestashop>blocklayered_c64a069750ff8924b029b2206cabf3b2'] = 'Inicializar la base de datos de navegación por capas';
+$_MODULE['<{blocklayered}prestashop>blocklayered_a607dc3941415ecea04bb1eb8a978962'] = 'Plantillas de los filtros existentes';
+$_MODULE['<{blocklayered}prestashop>blocklayered_9923a3739235561cc50eb9446dc1771e'] = 'las plantillas de filtros están configuradas:';
+$_MODULE['<{blocklayered}prestashop>blocklayered_7dce122004969d56ae2e0245cb754d35'] = 'Editar';
+$_MODULE['<{blocklayered}prestashop>blocklayered_d180b4e0681bba834c76b479590e1c1e'] = 'Eliminar plantilla de filtro #';
+$_MODULE['<{blocklayered}prestashop>blocklayered_d1457b72c3fb323a2671125aef3eab5d'] = '?';
+$_MODULE['<{blocklayered}prestashop>blocklayered_f2a6c498fb90ee345d997f888fce3b18'] = 'Borrar';
+$_MODULE['<{blocklayered}prestashop>blocklayered_058eeeba77f547f8a9a295a0efd4f6cd'] = 'No se encontró plantilla de filtro.';
+$_MODULE['<{blocklayered}prestashop>blocklayered_cb54e4c9b7712ca15c711aeacfabf0a2'] = 'Construya su propia plantilla de filtros';
+$_MODULE['<{blocklayered}prestashop>blocklayered_0ce4150f57948567deeaa58d0c367412'] = 'Paso 1 / 3 - Seleccione las categorías';
+$_MODULE['<{blocklayered}prestashop>blocklayered_99cdd6365310333a594b16e5658eee5c'] = 'Utilice esta plantilla para:';
+$_MODULE['<{blocklayered}prestashop>blocklayered_62f5d708d6ad1fa1ddd9429a65cccbea'] = 'Todas las categorías';
+$_MODULE['<{blocklayered}prestashop>blocklayered_fe0619d5f4999e09c622e32da7e7566a'] = 'Específicas';
+$_MODULE['<{blocklayered}prestashop>blocklayered_b0b5ccb4a195a07fd3eed14affb8695f'] = 'categorías';
+$_MODULE['<{blocklayered}prestashop>blocklayered_ef7de3f485174ff47f061ad27d83d0ee'] = 'seleccionadas';
+$_MODULE['<{blocklayered}prestashop>blocklayered_f72c75bdf80dc88b2529162f4947edc8'] = 'Por favor, seleccione al menos una categoría específica o seleccione \"Todas las categorías\".';
+$_MODULE['<{blocklayered}prestashop>blocklayered_64646db703ca003a37bd1e73977a3a4d'] = 'Categorías a partir de esta plantilla';
+$_MODULE['<{blocklayered}prestashop>blocklayered_d758a9754eb9f36db05c22ad0c77e38e'] = 'Seleccione al menos una categoría con esta plantilla de filtro';
+$_MODULE['<{blocklayered}prestashop>blocklayered_5965d2ce192837f00d743d8a674382c1'] = 'Pulse el botón \"Guardar esta selección\" o cerrar la ventana para guardar';
+$_MODULE['<{blocklayered}prestashop>blocklayered_72dd03f11489ff6f604a4eb57c957202'] = 'Guardar esta selección';
+$_MODULE['<{blocklayered}prestashop>blocklayered_2e527847e8c785f3fd99651f64006798'] = 'Paso 2 / 3 - Seleccione los filtros';
+$_MODULE['<{blocklayered}prestashop>blocklayered_3488a51eb7f723d65daeff912e69b177'] = 'Filtros seleccionados';
+$_MODULE['<{blocklayered}prestashop>blocklayered_cf3cd81b30d4c4fd996ae5374fe656da'] = 'No se ha elegido ningún filtro todavía.';
+$_MODULE['<{blocklayered}prestashop>blocklayered_8524de963f07201e5c086830d370797f'] = 'Cargando ...';
+$_MODULE['<{blocklayered}prestashop>blocklayered_597c70730ebddba7d845e686665f9f28'] = 'Ha seleccionado-Todas las categorías, todas las plantillas de filtro existentes se eliminarán, ¿está de acuerdo?';
+$_MODULE['<{blocklayered}prestashop>blocklayered_74a6a547d86659933a210680efb6e6d1'] = 'Paso 3 / 3 - de un nombre a la plantilla';
+$_MODULE['<{blocklayered}prestashop>blocklayered_f8263d99054a4cdb3428196f078fa212'] = 'Nombre de la plantilla:';
+$_MODULE['<{blocklayered}prestashop>blocklayered_b96ce93c61b856a0163c116820646b19'] = 'Mi plantilla';
+$_MODULE['<{blocklayered}prestashop>blocklayered_5f514b580ea1b6bdb681916bc1deb207'] = 'sólo como un recordatorio';
+$_MODULE['<{blocklayered}prestashop>blocklayered_ef1094d9826e98f5417e0a37f1742133'] = 'Guardar esta plantilla de filtro';
$_MODULE['<{blocklayered}prestashop>blocklayered_254f642527b45bc260048e30704edb39'] = 'Configuración';
-$_MODULE['<{blocklayered}prestashop>blocklayered_32cd1899a36fd598df5a4e417bc6339a'] = 'Posible compartir URL';
-$_MODULE['<{blocklayered}prestashop>blocklayered_05ce875b6f1cb8477077f33bad5e9325'] = 'Al activar esta opción, sus visitantes comparten la dirección URL de su búsqueda';
+$_MODULE['<{blocklayered}prestashop>blocklayered_054b4f3ea543c990f6b125f41af6ebf7'] = 'Opción';
+$_MODULE['<{blocklayered}prestashop>blocklayered_689202409e48743b914713f96d93947c'] = 'Valor';
+$_MODULE['<{blocklayered}prestashop>blocklayered_9868c3ac0748acf3b981a96cfe163ee8'] = 'Ocultar los valores de filtro cuando no hay ningún producto en venta';
+$_MODULE['<{blocklayered}prestashop>blocklayered_93cba07454f06a4a960172bbd6e2a435'] = 'Sí';
+$_MODULE['<{blocklayered}prestashop>blocklayered_bafd7322c6e97d25b6299b5d6fe8920b'] = 'No';
+$_MODULE['<{blocklayered}prestashop>blocklayered_8531c73de81b9ed94322dda7cf947daa'] = 'Mostrar el número de productos que concuerden';
+$_MODULE['<{blocklayered}prestashop>blocklayered_8b6c3aa61f1e15caefb66e68e7e64924'] = 'Permitir a los clientes compartir URLs';
$_MODULE['<{blocklayered}prestashop>blocklayered_abc07e5243a77d8bebcadd90fca23d74'] = 'Para ofrecer a sus clientes enlaces cortos, crear una cuenta en bit.ly, luego copiar y pegar usuario y API key';
$_MODULE['<{blocklayered}prestashop>blocklayered_d67850bd126f070221dcfd5fa6317043'] = 'Regístrate';
$_MODULE['<{blocklayered}prestashop>blocklayered_68fd0151074a3dba747f94b2fd8cf5f4'] = 'Ingresar bit.ly';
@@ -45,10 +68,22 @@ $_MODULE['<{blocklayered}prestashop>blocklayered_fcebe56087b9373f15514831184fa57
$_MODULE['<{blocklayered}prestashop>blocklayered_2d25c72c1b18e562f6654fff8e11711e'] = 'No disponible';
$_MODULE['<{blocklayered}prestashop>blocklayered_c0bd7654d5b278e65f21cf4e9153fdb4'] = 'Fabricante';
$_MODULE['<{blocklayered}prestashop>blocklayered_8c489d0946f66d17d73f26366a4bf620'] = 'Peso';
+$_MODULE['<{blocklayered}prestashop>blocklayered_308edffd52afae39cc6277e246ec5df8'] = 'Filtros disponibles';
+$_MODULE['<{blocklayered}prestashop>blocklayered_cfbc982f8fb7a0cc3abb3c85c795ab41'] = 'Filtro de Subcategorías ';
+$_MODULE['<{blocklayered}prestashop>blocklayered_cd50ff1c5332f9920acf8173c4aab425'] = 'Filtro stock del producto';
+$_MODULE['<{blocklayered}prestashop>blocklayered_048c1728a0a6cf36f56c9dcdd23d8a14'] = 'Filtro estado del producto';
+$_MODULE['<{blocklayered}prestashop>blocklayered_02ecc2cbb645a2b859deba6907334cc8'] = 'Filtro fabricante del producto';
+$_MODULE['<{blocklayered}prestashop>blocklayered_cc72ed9534a489b5d2e5882735bf1364'] = 'Filtro peso del producto';
+$_MODULE['<{blocklayered}prestashop>blocklayered_d73c57be7aad115d20508215e8ea9951'] = 'Grupo de atributos';
+$_MODULE['<{blocklayered}prestashop>blocklayered_736b91750e516139acc13c5eb6564f92'] = 'atributos';
+$_MODULE['<{blocklayered}prestashop>blocklayered_d2eb444e35c0a71f0a85df8194acb5b6'] = 'atributo';
+$_MODULE['<{blocklayered}prestashop>blocklayered_ee59f74265cd7f85d0ad30206a1a89b0'] = 'Este grupo permitirá al usuario seleccionar un color';
+$_MODULE['<{blocklayered}prestashop>blocklayered_b07e7131a6007b2a1a765bdd0e1e4894'] = 'Característica:';
+$_MODULE['<{blocklayered}prestashop>blocklayered_f09cc7ee3a9a93273f4b80601cafb00c'] = 'valores';
+$_MODULE['<{blocklayered}prestashop>blocklayered_2063c1608d6e0baf80249c42e2be5804'] = 'valor';
$_MODULE['<{blocklayered}prestashop>blocklayered_c32516babc5b6c47eb8ce1bfc223253c'] = 'Catálogo';
$_MODULE['<{blocklayered}prestashop>blocklayered_aa3c0ac7e57fcf0e2e25d270ff502b6e'] = 'Compartir su búsqueda';
$_MODULE['<{blocklayered}prestashop>blocklayered_1262d1b9fbffb3a8e85ac9e4b449e989'] = 'filtros habilitados:';
$_MODULE['<{blocklayered}prestashop>blocklayered_853ae90f0351324bd73ea615e6487517'] = ':';
$_MODULE['<{blocklayered}prestashop>blocklayered_ea4788705e6873b424c65e91c2846b19'] = 'Cancelar';
-$_MODULE['<{blocklayered}prestashop>blocklayered_87ba2ecc8b6915e8bd6f5089918229fd'] = 'Franja';
-$_MODULE['<{blocklayered}prestashop>blocklayered_8524de963f07201e5c086830d370797f'] = 'Cargando ...';
+$_MODULE['<{blocklayered}prestashop>blocklayered_75954a3c6f2ea54cb9dff249b6b5e8e6'] = 'Rango:';
diff --git a/modules/blocklink/config.xml b/modules/blocklink/config.xml
index ca288f68f..726e2f5c9 100755
--- a/modules/blocklink/config.xml
+++ b/modules/blocklink/config.xml
@@ -8,6 +8,6 @@
Are you sure you want to delete all your links ?
1
-
1
+
0
\ No newline at end of file
diff --git a/modules/canadapost/canadapost.php b/modules/canadapost/canadapost.php
new file mode 100755
index 000000000..fa8aad782
--- /dev/null
+++ b/modules/canadapost/canadapost.php
@@ -0,0 +1,1691 @@
+
+* @copyright 2007-2011 PrestaShop SA
+* @version Release: $Revision: 7288 $
+* @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 CanadaPost extends CarrierModule
+{
+ public $id_carrier;
+
+ private $_html = '';
+ private $_postErrors = array();
+ private $_webserviceTestResult = '';
+ private $_webserviceError = '';
+ private $_fieldsList = array();
+ private $_calculModeList = array();
+ private $_dimensionUnit = '';
+ private $_weightUnit = '';
+ private $_dimensionUnitList = array('CM' => 'CM', 'IN' => 'IN', 'CMS' => 'CM', 'INC' => 'IN');
+ private $_weightUnitList = array('KG' => 'KGS', 'KGS' => 'KGS', 'LBS' => 'LBS', 'LB' => 'LBS');
+ private $_moduleName = 'canadapost';
+
+ /*
+ ** Construct Method
+ **
+ */
+
+ public function __construct()
+ {
+ $this->name = 'canadapost';
+ $this->tab = 'shipping_logistics';
+ $this->version = '0.1';
+ $this->author = 'PrestaShop';
+ $this->limited_countries = array('ca');
+
+ parent::__construct ();
+
+ $this->displayName = $this->l('Canada Post Carrier');
+ $this->description = $this->l('Offer your customers, different delivery methods with Canada Post');
+
+ if (self::isInstalled($this->name))
+ {
+ // Loading Var
+ $warning = array();
+ $this->loadingVar();
+
+ // Check cURL option availibility
+ if (!is_callable('curl_exec'))
+ $warning[] = "'".$this->l('cURL option')."', ";
+
+ // Check Configuration Values
+ foreach ($this->_fieldsList as $keyConfiguration => $name)
+ if (!Configuration::get($keyConfiguration) && !empty($name))
+ $warning[] = '\''.$name.'\' ';
+
+ // Check calcul mode
+ if (!Configuration::get('CP_CARRIER_CALCUL_MODE'))
+ Configuration::updateValue('CP_CARRIER_CALCUL_MODE', 'onepackage');
+
+ // Checking Unit
+ $this->_dimensionUnit = $this->_dimensionUnitList[strtoupper(Configuration::get('PS_DIMENSION_UNIT'))];
+ $this->_weightUnit = $this->_weightUnitList[strtoupper(Configuration::get('PS_WEIGHT_UNIT'))];
+ if (!$this->_weightUnit || !$this->_weightUnitList[$this->_weightUnit])
+ $warning[] = $this->l('\'Weight Unit (LB or KG).\'').' ';
+ if (!$this->_dimensionUnit || !$this->_dimensionUnitList[$this->_dimensionUnit])
+ $warning[] = $this->l('\'Dimension Unit (CM or IN).\'').' ';
+
+ // Generate Warnings
+ if (count($warning))
+ $this->warning .= implode(' , ',$warning).$this->l('must be configured to use this module correctly').' ';
+ }
+ }
+
+ public function loadingVar()
+ {
+ // Loading Fields List
+ $this->_fieldsList = array(
+ 'CP_CARRIER_ACCOUNT' => $this->l('Canada Post account'),
+ 'CP_CARRIER_PACKAGING_WEIGHT' => $this->l('Packaging weight'),
+ 'CP_CARRIER_HANDLING_FEE' => $this->l('Handling fee'),
+ 'CP_CARRIER_ADDRESS1' => '',
+ 'CP_CARRIER_ADDRESS2' => '',
+ 'CP_CARRIER_POSTAL_CODE' => '',
+ 'CP_CARRIER_CITY' => '',
+ 'CP_CARRIER_STATE' => '',
+ 'CP_CARRIER_COUNTRY' => '',
+ 'CP_CARRIER_CALCUL_MODE' => '',
+ );
+
+ // Loading calcul mode list
+ $this->_calculModeList = array(
+ 'onepackage' => $this->l('All items in one package'),
+ 'split' => $this->l('Split one item per package')
+ );
+ }
+
+
+
+ /*
+ ** Install / Uninstall Methods
+ **
+ */
+
+ public function install()
+ {
+ // Install SQL
+ include(dirname(__FILE__).'/sql-install.php');
+ foreach ($sql as $s)
+ if (!Db::getInstance()->Execute($s))
+ return false;
+
+ // Install Carriers
+ $this->installCarriers();
+
+ // Install Module
+ if (!parent::install() OR !$this->registerHook('updateCarrier'))
+ return false;
+
+ return true;
+ }
+
+ public function uninstall()
+ {
+ // Uninstall Carriers
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'carrier', array('deleted' => 1), 'UPDATE', '`external_module_name` = \'canadapost\' OR `id_carrier` IN (SELECT DISTINCT(`id_carrier`) FROM `'._DB_PREFIX_.'cp_rate_service_code`)');
+
+ // Uninstall Config
+ foreach ($this->_fieldsList as $keyConfiguration => $name)
+ if (!Configuration::deleteByName($keyConfiguration))
+ return false;
+
+ // Uninstall SQL
+ include(dirname(__FILE__).'/sql-uninstall.php');
+ foreach ($sql as $s)
+ if (!Db::getInstance()->Execute($s))
+ return false;
+
+ // Uninstall Module
+ if (!parent::uninstall() OR !$this->unregisterHook('updateCarrier'))
+ return false;
+
+ return true;
+ }
+
+ public function installCarriers()
+ {
+ // Unactive all CanadaPost Carriers
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_service_code', array('active' => 0), 'UPDATE');
+
+ // Get all services availables
+ $rateServiceList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code`');
+ foreach ($rateServiceList as $rateService)
+ if (!$rateService['id_carrier'])
+ {
+ $config = array(
+ 'name' => $rateService['service'],
+ 'id_tax_rules_group' => 0,
+ 'active' => true,
+ 'deleted' => 0,
+ 'shipping_handling' => false,
+ 'range_behavior' => 0,
+ 'delay' => array('fr' => $rateService['delay'], 'en' => $rateService['delay'], Language::getIsoById(Configuration::get('PS_LANG_DEFAULT')) => $rateService['delay']),
+ 'id_zone' => 1,
+ 'is_module' => true,
+ 'shipping_external' => true,
+ 'external_module_name' => $this->_moduleName,
+ 'need_range' => true
+ );
+ $id_carrier = $this->installExternalCarrier($config);
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_service_code', array('id_carrier' => (int)($id_carrier), 'id_carrier_history' => (int)($id_carrier)), 'UPDATE', '`id_cp_rate_service_code` = '.(int)($rateService['id_cp_rate_service_code']));
+ }
+ }
+
+ public static function installExternalCarrier($config)
+ {
+ $carrier = new Carrier();
+ $carrier->name = $config['name'];
+ $carrier->id_tax_rules_group = $config['id_tax_rules_group'];
+ $carrier->id_zone = $config['id_zone'];
+ $carrier->active = $config['active'];
+ $carrier->deleted = $config['deleted'];
+ $carrier->delay = $config['delay'];
+ $carrier->shipping_handling = $config['shipping_handling'];
+ $carrier->range_behavior = $config['range_behavior'];
+ $carrier->is_module = $config['is_module'];
+ $carrier->shipping_external = $config['shipping_external'];
+ $carrier->external_module_name = $config['external_module_name'];
+ $carrier->need_range = $config['need_range'];
+
+ $languages = Language::getLanguages(true);
+ foreach ($languages as $language)
+ {
+ if ($language['iso_code'] == 'fr')
+ $carrier->delay[(int)$language['id_lang']] = $config['delay'][$language['iso_code']];
+ if ($language['iso_code'] == 'en')
+ $carrier->delay[(int)$language['id_lang']] = $config['delay'][$language['iso_code']];
+ if ($language['iso_code'] == Language::getIsoById(Configuration::get('PS_LANG_DEFAULT')))
+ $carrier->delay[(int)$language['id_lang']] = $config['delay'][$language['iso_code']];
+ }
+
+ if ($carrier->add())
+ {
+ $groups = Group::getGroups(true);
+ foreach ($groups as $group)
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'carrier_group', array('id_carrier' => (int)($carrier->id), 'id_group' => (int)($group['id_group'])), 'INSERT');
+
+ $rangePrice = new RangePrice();
+ $rangePrice->id_carrier = $carrier->id;
+ $rangePrice->delimiter1 = '0';
+ $rangePrice->delimiter2 = '10000';
+ $rangePrice->add();
+
+ $rangeWeight = new RangeWeight();
+ $rangeWeight->id_carrier = $carrier->id;
+ $rangeWeight->delimiter1 = '0';
+ $rangeWeight->delimiter2 = '10000';
+ $rangeWeight->add();
+
+ $zones = Zone::getZones(true);
+ foreach ($zones as $zone)
+ {
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'carrier_zone', array('id_carrier' => (int)($carrier->id), 'id_zone' => (int)($zone['id_zone'])), 'INSERT');
+ Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_.'delivery', array('id_carrier' => (int)($carrier->id), 'id_range_price' => (int)($rangePrice->id), 'id_range_weight' => NULL, 'id_zone' => (int)($zone['id_zone']), 'price' => '0'), 'INSERT');
+ Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_.'delivery', array('id_carrier' => (int)($carrier->id), 'id_range_price' => NULL, 'id_range_weight' => (int)($rangeWeight->id), 'id_zone' => (int)($zone['id_zone']), 'price' => '0'), 'INSERT');
+ }
+
+ // Copy Logo
+ if (!copy(dirname(__FILE__).'/carrier.jpg', _PS_SHIP_IMG_DIR_.'/'.(int)$carrier->id.'.jpg'))
+ return false;
+
+ // Return ID Carrier
+ return (int)($carrier->id);
+ }
+
+ return false;
+ }
+
+
+
+ /*
+ ** Global Form Config Methods
+ **
+ */
+
+ public function getContent()
+ {
+ $this->_html .= '
' . $this->l('Canada Post Carrier').' ';
+ if (!empty($_POST) AND Tools::isSubmit('submitSave'))
+ {
+ $this->_postValidation();
+ if (!sizeof($this->_postErrors))
+ $this->_postProcess();
+ else
+ foreach ($this->_postErrors AS $err)
+ $this->_html .= '
'.$err.'
';
+ }
+ $this->_displayForm();
+ return $this->_html;
+ }
+
+ private function _displayForm()
+ {
+ $this->_html .= '
+ '.$this->l('Canada Post Module Status').' ';
+
+ $alert = array();
+ $this->_webserviceTestResult = $this->webserviceTest();
+ if (!Configuration::get('CP_CARRIER_ACCOUNT'))
+ $alert['generalSettings'] = 1;
+ if (Db::getInstance()->getValue('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code` WHERE `active` = 1') < 1)
+ $alert['deliveryServices'] = 1;
+ if (!$this->_webserviceTestResult)
+ $alert['webserviceTest'] = 1;
+ if (!is_callable('curl_exec'))
+ $alert['curl'] = 1;
+
+
+ if (!count($alert))
+ $this->_html .= ''.$this->l('Canada Post Carrier is configured and online!').' ';
+ else
+ {
+ $this->_html .= ''.$this->l('Canada Post Carrier is not configured yet, you must:').' ';
+ $this->_html .= ' '.(isset($alert['generalSettings']) ? ' ' : ' ').' 1) '.$this->l('Fill the "General Settings" form');
+ $this->_html .= ' '.(isset($alert['deliveryServices']) ? ' ' : ' ').' 2) '.$this->l('Select your available delivery service');
+ $this->_html .= ' '.(isset($alert['webserviceTest']) ? ' ' : ' ').' 3) '.$this->l('Webservice test connection').($this->_webserviceError ? ' : '.$this->_webserviceError : '');
+ $this->_html .= ' '.(isset($alert['curl']) ? ' ' : ' ').' 4) '.$this->l('cURL is enabled');
+ }
+
+
+ $this->_html .= '
';
+ $this->_html .= $this->_displayFormConfig();
+ }
+
+ private function _postValidation()
+ {
+ if (Tools::getValue('section') == 'general')
+ $this->_postValidationGeneral();
+ elseif (Tools::getValue('section') == 'category')
+ $this->_postValidationCategory();
+ elseif (Tools::getValue('section') == 'product')
+ $this->_postValidationProduct();
+ }
+
+ private function _postProcess()
+ {
+ if (Tools::getValue('section') == 'general')
+ $this->_postProcessGeneral();
+ elseif (Tools::getValue('section') == 'category')
+ $this->_postProcessCategory();
+ elseif (Tools::getValue('section') == 'product')
+ $this->_postProcessProduct();
+ }
+
+
+
+
+ /*
+ ** General Form Config Methods
+ **
+ */
+
+ private function _displayFormConfig()
+ {
+ $html = '
+
+
+
+
+
+
+
+
+
+
+
+ ';
+ if (isset($_GET['id_tab']))
+ $html .= '';
+ return $html;
+ }
+
+ private function _displayFormGeneral()
+ {
+ global $cookie;
+ $configCurrency = new Currency((int)Configuration::get('PS_CURRENCY_DEFAULT'));
+
+ $html = '
+
+
+
+
+
+ ';
+ return $html;
+ }
+
+ private function _postValidationGeneral()
+ {
+ // Check configuration values
+ if (Tools::getValue('cp_carrier_account') == NULL)
+ $this->_postErrors[] = $this->l('Your Canada Post account is not specified');
+ elseif (Tools::getValue('cp_carrier_postal_code') == NULL)
+ $this->_postErrors[] = $this->l('Your Zip / Postal code is not specified');
+ elseif (Tools::getValue('cp_carrier_city') == NULL)
+ $this->_postErrors[] = $this->l('Your city is not specified');
+ elseif (Tools::getValue('cp_carrier_country') == NULL OR Tools::getValue('cp_carrier_country') == 0)
+ $this->_postErrors[] = $this->l('Your country is not specified');
+
+
+
+ // Check Canada Post webservice availibity
+ if (!$this->_postErrors)
+ {
+ // Unactive all Canada Post Carriers
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_service_code', array('active' => 0), 'UPDATE');
+
+ // If no errors appear, the carrier is being activated, else, the carrier is being deactivated
+ if (!$this->_postErrors)
+ {
+ // Get available services
+ $serviceSelected = Tools::getValue('service');
+
+ // Active available carrier
+ if ($serviceSelected)
+ foreach ($serviceSelected as $ss)
+ {
+ $id_carrier = Db::getInstance()->getValue('SELECT `id_carrier` FROM `'._DB_PREFIX_.'cp_rate_service_code` WHERE `id_cp_rate_service_code` = '.(int)($ss));
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_service_code', array('active' => 1), 'UPDATE', '`id_cp_rate_service_code` = '.(int)($ss));
+ }
+ }
+
+ // All new configurations values are saved to be sure to test webservices with it
+ Configuration::updateValue('CP_CARRIER_ACCOUNT', Tools::getValue('cp_carrier_account'));
+ Configuration::updateValue('CP_CARRIER_PACKAGING_WEIGHT', Tools::getValue('cp_carrier_packaging_weight'));
+ Configuration::updateValue('CP_CARRIER_HANDLING_FEE', Tools::getValue('cp_carrier_handling_fee'));
+ Configuration::updateValue('CP_CARRIER_ADDRESS1', Tools::getValue('cp_carrier_address1'));
+ Configuration::updateValue('CP_CARRIER_ADDRESS2', Tools::getValue('cp_carrier_address2'));
+ Configuration::updateValue('CP_CARRIER_POSTAL_CODE', Tools::getValue('cp_carrier_postal_code'));
+ Configuration::updateValue('CP_CARRIER_CITY', Tools::getValue('cp_carrier_city'));
+ Configuration::updateValue('CP_CARRIER_STATE', Tools::getValue('cp_carrier_state'));
+ Configuration::updateValue('CP_CARRIER_COUNTRY', Tools::getValue('cp_carrier_country'));
+ Configuration::updateValue('CP_CARRIER_CALCUL_MODE', Tools::getValue('cp_carrier_calcul_mode'));
+ Configuration::updateValue('PS_WEIGHT_UNIT', $this->_weightUnitList[strtoupper(Tools::getValue('ps_weight_unit'))]);
+ Configuration::updateValue('PS_DIMENSION_UNIT', $this->_dimensionUnitList[strtoupper(Tools::getValue('ps_dimension_unit'))]);
+ if (isset($this->_weightUnitList[strtoupper(Tools::getValue('ps_weight_unit'))]))
+ $this->_weightUnit = $this->_weightUnitList[strtoupper(Tools::getValue('ps_weight_unit'))];
+ if (isset($this->_dimensionUnitList[strtoupper(Tools::getValue('ps_dimension_unit'))]))
+ $this->_dimensionUnit = $this->_dimensionUnitList[strtoupper(Tools::getValue('ps_dimension_unit'))];
+ if (!$this->webserviceTest())
+ $this->_postErrors[] = $this->l('Prestashop could not connect to Canada Post webservices').' :
'.($this->_webserviceError ? $this->_webserviceError : $this->l('No error description found'));
+ }
+ }
+
+ private function _postProcessGeneral()
+ {
+ // Saving new configurations
+ if (Configuration::updateValue('CP_CARRIER_ACCOUNT', Tools::getValue('cp_carrier_account')) AND
+ Configuration::updateValue('CP_CARRIER_PACKAGING_WEIGHT', Tools::getValue('cp_carrier_packaging_weight')) AND
+ Configuration::updateValue('CP_CARRIER_HANDLING_FEE', Tools::getValue('cp_carrier_handling_fee')) AND
+ Configuration::updateValue('CP_CARRIER_POSTAL_CODE', Tools::getValue('cp_carrier_postal_code')) AND
+ Configuration::updateValue('CP_CARRIER_CITY', Tools::getValue('cp_carrier_city')) AND
+ Configuration::updateValue('CP_CARRIER_STATE', Tools::getValue('cp_carrier_state')) AND
+ Configuration::updateValue('CP_CARRIER_COUNTRY', Tools::getValue('cp_carrier_country')) AND
+ Configuration::updateValue('CP_CARRIER_CALCUL_MODE', Tools::getValue('cp_carrier_calcul_mode')) AND
+ Configuration::updateValue('PS_WEIGHT_UNIT', $this->_weightUnitList[strtoupper(Tools::getValue('ps_weight_unit'))]) AND
+ Configuration::updateValue('PS_DIMENSION_UNIT', $this->_dimensionUnitList[strtoupper(Tools::getValue('ps_dimension_unit'))]))
+ $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
+ else
+ $this->_html .= $this->displayErrors($this->l('Settings failed'));
+ }
+
+
+
+ /*
+ ** Category Form Config Methods
+ **
+ */
+
+ private function _getPathInTab($id_category)
+ {
+ global $cookie;
+
+ $category = Db::getInstance()->getRow('
+ SELECT id_category, level_depth, nleft, nright
+ FROM '._DB_PREFIX_.'category
+ WHERE id_category = '.(int)$id_category);
+
+ if (isset($category['id_category']))
+ {
+ $categories = Db::getInstance()->ExecuteS('
+ SELECT c.id_category, cl.name, cl.link_rewrite
+ FROM '._DB_PREFIX_.'category c
+ LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category)
+ WHERE c.nleft <= '.(int)$category['nleft'].' AND c.nright >= '.(int)$category['nright'].' AND cl.id_lang = '.(int)($cookie->id_lang).'
+ ORDER BY c.level_depth ASC
+ LIMIT '.(int)($category['level_depth'] + 1));
+
+ $n = 1;
+ $pathTab = array();
+ $nCategories = (int)sizeof($categories);
+ foreach ($categories AS $category)
+ $pathTab[] = htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8');
+
+ return $pathTab;
+ }
+ }
+
+ private function _getChildCategories($categories, $id, $path = array(), $pathAdd = '')
+ {
+ $html = '';
+ if ($pathAdd != '')
+ $path[] = $pathAdd;
+ if (isset($categories[$id]))
+ foreach ($categories[$id] as $idc => $cc)
+ {
+ $html .= '
';
+ if ($path)
+ foreach ($path as $p)
+ $html .= $p.' > ';
+ $html .= $cc['infos']['name'];
+ $html .= ' ';
+ $html .= $this->_getChildCategories($categories, $idc, $path, $cc['infos']['name']);
+ }
+ return $html;
+ }
+
+ private function _isPostCheck($id_cp_rate_service_code)
+ {
+ $services = Tools::getValue('service');
+ if ($services)
+ foreach ($services as $s)
+ if ($s == $id_cp_rate_service_code)
+ return 1;
+ return 0;
+ }
+
+ private function _displayFormCategory()
+ {
+ global $cookie;
+
+ // Check if the module is configured
+ if (!$this->_webserviceTestResult)
+ return '
'.$this->l('You have to configure "General Settings" tab before using this tab.').'
';
+
+ // Display header
+ $html = '
'.$this->l('In this tab, you can set a specific configuration for each category.').'
+
+
+
+ '.$this->l('ID Config').'
+ '.$this->l('Category').'
+ '.$this->l('Additional charges').'
+ '.$this->l('Services').'
+ '.$this->l('Actions').'
+
+
+ ';
+
+ // Loading config list
+ $configCategoryList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_category` > 0');
+ if (!$configCategoryList)
+ $html .= ''.$this->l('There is no specific Canada Post configuration for categories at this point.').' ';
+ foreach ($configCategoryList as $k => $c)
+ {
+ // Category Path
+ $path = '';
+ $pathTab = $this->_getPathInTab($c['id_category']);
+ foreach ($pathTab as $p)
+ {
+ if (!empty($path)) { $path .= ' > '; }
+ $path .= $p;
+ }
+
+ // Loading config currency
+ $configCurrency = new Currency($c['id_currency']);
+
+ // Loading services attached to this config
+ $services = '';
+ $servicesTab = Db::getInstance()->ExecuteS('
+ SELECT ursc.`service`
+ FROM `'._DB_PREFIX_.'cp_rate_config_service` urcs
+ LEFT JOIN `'._DB_PREFIX_.'cp_rate_service_code` ursc ON (ursc.`id_cp_rate_service_code` = urcs.`id_cp_rate_service_code`)
+ WHERE urcs.`id_cp_rate_config` = '.(int)$c['id_cp_rate_config']);
+ foreach ($servicesTab as $s)
+ $services .= $s['service'].' ';
+
+ // Display line
+ $alt = 0;
+ if ($k % 2 != 0)
+ $alt = ' class="alt_row"';
+ $html .= '
+
+ '.$c['id_cp_rate_config'].'
+ '.$path.'
+ '.$c['additional_charges'].' '.$configCurrency->sign.'
+ '.$services.'
+
+
+
+
+
+
+ ';
+ }
+
+ $html .= '
+
+
';
+
+ // Add or Edit Category Configuration
+ if (Tools::getValue('action') == 'edit' && Tools::getValue('section') == 'category')
+ {
+ // Loading config
+ $configSelected = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_cp_rate_config` = '.(int)(Tools::getValue('id_cp_rate_config')));
+
+ // Category Path
+ $path = '';
+ $pathTab = $this->_getPathInTab($configSelected['id_category']);
+ foreach ($pathTab as $p)
+ {
+ if (!empty($path)) { $path .= ' > '; }
+ $path .= $p;
+ }
+
+ $html .= '
'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ? )
+
';
+ }
+ else
+ {
+ $html .= '
'.$this->l('Add a rule').'
+
';
+ }
+
+ return $html;
+ }
+
+ private function _postValidationCategory()
+ {
+ // Check post values
+ if (Tools::getValue('id_category') == NULL)
+ $this->_postErrors[] = $this->l('You have to select a category.');
+
+ if (!$this->_postErrors)
+ {
+ $id_cp_rate_config = Db::getInstance()->getValue('SELECT `id_cp_rate_config` FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_category` = '.(int)Tools::getValue('id_category'));
+
+ // Check if a config does not exist in Add case
+ if ($id_cp_rate_config > 0 && Tools::getValue('action') == 'add')
+ $this->_postErrors[] = $this->l('This category already has a specific Canada Post configuration.');
+
+ // Check if a config exists and if the IDs config correspond in Upd case
+ if (Tools::getValue('action') == 'edit' && (!isset($id_cp_rate_config) || $id_cp_rate_config != Tools::getValue('id_cp_rate_config')))
+ $this->_postErrors[] = $this->l('An error occurred, please try again.');
+
+ // Check if a config exists in Delete case
+ if (Tools::getValue('action') == 'delete' && !isset($id_cp_rate_config))
+ $this->_postErrors[] = $this->l('An error occurred, please try again.');
+ }
+ }
+
+ private function _postProcessCategory()
+ {
+ // Init Var
+ $date = date('Y-m-d H:i:s');
+ $services = Tools::getValue('service');
+
+ // Add Script
+ if (Tools::getValue('action') == 'add')
+ {
+ $addTab = array(
+ 'id_product' => 0,
+ 'id_category' => (int)(Tools::getValue('id_category')),
+ 'id_currency' => (int)(Configuration::get('PS_CURRENCY_DEFAULT')),
+ 'additional_charges' => pSQL(Tools::getValue('additional_charges')),
+ 'date_add' => pSQL($date),
+ 'date_upd' => pSQL($date)
+ );
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_config', $addTab, 'INSERT');
+ $id_cp_rate_config = Db::getInstance()->Insert_ID();
+ foreach ($services as $s)
+ {
+ $addTab = array('id_cp_rate_service_code' => pSQL($s), 'id_cp_rate_config' => (int)$id_cp_rate_config, 'date_add' => pSQL($date), 'date_upd' => pSQL($date));
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_config_service', $addTab, 'INSERT');
+ }
+
+ // Display Results
+ if ($id_cp_rate_config > 0)
+ $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
+ else
+ $this->_html .= $this->displayErrors($this->l('Settings failed'));
+ }
+
+ // Update Script
+ if (Tools::getValue('action') == 'edit' && Tools::getValue('id_cp_rate_config'))
+ {
+ $updTab = array(
+ 'id_currency' => (int)(Configuration::get('PS_CURRENCY_DEFAULT')),
+ 'additional_charges' => pSQL(Tools::getValue('additional_charges')),
+ 'date_upd' => pSQL($date)
+ );
+ $result = Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_config', $updTab, 'UPDATE', '`id_cp_rate_config` = '.(int)Tools::getValue('id_cp_rate_config'));
+ Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cp_rate_config_service` WHERE `id_cp_rate_config` = '.(int)Tools::getValue('id_cp_rate_config'));
+ foreach ($services as $s)
+ {
+ $addTab = array('id_cp_rate_service_code' => pSQL($s), 'id_cp_rate_config' => (int)Tools::getValue('id_cp_rate_config'), 'date_add' => pSQL($date), 'date_upd' => pSQL($date));
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_config_service', $addTab, 'INSERT');
+ }
+
+ // Display Results
+ if ($result)
+ $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
+ else
+ $this->_html .= $this->displayErrors($this->l('Settings failed'));
+ }
+
+ // Delete Script
+ if (Tools::getValue('action') == 'delete' && Tools::getValue('id_cp_rate_config'))
+ {
+ $result1 = Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_cp_rate_config` = '.(int)Tools::getValue('id_cp_rate_config'));
+ $result2 = Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cp_rate_config_service` WHERE `id_cp_rate_config` = '.(int)Tools::getValue('id_cp_rate_config'));
+
+ // Display Results
+ if ($result1)
+ $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
+ else
+ $this->_html .= $this->displayErrors($this->l('Settings failed'));
+ }
+ }
+
+
+
+ /*
+ ** Product Form Config Methods
+ **
+ */
+
+ private function _displayFormProduct()
+ {
+ global $cookie;
+
+ // Check if the module is configured
+ if (!$this->_webserviceTestResult)
+ return '
'.$this->l('You have to configure "General Settings" tab before using this tab.').'
';
+
+ // Display header
+ $html = '
'.$this->l('In this tab, you can set a specific configuration for each product.').'
+
+
+
+ '.$this->l('ID Config').'
+ '.$this->l('Product').'
+ '.$this->l('Additional charges').'
+ '.$this->l('Services').'
+ '.$this->l('Actions').'
+
+
+ ';
+
+ // Loading config list
+ $configProductList = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_product` > 0');
+ if (!$configProductList)
+ $html .= ''.$this->l('There is no specific Canada Post configuration for products at this point.').' ';
+ foreach ($configProductList as $k => $c)
+ {
+ // Loading Product
+ $product = new Product((int)$c['id_product'], false, (int)$cookie->id_lang);
+
+ // Loading config currency
+ $configCurrency = new Currency($c['id_currency']);
+
+ // Loading services attached to this config
+ $services = '';
+ $servicesTab = Db::getInstance()->ExecuteS('
+ SELECT ursc.`service`
+ FROM `'._DB_PREFIX_.'cp_rate_config_service` urcs
+ LEFT JOIN `'._DB_PREFIX_.'cp_rate_service_code` ursc ON (ursc.`id_cp_rate_service_code` = urcs.`id_cp_rate_service_code`)
+ WHERE urcs.`id_cp_rate_config` = '.(int)$c['id_cp_rate_config']);
+ foreach ($servicesTab as $s)
+ $services .= $s['service'].' ';
+
+ // Display line
+ $alt = 0;
+ if ($k % 2 != 0)
+ $alt = ' class="alt_row"';
+ $html .= '
+
+ '.$c['id_cp_rate_config'].'
+ '.$product->name.'
+ '.$c['additional_charges'].' '.$configCurrency->sign.'
+ '.$services.'
+
+
+
+
+
+
+ ';
+ }
+
+ $html .= '
+
+
';
+
+ // Add or Edit Product Configuration
+ if (Tools::getValue('action') == 'edit' && Tools::getValue('section') == 'product')
+ {
+ // Loading config
+ $configSelected = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_cp_rate_config` = '.(int)(Tools::getValue('id_cp_rate_config')));
+ $product = new Product((int)$configSelected['id_product'], false, (int)$cookie->id_lang);
+
+ $html .= '
'.$this->l('Update a rule').' ('.$this->l('Add a rule').' ? )
+
';
+ }
+ else
+ {
+ $html .= '
'.$this->l('Add a rule').'
+
';
+ }
+
+ return $html;
+ }
+
+ private function _postValidationProduct()
+ {
+ // Check post values
+ if (Tools::getValue('id_product') == NULL)
+ $this->_postErrors[] = $this->l('You have to select a product.');
+
+ if (!$this->_postErrors)
+ {
+ $id_cp_rate_config = Db::getInstance()->getValue('SELECT `id_cp_rate_config` FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_product` = '.(int)Tools::getValue('id_product'));
+
+ // Check if a config does not exist in Add case
+ if ($id_cp_rate_config > 0 && Tools::getValue('action') == 'add')
+ $this->_postErrors[] = $this->l('This product already has a specific Canada Post configuration.');
+
+ // Check if a config exists and if the IDs config correspond in Upd case
+ if (Tools::getValue('action') == 'edit' && (!isset($id_cp_rate_config) || $id_cp_rate_config != Tools::getValue('id_cp_rate_config')))
+ $this->_postErrors[] = $this->l('An error occurred, please try again.');
+
+ // Check if a config exists in Delete case
+ if (Tools::getValue('action') == 'delete' && !isset($id_cp_rate_config))
+ $this->_postErrors[] = $this->l('An error occurred, please try again.');
+ }
+ }
+
+ private function _postProcessProduct()
+ {
+ // Init Var
+ $date = date('Y-m-d H:i:s');
+ $services = Tools::getValue('service');
+
+ // Add Script
+ if (Tools::getValue('action') == 'add')
+ {
+ $addTab = array(
+ 'id_product' => (int)(Tools::getValue('id_product')),
+ 'id_category' => 0,
+ 'id_currency' => (int)(Configuration::get('PS_CURRENCY_DEFAULT')),
+ 'additional_charges' => pSQL(Tools::getValue('additional_charges')),
+ 'date_add' => pSQL($date),
+ 'date_upd' => pSQL($date)
+ );
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_config', $addTab, 'INSERT');
+ $id_cp_rate_config = Db::getInstance()->Insert_ID();
+ foreach ($services as $s)
+ {
+ $addTab = array('id_cp_rate_service_code' => pSQL($s), 'id_cp_rate_config' => (int)$id_cp_rate_config, 'date_add' => pSQL($date), 'date_upd' => pSQL($date));
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_config_service', $addTab, 'INSERT');
+ }
+
+ // Display Results
+ if ($id_cp_rate_config > 0)
+ $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
+ else
+ $this->_html .= $this->displayErrors($this->l('Settings failed'));
+ }
+
+ // Update Script
+ if (Tools::getValue('action') == 'edit' && Tools::getValue('id_cp_rate_config'))
+ {
+ $updTab = array(
+ 'id_currency' => (int)(Configuration::get('PS_CURRENCY_DEFAULT')),
+ 'additional_charges' => pSQL(Tools::getValue('additional_charges')),
+ 'date_upd' => pSQL($date)
+ );
+ $result = Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_config', $updTab, 'UPDATE', '`id_cp_rate_config` = '.(int)Tools::getValue('id_cp_rate_config'));
+ Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cp_rate_config_service` WHERE `id_cp_rate_config` = '.(int)Tools::getValue('id_cp_rate_config'));
+ foreach ($services as $s)
+ {
+ $addTab = array('id_cp_rate_service_code' => pSQL($s), 'id_cp_rate_config' => (int)Tools::getValue('id_cp_rate_config'), 'date_add' => pSQL($date), 'date_upd' => pSQL($date));
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_config_service', $addTab, 'INSERT');
+ }
+
+ // Display Results
+ if ($result)
+ $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
+ else
+ $this->_html .= $this->displayErrors($this->l('Settings failed'));
+ }
+
+ // Delete Script
+ if (Tools::getValue('action') == 'delete' && Tools::getValue('id_cp_rate_config'))
+ {
+ $result1 = Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_cp_rate_config` = '.(int)Tools::getValue('id_cp_rate_config'));
+ $result2 = Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cp_rate_config_service` WHERE `id_cp_rate_config` = '.(int)Tools::getValue('id_cp_rate_config'));
+
+ // Display Results
+ if ($result1)
+ $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
+ else
+ $this->_html .= $this->displayErrors($this->l('Settings failed'));
+ }
+ }
+
+
+
+ /*
+ ** Help Config Methods
+ **
+ */
+
+ private function _displayHelp()
+ {
+ return '
'.$this->l('Welcome to the PrestaShop Canada Post Module configurator.').'
+
'.$this->l('This section will help you to understand how to configure this module correctly.').'
+
+
1. '.$this->l('General Settings').'
+
'.$this->l('See below for the description of each field :').'
+
'.$this->l('Your Canada Post Account').' : '.$this->l('You must subscribe to Canada Post website at this address').' http://www.canadapost.ca
+
'.$this->l('Zip / Postal Code').' : '.$this->l('This field must be the Zip / Postal code of your package starting point.').'
+
'.$this->l('Country').' : '.$this->l('This field must be the country of your package starting point.').'
+
'.$this->l('Delivery Service').' : '.$this->l('These checkboxes correspond to the delivery services you want to be available (when there is no specific configuration for the product or the category product).').'
+
+
2. '.$this->l('Categories Settings').'
+
'.$this->l('This section allows you to define a specific Canada Post configuration for each product category (such as Additional charges).').'
+
+
3. '.$this->l('Products Settings').'
+
'.$this->l('This section allows you to define a specific Canada Post configuration for each product (such as Additional charges).').'
+
+ ';
+ }
+
+ public function hookupdateCarrier($params)
+ {
+ if ((int)($params['id_carrier']) != (int)($params['carrier']->id))
+ {
+ $serviceSelected = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code` WHERE `id_carrier` = '.(int)$params['id_carrier']);
+ $update = array('id_carrier' => (int)($params['carrier']->id), 'id_carrier_history' => pSQL($serviceSelected['id_carrier_history'].'|'.(int)($params['carrier']->id)));
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_rate_service_code', $update, 'UPDATE', '`id_carrier` = '.(int)$params['id_carrier']);
+ }
+ }
+
+ public function displayInfoByCart()
+ {
+ }
+
+
+
+ /*
+ ** Front Methods
+ **
+ */
+
+ public function getCartCurrencyRate($id_currency_origin, $id_cart)
+ {
+ $conversionRate = 1;
+ $cart = new Cart($id_cart);
+ if ($id_currency_origin > 0 && $cart->id_currency != $id_currency_origin)
+ {
+ $currencyOrigin = new Currency((int)$id_currency_origin);
+ $conversionRate /= $currencyOrigin->conversion_rate;
+ $currencySelect = new Currency((int)$cart->id_currency);
+ $conversionRate *= $currencySelect->conversion_rate;
+ }
+ return $conversionRate;
+ }
+
+ public function getOrderShippingCostHash($wsParams)
+ {
+ $paramHash = '';
+ $productHash = '';
+ foreach ($wsParams['products'] as $product)
+ {
+ if (!empty($productHash))
+ $productHash .= '|';
+ $productHash .= $product['id_product'].':'.$product['id_product_attribute'].':'.$product['cart_quantity'];
+ }
+ foreach ($wsParams as $k => $v)
+ if ($k != 'products')
+ $paramHash .= '/'.$v;
+ return md5($productHash.$paramHash.Configuration::get('CP_CARRIER_CALCUL_MODE'));
+ }
+
+ public function getOrderShippingCostCache($wsParams)
+ {
+ // Get Cache
+ $row = Db::getInstance()->getRow("
+ SELECT * FROM `"._DB_PREFIX_."cp_cache`
+ WHERE `id_cart` = ".(int)($wsParams['id_cart'])."
+ AND `id_carrier` = ".(int)($this->id_carrier)."
+ AND `hash` = '".pSQL($wsParams['hash'])."'");
+
+ if ($row['id_currency'])
+ {
+ // Check Currency Rate And Calcul
+ $conversionRate = $this->getCartCurrencyRate($row['id_currency'], (int)$wsParams['id_cart']);
+ $row['total_charges'] = $row['total_charges'] * $conversionRate;
+
+ // Return Cache
+ return $row;
+ }
+
+ return false;
+ }
+
+ public function saveOrderShippingCostCache($wsParams, $wscost)
+ {
+ $is_available = 1;
+ if (!$wscost)
+ $is_available = 0;
+ $date = date('Y-m-d H:i:s');
+ $cart = new Cart((int)$wsParams['id_cart']);
+ $insert = array(
+ 'id_cart' => (int)($wsParams['id_cart']),
+ 'id_carrier' => (int)($this->id_carrier),
+ 'hash' => pSQL($wsParams['hash']),
+ 'id_currency' => (int)($cart->id_currency),
+ 'total_charges' => pSQL($wscost),
+ 'is_available' => (int)($is_available),
+ 'date_add' => pSQL($date),
+ 'date_upd' => pSQL($date)
+ );
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_cache', $insert, 'INSERT');
+ }
+
+ public function loadShippingCostConfig($product)
+ {
+ // Init var
+ $config = array();
+
+ // Check if there is a specific product configuration
+ if ($product['id_product'] > 0)
+ {
+ $productConfiguration = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_product` = '.(int)($product['id_product']));
+ if ($productConfiguration['id_cp_rate_config'])
+ {
+ $servicesConfiguration = Db::getInstance()->ExecuteS('
+ SELECT urcs.*, ursc.`id_carrier`
+ FROM `'._DB_PREFIX_.'cp_rate_config_service` urcs
+ LEFT JOIN `'._DB_PREFIX_.'cp_rate_service_code` ursc ON (ursc.`id_cp_rate_service_code` = urcs.`id_cp_rate_service_code`)
+ WHERE `id_cp_rate_config` = '.(int)($productConfiguration['id_cp_rate_config']));
+ foreach ($servicesConfiguration as $service)
+ $productConfiguration['services'][$service['id_cp_rate_service_code']] = $service;
+ return $productConfiguration;
+ }
+ }
+
+ // Check if there is a specific category configuration
+ if ($product['id_category_default'] > 0)
+ {
+ $categoryConfiguration = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'cp_rate_config` WHERE `id_category` = '.(int)($product['id_category_default']));
+ if ($categoryConfiguration['id_cp_rate_config'])
+ {
+ $servicesConfiguration = Db::getInstance()->ExecuteS('
+ SELECT urcs.*, ursc.`id_carrier`
+ FROM `'._DB_PREFIX_.'cp_rate_config_service` urcs
+ LEFT JOIN `'._DB_PREFIX_.'cp_rate_service_code` ursc ON (ursc.`id_cp_rate_service_code` = urcs.`id_cp_rate_service_code`)
+ WHERE `id_cp_rate_config` = '.(int)($categoryConfiguration['id_cp_rate_config']));
+ foreach ($servicesConfiguration as $service)
+ $categoryConfiguration['services'][$service['id_cp_rate_service_code']] = $service;
+ return $categoryConfiguration;
+ }
+ }
+
+ // Return general config
+ $servicesConfiguration = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code` WHERE `active` = 1');
+ foreach ($servicesConfiguration as $service)
+ $config['services'][$service['id_cp_rate_service_code']] = $service;
+ return $config;
+ }
+
+ public function getWebserviceShippingCost($wsParams)
+ {
+ // Init var
+ $cost = 0;
+
+ // Calcul mode condition
+ if (Configuration::get('CP_CARRIER_CALCUL_MODE') == 'onepackage')
+ {
+ $width = 0;
+ $height = 0;
+ $depth = 0;
+ $weight = 0;
+ $id_product = '';
+
+ foreach ($wsParams['products'] as $product)
+ {
+ if ($product['width'] && $product['width'] > $width) $width = $product['width'];
+ if ($product['height'] && $product['height'] > $height) $height = $product['height'];
+ if ($product['depth'] && $product['depth'] > $depth) $depth = $product['depth'];
+ if ($product['weight'])
+ $weight += ($product['weight'] * $product['quantity']);
+ $id_product = $product['id_product'].',';
+ }
+ $weight += Tools::getValue('cp_carrier_packaging_weight', Configuration::get('CP_CARRIER_PACKAGING_WEIGHT'));
+
+ // Get service in adequation with carrier and check if available
+ $servicesConfiguration = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code` WHERE `active` = 1');
+ foreach ($servicesConfiguration as $service)
+ $config['services'][$service['id_cp_rate_service_code']] = $service;
+ $serviceSelected = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code` WHERE `id_carrier` = '.(int)($this->id_carrier));
+ if (!isset($config['services'][$serviceSelected['id_cp_rate_service_code']]))
+ return false;
+
+ $wsParams['service'] = $serviceSelected['service'];
+ $wsParams['package_list'] = array();
+ $wsParams['package_list'][] = array(
+ 'width' => ($width > 0 ? $width : 7),
+ 'height' => ($height > 0 ? $height : 3),
+ 'depth' => ($depth > 0 ? $depth : 5),
+ 'weight' => ($weight > 0 ? $weight : .5),
+ 'quantity' => 1,
+ 'id_product' => $id_product,
+ );
+ }
+ else
+ {
+ // Getting shipping cost for each product
+ foreach ($wsParams['products'] as $product)
+ {
+ // Load specific configuration
+ $config = $this->loadShippingCostConfig($product);
+
+ // Get service in adequation with carrier and check if available
+ $serviceSelected = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'cp_rate_service_code` WHERE `id_carrier` = '.(int)($this->id_carrier));
+ if (!isset($config['services'][$serviceSelected['id_cp_rate_service_code']]))
+ return false;
+
+ // Load param product
+ $wsParams['service'] = $serviceSelected['service'];
+ $wsParams['package_list'][] = array(
+ 'width' => ($product['width'] ? $product['width'] : 1),
+ 'height' => ($product['height'] ? $product['height'] : 1),
+ 'depth' => ($product['depth'] ? $product['depth'] : 1),
+ 'weight' => ($product['weight'] ? $product['weight'] : 1),
+ 'quantity' => $product['quantity'],
+ 'id_product' => $product['id_product'],
+ );
+
+ // If Additional charges
+ if (isset($config['id_currency']) && isset($config['additional_charges']))
+ {
+ $conversionRate = 1;
+ $conversionRate = $this->getCartCurrencyRate((int)($config['id_currency']), (int)$wsParams['id_cart']);
+ $cost += ($config['additional_charges'] * $conversionRate);
+ }
+ }
+ }
+
+
+ // If webservice return a cost, we add it, else, we return the original shipping cost
+ $result = $this->getCanadaPostShippingCost($wsParams);
+ if ($result['connect'] && $result['cost'] > 0)
+ return ($cost + $result['cost'] + Tools::getValue('cp_carrier_handling_fee', Configuration::get('CP_CARRIER_HANDLING_FEE')));
+ return false;
+ }
+
+ public function getOrderShippingCost($params, $shipping_cost)
+ {
+ // Init var
+ $address = new Address($params->id_address_delivery);
+ $recipient_country = Db::getInstance()->getRow('SELECT `iso_code` FROM `'._DB_PREFIX_.'country` WHERE `id_country` = '.(int)($address->id_country));
+ $recipient_state = Db::getInstance()->getRow('SELECT `iso_code` FROM `'._DB_PREFIX_.'state` WHERE `id_state` = '.(int)($address->id_state));
+ $shipper_country = Db::getInstance()->getRow('SELECT `iso_code` FROM `'._DB_PREFIX_.'country` WHERE `id_country` = '.(int)(Configuration::get('CP_CARRIER_COUNTRY')));
+ $shipper_state = Db::getInstance()->getRow('SELECT `iso_code` FROM `'._DB_PREFIX_.'state` WHERE `id_state` = '.(int)(Configuration::get('CP_CARRIER_STATE')));
+ $products = $params->getProducts();
+
+ // Webservices Params
+ $wsParams = array(
+ 'id_cart' => $params->id,
+ 'id_address_delivery' => $params->id_address_delivery,
+ 'recipient_address1' => $address->address1,
+ 'recipient_address2' => $address->address2,
+ 'recipient_postalcode' => $address->postcode,
+ 'recipient_city' => $address->city,
+ 'recipient_country_iso' => $recipient_country['iso_code'],
+ 'recipient_state_iso' => $recipient_state['iso_code'],
+ 'shipper_address1' => Configuration::get('CP_CARRIER_ADDRESS1'),
+ 'shipper_address2' => Configuration::get('CP_CARRIER_ADDRESS2'),
+ 'shipper_postalcode' => Configuration::get('CP_CARRIER_POSTAL_CODE'),
+ 'shipper_city' => Configuration::get('CP_CARRIER_CITY'),
+ 'shipper_country_iso' => $shipper_country['iso_code'],
+ 'shipper_state_iso' => $shipper_state['iso_code'],
+ 'products' => $params->getProducts()
+ );
+ $wsParams['hash'] = $this->getOrderShippingCostHash($wsParams);
+
+ // Check cache
+ $cache = $this->getOrderShippingCostCache($wsParams);
+ if ($cache['id_cp_cache'] > 0)
+ {
+ if ($cache['is_available'] == 0)
+ return false;
+ if ($cache['total_charges'])
+ return $cache['total_charges'];
+ }
+
+ // Get Webservices Cost and Cache it
+ $wscost = $this->getWebserviceShippingCost($wsParams);
+ $this->saveOrderShippingCostCache($wsParams, $wscost);
+
+ if ($wscost > 0)
+ return $wscost + $shipping_cost;
+ return false;
+ }
+
+ public function getOrderShippingCostExternal($params)
+ {
+ return $this->getOrderShippingCost($params, 23);
+ }
+
+
+
+ /*
+ ** Webservices Methods
+ **
+ */
+
+ public function webserviceTest($service = '')
+ {
+ // Check API Key
+ if (!Configuration::get('CP_CARRIER_ACCOUNT'))
+ return false;
+
+ // Example Params for testing
+ $shipper_country = Db::getInstance()->getRow('SELECT `iso_code` FROM `'._DB_PREFIX_.'country` WHERE `id_country` = '.(int)(Configuration::get('CP_CARRIER_COUNTRY')));
+ $shipper_state = Db::getInstance()->getRow('SELECT `iso_code` FROM `'._DB_PREFIX_.'state` WHERE `id_state` = '.(int)(Configuration::get('CP_CARRIER_STATE')));
+ $wsParams = array(
+ 'recipient_address1' => Configuration::get('CP_CARRIER_ADDRESS1'),
+ 'recipient_address2' => Configuration::get('CP_CARRIER_ADDRESS2'),
+ 'recipient_postalcode' => Configuration::get('CP_CARRIER_POSTAL_CODE'),
+ 'recipient_city' => Configuration::get('CP_CARRIER_CITY'),
+ 'recipient_country_iso' => $shipper_country['iso_code'],
+ 'recipient_state_iso' => $shipper_state['iso_code'],
+ 'shipper_address1' => Configuration::get('CP_CARRIER_ADDRESS1'),
+ 'shipper_address2' => Configuration::get('CP_CARRIER_ADDRESS2'),
+ 'shipper_postalcode' => Configuration::get('CP_CARRIER_POSTAL_CODE'),
+ 'shipper_city' => Configuration::get('CP_CARRIER_CITY'),
+ 'shipper_country_iso' => $shipper_country['iso_code'],
+ 'shipper_state_iso' => $shipper_state['iso_code'],
+ 'package_list' => array(
+ array('width' => 10, 'height' => 3, 'depth' => 10, 'weight' => 0.75, 'quantity' => 1, 'id_product' => 1),
+ array('width' => 3, 'height' => 3, 'depth' => 3, 'weight' => 0.75, 'quantity' => 1, 'id_product' => 2),
+ ),
+ );
+
+ // Unit or Large Test
+ if (!empty($service))
+ $servicesList = array(array('service' => $service));
+ else
+ $servicesList = Db::getInstance()->ExecuteS('SELECT `service` FROM `'._DB_PREFIX_.'cp_rate_service_code`');
+
+ // Testing Service
+ foreach ($servicesList as $service)
+ {
+ // Sending Request
+ $service = $service['service'];
+ $wsParams['service'] = $service;
+
+ $delivery = Db::getInstance()->getValue('SELECT `result` FROM `'._DB_PREFIX_.'cp_cache_test` WHERE `hash` = \''.pSQL(md5($this->getXml($wsParams).$service)).'\'');
+ if ($delivery)
+ $delivery = unserialize($delivery);
+ else
+ $resultTab = $this->sendRequest($wsParams);
+
+ // Finding the good delivery service
+ if (isset($resultTab->ratesAndServicesResponse->product))
+ foreach ($resultTab->ratesAndServicesResponse->product as $d)
+ if (strtolower((string)$d->name) == strtolower($service))
+ {
+ $delivery = array();
+ $delivery['name'] = (string)$d->name;
+ $delivery['rate'] = (string)$d->rate;
+ }
+
+ // Return results
+ if ($delivery)
+ {
+ Db::getInstance()->autoExecute(_DB_PREFIX_.'cp_cache_test', array('hash' => pSQL(md5($this->getXml($wsParams).$service)), 'result' => pSQL(serialize($delivery)), 'date_add' => pSQL(date('Y-m-d H:i:s')), 'date_upd' => pSQL(date('Y-m-d H:i:s'))), 'INSERT');
+ return true;
+ }
+
+ if (isset($resultTab->error->statusMessage) && (string)$resultTab->error->statusMessage != '')
+ $this->_webserviceError = $this->l('Error').' '.(string)$resultTab->error->statusCode.' : '.(string)$resultTab->error->statusMessage;
+ else
+ {
+ $this->_webserviceError = $this->l('Canada Post Webservice seems to be down, please wait a few minutes and try again.');
+ return false;
+ }
+ }
+
+ return false;
+ }
+
+ public function getCanadaPostShippingCost($wsParams)
+ {
+ // Check Arguments
+ if (!$wsParams)
+ return array('connect' => false, 'cost' => 0);
+
+ // Sending Request
+ $resultTab = $this->sendRequest($wsParams);
+
+ // Finding the good delivery service
+ if (isset($resultTab->ratesAndServicesResponse->product) && $resultTab->ratesAndServicesResponse->product)
+ foreach ($resultTab->ratesAndServicesResponse->product as $d)
+ if (strtolower((string)$d->name) != '' && strtolower((string)$d->name) == strtolower($wsParams['service']))
+ {
+ $delivery = array();
+ $delivery['name'] = (string)$d->name;
+ $delivery['rate'] = (string)$d->rate;
+ }
+ if (!isset($delivery))
+ return array('connect' => false, 'cost' => 0);
+
+ // Check currency
+ $conversionRate = $this->getCartCurrencyRate(Currency::getIdByIsoCode('CAD'), $wsParams['id_cart']);
+
+ // Return results
+ return array('connect' => true, 'cost' => $delivery['rate'] * $conversionRate);
+ }
+
+ public function sendRequest($wsParams)
+ {
+ // POST Request
+ $errno = $errstr = $result = '';
+ $xml = $this->getXml($wsParams);
+
+ if (is_callable('curl_exec'))
+ {
+ // Curl Request
+ $ch = curl_init("http://sellonline.canadapost.ca");
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 60);
+ curl_setopt($ch, CURLOPT_PORT, 30000);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
+ $result = curl_exec($ch);
+ }
+ else
+ {
+ // FsockOpen Request
+ $timeout = 5;
+ $fp = fsockopen("http://sellonline.canadapost.ca:30000", "80", $errno, $errstr, $timeout);
+ if ($fp)
+ {
+ $request = "POST HTTP/1.1\r\n";
+ $request .= "Host: sellonline.canadapost.ca\r\n";
+ $request .= "Content-type: application/x-www-form-urlencoded\r\n";
+ $request .= "Connection: Close\r\n";
+ $request .= "Content-length: ".strlen($xml)."\r\n\r\n";
+ $request .= $xml."\r\n\r\n";
+ fwrite($fp, $request);
+
+ stream_set_blocking($fp, TRUE);
+ stream_set_timeout($fp,$timeout);
+ $info = stream_get_meta_data($fp);
+
+ $result = '';
+ while ((!feof($fp)) && (!$info['timed_out']))
+ {
+ $result .= fgets($fp, 4096);
+ $info = stream_get_meta_data($fp);
+ }
+ if ($info['timed_out'])
+ {
+ $this->_webserviceError = $this->l('Canada Post Webservice timed out.');
+ return false;
+ }
+ }
+ else
+ {
+ $this->_webserviceError = $this->l('Could not connect to CanadaPost.com');
+ return false;
+ }
+ }
+
+ // Get xml from HTTP Result
+ $data = strstr($result, '');
+ $resultTab = simplexml_load_string($data);
+
+ return $resultTab;
+ }
+
+
+ public function getXml($wsParams = array())
+ {
+ // Template Xml Package List
+ $xmlPackageList = '';
+ $xmlPackageTemplate = @file_get_contents(dirname(__FILE__).'/xml-package.tpl');
+
+ foreach ($wsParams['package_list'] as $k => $p)
+ {
+ // KG, LB, OU conversions
+ if ($this->_weightUnit == 'LB' || $this->_weightUnit == 'LBS')
+ $p['weight'] = round($p['weight'] / 2.20462262);
+
+ // Replace in template
+ $search = array(
+ '[[Quantity]]',
+ '[[PackageWeight]]',
+ '[[Length]]',
+ '[[Width]]',
+ '[[Height]]',
+ '[[Name]]',
+ );
+ $replace = array(
+ $p['quantity'],
+ $p['weight'],
+ $p['width'],
+ $p['height'],
+ $p['depth'],
+ 'Product '.$p['id_product'],
+ );
+ $xmlPackageList .= str_replace($search, $replace, $xmlPackageTemplate);
+ }
+
+
+ // Template Xml
+ $search = array(
+ '[[IsoCode]]',
+ '[[UserLogin]]',
+ '[[ShipFromPostalCode]]',
+ '[[ItemsPrice]]',
+ '[[ShipToCity]]',
+ '[[ShipToStateCode]]',
+ '[[ShipToCountryCode]]',
+ '[[ShipToPostalCode]]',
+ '[[PackageList]]',
+ );
+ $replace = array(
+ 'EN',
+ Configuration::get('CP_CARRIER_ACCOUNT'),
+ $wsParams['shipper_postalcode'],
+ 10,
+ $wsParams['recipient_city'],
+ $wsParams['recipient_state_iso'],
+ $wsParams['recipient_country_iso'],
+ $wsParams['recipient_postalcode'],
+ $xmlPackageList,
+ );
+ $xmlTemplate = @file_get_contents(dirname(__FILE__).'/xml.tpl');
+ $xml = str_replace($search, $replace, $xmlTemplate);
+
+
+ // Return
+ return $xml;
+ }
+
+}
+
diff --git a/modules/canadapost/carrier.jpg b/modules/canadapost/carrier.jpg
new file mode 100644
index 000000000..15d0eb575
Binary files /dev/null and b/modules/canadapost/carrier.jpg differ
diff --git a/modules/canadapost/config.xml b/modules/canadapost/config.xml
new file mode 100755
index 000000000..391ac0b9d
--- /dev/null
+++ b/modules/canadapost/config.xml
@@ -0,0 +1,12 @@
+
+
+ canadapost
+
+
+
+
+
+ 1
+ 1
+ ca
+
\ No newline at end of file
diff --git a/modules/mondialrelay/kit_mondialrelay/index.php b/modules/canadapost/index.php
old mode 100644
new mode 100755
similarity index 96%
rename from modules/mondialrelay/kit_mondialrelay/index.php
rename to modules/canadapost/index.php
index 4e2611d37..b559f9855
--- a/modules/mondialrelay/kit_mondialrelay/index.php
+++ b/modules/canadapost/index.php
@@ -20,7 +20,7 @@
*
* @author PrestaShop SA
* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision$
+* @version Release: $Revision: 7233 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
diff --git a/modules/canadapost/logo.gif b/modules/canadapost/logo.gif
new file mode 100644
index 000000000..e7dac26dc
Binary files /dev/null and b/modules/canadapost/logo.gif differ
diff --git a/modules/canadapost/sql-install.php b/modules/canadapost/sql-install.php
new file mode 100755
index 000000000..84db5724f
--- /dev/null
+++ b/modules/canadapost/sql-install.php
@@ -0,0 +1,81 @@
+
+ [[Quantity]]
+ [[PackageWeight]]
+ [[Length]]
+ [[Width]]
+ [[Height]]
+ [[Name]]
+
diff --git a/modules/canadapost/xml.tpl b/modules/canadapost/xml.tpl
new file mode 100755
index 000000000..b60826a4b
--- /dev/null
+++ b/modules/canadapost/xml.tpl
@@ -0,0 +1,16 @@
+
+
+ [[IsoCode]]
+
+ [[UserLogin]]
+ [[ShipFromPostalCode]]
+ [[ItemsPrice]]
+
+[[PackageList]]
+
+ [[ShipToCity]]
+ [[ShipToStateCode]]
+ [[ShipToCountryCode]]
+ [[ShipToPostalCode]]
+
+
diff --git a/modules/ebay/ebay.php b/modules/ebay/ebay.php
index daa2979b0..45f51295b 100755
--- a/modules/ebay/ebay.php
+++ b/modules/ebay/ebay.php
@@ -457,9 +457,8 @@ class Ebay extends Module
// Displaying Information from Prestashop
- $context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 5)));
- $prestashopContent = @file_get_contents('http://www.prestashop.com/partner/modules/ebay.php?version='.$this->version.'&shop='.urlencode(Configuration::get('PS_SHOP_NAME')).'®istered='.($alert['registration'] == 1 ? 'no' : 'yes').'&url='.urlencode($_SERVER['HTTP_HOST']).'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)$this->context->language->id.'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $context);
-
+ $stream_context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 5)));
+ $prestashopContent = @file_get_contents('http://www.prestashop.com/partner/modules/ebay.php?version='.$this->version.'&shop='.urlencode(Configuration::get('PS_SHOP_NAME')).'®istered='.($alert['registration'] == 1 ? 'no' : 'yes').'&url='.urlencode($_SERVER['HTTP_HOST']).'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)$this->context->language->id.'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $stream_context);
// Displaying page
$this->_html .= '
@@ -865,9 +864,9 @@ class Ebay extends Module
'.$this->l('Beware : Only product default categories are used for this configuration.').'
- * Certaines catégories bénéficient du nouveau format d’annonces multi-versions qui permet de publier 1 seule annonce pour plusieurs versions du même produit.
- Pour les catégories ne bénéficiant pas de ce format multi-versions, une annonce sera créée pour chaque version du produit.
- Cliquez ici pour plus d’informations sur les catégories multi-versions
+ * Certaines catégories bénéficient du nouveau format d’annonces multi-versions qui permet de publier 1 seule annonce pour plusieurs versions du même produit.
+ Pour les catégories ne bénéficiant pas de ce format multi-versions, une annonce sera créée pour chaque version du produit.
+ Cliquez ici pour plus d’informations sur les catégories multi-versions
';
- ?>
-
-
-
-
-
-
-
-
- $(document).ready(function ()
- {
- recherche_MR(\'relativ_base_dir='.$_GET['relativ_base_dir'].'&Pays='.$_GET['Pays'].'&Ville='.$_GET['Ville'].'&CP='.$_GET['CP'].'&Taille=&Poids='.$_GET['Poids'].'&Action='.$_GET['Action'].'&num='.$_GET['num'].'\');
-
- window.onload = function()
- {
- var cpt = 0;
- google_map_init();
- if (json_addresses && json_addresses.addresses)
- while (json_addresses.addresses[cpt])
- {
- if (json_addresses.addresses[cpt].address3.length)
- {
- address_google = json_addresses.addresses[cpt].address3+\' \'+json_addresses.addresses[cpt].postcode+\' \'+json_addresses.addresses[cpt].city+\' \'+json_addresses.addresses[cpt].iso_country;
- address = json_addresses.addresses[cpt].address1+\' \'+json_addresses.addresses[cpt].address2+\' \'+json_addresses.addresses[cpt].address3+\' \'+json_addresses.addresses[cpt].postcode+\' \'+json_addresses.addresses[cpt].city+\' \'+json_addresses.addresses[cpt].iso_country;
- codeAddress(address, address_google);
- }
- cpt++;
- }
- }
- });
-';
-?>
diff --git a/modules/mondialrelay/images/selectRelayPoint.png b/modules/mondialrelay/images/selectRelayPoint.png
new file mode 100755
index 000000000..b6462f07a
Binary files /dev/null and b/modules/mondialrelay/images/selectRelayPoint.png differ
diff --git a/modules/mondialrelay/it.php b/modules/mondialrelay/it.php
index 0a25e3c38..2295d417c 100644
--- a/modules/mondialrelay/it.php
+++ b/modules/mondialrelay/it.php
@@ -2,11 +2,6 @@
global $_MODULE;
$_MODULE = array();
-$_MODULE['<{mondialrelay}prestashop>mondialrelay_2f84f9d5731852c4d07d52ef0badc42e'] = 'Problema per ottenere gli indirizzi da MondialRelay Webservice: i server di Mondial Relay potrebbero essere inattivi';
-$_MODULE['<{mondialrelay}prestashop>mondialrelay_016854c68c7122b18d89ff0f5e40502b'] = 'Il Relay Point non è vicino al tuo indirizzo, per favore cambia il tuo indirizzo o utilizza un altro corriere';
-$_MODULE['<{mondialrelay}prestashop>mondialrelay_21034ae6d01a83e702839a72ba8a77b0'] = '(Tasse escl.)';
-$_MODULE['<{mondialrelay}prestashop>mondialrelay_1f87346a16cf80c372065de3c54c86d9'] = '(Tasse incl.)';
-$_MODULE['<{mondialrelay}prestashop>mondialrelay_e7a6ca4e744870d455a57b644f696457'] = 'Gratis!';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_44585fcd617dce6416d8283b026714c1'] = 'Mondial Relay';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_ed4a3b96dc1f38c160775cac1f7bcd6d'] = 'Consegna nei punti Relay';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_70d70ce314f545b7c500a086f147f64b'] = 'Negozio non valido';
@@ -33,7 +28,6 @@ $_MODULE['<{mondialrelay}prestashop>mondialrelay_b962d8fb95f5a439f50502152f3bad7
$_MODULE['<{mondialrelay}prestashop>mondialrelay_faf1247ae6846a9955a466d4f301bbe4'] = 'Pagina corriere';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_10d78806b84b97ebc774e9f6277af6ac'] = 'Per generare le etichette, è necessario disporre di un indirizzo valido e registrato per il tuo negozio sulla tua ';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_af5efea250326c1c34d69aa9364b482c'] = 'pagina contatti';
-$_MODULE['<{mondialrelay}prestashop>mondialrelay_ddcd6a653f661fd7d219d9102528b917'] = 'Vai al front office';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_fcf5b2122da1d5a5f5c7253b96a3f9d9'] = 'URL Cron task:';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_362dff77f7403550e886db901404856c'] = 'Cancellazione riuscita';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_66661dacf33146201b60dc16520ddd68'] = 'Aggiungere un metodo di spedizione';
@@ -62,6 +56,7 @@ $_MODULE['<{mondialrelay}prestashop>mondialrelay_907eba32d950bfab68227fd7ea22999
$_MODULE['<{mondialrelay}prestashop>mondialrelay_0c24ec05a02c710cedd400e3680d8b81'] = 'Elenco metodo di spedizione ';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_14039af96b01e718a9c9d9c1259b6472'] = 'Nessun metodo di spedizione creato';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_8596361cec00f8d2438d264827eee737'] = 'Config di spedizione.';
+$_MODULE['<{mondialrelay}prestashop>mondialrelay_c9cc8cce247e49bae79f15173ce97354'] = 'Salva';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_f4f70727dc34561dfde1a3c529b6205c'] = 'Impostazioni';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_d02bbc3cb147c272b0445ac5ca7d1a36'] = 'Stato ordine';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_818f954f4838ecad839c5dcbd287d291'] = 'Scegli lo stato dell\'ordine per le etichette. È possibile gestire le etichette';
@@ -72,7 +67,6 @@ $_MODULE['<{mondialrelay}prestashop>mondialrelay_93cba07454f06a4a960172bbd6e2a43
$_MODULE['<{mondialrelay}prestashop>mondialrelay_b9f5c797ebbf55adccdd8539a65a0241'] = 'Disattivato';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_bafd7322c6e97d25b6299b5d6fe8920b'] = 'No';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_9c5c09beb32c36129b857c2a40c861b6'] = 'Visualizza una mappa di Google sul tuo operatore Mondial Relay, può rallentare il caricamento della pagina del corriere ';
-$_MODULE['<{mondialrelay}prestashop>mondialrelay_c9cc8cce247e49bae79f15173ce97354'] = 'Salva';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_1ba3935c9858ffb8e19a35ca640b8505'] = 'Impostazioni account Mondial Relay';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_12a3fbd35c1cab4b1101b91d708efd15'] = 'Insegna WebService:';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_6f0434b67007b555dfd1201f4e0d5254'] = 'Codice marchio:';
@@ -86,5 +80,3 @@ $_MODULE['<{mondialrelay}prestashop>mondialrelay_0dbe844fb964d5eca2f51be724e4329
$_MODULE['<{mondialrelay}prestashop>mondialrelay_c6aefd5e2191e1210a2f50416812b517'] = 'Follow-up URL';
$_MODULE['<{mondialrelay}prestashop>mondialrelay_61e70b58e38fd01daa254f44c4fa264b'] = 'N. Point Relay:';
$_MODULE['<{mondialrelay}prestashop>orderdetail_81b7b4587a2a3ea7a0d6bb1df3fbba54'] = 'Consegna a';
-
-?>
\ No newline at end of file
diff --git a/modules/mondialrelay/js/gmap.js b/modules/mondialrelay/js/gmap.js
new file mode 100644
index 000000000..4d0e9fd7f
--- /dev/null
+++ b/modules/mondialrelay/js/gmap.js
@@ -0,0 +1,2126 @@
+/*
+ * GMAP3 Plugin for JQuery
+ * Version : 3.4
+ * Date : July 04, 2011
+ * Licence : GPL v3 : http://www.gnu.org/licenses/gpl.html
+ * Author : DEMONTE Jean-Baptiste
+ * Contact : jbdemonte@gmail.com
+ * Web site : http://gmap3.net
+ *
+ * Copyright (c) 2010-2011 Jean-Baptiste DEMONTE
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * - Neither the name of the author nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+(function ($) {
+
+ /***************************************************************************/
+ /* STACK */
+ /***************************************************************************/
+ function Stack (){
+ var st={};
+ this.init = function (id){
+ if (!st[id]){
+ st[id] = [];
+ }
+ }
+ this.empty = function (id){
+ var i;
+ if (!st[id]) {
+ return true;
+ }
+ for(i = 0; i < st[id].length; i++){
+ if (st[id][i]){
+ return false
+ }
+ }
+ return true;
+ }
+ this.add = function (id, v){
+ this.init(id);
+ st[id].push(v);
+ }
+ this.addNext = function (id, v){
+ var t=[], i, k = 0;
+ this.init(id);
+ for(i = 0; i < st[id].length; i++){
+ if (!st[id][i]){
+ continue;
+ }
+ if (k == 1) {
+ t.push(v);
+ }
+ t.push(st[id][i]);
+ k++;
+ }
+ if (k < 2) {
+ t.push(v);
+ }
+ st[id] = t;
+ }
+ this.get = function (id){
+ var i;
+ if (st[id]){
+ for(i = 0; i < st[id].length; i++){
+ if (st[id][i]) {
+ return st[id][i];
+ }
+ }
+ }
+ return false;
+ }
+ this.ack = function (id){
+ var i;
+ if (st[id]) {
+ for(i = 0; i < st[id].length; i++){
+ if (st[id][i]) {
+ delete st[id][i];
+ break;
+ }
+ }
+ if (this.empty(id)){
+ delete st[id];
+ }
+ }
+ }
+ }
+ /***************************************************************************/
+ /* CLUSTERER */
+ /***************************************************************************/
+
+ function Clusterer(){
+ var markers = [], events=[], stored=[], latest=[], redrawing = false, redraw;
+
+ this.events = function(){
+ for(var i=0; i= 0){
+ same[j] = true;
+ } else {
+ this.freeIndex(i);
+ }
+ }
+ return same;
+ }
+
+ this.add = function(latLng, marker){
+ markers.push({latLng:latLng, marker:marker});
+ }
+
+ this.get = function(i){
+ return markers[i];
+ }
+
+ this.clusters = function(map, radius, force){
+ var proj = map.getProjection(),
+ nwP = proj.fromLatLngToPoint(
+ new google.maps.LatLng(
+ map.getBounds().getNorthEast().lat(),
+ map.getBounds().getSouthWest().lng()
+ )
+ ),
+ i, j, j2, p, x, y, k, k2,
+ z = map.getZoom(),
+ pos = {},
+ saved = {},
+ unik = {},
+ clusters = [],
+ cluster,
+ chk,
+ lat, lng, keys, cnt,
+ bounds = map.getBounds();
+
+ cnt = 0;
+ keys = {};
+ for(i = 0; i < markers.length; i++){
+ if (!bounds.contains(markers[i].latLng)){
+ continue;
+ }
+ p = proj.fromLatLngToPoint(markers[i].latLng);
+ pos[i] = [
+ Math.floor((p.x - nwP.x) * Math.pow(2, z)),
+ Math.floor((p.y - nwP.y) * Math.pow(2, z))
+ ];
+ keys[i] = true;
+ cnt++;
+ }
+ // check if visible markers have changed
+ if (!force){
+ for(k = 0; k < latest.length; k++){
+ if( k in keys ){
+ cnt--;
+ } else {
+ break;
+ }
+ }
+ if (!cnt){
+ return false; // no change
+ }
+ }
+
+ // save current keys to check later if an update has been done
+ latest = keys;
+
+ keys = [];
+ for(i in pos){
+ x = pos[i][0];
+ y = pos[i][1];
+ if ( !(x in saved) ){
+ saved[x] = {};
+ }
+ if (!( y in saved[x]) ) {
+ saved[x][y] = i;
+ unik[i] = {};
+ keys.push(i);
+ }
+ unik[ saved[x][y] ][i] = true;
+ }
+ radius = Math.pow(radius, 2);
+ delete(saved);
+
+ k = 0;
+ while(1){
+ while((k 1;
+ saved = cluster;
+ } else {
+ chk = cluster.idx.length > saved.idx.length;
+ if (chk){
+ saved = cluster;
+ }
+ }
+ if (chk){
+ p = proj.fromLatLngToPoint( new google.maps.LatLng(saved.lat, saved.lng) );
+ lat = Math.floor((p.x - nwP.x) * Math.pow(2, z));
+ lng = Math.floor((p.y - nwP.y) * Math.pow(2, z));
+ }
+ } while(chk);
+
+ for(k2 = 0; k2 < saved.idx.length; k2++){
+ if (saved.idx[k2] in unik){
+ delete(unik[saved.idx[k2]]);
+ }
+ }
+ clusters.push(saved);
+ }
+ return clusters;
+ }
+
+ this.getBounds = function(){
+ var i, bounds = new google.maps.LatLngBounds();
+ for(i = 0; i < markers.length; i++){
+ bounds.extend(markers[i].latLng);
+ }
+ return bounds;
+ }
+ }
+
+ /***************************************************************************/
+ /* GMAP3 */
+ /***************************************************************************/
+
+ var gmap3 = {
+ _ids:{},
+ _properties:['events','onces','options','apply', 'callback', 'data', 'tag'],
+
+ _default:{
+ verbose:false,
+ unit: 'mi',
+ init:{
+ mapTypeId : google.maps.MapTypeId.ROADMAP,
+ center:[46.578498,2.457275],
+ zoom: 2
+ }
+ },
+ _running:{
+ },
+ _stack: new Stack(),
+ /**
+ * @desc create default structure if not existing
+ **/
+ _init: function($this, id){
+ if (!this._ids[id]) {
+ this._ids[id] = {
+ $this:$this,
+ styles: {},
+ stored:{},
+ map:null
+ };
+ }
+ },
+ /**
+ * @desc store actions to do in a stack manager
+ **/
+ _plan: function($this, id, list){
+ var k;
+ this._init($this, id);
+ for(k = 0; k < list.length; k++) {
+ this._stack.add(id, list[k] );
+ }
+ this._run(id);
+ },
+ /**
+ * @desc return true if action has to be executed directly
+ **/
+ _isDirect: function(id, todo){
+ var action = this._ival(todo, 'action'),
+ directs = {
+ distance :true,
+ earthradius :true,
+ get :true
+ };
+ return action in directs;
+ },
+ /**
+ * @desc execute action directly
+ **/
+ _direct: function(id, todo){
+ var action = this._ival(todo, 'action');
+ if (action.substr(0,1) == ':'){
+ action = action.substr(1);
+ }
+ return this[action](id, $.extend({}, action in this._default ? this._default[action] : {}, todo.args ? todo.args : todo));
+ },
+ /**
+ * @desc store one action to do in a stack manager after the first
+ **/
+ _planNext: function(id, a){
+ var $this = this._jObject(id);
+ this._init($this, id);
+ this._stack.addNext(id, a);
+ },
+ /**
+ * @desc called when action in finished, to acknoledge the current in stack and start next one
+ **/
+ _end: function(id){
+ delete this._running[id];
+ this._stack.ack(id);
+ this._run(id);
+ },
+ /**
+ * @desc if not running, start next action in stack
+ **/
+ _run: function(id){
+ if (this._running[id]) return;
+ var a = this._stack.get(id);
+ if (!a) return;
+ this._running[id] = true;
+ this._proceed(id, a);
+ },
+
+ _geocoder: null,
+ _getGeocoder: function(){
+ if (!this._geocoder) this._geocoder = new google.maps.Geocoder();
+ return this._geocoder;
+ },
+
+ _directionsService: null,
+ _getDirectionsService: function(){
+ if (!this._directionsService) this._directionsService = new google.maps.DirectionsService();
+ return this._directionsService;
+ },
+
+ _elevationService: null,
+ _getElevationService: function(){
+ if (!this._elevationService) this._elevationService = new google.maps.ElevationService();
+ return this._elevationService;
+ },
+
+ _maxZoomService:null,
+ _getMaxZoomService: function(){
+ if (!this._maxZoomService) this._maxZoomService = new google.maps.MaxZoomService();
+ return this._maxZoomService;
+ },
+
+ _getMap: function( id ){
+ return this._ids[id].map;
+ },
+
+ _setMap: function (id, map){
+ this._ids[id].map = map;
+ },
+
+ _jObject: function( id ){
+ return this._ids[id].$this;
+ },
+
+ _addStyle: function(id, styleId, style){
+ this._ids[id].styles[ styleId ] = style;
+ },
+
+ _getStyles: function(id){
+ return this._ids[id].styles;
+ },
+
+ _getStyle: function(id, styleId){
+ return this._ids[id].styles[ styleId ];
+ },
+
+ _styleExist: function(id, styleId){
+ return this._ids[id] && this._ids[id].styles[ styleId ];
+ },
+
+ _getDirectionRenderer: function(id){
+ return this._getStored(id, 'directionrenderer');
+ },
+
+ _exist: function(id){
+ return this._ids[id].map ? true : false;
+ },
+
+ /**
+ * @desc return last non-null object
+ **/
+ _getStored: function(id, name, last, tag){
+ if (!this._ids[id].stored[name] || !this._ids[id].stored[name].length){
+ return null;
+ }
+ var t = this._ids[id].stored[name],
+ i,
+ idx = last ? t.length : -1,
+ add = last ? -1 : 1;
+ for(i=0; i= 0; idx--){
+ if ( (t[idx] !== undefined) && (t[idx].tag !== undefined) && ($.inArray(t[idx].tag, tag) >= 0) ){
+ break;
+ }
+ }
+ } else {
+ for(idx = 0; idx < t.length; idx++){
+ if ( (t[idx] !== undefined) && (t[idx].tag !== undefined) && ($.inArray(t[idx].tag, tag) >= 0) ){
+ break;
+ }
+ }
+ }
+ } else {
+ idx = pop ? t.length - 1 : 0;
+ }
+ if ( !(idx in t) ) {
+ return false;
+ }
+ // Google Map element
+ if (typeof(t[idx].obj.setMap) === 'function') {
+ t[idx].obj.setMap(null);
+ }
+ // JQuery
+ if (typeof(t[idx].obj.remove) === 'function') {
+ t[idx].obj.remove();
+ }
+ // internal (cluster)
+ if (typeof(t[idx].obj.free) === 'function') {
+ t[idx].obj.free();
+ }
+ delete t[idx].obj;
+ if (tag !== undefined){
+ this._ids[id].stored[name] = this._rmFromArray(t,idx);
+ } else {
+ if (pop) {
+ t.pop();
+ } else {
+ t.shift();
+ }
+ }
+ return true;
+ },
+
+ /**
+ * @desc manage remove objects
+ **/
+ _clear: function(id, list, last, first, tag){
+ var n, i;
+ if (!list || !list.length){
+ list = [];
+ for(k in this._ids[id].stored){
+ list.push(k);
+ }
+ } else {
+ list = this._array(list);
+ }
+ for(i = 0; i < list.length; i++){
+ if (list[i]){
+ n = list[i].toLowerCase();
+ if (!this._ids[id].stored[n]) continue;
+ if (last){
+ this._unstore(id, n, tag, true);
+ } else if (first){
+ this._unstore(id, n, tag, false);
+ } else {
+ while (this._unstore(id, n, tag, false));
+ }
+ }
+ }
+ },
+
+ /**
+ * @desc return true if "init" action must be run
+ **/
+ _autoInit: function(name){
+ var i,
+ names = [
+ 'init',
+ 'geolatlng',
+ 'getlatlng',
+ 'getroute',
+ 'getelevation',
+ 'addstyledmap',
+ 'setdefault',
+ 'destroy'
+ ];
+ if ( !name ) {
+ return true;
+ }
+ for(i = 0; i < names.length; i++){
+ if (names[i] === name) {
+ return false;
+ }
+ }
+ return true;
+ },
+ /**
+ * @desc call functions associated
+ * @param
+ * id : string
+ * action : string : function wanted
+ *
+ * options : {}
+ *
+ * O1 : {}
+ * O2 : {}
+ * ...
+ * On : {}
+ * => On : option : {}
+ * action : string : function name
+ * ... (depending of functions called)
+ *
+ * args : [] : parameters for directs call to map
+ * target? : object : replace map to call function
+ **/
+ _proceed: function(id, todo){
+ todo = todo || {};
+ var action = this._ival(todo, 'action') || 'init',
+ iaction = action.toLowerCase(),
+ ok = true,
+ target = this._ival(todo, 'target'),
+ args = this._ival(todo, 'args'),
+ map, out;
+ if ( !this._exist(id) && this._autoInit(iaction) ){
+ this.init(id, $.extend({}, this._default.init, todo.args && todo.args.map ? todo.args.map : todo.map ? todo.map : {}), true);
+ }
+ if (!target && !args && (iaction in this) && (typeof(this[iaction]) === 'function')){
+ // framework functions
+ this[iaction](id, $.extend({}, iaction in this._default ? this._default[iaction] : {}, todo.args ? todo.args : todo)); // call fnc and extends defaults data
+ } else {
+ if (target && (typeof(target) === 'object')){
+ if (typeof(target[action]) === 'function'){
+ out = target[action].apply(target, todo.args ? todo.args : []);
+ } else ok = false;
+ // gm direct function : no result so not rewrited, directly wrapped using array "args" as parameters (ie. setOptions, addMapType, ...)
+ } else {
+ map = this._getMap(id);
+ if (typeof(map[action]) === 'function'){
+ out = map[action].apply(map, todo.args ? todo.args : [] );
+ } else ok = false;
+ }
+ if (!ok && this._default.verbose) alert("unknown action : " + action);
+ this._callback(id, out, todo);
+ this._end(id);
+ }
+ },
+
+ /**
+ * @desc call a function of framework or google map object of the instance
+ * @param
+ * id : string : instance
+ * fncName : string : function name
+ * ... (depending on function called)
+ **/
+ _call: function(/* id, fncName [, ...] */){
+ if ( (arguments.length < 2) || (!this._exist(arguments[0])) ){
+ return ;
+ }
+ var i, id = arguments[0],
+ fname = arguments[1],
+ map = this._getMap(id),
+ args = [];
+ if (typeof(map[ fname ]) !== 'function') {
+ return;
+ }
+ for(i=2; i { eventName => function, }
+ * onces => { eventName => function, }
+ * data => mixed data
+ * ]
+ **/
+ _attachEvents : function(id, sender, todo){
+ var name;
+ if (!todo) return
+ if (todo.events){
+ for(name in todo.events){
+ if (typeof(todo.events[name]) === 'function'){
+ this._attachEvent(id, sender, name, todo.events[name], todo.data, false);
+ }
+ }
+ }
+ if (todo.onces){
+ for(name in todo.onces){
+ if (typeof(todo.onces[name]) === 'function'){
+ this._attachEvent(id, sender, name, todo.onces[name], todo.data, true);
+ }
+ }
+ }
+ },
+
+ /**
+ * @desc execute callback functions
+ **/
+ _callback: function(mixed, result, todo){
+ var k, $j;
+ if (typeof(todo.callback) === 'function') {
+ $j = typeof(mixed) === 'number' ? this._jObject(mixed) : mixed;
+ todo.callback.apply($j, [result]);
+ } else if (typeof(todo.callback) === 'object') {
+ for(k in todo.callback){
+ if (!$j) $j = typeof(mixed) === 'number' ? this._jObject(mixed) : mixed;
+ if (typeof(todo.callback[k]) === 'function') todo.callback[k].apply($j, [result]);
+ }
+ }
+ },
+
+ /**
+ * @desc execute end functions
+ **/
+ _manageEnd: function(id, sender, todo, internal){
+ var k, c;
+ if (sender && (typeof(sender) === 'object')){
+ this._attachEvents(id, sender, todo);
+ for(k in todo.apply){
+ c = todo.apply[k];
+ if(!c.action) continue;
+ if (typeof(sender[c.action]) !== 'function') {
+ continue;
+ }
+ if (c.args) {
+ sender[c.action].apply(sender, c.args);
+ } else {
+ sender[c.action]();
+ }
+ }
+ }
+ if (!internal) {
+ this._callback(id, sender, todo);
+ this._end(id);
+ }
+ },
+
+ /**
+ * @desc return true if mixed is usable as number
+ **/
+ _isNumeric: function (mixed){
+ return (typeof(mixed) === 'number' || typeof(mixed) === 'string') && mixed !== '' && !isNaN(mixed);
+ },
+
+ /**
+ * @desc convert mixed [ lat, lng ] objet by google.maps.LatLng
+ **/
+ _latLng: function(mixed, emptyReturnMixed, noFlat){
+ var k, latLng={}, i=0,
+ empty = emptyReturnMixed ? mixed : null;
+ if (!mixed || (typeof(mixed) === 'string')){
+ return empty;
+ }
+ if (mixed.latLng) {
+ return this._latLng(mixed.latLng);
+ }
+ if (typeof(mixed.lat) === 'function') {
+ return mixed;
+ } else if ( this._isNumeric(mixed.lat) ) {
+ return new google.maps.LatLng(mixed.lat, mixed.lng);
+ } else if ( !noFlat ){
+ for(k in mixed){
+ if ( !this._isNumeric(mixed[k]) ) return empty;
+ latLng[i?'lng':'lat'] = mixed[k];
+ if (i) break;
+ i++;
+ }
+ if (i) return new google.maps.LatLng(latLng.lat, latLng.lng);
+ }
+ return empty;
+ },
+
+ _count: function(mixed){
+ var k, c = 0;
+ for(k in mixed) c++;
+ return c;
+ },
+
+ /**
+ * @desc convert mixed [ sw, ne ] object by google.maps.LatLngBounds
+ **/
+ _latLngBounds: function(mixed, flatAllowed, emptyReturnMixed){
+ var empty, cnt, ne, sw, k, t, ok, nesw, i;
+ if (!mixed) {
+ return null;
+ }
+ empty = emptyReturnMixed ? mixed : null;
+ if (typeof(mixed.getCenter) === 'function') {
+ return mixed;
+ }
+ cnt = this._count(mixed);
+ if (cnt == 2){
+ if (mixed.ne && mixed.sw){
+ ne = this._latLng(mixed.ne);
+ sw = this._latLng(mixed.sw);
+ } else {
+ for(k in mixed){
+ if (!ne) {
+ ne = this._latLng(mixed[k]);
+ } else {
+ sw = this._latLng(mixed[k]);
+ }
+ }
+ }
+ if (sw && ne) return new google.maps.LatLngBounds(sw, ne);
+ return empty;
+ } else if (cnt == 4){
+ t = ['n', 'e', 's', 'w'];
+ ok=true;
+ for(i in t) ok &= this._isNumeric(mixed[t[i]]);
+ if (ok) return new google.maps.LatLngBounds(this._latLng([mixed.s, mixed.w]), this._latLng([mixed.n, mixed.e]));
+ if (flatAllowed){
+ i=0;
+ nesw={};
+ for(k in mixed){
+ if (!this._isNumeric(mixed[k])) return empty;
+ nesw[t[i]] = mixed[k];
+ i++;
+ }
+ return new google.maps.LatLngBounds(this._latLng([nesw.s, nesw.w]), this._latLng([nesw.n, nesw.e]));
+ }
+ }
+ return empty;
+ },
+
+ /**
+ * @desc search an (insensitive) key
+ **/
+ _ikey: function(object, key){
+ if (key.toLowerCase){
+ key = key.toLowerCase();
+ for(var k in object){
+ if (k.toLowerCase && (k.toLowerCase() == key)) return k;
+ }
+ }
+ return false;
+ },
+
+ /**
+ * @desc search an (insensitive) key
+ **/
+ _ival: function(object, key, def){
+ var k = this._ikey(object, key);
+ if ( k ) return object[k];
+ return def;
+ },
+
+ /**
+ * @desc return true if at least one key is set in object
+ * nb: keys in lowercase
+ **/
+ _hasKey: function(object, keys){
+ var n, k;
+ if (!object || !keys) return false;
+ for(n in object){
+ if (n.toLowerCase){
+ n = n.toLowerCase();
+ for(k in keys){
+ if (n == keys[k]) return true;
+ }
+ }
+ }
+ return false;
+ },
+
+ /**
+ * @desc return a standard object
+ * nb: include in lowercase
+ **/
+ _extractObject: function(todo, include, r){
+ if (this._hasKey(todo, this._properties) || this._hasKey(todo, include)){
+ var k, p, ip, r={};
+ for(k in this._properties){
+ p=this._properties[k];
+ ip = this._ikey(todo, p);
+ r[p] = ip ? todo[ip] : {};
+ }
+ for(k in include){
+ p=include [k];
+ ip = this._ikey(todo, p);
+ if (ip) r[p] = todo[ip];
+ }
+ return r;
+ } else {
+ r.options= {};
+ for(k in todo){
+ if (k === 'action') continue;
+ r.options[k] = todo[k];
+ }
+ return r;
+ }
+ },
+
+ /**
+ * @desc identify object from object list or parameters list : [ objectName:{data} ] or [ otherObject:{}, ] or [ object properties ]
+ * nb: include, exclude in lowercase
+ **/
+ _object: function(name, todo, include, exclude){
+ var k = this._ikey(todo, name),
+ p, r = {}, keys=['map'],
+ cb='callback';
+ r[cb] = this._ival(todo, cb);
+ if (k) return this._extractObject(todo[k], include, r);
+ for(k in exclude) keys.push(exclude[k]);
+ if (!this._hasKey(todo, keys)) r = this._extractObject(todo, include, r);
+ for(k in this._properties){
+ p=this._properties[k];
+ if (!r[p]) r[p] = {};
+ }
+ return r;
+ },
+
+ /**
+ * @desc Returns the geographical coordinates from an address and call internal method
+ **/
+ _resolveLatLng: function(id, todo, method, all){
+ var address = this._ival(todo, 'address'),
+ region, params,
+ that = this, cb;
+ if ( address ){
+ cb = function(results, status) {
+ if (status == google.maps.GeocoderStatus.OK){
+ that[method](id, todo, all ? results : results[0].geometry.location);
+ } else {
+ if (that._default.verbose){
+ alert('Geocode error : ' + status);
+ }
+ that[method](id, todo, false);
+ }
+ };
+ if (typeof(address) === 'object'){
+ params = address;
+ } else {
+ params = { 'address': address };
+ region = this._ival(todo, 'region');
+ if (region){
+ params.region = region;
+ }
+ }
+ this._getGeocoder().geocode( params, cb );
+ } else {
+ this[method](id, todo, this._latLng(todo, false, true));
+ }
+ },
+
+ /*============================*/
+ /* PUBLIC */
+ /*============================*/
+
+ /**
+ * @desc Destroy an existing instance
+ **/
+ destroy: function(id, todo){
+ var k, $j;
+ if (this._ids[id]){
+ this._clear(id);
+ this._ids[id].$this.empty();
+ if (this._ids[id].bl) delete this._ids[id].bl;
+ for(k in this._ids[id].styles){
+ delete this._ids[id].styles[ k ];
+ }
+ delete this._ids[id].map;
+ $j = this._jObject(id);
+ delete this._ids[id];
+ this._callback($j, null, todo);
+ }
+ this._end(id);
+ },
+
+ /**
+ * @desc Initialize google map object an attach it to the dom element (using id)
+ **/
+ init: function(id, todo, internal){
+ var o, opts, map, styles, k, $this;
+ if ( (id == '') || (this._exist(id)) ) return this._end(id);
+ o = this._object('map', todo);
+ if ( (typeof(o.options.center) === 'boolean') && o.options.center) {
+ return false; // wait for an address resolution
+ }
+ opts = $.extend({}, this._default.init, o.options);
+ if (!opts.center) {
+ opts.center = [this._default.init.center.lat, this._default.init.center.lng];
+ }
+ opts.center = this._latLng(opts.center);
+ $this = this._jObject(id);
+ this._setMap(id, new google.maps.Map($this.get(0), opts));
+ map = this._getMap(id);
+
+ // add previous added styles
+ styles = this._getStyles( id );
+ for(k in styles) map.mapTypes.set(k, styles[k]);
+
+ this._manageEnd(id, map, o, internal);
+ return true;
+ },
+
+ /**
+ * @desc Returns the geographical coordinates from an address
+ **/
+ getlatlng: function(id, todo){
+ this._resolveLatLng(id, todo, '_getLatLng', true);
+ },
+ _getLatLng: function(id, todo, results){
+ this._manageEnd(id, results, todo);
+ },
+
+ /**
+ * @desc Return address from latlng
+ **/
+ getaddress: function(id, todo){
+ var callback,
+ $this = this._jObject(id),
+ latLng = this._latLng(todo, false, true),
+ address = this._ival(todo, 'address'),
+ params = latLng ? {latLng:latLng} : ( address ? (typeof(address) === 'string' ? {address:address} : address) : null),
+ cb = this._ival(todo, 'callback');
+ if (params && cb && typeof(cb) === 'function') {
+ callback = function(results, status) {
+ var out = status == google.maps.GeocoderStatus.OK ? results : false;
+ cb.apply($this, [out, status]);
+ };
+ this._getGeocoder().geocode(params, callback);
+ }
+ this._end(id);
+ },
+
+ /**
+ * @desc Return a route
+ **/
+ getroute: function(id, todo){
+ var callback,
+ $this = this._jObject(id),
+ cb = this._ival(todo, 'callback');
+ if ( (typeof(cb) === 'function') && todo.options ) {
+ todo.options.origin = this._latLng(todo.options.origin, true);
+ todo.options.destination = this._latLng(todo.options.destination, true);
+ callback = function(results, status) {
+ var out = status == google.maps.DirectionsStatus.OK ? results : false;
+ cb.apply($this, [out, status]);
+ };
+ this._getDirectionsService().route( todo.options, callback );
+ }
+ this._end(id);
+ },
+ /**
+ * @desc return elevation
+ **/
+ getelevation: function(id, todo){
+ var callback, latLng, ls, k, path, samples,
+ locations = [],
+ $this = this._jObject(id),
+ cb = this._ival(todo, 'callback'),
+ latLng = this._ival(todo, 'latlng');
+ if (cb && typeof(cb) === 'function') {
+ callback = function(results, status) {
+ var out = status == google.maps.ElevationStatus.OK ? results : false;
+ cb.apply($this, [out, status]);
+ };
+ if (latLng){
+ locations.push( this._latLng(latLng) );
+ } else {
+ ls = this._ival(todo, 'locations');
+ if (ls){
+ for(k in ls){
+ locations.push( this._latLng(ls[k]) );
+ }
+ }
+ }
+ if (locations.length){
+ this._getElevationService().getElevationForLocations({locations:locations}, callback);
+ } else {
+ path = this._ival(todo, 'path');
+ samples = this._ival(todo, 'samples');
+ if (path && samples){
+ for(k in path){
+ locations.push(this._latLng(path[k]));
+ }
+ if (locations.length){
+ this._getElevationService().getElevationAlongPath( {path:locations, samples:samples}, callback );
+ }
+ }
+ }
+ }
+ this._end(id);
+ },
+
+ /**
+ * @desc Add a marker to a map after address resolution
+ * if [infowindow] add an infowindow attached to the marker
+ **/
+ addmarker: function(id, todo){
+ this._resolveLatLng(id, todo, '_addMarker');
+ },
+
+ _addMarker: function(id, todo, latLng, internal){
+ var result, oi, to,
+ n = 'marker', niw = 'infowindow',
+ o = this._object(n, todo, ['to']);
+ if (!internal){
+ if (!latLng) {
+ this._manageEnd(id, false, o);
+ return;
+ }
+ this._subcall(id, todo, latLng);
+ } else if (!latLng){
+ return;
+ }
+ if (o.to){
+ to = this._getStoredId(id, o.to);
+ result = to && (typeof(to.add) === 'function');
+ if (result){
+ to.add(latLng, todo);
+ if (typeof(to.redraw) === 'function'){
+ to.redraw();
+ }
+ }
+ if (!internal){
+ this._manageEnd(id, result, o);
+ }
+ } else {
+ o.options.position = latLng;
+ o.options.map = this._getMap(id);
+ result = new google.maps.Marker(o.options);
+ if ( todo[niw] ){
+ oi = this._object(niw, todo[niw], ['open']);
+ if ( (oi['open'] === undefined) || oi['open'] ) {
+ oi.apply = this._array(oi.apply);
+ oi.apply.unshift({action:'open', args:[this._getMap(id), result]});
+ }
+ oi.action = 'add'+niw;
+ this._planNext(id, oi);
+ }
+ if (!internal){
+ this._store(id, n, result, o);
+ this._manageEnd(id, result, o);
+ }
+ }
+ return result;
+ },
+
+ /**
+ * @desc Add markers (without address resolution)
+ **/
+ addmarkers: function(id, todo){
+ if (this._ival(todo, 'clusters')){
+ this._addclusteredmarkers(id, todo);
+ } else {
+ this._addmarkers(id, todo);
+ }
+ },
+ _addmarkers: function(id, todo){
+ var result, o, k, latLng, marker, options = {}, tmp, to,
+ n = 'marker',
+ markers = this._ival(todo, 'markers');
+ this._subcall(id, todo);
+ if ( !markers || (typeof(markers) !== 'object') ) {
+ return this._end(id);
+ }
+ o = this._object(n, todo, ['to', 'markers']);
+
+ if (o.to){
+ to = this._getStoredId(id, o.to);
+ result = to && (typeof(to.add) === 'function');
+ if (result){
+ for(k in markers){
+ latLng = this._latLng(markers[k]);
+ if (!latLng) continue;
+ to.add(latLng, markers[k]);
+ }
+ if (typeof(to.redraw) === 'function'){
+ to.redraw();
+ }
+ }
+ this._manageEnd(id, result, o);
+ } else {
+ $.extend(true, options, o.options);
+ options.map = this._getMap(id);
+ result = [];
+ for(k in markers){
+ latLng = this._latLng(markers[k]);
+ if (!latLng) continue;
+ if (markers[k].options){
+ tmp = {};
+ $.extend(true, tmp, options, markers[k].options);
+ o.options = tmp;
+ } else {
+ o.options = options;
+ }
+ o.options.position = latLng;
+ marker = new google.maps.Marker(o.options);
+ result.push(marker);
+ o.data = markers[k].data;
+ o.tag = markers[k].tag;
+ this._store(id, n, marker, o);
+ this._manageEnd(id, marker, o, true);
+ }
+ o.options = options; // restore previous for futur use
+ this._callback(id, result, todo);
+ this._end(id);
+ }
+ },
+
+ resize: function(id)
+ {
+ google.maps.event.trigger(this._getMap(id), 'resize');
+ },
+
+ getscale: function(id, todo, internal){
+ var map = this._getMap(id),
+ zoom = map.getZoom(),
+ scales = [
+ 77.864462034120315,
+ 45.42785688110077,
+ 16.220730575856892,
+ 6.879509682822463,
+ 3.5034960477802986,
+ 1.8034610362879133,
+ 0.9127181102723314,
+ 0.4598746767146186,
+ 0.23053567913908648,
+ 0.11545247438886701,
+ 0.05775371939320953,
+ 0.02881647975962874,
+ 0.014414070716531697,
+ 0.007207618499622224,
+ 0.003603886381819732,
+ 0.0018015948787526637,
+ 0.0009008246767800296,
+ 0.0004504160086085826,
+ 0.00022520761796505934,
+ 0.00011260535432642145,
+ 0.00005630113180858676
+ ];
+ scale = scales[zoom];
+ if (!internal){
+ this._callback(id, scale, todo);
+ this._end(id);
+ }
+ return scale;
+ },
+ _addclusteredmarkers:function(id, todo){
+ var clusterer, i, latLng, storeId,
+ that = this,
+ radius = this._ival(todo, 'radius'),
+ markers = this._ival(todo, 'markers'),
+ styles = this._ival(todo, 'clusters');
+
+ if (! this._getMap(id).getBounds() ){ // map not initialised => bounds not available
+ // wait for map
+ google.maps.event.addListenerOnce(
+ this._getMap(id),
+ 'bounds_changed',
+ function() {
+ that._addclusteredmarkers(id, todo);
+ }
+ );
+ return;
+ }
+
+ if (typeof(radius) === 'number'){
+ clusterer = new Clusterer();
+ for (i = 0 ; i < markers.length; i++){
+ latLng = this._latLng(markers[i]);
+ clusterer.add(latLng, markers[i]);
+ }
+ storeId = this._initClusters(id, todo, clusterer, radius, styles);
+ }
+
+ this._callback(id, storeId, todo);
+ this._end(id);
+ },
+
+ _initClusters: function(id, todo, clusterer, radius, styles){
+ var that=this,
+ map = this._getMap(id);
+
+ clusterer.setRedraw(function(force){
+ var same, clusters = clusterer.clusters(map, radius, force);
+ if (clusters){
+ same = clusterer.freeDiff(clusters);
+ that._displayClusters(id, todo, clusterer, clusters, same, styles);
+ }
+ });
+
+ clusterer.events(
+ google.maps.event.addListener(
+ map,
+ 'zoom_changed',
+ function() {
+ clusterer.redraw(true);
+ }
+ ),
+ google.maps.event.addListener(
+ map,
+ 'bounds_changed',
+ function() {
+ clusterer.redraw();
+ }
+ )
+ );
+
+ clusterer.redraw();
+ return this._store(id, 'cluster', clusterer, todo);
+ },
+
+ _displayClusters: function(id, todo, clusterer, clusters, same, styles){
+ var k, i, ii, m, done, obj, cluster, options = {}, tmp,
+ atodo,
+ ctodo = this._ival(todo, 'cluster') || {},
+ mtodo = this._ival(todo, 'marker') || todo;
+ for(i = 0; i < clusters.length; i++){
+ if (i in same){
+ continue;
+ }
+ cluster = clusters[i];
+ done = false;
+ if (cluster.idx.length > 1){
+ m = 0;
+ for(k in styles){
+ if ( (k > m) && (k <= cluster.idx.length) ){
+ m = k;
+ }
+ }
+ if (styles[m]){
+ atodo = {
+ content:styles[m].content.replace('CLUSTER_COUNT', cluster.idx.length),
+ offset:{
+ x: -this._ival(styles[m], 'width')/2,
+ y: -this._ival(styles[m], 'height')/2
+ }
+ };
+ obj = this._addOverlay(id, atodo, this._latLng(cluster), true);
+
+ ctodo.data = {
+ latLng: this._latLng(cluster),
+ markers:[]
+ };
+ for(ii=0; ii '),
+ listeners = [];
+
+ this._subcall(id, todo, latLng);
+ map = this._getMap(id);
+
+ $div
+ .css('border', 'none')
+ .css('borderWidth', '0px')
+ .css('position', 'absolute');
+ $div.append($(opts.content));
+
+ function f() {
+ google.maps.OverlayView.call(this);
+ this.setMap(map);
+ }
+
+ f.prototype = new google.maps.OverlayView();
+
+ f.prototype.onAdd = function() {
+ var panes = this.getPanes();
+ if (opts.pane in panes) {
+ $(panes[opts.pane]).append($div);
+ }
+ }
+ f.prototype.draw = function() {
+ var overlayProjection = this.getProjection(),
+ ps = overlayProjection.fromLatLngToDivPixel(latLng),
+ that = this;
+
+ $div
+ .css('left', (ps.x+opts.offset.x) + 'px')
+ .css('top' , (ps.y+opts.offset.y) + 'px');
+
+ $.each( ("dblclick click mouseover mousemove mouseout mouseup mousedown").split(" "), function( i, name ) {
+ listeners.push(
+ google.maps.event.addDomListener($div[0], name, function(e) {
+ google.maps.event.trigger(that, name);
+ })
+ );
+ });
+ listeners.push(
+ google.maps.event.addDomListener($div[0], "contextmenu", function(e) {
+ google.maps.event.trigger(that, "rightclick");
+ })
+ );
+ }
+ f.prototype.onRemove = function() {
+ for (var i = 0; i < listeners.length; i++) {
+ google.maps.event.removeListener(listeners[i]);
+ }
+ $div.remove();
+ }
+ f.prototype.hide = function() {
+ $div.hide();
+ }
+ f.prototype.show = function() {
+ $div.show();
+ }
+ f.prototype.toggle = function() {
+ if ($div) {
+ if ($div.is(':visible')){
+ this.show();
+ } else {
+ this.hide();
+ }
+ }
+ }
+ f.prototype.toggleDOM = function() {
+ if (this.getMap()) {
+ this.setMap(null);
+ } else {
+ this.setMap(map);
+ }
+ }
+ f.prototype.getDOMElement = function() {
+ return $div[0];
+ }
+ ov = new f();
+ if (!internal){
+ this._store(id, 'overlay', ov, o);
+ this._manageEnd(id, ov, o);
+ }
+ return ov;
+ },
+
+ /**
+ * @desc add fixed panel to a map
+ **/
+ addfixpanel: function(id, todo){
+ var n = 'fixpanel',
+ o = this._object(n, todo),
+ x=0, y=0, $c, $div;
+ if (o.options.content){
+ $c = $(o.options.content);
+
+ if (o.options.left !== undefined){
+ x = o.options.left;
+ } else if (o.options.right !== undefined){
+ x = this._jObject(id).width() - $c.width() - o.options.right;
+ } else if (o.options.center){
+ x = (this._jObject(id).width() - $c.width()) / 2;
+ }
+
+ if (o.options.top !== undefined){
+ y = o.options.top;
+ } else if (o.options.bottom !== undefined){
+ y = this._jObject(id).height() - $c.height() - o.options.bottom;
+ } else if (o.options.middle){
+ y = (this._jObject(id).height() - $c.height()) / 2
+ }
+
+ $div = $('
')
+ .css('position', 'absolute')
+ .css('top', y+'px')
+ .css('left', x+'px')
+ .css('z-index', '1000')
+ .append(o.options.content);
+
+ this._jObject(id).first().prepend($div);
+ this._attachEvents(id, this._getMap(id), o);
+ this._store(id, n, $div, o);
+ this._callback(id, $div, o);
+ }
+ this._end(id);
+ },
+
+ /**
+ * @desc Add a direction renderer to a map
+ **/
+ adddirectionsrenderer: function(id, todo, internal){
+ var n = 'directionrenderer',
+ dr, o = this._object(n, todo, ['panelId']);
+ this._clear(id, n);
+ o.options.map = this._getMap(id);
+ dr = new google.maps.DirectionsRenderer(o.options);
+ if (o.panelId) {
+ dr.setPanel(document.getElementById(o.panelId));
+ }
+ this._store(id, n, dr, o);
+ this._manageEnd(id, dr, o, internal);
+ },
+
+ /**
+ * @desc Set direction panel to a dom element from it ID
+ **/
+ setdirectionspanel: function(id, todo){
+ var dr, o = this._object('directionpanel', todo, ['id']);
+ if (o.id) {
+ dr = this._getDirectionRenderer(id);
+ dr.setPanel(document.getElementById(o.id));
+ }
+ this._manageEnd(id, dr, o);
+ },
+
+ /**
+ * @desc Set directions on a map (create Direction Renderer if needed)
+ **/
+ setdirections: function(id, todo){
+ var dr, o = this._object('directions', todo);
+ if (todo) o.options.directions = todo.directions ? todo.directions : (todo.options && todo.options.directions ? todo.options.directions : null);
+ if (o.options.directions) {
+ dr = this._getDirectionRenderer(id);
+ if (!dr) {
+ this.adddirectionsrenderer(id, o, true);
+ dr = this._getDirectionRenderer(id);
+ } else {
+ dr.setDirections(o.options.directions);
+ }
+ }
+ this._manageEnd(id, dr, o);
+ },
+
+ /**
+ * @desc set a streetview to a map
+ **/
+ setstreetview: function(id, todo){
+ var o = this._object('streetview', todo, ['id']),
+ panorama;
+ if (o.options.position){
+ o.options.position = this._latLng(o.options.position);
+ }
+ panorama = new google.maps.StreetViewPanorama(document.getElementById(o.id),o.options);
+ this._getMap(id).setStreetView(panorama);
+ this._manageEnd(id, panorama, o);
+ },
+
+ /**
+ * @desc add a kml layer to a map
+ **/
+ addkmllayer: function(id, todo){
+ var n = 'kmllayer',
+ o = this._object(n, todo, ['url']),
+ kml;
+ o.options.map = this._getMap(id);
+ kml = new google.maps.KmlLayer(o.url, o.options);
+ this._store(id, n, kml, o);
+ this._manageEnd(id, kml, o);
+ },
+
+ /**
+ * @desc add a traffic layer to a map
+ **/
+ addtrafficlayer: function(id, todo){
+ var n = 'trafficlayer',
+ o = this._object(n, todo),
+ tl = this._getStored(id, n);
+ if (!tl){
+ tl = new google.maps.TrafficLayer();
+ tl.setMap(this._getMap(id));
+ this._store(id, n, tl, o);
+ }
+ this._manageEnd(id, tl, o);
+ },
+
+ /**
+ * @desc set a bicycling layer to a map
+ **/
+ addbicyclinglayer: function(id, todo){
+ var n = 'bicyclinglayer',
+ o = this._object(n, todo),
+ bl = this._getStored(id, n);
+ if (!bl){
+ bl = new google.maps.BicyclingLayer();
+ bl.setMap(this._getMap(id));
+ this._store(id, n, bl, o);
+ }
+ this._manageEnd(id, bl, o);
+ },
+
+
+ /**
+ * @desc add a ground overlay to a map
+ **/
+ addgroundoverlay: function(id, todo){
+ var n = 'groundoverlay',
+ o = this._object(n, todo, ['bounds', 'url']),
+ ov;
+ o.bounds = this._latLngBounds(o.bounds);
+ if (o.bounds && o.url){
+ ov = new google.maps.GroundOverlay(o.url, o.bounds);
+ ov.setMap(this._getMap(id));
+ this._store(id, n, ov, o);
+ }
+ this._manageEnd(id, ov, o);
+ },
+
+ /**
+ * @desc Geolocalise the user and return a LatLng
+ **/
+ geolatlng: function(id, todo){
+ var geo,
+ cb = this._ival(todo, 'callback'),
+ $this = this._jObject(id);
+ if (typeof(cb) === 'function') {
+ if(navigator.geolocation) {
+ browserSupportFlag = true;
+ navigator.geolocation.getCurrentPosition(function(position) {
+ var out = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
+ cb.apply($this, [out]);
+ }, function() {
+ var out = false;
+ cb.apply($this, [out]);
+ });
+ } else if (google.gears) {
+ browserSupportFlag = true;
+ geo = google.gears.factory.create('beta.geolocation');
+ geo.getCurrentPosition(function(position) {
+ var out = new google.maps.LatLng(position.latitude,position.longitude);
+ cb.apply($this, [out]);
+ }, function() {
+ out = false;
+ cb.apply($this, [out]);
+ });
+ } else {
+ out = false;
+ cb.apply($this, [out]);
+ }
+ }
+ this._end(id);
+ },
+
+ /**
+ * @desc Add a style to a map
+ **/
+ addstyledmap: function(id, todo, internal){
+ var o = this._object('styledmap', todo, ['id', 'style']),
+ style;
+ if (o.style && o.id && !this._styleExist(id, o.id)) {
+ style = new google.maps.StyledMapType(o.style, o.options);
+ this._addStyle(id, o.id, style);
+ if (this._getMap(id)) this._getMap(id).mapTypes.set(o.id, style);
+ }
+ this._manageEnd(id, style, o, internal);
+ },
+
+ /**
+ * @desc Set a style to a map (add it if needed)
+ **/
+ setstyledmap: function(id, todo){
+ var o = this._object('styledmap', todo, ['id', 'style']),
+ style;
+ if (o.id) {
+ this.addstyledmap(id, o, true);
+ style = this._getStyle(id, o.id);
+ if (style) {
+ this._getMap(id).setMapTypeId(o.id);
+ this._callback(id, style, todo);
+ }
+ }
+ this._manageEnd(id, style, o);
+ },
+
+ /**
+ * @desc Remove objects from a map
+ **/
+ clear: function(id, todo){
+ var list = this._array(this._ival(todo, 'list') || this._ival(todo, 'name')),
+ last = this._ival(todo, 'last', false),
+ first = this._ival(todo, 'first', false),
+ tag = this._ival(todo, 'tag');
+ if (tag !== undefined){
+ tag = this._array(tag);
+ }
+ this._clear(id, list, last, first, tag);
+ this._end(id);
+ },
+
+ /**
+ * @desc Return Google object(s) wanted
+ **/
+ get: function(id, todo){
+ var name = this._ival(todo, 'name') || 'map',
+ first= this._ival(todo, 'first'),
+ all = this._ival(todo, 'all'),
+ tag = this._ival(todo, 'tag'),
+ r, i, t;
+ name = name.toLowerCase();
+ if (tag !== undefined){
+ tag = this._array(tag);
+ }
+ if (name == 'map'){
+ return this._getMap(id);
+ }
+ if (first){
+ return this._getStored(id, name, false, tag);
+ } else if (all){
+ r = new Array();
+ t = this._ids[id].stored[name];
+ if (t){
+ for(i = 0; i < t.length; i++){
+ if (!t[i]){
+ continue;
+ }
+ if (tag !== undefined) {
+ if ( (t[i].tag === undefined) || ($.inArray(t[i].tag, tag) < 0) ){
+ continue;
+ }
+ }
+ r.push(t[i].obj);
+ }
+ }
+ return r;
+ } else {
+ return this._getStored(id, name, true, tag);
+ }
+ },
+
+ /**
+ * @desc return the radius of the earth depending on the unit
+ **/
+ earthradius: function(unit){
+ unit = unit ? unit : this._default.unit;
+ return (typeof(unit) === 'string' && (unit.toLowerCase() === 'km')) ? 6371 : 3959;
+ },
+
+ /**
+ * @desc the distance between 2 latLng depending on the unit
+ **/
+ distance: function(id, todo){
+ var unit = this._ival(todo, 'unit'),
+ a = this._latLng(this._ival(todo, 'a')),
+ b = this._latLng(this._ival(todo, 'b')),
+ e,f,g,h, dist;
+ if (a && b){
+ e=(Math.PI*a.lat()/180);
+ f=(Math.PI*a.lng()/180);
+ g=(Math.PI*b.lat()/180);
+ h=(Math.PI*b.lng()/180);
+ dist = this.earthradius(unit)*Math.acos(Math.min(Math.cos(e)*Math.cos(g)*Math.cos(f)*Math.cos(h)+Math.cos(e)*Math.sin(f)*Math.cos(g)*Math.sin(h)+Math.sin(e)*Math.sin(g),1));
+ }
+ return dist;
+ },
+
+ /**
+ * @desc return the max zoom of a latlng
+ **/
+ getmaxzoom: function(id, todo){
+ this._resolveLatLng(id, todo, '_getMaxZoom');
+ },
+ _getMaxZoom: function(id, todo, latLng){
+ var callback,
+ $this = this._jObject(id),
+ cb = this._ival(todo, 'callback');
+ if (cb && typeof(cb) === 'function') {
+ callback = function(result) {
+ var zoom = result.status == google.maps.MaxZoomStatus.OK ? result.zoom : false;
+ cb.apply($this, [zoom, result.status]);
+ };
+ this._getMaxZoomService().getMaxZoomAtLatLng(latLng, callback);
+ }
+ this._end(id);
+ },
+
+ /**
+ * @desc modify default values
+ **/
+ setdefault: function(id, todo, internal){
+ for(var k in todo){
+ if (typeof(this._default[k]) === 'object'){
+ this._default[k] = jQuery.extend({}, this._default[k], todo[k]);
+ } else {
+ this._default[k] = todo[k];
+ }
+ }
+ if (!internal){
+ this._end(id);
+ }
+ },
+ /**
+ * @desc : autofit a map using its overlays (markers, rectangles ...)
+ **/
+ autofit: function(id, todo, internal){
+ var n, i, stored, obj, empty = true, bounds = new google.maps.LatLngBounds();
+ if (id in this._ids){
+ for(n in this._ids[id].stored){
+ stored = this._ids[id].stored[n];
+ for(i = 0; i < stored.length; i++){
+ obj = stored[i].obj;
+ if (obj.getPosition){
+ bounds.extend(obj.getPosition());
+ empty = false;
+ } else if (obj.getBounds){
+ bounds.extend(obj.getBounds().getNorthEast());
+ bounds.extend(obj.getBounds().getSouthWest());
+ empty = false;
+ } else if (obj.getPaths){
+ obj.getPaths().forEach(function(path){
+ path.forEach(function(latLng){
+ bounds.extend(latLng);
+ empty = false;
+ });
+ });
+ } else if (obj.getPath){
+ obj.getPath().forEach(function(latLng){
+ bounds.extend(latLng);
+ empty = false;
+ });
+ } else if (obj.getCenter){
+ bounds.extend(obj.getCenter());
+ empty = false;
+ }
+ }
+ }
+ if (!empty){
+ this._getMap(id).fitBounds(bounds);
+ }
+ }
+ if (!internal){
+ this._manageEnd(id, empty ? false : bounds, todo, internal);
+ }
+ }
+
+ };
+
+ var globalId = 0;
+
+ $.fn.gmap3 = function(){
+ var a,i,
+ todo = [],
+ results = [],
+ empty = true;
+ for(i=0; i