diff --git a/admin-dev/ajax.php b/admin-dev/ajax.php index fecfe8600..b2ac42f51 100644 --- a/admin-dev/ajax.php +++ b/admin-dev/ajax.php @@ -639,7 +639,7 @@ if (Tools::isSubmit('getAdminHomeElement')) $protocol = Tools::usingSecureMode() ? 'https' : 'http'; $isoUser = Context::getContext()->language->iso_code; $isoCountry = Context::getContext()->country->iso_code; - $stream_context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 5))); + $stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => 5))); // SCREENCAST if (@fsockopen('www.prestashop.com', 80, $errno, $errst, 3)) diff --git a/admin-dev/tabs/AdminAttributes.php b/admin-dev/tabs/AdminAttributes.php index 85597d464..0b1704571 100644 --- a/admin-dev/tabs/AdminAttributes.php +++ b/admin-dev/tabs/AdminAttributes.php @@ -77,7 +77,11 @@ class AdminAttributes extends AdminTab * '.$this->l('Invalid characters:').' <>;=#{}  '; - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name'); + echo ' + '; + $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'name', false, true); echo '
@@ -117,6 +121,7 @@ class AdminAttributes extends AdminTab ).'

+ '.Module::hookExec('attributeForm', array('id_attribute' => $obj->id)).'
@@ -136,6 +141,10 @@ class AdminAttributes extends AdminTab if (!Combination::isFeatureActive()) return; + + Module::hookExec('postProcessAttribute', + array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessFeatureValue to stop saving process + if (Tools::getValue('submitDel'.$this->table)) { if ($this->tabAccess['delete'] === '1') diff --git a/admin-dev/tabs/AdminAttributesGroups.php b/admin-dev/tabs/AdminAttributesGroups.php index 26a7243c0..11e8f9e7c 100644 --- a/admin-dev/tabs/AdminAttributesGroups.php +++ b/admin-dev/tabs/AdminAttributesGroups.php @@ -75,6 +75,9 @@ class AdminAttributesGroups extends AdminTab if (Tools::isSubmit('submitAddattribute') || Tools::isSubmit('submitDelattribute')) $this->adminAttributes->postProcess($this->token); + Module::hookExec('postProcessAttributeGroup', + array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessAttributeGroup to stop saving process + if(Tools::getValue('submitDel'.$this->table)) { if ($this->tabAccess['delete'] === '1') @@ -226,8 +229,11 @@ class AdminAttributesGroups extends AdminTab
* '.$this->l('Invalid characters:').' <>;=#{}  -
'; - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤public_name', 'name'); + + '; + $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'name', false, true); echo '
@@ -240,7 +246,7 @@ class AdminAttributesGroups extends AdminTab '.$this->l('Invalid characters:').' <>;=#{} 

'.$this->l('Term or phrase displayed to the customer').'

'; - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤public_name', 'public_name'); + $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'public_name', false, true); echo '
diff --git a/admin-dev/tabs/AdminFeatures.php b/admin-dev/tabs/AdminFeatures.php index 8f55c54b4..9d6259542 100644 --- a/admin-dev/tabs/AdminFeatures.php +++ b/admin-dev/tabs/AdminFeatures.php @@ -158,8 +158,11 @@ class AdminFeatures extends AdminTab
* '.$this->l('Invalid characters:').' <>;=#{}  -
'; - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name'); + + '; + $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'name', false, true); echo '
'; @@ -193,6 +196,9 @@ class AdminFeatures extends AdminTab $this->adminFeaturesValues->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, $this->id); $this->adminFeaturesValues->postProcess($this->token); + Module::hookExec('postProcessFeature', + array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessFeature to stop saving process + if(Tools::getValue('submitDel'.$this->table)) { if ($this->tabAccess['delete'] === '1') @@ -214,5 +220,3 @@ class AdminFeatures extends AdminTab parent::postProcess(); } } - - diff --git a/admin-dev/tabs/AdminFeaturesValues.php b/admin-dev/tabs/AdminFeaturesValues.php index 04a237caf..65c590787 100644 --- a/admin-dev/tabs/AdminFeaturesValues.php +++ b/admin-dev/tabs/AdminFeaturesValues.php @@ -67,8 +67,11 @@ class AdminFeaturesValues extends AdminTab
* '.$this->l('Invalid characters:').' <>;=#{}  -
'; - $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'value', 'value'); + + '; + $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'value', false, true); echo '
@@ -81,6 +84,7 @@ class AdminFeaturesValues extends AdminTab echo ' * + '.Module::hookExec('featureValueForm', array('id_feature_value' => $obj->id)).'
@@ -94,6 +98,9 @@ class AdminFeaturesValues extends AdminTab */ public function postProcess($token = NULL) { + Module::hookExec('postProcessFeatureValue', + array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessFeatureValue to stop saving process + if(Tools::getValue('submitDel'.$this->table)) { if ($this->tabAccess['delete'] === '1') diff --git a/admin-dev/tabs/AdminTranslations.php b/admin-dev/tabs/AdminTranslations.php index 498770a6d..0b438714f 100644 --- a/admin-dev/tabs/AdminTranslations.php +++ b/admin-dev/tabs/AdminTranslations.php @@ -250,7 +250,7 @@ class AdminTranslations extends AdminTab $arr_import_lang = explode('|', Tools::getValue('params_import_language')); /* 0 = Language ISO code, 1 = PS version */ if (Validate::isLangIsoCode($arr_import_lang[0])) { - if ($content = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/gzip/'.$arr_import_lang[1].'/'.$arr_import_lang[0].'.gzip', false, stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5))))) + if ($content = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/gzip/'.$arr_import_lang[1].'/'.$arr_import_lang[0].'.gzip', false, @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5))))) { $file = _PS_TRANSLATIONS_DIR_.$arr_import_lang[0].'.gzip'; if (file_put_contents($file, $content)) @@ -712,7 +712,7 @@ class AdminTranslations extends AdminTab $this->displayWarning($this->l('If you choose to update an existing language pack, all your previous customization in the theme named prestashop will be lost. This includes front office expressions and default e-mail templates.')); echo '
'.$this->l('Language you want to add or update:').' '; - if ($lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_each_language_pack.php?version='._PS_VERSION_, false, stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5))))) + if ($lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_each_language_pack.php?version='._PS_VERSION_, false, @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5))))) { // Notice : for php < 5.2 compatibility, Tools::jsonDecode. The second parameter to true will set us if ($lang_packs != '' AND $lang_packs = Tools::jsonDecode($lang_packs,true)) diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 8599114a5..675acc9aa 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -2267,22 +2267,26 @@ abstract class AdminTabCore * Display flags in forms for translations * * @param array $languages All languages available - * @param integer $defaultLanguage Default language id + * @param integer $default_language Default language id * @param string $ids Multilingual div ids in form * @param string $id Current div id] - * #param boolean $return define the return way : false for a display, true for a return + * @param boolean $return define the return way : false for a display, true for a return + * @param boolean $use_vars_instead_of_ids use an js vars instead of ids seperate by "¤" */ - public function displayFlags($languages, $defaultLanguage, $ids, $id, $return = false) + public function displayFlags($languages, $default_language, $ids, $id, $return = false, $use_vars_instead_of_ids = false) { if (sizeof($languages) == 1) return false; $output = '
- +
'.$this->l('Choose language:').'

'; foreach ($languages as $language) + if($use_vars_instead_of_ids) + $output .= ''.$language['name'].' '; + else $output .= ''.$language['name'].' '; $output .= '
'; diff --git a/classes/Attribute.php b/classes/Attribute.php index 3cf6edd5b..f81fb3968 100644 --- a/classes/Attribute.php +++ b/classes/Attribute.php @@ -1,6 +1,6 @@ 'isUnsignedId', 'color' => 'isColor', 'position' => 'isInt'); protected $fieldsRequiredLang = array('name'); protected $fieldsSizeLang = array('name' => 64); protected $fieldsValidateLang = array('name' => 'isGenericName'); - + protected $table = 'attribute'; protected $identifier = 'id_attribute'; - + protected $webserviceParameters = array( 'objectsNodeName' => 'product_option_values', 'objectNodeName' => 'product_option_value', @@ -52,14 +52,14 @@ class AttributeCore extends ObjectModel 'id_attribute_group' => array('xlink_resource'=> 'product_options'), ), ); - + public function __construct() { $this->image_dir = _PS_COL_IMG_DIR_; parent::__construct(); } - + public function getFields() { $this->validateFields(); @@ -70,7 +70,7 @@ class AttributeCore extends ObjectModel return $fields; } - + /** * Check then return multilingual fields for database interaction * @@ -96,10 +96,30 @@ class AttributeCore extends ObjectModel if (Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product_attribute` IN ('.implode(', ', $combinationIds).')') === false) return false; } + /* Reinitializing position */ $this->cleanPositions((int)$this->id_attribute_group); - return parent::delete(); + $return = parent::delete(); + if ($return) + Module::hookExec('afterDeleteAttribute', array('id_attribute' => $this->id)); + return $return; + } + + public function update($nullValues = false) + { + $return = parent::update($nullValues); + if ($return) + Module::hookExec('afterSaveAttribute', array('id_attribute' => $this->id)); + return $return; + } + + public function add($autodate = true, $nullValues = false) + { + $return = parent::add($autodate, $nullValues); + if ($return) + Module::hookExec('afterSaveAttribute', array('id_attribute' => $this->id)); + return $return; } /** @@ -122,7 +142,7 @@ class AttributeCore extends ObjectModel '.($notNull ? 'WHERE a.`id_attribute` IS NOT NULL AND al.`name` IS NOT NULL' : '').' ORDER BY agl.`name` ASC, a.`position` ASC'); } - + /** * Get quantity for a given attribute combinaison * Check if quantity is enough to deserve customer @@ -158,9 +178,9 @@ class AttributeCore extends ObjectModel $row = Db::getInstance()->getRow(' SELECT SUM(quantity) as quantity - FROM `'._DB_PREFIX_.'product_attribute` + FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product` = '.(int)$id_product); - + if ($row['quantity'] !== NULL) return (int)$row['quantity']; return false; @@ -179,7 +199,7 @@ class AttributeCore extends ObjectModel $id_product = (int)$arr['id_product']; $qty = self::getAttributeQty($id_product); - + if ($qty !== false) { $arr['quantity'] = (int)$qty; @@ -215,9 +235,9 @@ class AttributeCore extends ObjectModel { $minimal_quantity = Db::getInstance()->getValue(' SELECT `minimal_quantity` - FROM `'._DB_PREFIX_.'product_attribute` + FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product_attribute` = '.(int)$id_product_attribute); - + if ($minimal_quantity > 1) return (int)$minimal_quantity; return false; @@ -262,7 +282,7 @@ class AttributeCore extends ObjectModel WHERE `id_attribute` = '.(int)$movedAttribute['id_attribute'].' AND `id_attribute_group`='.(int)$movedAttribute['id_attribute_group'])); } - + /** * Reorder attribute position in group $id_attribute_group. * Call it after deleting an attribute from a group. @@ -299,9 +319,9 @@ class AttributeCore extends ObjectModel /** * getHigherPosition - * + * * Get the higher attribute position from a group attribute - * + * * @param integer $id_attribute_group * @return integer $position */ @@ -309,7 +329,7 @@ class AttributeCore extends ObjectModel { $sql = 'SELECT `position` FROM `'._DB_PREFIX_.'attribute` - WHERE id_attribute_group = '.(int)$id_attribute_group.' + WHERE id_attribute_group = '.(int)$id_attribute_group.' ORDER BY position DESC'; return ((DB::getInstance()->getValue($sql)!==false)) ? DB::getInstance()->getValue($sql) : -1; } diff --git a/classes/Cart.php b/classes/Cart.php index 06204c41f..3d7054f77 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1206,33 +1206,20 @@ class CartCore extends ObjectModel } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) - { $shipping = $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone); - - if (!isset($tmp)) - $tmp = $shipping; - - if ($shipping <= $tmp) - { - $id_carrier = (int)($row['id_carrier']); - $tmp = $shipping; - } - } - else // by price - { + else $shipping = $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int)($this->id_currency)); - if (!isset($tmp)) - $tmp = $shipping; + if (!isset($minShippingPrice)) + $minShippingPrice = $shipping; - if ($shipping <= $tmp) + if ($shipping <= $minShippingPrice) { $id_carrier = (int)($row['id_carrier']); - $tmp = $shipping; + $minShippingPrice = $shipping; } } } - } if (empty($id_carrier)) $id_carrier = Configuration::get('PS_CARRIER_DEFAULT'); @@ -1701,13 +1688,13 @@ class CartCore extends ObjectModel LEFT JOIN '._DB_PREFIX_.'customized_data cd ON cd.id_customization = c.id_customization WHERE c.id_cart = '.(int)$this->id); - // Group line by id_customization + // Get datas from customization table $customsById = array(); foreach ($customs AS $custom) { if(!isset($customsById[$custom['id_customization']])) - $customsById[$custom['id_customization']] = array(); - $customsById[$custom['id_customization']][] = $custom; + $customsById[$custom['id_customization']] = array('id_product_attribute' => $custom['id_product_attribute'], + 'id_product' => $custom['id_product'], 'quantity' => $custom['quantity']); } // Insert new customizations @@ -1716,8 +1703,8 @@ class CartCore extends ObjectModel { Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute(' INSERT INTO `'._DB_PREFIX_.'customization` (id_cart, id_product_attribute, id_product, quantity) - VALUES('.(int)$cart->id.', '.(int)$custom['id_product_attribute'].', '.(int)$custom['id_product'].', '.(int)$custom['quantity'].')'); - $custom_ids[$custom['id_customization']] = Db::getInstance(_PS_USE_SQL_SLAVE_)->Insert_ID(); + VALUES('.(int)$cart->id.', '.(int)$val['id_product_attribute'].', '.(int)$val['id_product'].', '.(int)$val['quantity'].')'); + $custom_ids[$customizationId] = Db::getInstance(_PS_USE_SQL_SLAVE_)->Insert_ID(); } // Insert customized_data diff --git a/classes/Category.php b/classes/Category.php index aadf827e0..f6e12e5e5 100644 --- a/classes/Category.php +++ b/classes/Category.php @@ -399,19 +399,27 @@ class CategoryCore extends ObjectModel } /** - * Re-calculate the levels of all childs + * Updates level_depth for all children of the given id_category + * + * @param integer $id_category parent category */ public function recalculateLevelDepth($id_category) { - /* Gets all childs */ - $categories = Db::getInstance()->ExecuteS('SELECT id_category, id_parent, level_depth FROM '._DB_PREFIX_.'category - WHERE id_parent = '.$id_category); - $level = Db::getInstance()->getRow('SELECT level_depth FROM '._DB_PREFIX_.'category - WHERE id_category = '.$id_category); - /* Update level of depth for all childs */ + /* Gets all children */ + $categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' + SELECT id_category, id_parent, level_depth + FROM '._DB_PREFIX_.'category + WHERE id_parent = '.(int)$id_category); + /* Gets level_depth */ + $level = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' + SELECT level_depth + FROM '._DB_PREFIX_.'category + WHERE id_category = '.(int)$id_category); + /* Updates level_depth for all children */ foreach ($categories as $sub_category) { - Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'category + Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute(' + UPDATE '._DB_PREFIX_.'category SET level_depth = '.($level['level_depth'] + 1).' WHERE id_category = '.$sub_category['id_category']); /* Recursive call */ diff --git a/classes/Customer.php b/classes/Customer.php index 9a1f5a02b..738b21ad6 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -279,7 +279,7 @@ class CustomerCore extends ObjectModel * * @param string $email e-mail * @param $return_id boolean - * @param $ignoreGuest boolean, for exclure guest customer + * @param $ignoreGuest boolean, to exclude guest customer * @return Customer ID if found, false otherwise */ static public function customerExists($email, $return_id = false, $ignoreGuest = true, Shop $shop = null) diff --git a/classes/FeatureValue.php b/classes/FeatureValue.php index 5cb2b0859..e8430cf73 100644 --- a/classes/FeatureValue.php +++ b/classes/FeatureValue.php @@ -167,10 +167,30 @@ class FeatureValueCore extends ObjectModel return (int)$id_feature_value; } + public function add($autodate = true, $nullValues = false) + { + $return = parent::add($autodate, $nullValues); + if ($return) + Module::hookExec('afterSaveFeatureValue', array('id_feature_value' => $this->id)); + return $return; + } + public function delete() { /* Also delete related products */ Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'feature_product` WHERE `id_feature_value` = '.(int)$this->id); - return parent::delete(); + $return = parent::delete(); + + if ($return) + Module::hookExec('afterDeleteFeatureValue', array('id_feature_value' => $this->id)); + return $return; + } + + public function update($nullValues = false) + { + $return = parent::update($nullValues); + if ($return) + Module::hookExec('afterSaveFeatureValue', array('id_feature_value' => $this->id)); + return $return; } } \ No newline at end of file diff --git a/classes/FrontController.php b/classes/FrontController.php index 9d74113a9..ab58f4dc0 100755 --- a/classes/FrontController.php +++ b/classes/FrontController.php @@ -599,6 +599,11 @@ class FrontControllerCore extends ControllerCore asort($nArray); $this->n = abs((int)(Tools::getValue('n', ((isset($this->context->cookie->nb_item_per_page) AND $this->context->cookie->nb_item_per_page >= 10) ? $this->context->cookie->nb_item_per_page : (int)(Configuration::get('PS_PRODUCTS_PER_PAGE')))))); $this->p = abs((int)(Tools::getValue('p', 1))); + + $current_url = tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']); + //delete parameter page + $current_url = preg_replace('/(\?)?(&)?p=\d+/', '$1', $current_url); + $range = 2; /* how many pages around page selected */ if ($this->p < 0) @@ -625,7 +630,8 @@ class FrontControllerCore extends ControllerCore 'nArray' => $nArray, 'range' => (int)($range), 'start' => (int)($start), - 'stop' => (int)($stop) + 'stop' => (int)($stop), + 'current_url' => $current_url ); $this->context->smarty->assign($pagination_infos); } diff --git a/classes/HelpAccess.php b/classes/HelpAccess.php index 808659fea..ab219bef5 100644 --- a/classes/HelpAccess.php +++ b/classes/HelpAccess.php @@ -56,11 +56,7 @@ class HelpAccessCore $tooltip = ''; $url = HelpAccess::URL.'/documentation/renderIcon?label='.$label.'&iso_lang='.$iso_lang.'&country='.$country.'&version='.$version; - $ctx = stream_context_create(array( - 'http' => array( - 'timeout' => 10 - ) - )); + $ctx = @stream_context_create(array('http' => array('timeout' => 10))); $res = @file_get_contents($url, 0, $ctx); diff --git a/classes/Module.php b/classes/Module.php index ca6b04d63..235c6cfe3 100644 --- a/classes/Module.php +++ b/classes/Module.php @@ -66,7 +66,7 @@ abstract class ModuleCore /** @var string Message display before uninstall a module */ public $beforeUninstall = NULL; - public $_errors = false; + protected $_errors = false; protected $table = 'module'; @@ -296,22 +296,26 @@ abstract class ModuleCore * Display flags in forms for translations * * @param array $languages All languages available - * @param integer $defaultLanguage Default language id + * @param integer $default_language Default language id * @param string $ids Multilingual div ids in form * @param string $id Current div id] - * #param boolean $return define the return way : false for a display, true for a return + * @param boolean $return define the return way : false for a display, true for a return + * @param boolean $use_vars_instead_of_ids use an js vars instead of ids seperate by "¤" */ - public function displayFlags($languages, $defaultLanguage, $ids, $id, $return = false) + public function displayFlags($languages, $default_language, $ids, $id, $return = false, $use_vars_instead_of_ids = false) { if (sizeof($languages) == 1) return false; $output = '
- +
'.$this->l('Choose language:').'

'; foreach ($languages as $language) + if($use_vars_instead_of_ids) + $output .= ''.$language['name'].' '; + else $output .= ''.$language['name'].' '; $output .= '
'; diff --git a/classes/Tools.php b/classes/Tools.php index f5fd06537..7827d5272 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -556,7 +556,8 @@ class ToolsCore /** * Display an error according to an error code * - * @param integer $code Error code + * @param string $string Error message + * @param boolean $htmlentities By default at true for parsing error message with htmlentities */ public static function displayError($string = 'Fatal error', $htmlentities = true, Context $context = null) { @@ -656,7 +657,7 @@ class ToolsCore /* Categories specifics meta tags */ elseif ($id_category = self::getValue('id_category')) { - $page_number = self::getValue('p'); + $page_number = (int)self::getValue('p'); $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description` FROM `'._DB_PREFIX_.'category_lang` cl @@ -665,6 +666,8 @@ class ToolsCore { if (empty($row['meta_description'])) $row['meta_description'] = strip_tags($row['description']); + + // Paginate title if (!empty($row['meta_title'])) $row['meta_title'] = $row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME'); else @@ -677,7 +680,7 @@ class ToolsCore /* Manufacturers specifics meta tags */ elseif ($id_manufacturer = self::getValue('id_manufacturer')) { - $page_number = self::getValue('p'); + $page_number = (int)self::getValue('p'); $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT `name`, `meta_title`, `meta_description`, `meta_keywords` FROM `'._DB_PREFIX_.'manufacturer_lang` ml @@ -1178,7 +1181,7 @@ class ToolsCore public static function file_get_contents($url, $useIncludePath = false, $streamContext = NULL, $curlTimeOut = 5) { if ($streamContext == NULL) - $streamContext = stream_context_create(array('http' => array('timeout' => 5))); + $streamContext = @stream_context_create(array('http' => array('timeout' => 5))); if (in_array(ini_get('allow_url_fopen'), array('On', 'on', '1'))) return @file_get_contents($url, $useIncludePath, $streamContext); diff --git a/classes/Upgrader.php b/classes/Upgrader.php index 66d28fb78..9cf020816 100644 --- a/classes/Upgrader.php +++ b/classes/Upgrader.php @@ -25,20 +25,19 @@ * International Registered Trademark & Property of PrestaShop SA */ -class UpgraderCore{ +class UpgraderCore +{ const DEFAULT_CHECK_VERSION_DELAY_HOURS = 24; - public $rss_version_link = 'http://www.prestashop.com/xml/version.xml'; + public $rss_version_link = 'http://www.prestashop.com/xml/upgrader.xml'; public $rss_md5file_link_dir = 'http://www.prestashop.com/xml/md5/'; /** * link contains hte url where to download the file * * @var string */ - private $needUpgrade = false; - private $noRefresh = false; - private $changedFiles = array(); - private $missingFiles = array(); - private $versionIsModified = false; + private $need_upgrade = false; + private $changed_files = array(); + private $missing_files = array(); public $version_name; public $version_num; @@ -50,18 +49,9 @@ class UpgraderCore{ public function __get($var) { - if($var == 'needUpgrade') + if ($var == 'need_upgrade') return $this->isLastVersion(); } - /** - * we need to checkPSVersion when we use that class - * @param boolean noRefresh if true, checkPSVersion will not refresh its information - * @return object Upgrader - */ - public function __construct($noRefresh = false) - { - $this->noRefresh = (bool)$noRefresh; - } /** * downloadLast download the last version of PrestaShop and save it in $dest/$filename @@ -87,7 +77,7 @@ class UpgraderCore{ if (empty($this->link)) $this->checkPSVersion(); - return $this->needUpgrade; + return $this->need_upgrade; } @@ -100,13 +90,15 @@ class UpgraderCore{ { if (empty($this->link)) { - - $lastCheck = Configuration::get('PS_LAST_VERSION_CHECK'); + if (class_exists('Configuration')) + $last_check = Configuration::get('PS_LAST_VERSION_CHECK'); + else + $last_check = 0; // if we use the autoupgrade process, we will never refresh it // except if no check has been done before - if ($force OR ($lastCheck < time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS)) ) + if ($force || ($last_check < time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS))) { - libxml_set_streams_context(stream_context_create(array('http' => array('timeout' => 3)))); + libxml_set_streams_context(@stream_context_create(array('http' => array('timeout' => 3)))); if ($feed = @simplexml_load_file($this->rss_version_link)) { @@ -118,7 +110,7 @@ class UpgraderCore{ $this->autoupgrade = (int)$feed->autoupgrade; $this->autoupgrade_module = (int)$feed->autoupgrade_module; $this->desc = (string)$feed->desc ; - $configLastVersion = array( + $config_last_version = array( 'name' => $this->version_name, 'num' => $this->version_num, 'link' => $this->link, @@ -128,22 +120,24 @@ class UpgraderCore{ 'changelog' => $this->changelog, 'desc' => $this->desc ); - - Configuration::updateValue('PS_LAST_VERSION',serialize($configLastVersion)); + if (class_exists('Configuration')) + { + Configuration::updateValue('PS_LAST_VERSION', serialize($config_last_version)); Configuration::updateValue('PS_LAST_VERSION_CHECK',time()); } } + } else { - $lastVersionCheck = @unserialize(Configuration::get('PS_LAST_VERSION')); - $this->version_name = $lastVersionCheck['name']; - $this->version_num = $lastVersionCheck['num']; - $this->link = $lastVersionCheck['link']; - $this->autoupgrade = $lastVersionCheck['autoupgrade']; - $this->autoupgrade_module = $lastVersionCheck['autoupgrade_module']; - $this->md5 = $lastVersionCheck['md5']; - $this->desc = $lastVersionCheck['desc']; - $this->changelog = $lastVersionCheck['changelog']; + $last_version_check = @unserialize(Configuration::get('PS_LAST_VERSION')); + $this->version_name = $last_version_check['name']; + $this->version_num = $last_version_check['num']; + $this->link = $last_version_check['link']; + $this->autoupgrade = $last_version_check['autoupgrade']; + $this->autoupgrade_module = $last_version_check['autoupgrade_module']; + $this->md5 = $last_version_check['md5']; + $this->desc = $last_version_check['desc']; + $this->changelog = $last_version_check['changelog']; } } // retro-compatibility : @@ -151,7 +145,7 @@ class UpgraderCore{ // false otherwise if (version_compare(_PS_VERSION_, $this->version_num, '<')) { - $this->needUpgrade = true; + $this->need_upgrade = true; return array('name' => $this->version_name, 'link' => $this->link); } else @@ -160,61 +154,69 @@ class UpgraderCore{ public function getChangedFilesList() { - $checksum = simplexml_load_file($this->rss_md5file_link_dir._PS_VERSION_.'.xml'); + if (count($this->changed_files) == 0) + { + $checksum = @simplexml_load_file($this->rss_md5file_link_dir._PS_VERSION_.'.xml'); if ($checksum === false) - throw new Exception('No checksum xml file for your Prestashop version'); - $this->browseXmlAndCompare($checksum); - - return $this->changedFiles; + return false; + else + $this->browseXmlAndCompare($checksum->ps_root_dir[0]); } + return $this->changed_files; + } protected function addChangedFile($path) { - $this->versionIsModified = true; - $this->changedFiles[] = $path; + $this->version_is_modified = true; + $this->changed_files[] = $path; + //array_unique($this->changed_files); } protected function addMissingFile($path) { - $this->versionIsModified = true; - $this->missingFiles[] = $path; + $this->version_is_modified = true; + $this->missing_files[] = $path; + //array_unique($this->missingFile); } - protected function browseXmlAndCompare($node, &$currentPath = array(), $level = 0) + protected function browseXmlAndCompare($node, &$current_path = array(), $level = 1) { foreach ($node as $key => $child) { - if (is_object($child) && $child->getName() != 'md5file') + if (is_object($child) && $child->getName() == 'dir') { - $level += 1; - $currentPath[$level] = $child->getName(); - $this->browseXmlAndCompare($child, $currentPath, $level); - $level -= 1; + $current_path[$level] = (string)$child['name']; + $this->browseXmlAndCompare($child, $current_path, $level + 1); } - else + else if (is_object($child) && $child->getName() == 'md5file') { - $path = ''; - for ($i=1;$i<=$level;$i++) - $path .= $currentPath[$i].'/'; - $path .= (string)$child->attributes()->name; + $path = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR; + for ($i = 1; $i < $level; $i++) + $path .= $current_path[$i].'/'; + $path .= (string)$child['name']; $path = str_replace('ps_root_dir',_PS_ROOT_DIR_,$path); + + // replace default admin dir by current one + $path = str_replace(_PS_ROOT_DIR_.'/admin', _PS_ADMIN_DIR_, $path); if(!file_exists($path)) $this->addMissingFile($path); - else if (!$this->compareChecksum($path, (string)$child->attributes()->sum)) + else if (!$this->compareChecksum($path, (string)$child)) $this->addChangedFile($path); + // else, file is original (and ok) } } } - protected function compareChecksum($path, $originalSum) + protected function compareChecksum($path, $original_sum) { - if (md5_file($path) == $originalSum) + if (md5_file($path) == $original_sum) return true; return false; } public function isAuthenticPrestashopVersion() { - return !$this->versionIsModified; + $this->getChangedFilesList(); + return !$this->version_is_modified; } } diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index 5834c17da..776542702 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -20,7 +20,7 @@ * * @author PrestaShop SA * @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 7095 $ +* @version Release: $Revision: 8673 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ @@ -34,90 +34,102 @@ class GuestTrackingControllerCore extends FrontController parent::init(); if ($this->context->customer->isLogged()) - Tools::redirect('index.php?controller=history'); + Tools::redirect('history.php'); } public function process() { - if ($id_order = Tools::getValue('id_order') AND $email = Tools::getValue('email')) + parent::process(); + + $id_order = (int)Tools::getValue('id_order'); + $email = Tools::getValue('email'); + $order = new Order((int)$id_order); + + if (empty($id_order)) + $this->errors[] = Tools::displayError('Please provide your Order ID'); + elseif (empty($email)) + $this->errors[] = Tools::displayError('Please provide your e-mail address'); + elseif (!Validate::isEmail($email)) + $this->errors[] = Tools::displayError('Please provide a valid e-mail address'); + elseif (!Customer::customerExists($email, false, false)) + $this->errors[] = Tools::displayError('There is no account associated with this e-mail address'); + elseif (Customer::customerExists($email, false, true)) { - $order = new Order((int)$id_order); - if (!Validate::isLoadedObject($order)) - $this->errors[] = Tools::displayError('Invalid order'); - elseif (!$order->isAssociatedAtGuest($email)) - $this->errors[] = Tools::displayError('Invalid order'); - else + $this->errors[] = Tools::displayError('Your guest account has already been transformed into a customer account. Please log-in to your customer account to view this order, this section is reserved for guest accounts'); + $this->context->smarty->assign('show_login_link', true); + } + elseif (!Validate::isLoadedObject($order)) + $this->errors[] = Tools::displayError('Invalid Order ID'); + elseif (!$order->isAssociatedAtGuest($email)) + $this->errors[] = Tools::displayError('123'); + else + { + $customer = new Customer((int)$order->id_customer); + $id_order_state = (int)($order->getCurrentState()); + $carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang)); + $addressInvoice = new Address((int)($order->id_address_invoice)); + $addressDelivery = new Address((int)($order->id_address_delivery)); + $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); + $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); + + $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields); + $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields); + + if ($order->total_discounts > 0) + $this->context->smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts)); + $products = $order->getProducts(); + $customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart)); + Product::addCustomizationPrice($products, $customizedDatas); + + $this->processAddressFormat($addressDelivery, $addressInvoice); + $this->context->smarty->assign(array( + 'shop_name' => Configuration::get('PS_SHOP_NAME'), + 'order' => $order, + 'return_allowed' => false, + 'currency' => new Currency($order->id_currency), + 'order_state' => (int)($id_order_state), + 'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')), + 'invoice' => (OrderState::invoiceAvailable((int)($id_order_state)) AND $order->invoice_number), + 'order_history' => $order->getHistory((int)$this->context->language->id, false, true), + 'products' => $products, + 'discounts' => $order->getDiscounts(), + 'carrier' => $carrier, + 'address_invoice' => $addressInvoice, + 'invoiceState' => (Validate::isLoadedObject($addressInvoice) AND $addressInvoice->id_state) ? new State((int)($addressInvoice->id_state)) : false, + 'address_delivery' => $addressDelivery, + 'deliveryState' => (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state) ? new State((int)($addressDelivery->id_state)) : false, + 'is_guest' => true, + 'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC), + 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, + 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, + 'use_tax' => Configuration::get('PS_TAX'), + 'customizedDatas' => $customizedDatas, + 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, + 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues)); + if ($carrier->url AND $order->shipping_number) + $this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); + $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); + Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order)); + + if (Tools::isSubmit('submitTransformGuestToCustomer')) { $customer = new Customer((int)$order->id_customer); - $id_order_state = (int)($order->getCurrentState()); - $carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang)); - $addressInvoice = new Address((int)($order->id_address_invoice)); - $addressDelivery = new Address((int)($order->id_address_delivery)); - $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country); - $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country); - - $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields); - $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields); - - if ($order->total_discounts > 0) - $this->context->smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts)); - $products = $order->getProducts(); - $customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart)); - Product::addCustomizationPrice($products, $customizedDatas); - - $this->processAddressFormat($addressDelivery, $addressInvoice); - $this->context->smarty->assign(array( - 'shop_name' => Configuration::get('PS_SHOP_NAME'), - 'order' => $order, - 'return_allowed' => false, - 'currency' => new Currency($order->id_currency), - 'order_state' => (int)($id_order_state), - 'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')), - 'invoice' => (OrderState::invoiceAvailable((int)($id_order_state)) AND $order->invoice_number), - 'order_history' => $order->getHistory($this->context->language->id, false, true), - 'products' => $products, - 'discounts' => $order->getDiscounts(), - 'carrier' => $carrier, - 'address_invoice' => $addressInvoice, - 'invoiceState' => (Validate::isLoadedObject($addressInvoice) AND $addressInvoice->id_state) ? new State((int)($addressInvoice->id_state)) : false, - 'address_delivery' => $addressDelivery, - 'deliveryState' => (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state) ? new State((int)($addressDelivery->id_state)) : false, - 'is_guest' => true, - 'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC), - 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, - 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, - 'use_tax' => Configuration::get('PS_TAX'), - 'customizedDatas' => $customizedDatas, - 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, - 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues)); - if ($carrier->url AND $order->shipping_number) - $this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url)); - $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order))); - Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order)); - - if (Tools::isSubmit('submitTransformGuestToCustomer')) - { - $customer = new Customer((int)$order->id_customer); - if (!Validate::isLoadedObject($customer)) - $this->errors[] = Tools::displayError('Invalid customer'); - if (!$customer->transformToCustomer($this->context->language->id, Tools::getValue('password'))) - $this->errors[] = Tools::displayError('An error occurred while transforming guest to customer.'); - if (!Tools::getValue('password')) - $this->errors[] = Tools::displayError('Invalid password'); - else - $this->context->smarty->assign('transformSuccess', true); - } + if (!Validate::isLoadedObject($customer)) + $this->errors[] = Tools::displayError('Invalid customer'); + if (!$customer->transformToCustomer($this->context->language->id, Tools::getValue('password'))) + $this->errors[] = Tools::displayError('An error occurred while transforming guest to customer.'); + if (!Tools::getValue('password')) + $this->errors[] = Tools::displayError('Invalid password'); + else + $this->context->smarty->assign('transformSuccess', true); } - if (sizeof($this->errors)) - /* Handle brute force attacks */ - sleep(1); } - $this->context->smarty->assign(array( - 'action' => $this->context->link->getPageLink('guest-tracking.php'), - 'errors' => $this->errors - )); + /* Handle brute force attacks */ + if (sizeof($this->errors)) + sleep(1); + $this->context->smarty->assign(array('action' => $this->context->link->getPageLink('guest-tracking.php'), 'errors' => $this->errors)); $this->setTemplate(_PS_THEME_DIR_.'guest-tracking.tpl'); } diff --git a/install-dev/index.php b/install-dev/index.php index e4519acf3..f9ffb4191 100644 --- a/install-dev/index.php +++ b/install-dev/index.php @@ -778,7 +778,7 @@ if ($lm->getIncludeTradFilename()) return ''; } - $stream_context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 3))); + $stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => 3))); $content = @file_get_contents('http://www.prestashop.com/partner/preactivation/partners.php?version=1.0', false, $stream_context); if ($content && $content[0] == '<') { diff --git a/install-dev/preactivation.php b/install-dev/preactivation.php index a58b62e9a..23d976022 100644 --- a/install-dev/preactivation.php +++ b/install-dev/preactivation.php @@ -17,7 +17,7 @@ $p = addslashes(strtolower($_GET['partner'])); $c = addslashes(strtolower($_GET['country_iso_code'])); - $stream_context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 5))); + $stream_context = @stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 5))); $content = @file_get_contents('http://www.prestashop.com/partner/preactivation/fields.php?version=1.0&partner='.$p.'&country_iso_code='.$c, false, $stream_context); if ($content && $content[0] == '<') @@ -102,7 +102,7 @@ if ($_GET['request'] == 'send') { - $stream_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 diff --git a/install-dev/sql/db_settings_lite.sql b/install-dev/sql/db_settings_lite.sql index 253a1757f..523d0e7e7 100644 --- a/install-dev/sql/db_settings_lite.sql +++ b/install-dev/sql/db_settings_lite.sql @@ -73,9 +73,19 @@ INSERT INTO `PREFIX_hook` (`id_hook`, `name`, `title`, `description`, `position` (70, 'featureForm', 'Add fields to the form "feature"', 'Add fields to the form "feature"', 0, 0), (71, 'afterSaveFeature', 'On saving attribute feature', 'On saving attribute feature', 0, 0), (72, 'afterDeleteFeature', 'On deleting attribute feature', 'On deleting attribute feature', 0, 0), -(73, 'taxManager', 'Tax Manager Factory', '' , 0, 0), -(74, 'afterSaveProduct', 'On saving products', 'On saving products', 0, 0), -(75, 'productListAssign', 'Assign product list to a category', 'Assign product list to a category', 0, 0); +(73, 'afterSaveProduct', 'On saving products', 'On saving products', 0, 0), +(74, 'productListAssign', 'Assign product list to a category', 'Assign product list to a category', 0, 0), +(75, 'postProcessAttributeGroup', 'On post-process in admin attribute group', 'On post-process in admin attribute group', 0, 0), +(76, 'postProcessFeature', 'On post-process in admin feature', 'On post-process in admin feature', 0, 0), +(77, 'featureValueForm', 'Add fileds to the form "feature value"', 'Add fileds to the form "feature value"', 0, 0), +(78, 'postProcessFeatureValue', 'On post-process in admin feature value', 'On post-process in admin feature value', 0, 0), +(79, 'afterDeleteFeatureValue', 'On deleting attribute feature value', 'On deleting attribute feature value', 0, 0), +(90, 'afterSaveFeatureValue', 'On saving attribute feature value', 'On saving attribute feature value', 0, 0), +(91, 'attributeForm', 'Add fileds to the form "feature value"', 'Add fileds to the form "feature value"', 0, 0), +(92, 'postProcessAttribute', 'On post-process in admin feature value', 'On post-process in admin feature value', 0, 0), +(93, 'afterDeleteAttribute', 'On deleting attribute feature value', 'On deleting attribute feature value', 0, 0), +(94, 'afterSaveAttribute', 'On saving attribute feature value', 'On saving attribute feature value', 0, 0), +(95, 'taxManager', 'Tax Manager Factory', '' , 0, 0); INSERT INTO `PREFIX_configuration` (`id_configuration`, `name`, `value`, `date_add`, `date_upd`) VALUES (1, 'PS_LANG_DEFAULT', '1', NOW(), NOW()), diff --git a/install-dev/sql/upgrade/1.4.5.0.sql b/install-dev/sql/upgrade/1.4.5.0.sql index e24e13b6a..76931c7e7 100644 --- a/install-dev/sql/upgrade/1.4.5.0.sql +++ b/install-dev/sql/upgrade/1.4.5.0.sql @@ -23,9 +23,18 @@ INSERT INTO `PREFIX_hook` (`name`, `title`, `description`, `position`, `live_edi ('attributeGroupForm', 'Add fields to the form "attribute group"', 'Add fields to the form "attribute group"', 0, 0), ('afterSaveAttributeGroup', 'On saving attribute group', 'On saving attribute group', 0, 0), ('afterDeleteAttributeGroup', 'On deleting attribute group', 'On deleting "attribute group', 0, 0), -('featureForm', 'Add fileds to the form "feature"', 'Add fileds to the form "feature"', 0, 0), +('featureForm', 'Add fields to the form "feature"', 'Add fields to the form "feature"', 0, 0), ('afterSaveFeature', 'On saving attribute feature', 'On saving attribute feature', 0, 0), ('afterDeleteFeature', 'On deleting attribute feature', 'On deleting attribute feature', 0, 0), ('afterSaveProduct', 'On saving products', 'On saving products', 0, 0), -('productListAssign', 'Assign product list to a category', 'Assign product list to a category', 0, 0); - +('productListAssign', 'Assign product list to a category', 'Assign product list to a category', 0, 0), +('postProcessAttributeGroup', 'On post-process in admin attribute group', 'On post-process in admin attribute group', 0, 0), +('postProcessFeature', 'On post-process in admin feature', 'On post-process in admin feature', 0, 0), +('featureValueForm', 'Add fields to the form "feature value"', 'Add fields to the form "feature value"', 0, 0), +('postProcessFeatureValue', 'On post-process in admin feature value', 'On post-process in admin feature value', 0, 0), +('afterDeleteFeatureValue', 'On deleting attribute feature value', 'On deleting attribute feature value', 0, 0), +('afterSaveFeatureValue', 'On saving attribute feature value', 'On saving attribute feature value', 0, 0), +('attributeForm', 'Add fields to the form "feature value"', 'Add fields to the form "feature value"', 0, 0), +('postProcessAttribute', 'On post-process in admin feature value', 'On post-process in admin feature value', 0, 0), +('afterDeleteAttribute', 'On deleting attribute feature value', 'On deleting attribute feature value', 0, 0), +('afterSaveAttribute', 'On saving attribute feature value', 'On saving attribute feature value', 0, 0); \ No newline at end of file diff --git a/install-dev/xml/checkShopInfos.php b/install-dev/xml/checkShopInfos.php index 5f8808c37..cb58a6b1a 100644 --- a/install-dev/xml/checkShopInfos.php +++ b/install-dev/xml/checkShopInfos.php @@ -209,7 +209,7 @@ if (isFormValid()) require_once(dirname(__FILE__).'/../../classes/LocalizationPack.php'); - $stream_context = stream_context_create(array('http' => array('timeout' => 5))); + $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'); diff --git a/modules/autoupgrade/AdminSelfUpgrade.php b/modules/autoupgrade/AdminSelfUpgrade.php index 6c318bce0..e7b679e6a 100644 --- a/modules/autoupgrade/AdminSelfUpgrade.php +++ b/modules/autoupgrade/AdminSelfUpgrade.php @@ -459,15 +459,29 @@ $this->standalone = true; } public function ajaxProcessCheckFilesVersion() { - if ($testOrigCore = $this->upgrader->isAuthenticPrestashopVersion() !== false) + if ($this->upgrader->isAuthenticPrestashopVersion() !== false) + { $this->nextParams['status'] = 'ok'; + $testOrigCore = true; + } else - $this->nextParams['status'] = 'nok'; + { + $testOrigCore = false; + $this->nextParams['status'] = 'warn'; + } $changedFileList = $this->upgrader->getChangedFilesList(); - + if ($changedFileList === false) + { + $changedFileList = array(); + $this->nextParams['msg'] = $this->l('Unable to check files'); + $this->nextParams['status'] = 'error'; + } + else + { // echo ' '. $this->nextParams['msg'] = ($testOrigCore?$this->l('Core files are ok'):sprintf($this->l('%s core files have been modified'), sizeof($changedFileList))); + } $this->nextParams['result'] = $changedFileList; } public function ajaxProcessUpgradeNow() @@ -534,7 +548,7 @@ $this->standalone = true; if (file_exists($destExtract)) Tools::deletedirectory($destExtract); - if (Tools::ZipExtract($filepath,$destExtract)) + if (self::ZipExtract($filepath,$destExtract)) { $adminDir = str_replace($this->prodRootDir, '', $this->adminDir); rename($this->latestRootDir.DIRECTORY_SEPARATOR.'admin', $this->latestRootDir.DIRECTORY_SEPARATOR.$adminDir); @@ -935,9 +949,11 @@ $this->standalone = true; if (self::ZipExtract($filepath, $destExtract)) { // once it's restored, do not delete the archive file. This has to be done manually + // but we can empty the var, to avoid loop. + $this->backupFilesFilename = ''; if (!empty($this->backupDbFilename) AND file_exists($this->backupDbFilename) ) { - $this->nextDesc = $this->l('Files restored. No database backup found. Restoration done.'); + $this->nextDesc = $this->l('Files restored. Checking next step ...'); $this->next = 'rollback'; } else @@ -1548,7 +1564,7 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where $srcRootWritable = '../img/admin/disabled.gif'; echo ''.$this->l('Root directory status').' : '.' '.($this->rootWritable?$this->l('fully writable'):$this->l('not writable recursively')).'

'; - if ($this->upgrader->needUpgrade) + if ($this->upgrader->need_upgrade) { if ($this->upgrader->autoupgrade) $srcAutoupgrade = '../img/admin/enabled.gif'; @@ -1556,6 +1572,12 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where $srcAutoupgrade = '../img/admin/disabled.gif'; echo ''.$this->l('Autoupgrade allowed').' : '.' '.($this->upgrader->autoupgrade?$this->l('This release allow autoupgrade.'):$this->l('This release does not allow autoupgrade')).'.

'; } + else + { + $srcAutoupgrade = '../img/admin/disabled.gif'; + echo ''.$this->l('Autoupgrade allowed').' : '.' .

'; + } + if (Configuration::get('PS_SHOP_ENABLE')) { @@ -1606,7 +1628,7 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where // echo ''; // echo ''; echo '
'; - if ($this->upgrader->needUpgrade) + if ($this->upgrader->need_upgrade) { if($this->configOk()) { @@ -2129,8 +2151,12 @@ $js.= '$(document).ready(function(){ res = $.parseJSON(res); answer = res.nextParams; $("#checkPrestaShopFilesVersion").html(""+answer.msg+" "); + if (answer.status == "error") + $("#checkPrestaShopFilesVersion").prepend(" "); + else + { + $("#checkPrestaShopFilesVersion").prepend(answer.status); $("#checkPrestaShopFilesVersion").append("'.$this->l('See or hide the list').'
"); - $("#checkPrestaShopFilesVersion").append("
"); $("#changedList").html("
    "); @@ -2139,7 +2165,7 @@ $js.= '$(document).ready(function(){ }); $("#toggleChangedList").bind("click",function(e){e.preventDefault();$("#changedList").toggle();}); - + } } , error: function(res,textStatus,jqXHR) diff --git a/modules/autoupgrade/Upgrader.php b/modules/autoupgrade/Upgrader.php index da4669ebc..9cf020816 100644 --- a/modules/autoupgrade/Upgrader.php +++ b/modules/autoupgrade/Upgrader.php @@ -25,19 +25,19 @@ * International Registered Trademark & Property of PrestaShop SA */ -class UpgraderCore{ +class UpgraderCore +{ const DEFAULT_CHECK_VERSION_DELAY_HOURS = 24; - public $rss_version_link = 'http://www.prestashop.com/xml/version.xml'; + public $rss_version_link = 'http://www.prestashop.com/xml/upgrader.xml'; public $rss_md5file_link_dir = 'http://www.prestashop.com/xml/md5/'; /** * link contains hte url where to download the file * * @var string */ - private $needUpgrade = false; - private $noRefresh = false; - private $changedFiles = array(); - private $missingFiles = array(); + private $need_upgrade = false; + private $changed_files = array(); + private $missing_files = array(); public $version_name; public $version_num; @@ -49,18 +49,9 @@ class UpgraderCore{ public function __get($var) { - if($var == 'needUpgrade') + if ($var == 'need_upgrade') return $this->isLastVersion(); } - /** - * we need to checkPSVersion when we use that class - * @param boolean noRefresh if true, checkPSVersion will not refresh its information - * @return object Upgrader - */ - public function __construct($noRefresh = false) - { - $this->noRefresh = (bool)$noRefresh; - } /** * downloadLast download the last version of PrestaShop and save it in $dest/$filename @@ -86,7 +77,7 @@ class UpgraderCore{ if (empty($this->link)) $this->checkPSVersion(); - return $this->needUpgrade; + return $this->need_upgrade; } @@ -100,14 +91,14 @@ class UpgraderCore{ if (empty($this->link)) { if (class_exists('Configuration')) - $lastCheck = Configuration::get('PS_LAST_VERSION_CHECK'); + $last_check = Configuration::get('PS_LAST_VERSION_CHECK'); else - $lastCheck = 0; + $last_check = 0; // if we use the autoupgrade process, we will never refresh it // except if no check has been done before - if ($force OR ($lastCheck < time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS)) ) + if ($force || ($last_check < time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS))) { - libxml_set_streams_context(stream_context_create(array('http' => array('timeout' => 3)))); + libxml_set_streams_context(@stream_context_create(array('http' => array('timeout' => 3)))); if ($feed = @simplexml_load_file($this->rss_version_link)) { @@ -119,7 +110,7 @@ class UpgraderCore{ $this->autoupgrade = (int)$feed->autoupgrade; $this->autoupgrade_module = (int)$feed->autoupgrade_module; $this->desc = (string)$feed->desc ; - $configLastVersion = array( + $config_last_version = array( 'name' => $this->version_name, 'num' => $this->version_num, 'link' => $this->link, @@ -131,22 +122,22 @@ class UpgraderCore{ ); if (class_exists('Configuration')) { - Configuration::updateValue('PS_LAST_VERSION',serialize($configLastVersion)); + Configuration::updateValue('PS_LAST_VERSION', serialize($config_last_version)); Configuration::updateValue('PS_LAST_VERSION_CHECK',time()); } } } else { - $lastVersionCheck = @unserialize(Configuration::get('PS_LAST_VERSION')); - $this->version_name = $lastVersionCheck['name']; - $this->version_num = $lastVersionCheck['num']; - $this->link = $lastVersionCheck['link']; - $this->autoupgrade = $lastVersionCheck['autoupgrade']; - $this->autoupgrade_module = $lastVersionCheck['autoupgrade_module']; - $this->md5 = $lastVersionCheck['md5']; - $this->desc = $lastVersionCheck['desc']; - $this->changelog = $lastVersionCheck['changelog']; + $last_version_check = @unserialize(Configuration::get('PS_LAST_VERSION')); + $this->version_name = $last_version_check['name']; + $this->version_num = $last_version_check['num']; + $this->link = $last_version_check['link']; + $this->autoupgrade = $last_version_check['autoupgrade']; + $this->autoupgrade_module = $last_version_check['autoupgrade_module']; + $this->md5 = $last_version_check['md5']; + $this->desc = $last_version_check['desc']; + $this->changelog = $last_version_check['changelog']; } } // retro-compatibility : @@ -154,7 +145,7 @@ class UpgraderCore{ // false otherwise if (version_compare(_PS_VERSION_, $this->version_num, '<')) { - $this->needUpgrade = true; + $this->need_upgrade = true; return array('name' => $this->version_name, 'link' => $this->link); } else @@ -163,63 +154,69 @@ class UpgraderCore{ public function getChangedFilesList() { - $checksum = simplexml_load_file($this->rss_md5file_link_dir._PS_VERSION_.'.xml'); + if (count($this->changed_files) == 0) + { + $checksum = @simplexml_load_file($this->rss_md5file_link_dir._PS_VERSION_.'.xml'); if ($checksum === false) - throw new Exception('No checksum xml file for your Prestashop version'); - $this->browseXmlAndCompare($checksum); - - return $this->changedFiles; + return false; + else + $this->browseXmlAndCompare($checksum->ps_root_dir[0]); } + return $this->changed_files; + } protected function addChangedFile($path) { - $this->versionIsModified = true; - $this->changedFiles[] = $path; - //array_unique($this->changedFiles); + $this->version_is_modified = true; + $this->changed_files[] = $path; + //array_unique($this->changed_files); } protected function addMissingFile($path) { - $this->versionIsModified = true; - $this->missingFiles[] = $path; + $this->version_is_modified = true; + $this->missing_files[] = $path; //array_unique($this->missingFile); } - protected function browseXmlAndCompare($node, &$currentPath = array(), $level = 0) + protected function browseXmlAndCompare($node, &$current_path = array(), $level = 1) { foreach ($node as $key => $child) { - if (is_object($child) && $child->getName() != 'md5file') + if (is_object($child) && $child->getName() == 'dir') { - $level += 1; - $currentPath[$level] = $child->getName(); - $this->browseXmlAndCompare($child, $currentPath, $level); - $level -= 1; + $current_path[$level] = (string)$child['name']; + $this->browseXmlAndCompare($child, $current_path, $level + 1); } - else + else if (is_object($child) && $child->getName() == 'md5file') { - $path = ''; - for ($i=1;$i<=$level;$i++) - $path .= $currentPath[$i].'/'; - $path .= (string)$child->attributes()->name; + $path = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR; + for ($i = 1; $i < $level; $i++) + $path .= $current_path[$i].'/'; + $path .= (string)$child['name']; $path = str_replace('ps_root_dir',_PS_ROOT_DIR_,$path); + + // replace default admin dir by current one + $path = str_replace(_PS_ROOT_DIR_.'/admin', _PS_ADMIN_DIR_, $path); if(!file_exists($path)) $this->addMissingFile($path); - else if (!$this->compareChecksum($path, (string)$child->attributes()->sum)) + else if (!$this->compareChecksum($path, (string)$child)) $this->addChangedFile($path); + // else, file is original (and ok) } } } - protected function compareChecksum($path, $originalSum) + protected function compareChecksum($path, $original_sum) { - if (md5_file($path) == $originalSum) + if (md5_file($path) == $original_sum) return true; return false; } public function isAuthenticPrestashopVersion() { - return !$this->versionIsModified; + $this->getChangedFilesList(); + return !$this->version_is_modified; } } diff --git a/modules/autoupgrade/fr.php b/modules/autoupgrade/fr.php index f1de5b9bb..167184197 100644 --- a/modules/autoupgrade/fr.php +++ b/modules/autoupgrade/fr.php @@ -24,11 +24,8 @@ $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_4f7c02592a962e40a920f32f3a24 $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_3f10faa8b44a7175ae8fc5dcb8dec5de'] = 'Tous les fichiers ont été mis à jour. Mise à jour de la base de données en cours.'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_1ad932e3b85eb2907a817cd3e3e6907e'] = 'Erreur pour la mise à jour de %s'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_078a325fbcc1dbd50bd9f969ce954965'] = 'encore %2$s fichiers à mettre à jour.'; -$_MODULE['<{autoupgrade}prestashop>adminselfupgrade_62740df131433ec9d45bf1810eefb19b'] = 'erreur pendant la mise à jour de la base de données.'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_9a2f2cf276ea9f79b31a815897c0e3e6'] = '%s ignoré.'; -$_MODULE['<{autoupgrade}prestashop>adminselfupgrade_63ded4905ba41ac4bf00373df2739576'] = 'création du répertoire %2$s. encore %3$s fichiers à mettre à jour.'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_11978affb3b0dbb16c50d571fd05de6d'] = 'erreur lors de la création du répertoire %s'; -$_MODULE['<{autoupgrade}prestashop>adminselfupgrade_1b854285afc1988b6f83414fde5943ab'] = '%1$s copié dans %2$s. encore %3$s fichiers à mettre à jour.'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_0e06ce0972ad338e1d96e8589dc21b9c'] = 'erreur lors de la copie de %1$s vers %2$s'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_5f7f50973696d0a42c1efcc07f7820a0'] = 'Votre site est maintenant restauré.'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_28517b8a291c50d80aa53a078407065b'] = 'Répertoire racine nettoyée.'; @@ -138,9 +135,8 @@ $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_7f786b903ea8045f5b5b7e3c5a4e $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_3a3a651c9a67bca9ac902da789466b93'] = 'Mise à jour instable'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_a22eff458b4f4bce6d3232e367ff0138'] = 'Votre configuration actuelle indique que vous voulez mettre à jour votre système à partir d\'une branche de développement instable, sans numéro de version. Si vous mettez à jour, vous ne pourrez plus appliquer le processus de versions stables officiel.'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_dae8ace18bdcbcc6ae5aece263e14fe8'] = 'Options'; -$_MODULE['<{autoupgrade}prestashop>adminselfupgrade_c747916b25dcb02e0e81ee84dbd966ea'] = 'Vous n\'avez pas besoin d\'utiliser cette fonctionnalité.'; -$_MODULE['<{autoupgrade}prestashop>adminselfupgrade_6b3930a184368a458be6e4429f409877'] = 'Mise à jour terminée. Vérifiez votre boutique (essayez de faire une commande, vérifier le thème)'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_91195bbbacc2147a736c849c46368ed8'] = 'Voulez vous restaurer votre boutique'; +$_MODULE['<{autoupgrade}prestashop>adminselfupgrade_6b3930a184368a458be6e4429f409877'] = 'Mise à jour terminée. Vérifiez votre boutique (essayez de faire une commande, vérifier le thème)'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_a498f9476a893d51ee02b3601678d318'] = 'Cliquez pour restaurer la base de donnée'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_f34d5debb2bba76aa3e077937a07e373'] = 'Cliquez pour restaurer les fichiers'; $_MODULE['<{autoupgrade}prestashop>adminselfupgrade_60283aa37e2063b2ada2f99216e1332a'] = 'Votre serveur ne peut pas télécharger le fichier. S\'il vous plaît le télécharger d\'abord par ftp dans votre répertoire admin/autoupgrade'; diff --git a/modules/blocklayered/blocklayered-attribute-indexer.php b/modules/blocklayered/blocklayered-attribute-indexer.php new file mode 100644 index 000000000..1cdae3657 --- /dev/null +++ b/modules/blocklayered/blocklayered-attribute-indexer.php @@ -0,0 +1,11 @@ +indexAttribute(); \ No newline at end of file diff --git a/modules/blocklayered/blocklayered.js b/modules/blocklayered/blocklayered.js index 5a9d9f4d4..2ef6e7ac0 100644 --- a/modules/blocklayered/blocklayered.js +++ b/modules/blocklayered/blocklayered.js @@ -51,7 +51,7 @@ $(document).ready(function() }); // Click on label - $("label a").live({ + $('label a').live({ click: function() { if($(this).parent().parent().find('input').attr('disabled') == '') { @@ -104,19 +104,19 @@ function updatelink(link) function getValueSelected(){ - var checkboxChecked = ""; - $("#layered_form input:checkbox:checked").each(function(){ - checkboxChecked += '#' + $(this).attr('id')+"="+$(this).val(); + var checkboxChecked = ''; + $('#layered_form input:checkbox:checked').each(function(){ + checkboxChecked += '#' + $(this).attr('id')+'='+$(this).val(); }); - $("#layered_form input:hidden").each(function(){ - checkboxChecked += '#' + $(this).attr('name')+"="+$(this).val(); + $('#layered_form input:hidden').each(function(){ + checkboxChecked += '#' + $(this).attr('name')+'='+$(this).val(); }); $(['price','weight']).each(function(i, filter) { - if ($("#layered_"+filter+"_slider").length) + if ($('#layered_'+filter+'_slider').length) { - if (typeof($("#layered_"+filter+"_slider").slider('values', 0)) != 'object') + if (typeof($('#layered_'+filter+'_slider').slider('values', 0)) != 'object') { - checkboxChecked += '#'+filter+'='+$("#layered_"+filter+"_slider").slider('values', 0)+'_'+$("#layered_"+filter+"_slider").slider('values', 1); + checkboxChecked += '#'+filter+'='+$('#layered_'+filter+'_slider').slider('values', 0)+'_'+$('#layered_'+filter+'_slider').slider('values', 1); } } }); @@ -125,7 +125,8 @@ function getValueSelected(){ function friendlyUrl(link, encode) { - var friendlyTab = { + var friendlyTab = + { 'layered_condition_' : 'cond_', 'layered_id_attribute_group_' : 'g_', 'id_category_layered=' : 'c=', @@ -134,13 +135,17 @@ function friendlyUrl(link, encode) 'layered_category_' : 'cat_', }; - if(encode == 'short'){ - $.each(friendlyTab, function(key, value) { + if(encode == 'short') + { + $.each(friendlyTab, function(key, value) + { Expression = new RegExp(key,'g'); link = link.replace(Expression, value); }); - }else{ - $.each(friendlyTab, function(key, value) { + }else + { + $.each(friendlyTab, function(key, value) + { Expression = new RegExp(value,'g'); link = link.replace(Expression, key); }); @@ -176,9 +181,9 @@ function cancelFilter() { if($(this).attr('rel').search(/_slider$/) > 0) { - $('#'+$(this).attr('rel')).slider("values" , 0, $('#'+$(this).attr('rel')).slider( "option" , 'min' )); - $('#'+$(this).attr('rel')).slider("values" , 1, $('#'+$(this).attr('rel')).slider( "option" , 'max' )); - $('#'+$(this).attr('rel')).slider('option', 'slide')(0,{values:[$('#'+$(this).attr('rel')).slider( "option" , 'min' ), $('#'+$(this).attr('rel')).slider( "option" , 'max' )]}); + $('#'+$(this).attr('rel')).slider('values' , 0, $('#'+$(this).attr('rel')).slider('option' , 'min' )); + $('#'+$(this).attr('rel')).slider('values' , 1, $('#'+$(this).attr('rel')).slider('option' , 'max' )); + $('#'+$(this).attr('rel')).slider('option', 'slide')(0,{values:[$('#'+$(this).attr('rel')).slider( 'option' , 'min' ), $('#'+$(this).attr('rel')).slider( 'option' , 'max' )]}); } else { @@ -242,9 +247,8 @@ function reloadContent(params_plus) // Get nb items per page var n = ''; $('#pagination #nb_item').children().each(function(it, option) { - if(option.selected) { + if (option.selected) n = '&n='+option.value; - } }); ajaxQuery = $.ajax( @@ -267,14 +271,13 @@ function reloadContent(params_plus) ajaxLoaderOn = 0; // On submiting nb items form, relaod with the good nb of items - $("#pagination form").submit(function() { + $('#pagination form').submit(function() { val = $('#pagination #nb_item').val(); $('#pagination #nb_item').children().each(function(it, option) { - if(option.value == val) { + if (option.value == val) $(option).attr('selected', 'selected'); - } else { + else $(option).removeAttr('selected'); - } }); // Reload products and pagination reloadContent(); @@ -282,12 +285,28 @@ function reloadContent(params_plus) }); ajaxCart.overrideButtonsInThePage(); - if(typeof(reloadProductComparison) == 'function') { + if (typeof(reloadProductComparison) == 'function') reloadProductComparison(); - } initSliders(); - if(typeof(current_friendly_url != 'undefined')) + // Currente page url + if (typeof(current_friendly_url) == 'undefined') + current_friendly_url = '#'; + + // Get all sliders value + $(['price', 'weight']).each(function(it, sliderType) + { + if ($('#layered_'+sliderType+'_slider')) + { + // Check if slider is enable & if slider is used + if(typeof($('#layered_'+sliderType+'_slider').slider('values', 0)) != 'object') + if ($('#layered_'+sliderType+'_slider').slider('values', 0) != $('#layered_'+sliderType+'_slider').slider('option' , 'min') + || $('#layered_'+sliderType+'_slider').slider('values', 1) != $('#layered_'+sliderType+'_slider').slider('option' , 'max')) + current_friendly_url += '/'+sliderType+'-'+$('#layered_'+sliderType+'_slider').slider('values', 0)+'-'+$('#layered_'+sliderType+'_slider').slider('values', 1) + } + }); + if (current_friendly_url == '#') + current_friendly_url = '#/'; window.location = current_friendly_url; } }); diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index a5351525a..72d8e81e6 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -49,27 +49,33 @@ class BlockLayered extends Module public function install() { - if ($result = parent::install() && $this->registerHook('leftColumn') && $this->registerHook('header') && $this->registerHook('footer') + if ($this->registerHook('leftColumn') && $this->registerHook('header') && $this->registerHook('footer') && $this->registerHook('categoryAddition') && $this->registerHook('categoryUpdate') && $this->registerHook('attributeGroupForm') && $this->registerHook('afterSaveAttributeGroup') && $this->registerHook('afterDeleteAttributeGroup') && $this->registerHook('featureForm') && $this->registerHook('afterDeleteFeature') && $this->registerHook('afterSaveFeature') && $this->registerHook('categoryDeletion') - && $this->registerHook('afterSaveProduct') && $this->registerHook('productListAssign')) + && $this->registerHook('afterSaveProduct') && $this->registerHook('productListAssign') && $this->registerHook('postProcessAttributeGroup') + && $this->registerHook('postProcessFeature') && $this->registerHook('featureValueForm') && $this->registerHook('postProcessFeatureValue') + && $this->registerHook('afterDeleteFeatureValue') && $this->registerHook('afterSaveFeatureValue') && $this->registerHook('attributeForm') + && $this->registerHook('postProcessAttribute') && $this->registerHook('afterDeleteAttribute') && $this->registerHook('afterSaveAttribute') + && parent::install()) { Configuration::updateValue('PS_LAYERED_HIDE_0_VALUES', 0); Configuration::updateValue('PS_LAYERED_SHOW_QTIES', 1); $this->rebuildLayeredStructure(); $this->rebuildLayeredCache(); - } - self::_installPriceIndexTable(); self::_installFriendlyUrlTable(); self::_installIndexableAttributeTable(); + self::_installProductAttributeTable(); $this->indexUrl(); + $this->indexAttribute(); self::fullIndexProcess(); - return $result; + return true; + } + return false; } public function uninstall() @@ -78,22 +84,24 @@ class BlockLayered extends Module Configuration::deleteByName('PS_LAYERED_HIDE_0_VALUES'); Configuration::deleteByName('PS_LAYERED_SHOW_QTIES'); - Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'price_static_index'); + Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_price_index'); Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_friendly_url'); Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_attribute_group'); Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_feature'); + Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_attribute_group_lang'); + Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_indexable_feature_lang'); Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_category'); Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_filter'); - + Db::getInstance()->Execute('DROP TABLE IF EXISTS '._DB_PREFIX_.'layered_product_attribute'); return parent::uninstall(); } private function _installPriceIndexTable() { - Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'price_static_index`'); + Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_price_index`'); Db::getInstance()->Execute(' - CREATE TABLE `'._DB_PREFIX_.'price_static_index` ( + CREATE TABLE `'._DB_PREFIX_.'layered_price_index` ( `id_product` INT NOT NULL, `id_currency` INT NOT NULL, `price_min` INT NOT NULL, `price_max` INT NOT NULL, PRIMARY KEY (`id_product`, `id_currency`), INDEX `id_currency` (`id_currency`), @@ -117,6 +125,7 @@ class BlockLayered extends Module private function _installIndexableAttributeTable() { + // Attributes Groups Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_group`'); Db::getInstance()->Execute(' CREATE TABLE `'._DB_PREFIX_.'layered_indexable_attribute_group` ( @@ -127,17 +136,93 @@ class BlockLayered extends Module INSERT INTO `'._DB_PREFIX_.'layered_indexable_attribute_group` SELECT id_attribute_group, 1 FROM `'._DB_PREFIX_.'attribute_group`'); + Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_group_lang`'); + Db::getInstance()->Execute(' + CREATE TABLE `'._DB_PREFIX_.'layered_indexable_attribute_group_lang` ( + `id_attribute_group` INT NOT NULL, + `id_lang` INT NOT NULL, + `url_name` VARCHAR(20), + `meta_title` VARCHAR(20), + PRIMARY KEY (`id_attribute_group`, `id_lang`)) ENGINE = '._MYSQL_ENGINE_); + + // Attributes + Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_attribute_lang`'); + Db::getInstance()->Execute(' + CREATE TABLE `'._DB_PREFIX_.'layered_indexable_attribute_lang` ( + `id_attribute` INT NOT NULL, + `id_lang` INT NOT NULL, + `url_name` VARCHAR(20), + `meta_title` VARCHAR(20), + PRIMARY KEY (`id_attribute`, `id_lang`)) ENGINE = '._MYSQL_ENGINE_); + + + // Features Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature`'); Db::getInstance()->Execute(' CREATE TABLE `'._DB_PREFIX_.'layered_indexable_feature` ( `id_feature` INT NOT NULL, `indexable` BOOL NOT NULL DEFAULT 0, PRIMARY KEY (`id_feature`)) ENGINE = '._MYSQL_ENGINE_); + Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'layered_indexable_feature` SELECT id_feature, 1 FROM `'._DB_PREFIX_.'feature`'); + + Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_lang`'); + Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_lang`'); + Db::getInstance()->Execute(' + CREATE TABLE `'._DB_PREFIX_.'layered_indexable_feature_lang` ( + `id_feature` INT NOT NULL, + `id_lang` INT NOT NULL, + `url_name` VARCHAR(20) NOT NULL, + `meta_title` VARCHAR(20), + PRIMARY KEY (`id_feature`, `id_lang`)) ENGINE = '._MYSQL_ENGINE_); + + // Features values + Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_indexable_feature_value_lang`'); + Db::getInstance()->Execute(' + CREATE TABLE `'._DB_PREFIX_.'layered_indexable_feature_value_lang` ( + `id_feature_value` INT NOT NULL, + `id_lang` INT NOT NULL, + `url_name` VARCHAR(20), + `meta_title` VARCHAR(20), + PRIMARY KEY (`id_feature_value`, `id_lang`)) ENGINE = '._MYSQL_ENGINE_); } + /** + * + * create table product attribute + */ + public function _installProductAttributeTable() + { + Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'layered_product_attribute`'); + Db::getInstance()->Execute(' + CREATE TABLE `'._DB_PREFIX_.'layered_product_attribute` ( + `id_attribute` int(10) unsigned NOT NULL, + `id_product` int(10) unsigned NOT NULL, + `id_attribute_group` int(10) unsigned NOT NULL DEFAULT "0", + KEY `id_attribute` (`id_attribute`) + ) ENGINE= '._MYSQL_ENGINE_); + } + + /** + * + * Generate data product attribute + */ + public function indexAttribute() + { + Db::getInstance()->execute('TRUNCATE '._DB_PREFIX_.'layered_product_attribute'); + + Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'layered_product_attribute` (`id_attribute`, `id_product`, `id_attribute_group`) + SELECT pac.id_attribute, pa.id_product, ag.id_attribute_group + FROM '._DB_PREFIX_.'product_attribute pa + INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute + INNER JOIN '._DB_PREFIX_.'attribute a ON (a.id_attribute = pac.id_attribute) + INNER JOIN '._DB_PREFIX_.'attribute_group ag ON ag.id_attribute_group = a.id_attribute_group + GROUP BY a.id_attribute, pa.id_product'); + + return 1; + } /* * Url indexation */ @@ -159,12 +244,17 @@ class BlockLayered extends Module { case 'id_attribute_group': $attributes = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' - SELECT agl.public_name name, a.id_attribute_group id_name, al.name value, a.id_attribute id_value, al.id_lang + SELECT agl.public_name name, a.id_attribute_group id_name, al.name value, a.id_attribute id_value, al.id_lang, + liagl.url_name name_url_name, lial.url_name value_url_name FROM '._DB_PREFIX_.'attribute_group ag INNER JOIN '._DB_PREFIX_.'attribute_group_lang agl ON (agl.id_attribute_group = ag.id_attribute_group) INNER JOIN '._DB_PREFIX_.'attribute a ON (a.id_attribute_group = ag.id_attribute_group) INNER JOIN '._DB_PREFIX_.'attribute_lang al ON (al.id_attribute = a.id_attribute) - INNER JOIN '._DB_PREFIX_.'layered_indexable_attribute_group liag ON (liag.id_attribute_group = a.id_attribute_group AND liag.indexable = 1) + LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_group liag ON (liag.id_attribute_group = a.id_attribute_group) + LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_group_lang liagl + ON (liagl.id_attribute_group = ag.id_attribute_group AND liagl.id_lang = '.(int)$filter['id_lang'].') + LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_lang lial + ON (lial.id_attribute = a.id_attribute AND lial.id_lang = '.(int)$filter['id_lang'].') WHERE a.id_attribute_group = '.(int)$filter['id_value'].' AND agl.id_lang = al.id_lang AND agl.id_lang = '.(int)$filter['id_lang']); foreach ($attributes as $attribute) { @@ -174,19 +264,24 @@ class BlockLayered extends Module $attributeValues[$attribute['id_lang']][$filter['id_category']] = array(); if (!isset($attributeValues[$attribute['id_lang']][$filter['id_category']]['c'.$attribute['id_name']])) $attributeValues[$attribute['id_lang']][$filter['id_category']]['c'.$attribute['id_name']] = array(); - $attributeValues[$attribute['id_lang']][$filter['id_category']]['c'.$attribute['id_name']][] = array('name' => $attribute['name'], - 'id_name' => 'c'.$attribute['id_name'], 'value' => $attribute['value'], 'id_value' => $attribute['id_name'].'_'.$attribute['id_value'], + $attributeValues[$attribute['id_lang']][$filter['id_category']]['c'.$attribute['id_name']][] = array('name' => (!empty($attribute['name_url_name']) ? $attribute['name_url_name'] : $attribute['name']), + 'id_name' => 'c'.$attribute['id_name'], 'value' => (!empty($attribute['value_url_name']) ? $attribute['value_url_name'] : $attribute['value']), 'id_value' => $attribute['id_name'].'_'.$attribute['id_value'], 'id_id_value' => $attribute['id_value'], 'category_name' => $filter['link_rewrite'], 'type' => $filter['type']); } break; case 'id_feature': $features = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' - SELECT fl.name name, fl.id_feature id_name, fvl.id_feature_value id_value, fvl.value value, fl.id_lang + SELECT fl.name name, fl.id_feature id_name, fvl.id_feature_value id_value, fvl.value value, fl.id_lang, fl.id_lang, + lifl.url_name name_url_name, lifvl.url_name value_url_name FROM '._DB_PREFIX_.'feature_lang fl - INNER JOIN '._DB_PREFIX_.'layered_indexable_feature lif ON (lif.id_feature = fl.id_feature AND indexable = 1) + LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature lif ON (lif.id_feature = fl.id_feature) INNER JOIN '._DB_PREFIX_.'feature_value fv ON (fv.id_feature = fl.id_feature) INNER JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = fv.id_feature_value) + LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_lang lifl + ON (lifl.id_feature = fl.id_feature AND lifl.id_lang = '.(int)$filter['id_lang'].') + LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_value_lang lifvl + ON (lifvl.id_feature_value = fvl.id_feature_value AND lifvl.id_lang = '.(int)$filter['id_lang'].') WHERE fl.id_feature = '.(int)$filter['id_value'].' AND fvl.id_lang = fl.id_lang AND fvl.id_lang = '.(int)$filter['id_lang']); foreach ($features as $feature) { @@ -196,8 +291,8 @@ class BlockLayered extends Module $attributeValues[$feature['id_lang']][$filter['id_category']] = array(); if (!isset($attributeValues[$feature['id_lang']][$filter['id_category']]['f'.$feature['id_name']])) $attributeValues[$feature['id_lang']][$filter['id_category']]['f'.$feature['id_name']] = array(); - $attributeValues[$feature['id_lang']][$filter['id_category']]['f'.$feature['id_name']][] = array('name' => $feature['name'], - 'id_name' => 'f'.$feature['id_name'], 'value' => $feature['value'], 'id_value' => $feature['id_value'], + $attributeValues[$feature['id_lang']][$filter['id_category']]['f'.$feature['id_name']][] = array('name' => (!empty($feature['name_url_name']) ? $feature['name_url_name'] : $feature['name']), + 'id_name' => 'f'.$feature['id_name'], 'value' => (!empty($attribute['value_url_name']) ? $attribute['value_url_name'] : $feature['value']), 'id_value' => $feature['id_value'], 'category_name' => $filter['link_rewrite'], 'type' => $filter['type']); } break; @@ -209,8 +304,7 @@ class BlockLayered extends Module INNER JOIN '._DB_PREFIX_.'category_lang cl ON (c.id_category = cl.id_category) WHERE nleft > (SELECT nleft FROM '._DB_PREFIX_.'category WHERE id_category = '.$filter['id_category'].') AND nright < (SELECT nright FROM '._DB_PREFIX_.'category WHERE id_category = '.$filter['id_category'].') - AND cl.id_lang = '.(int)$filter['id_lang'].' - '); + AND cl.id_lang = '.(int)$filter['id_lang'].' '); foreach($categories as $category) { if (!isset($attributeValues[$category['id_lang']])) @@ -229,8 +323,7 @@ class BlockLayered extends Module $manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT m.name as name,l.id_lang as id_lang, id_manufacturer FROM '._DB_PREFIX_.'manufacturer m , '._DB_PREFIX_.'lang l - WHERE l.id_lang = '.(int)$filter['id_lang'].' - '); + WHERE l.id_lang = '.(int)$filter['id_lang'].' '); foreach ($manufacturers as $manufacturer) { @@ -270,9 +363,7 @@ class BlockLayered extends Module { // Foreach categories foreach($attributesByCategoriesByLang as $id_category => $attributesByCategory) - { foreach($attributesByCategory as $attribute) - { foreach($attribute as $param) { $selectedFilters = array(); @@ -290,8 +381,6 @@ class BlockLayered extends Module } } } - } - } if ($ajax) return '{"result": 1}'; else @@ -350,6 +439,8 @@ class BlockLayered extends Module $smarty->assign('categoryNameComplement', $title); $this->getProducts($selectedFilters, $params['catProducts'], $params['nbProducts'], $p, $n, $pages_nb, $start, $stop, $range); + //test nofollow link + $smarty->assign('no_follow', $filterBlock['nofollow']); } public function hookAfterSaveProduct($params) @@ -367,6 +458,165 @@ class BlockLayered extends Module Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature WHERE id_feature = '.(int)$params['id_feature']); Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_feature VALUES ('.(int)$params['id_feature'].', '.(int)Tools::getValue('layered_indexable').')'); + + Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_lang WHERE id_feature = '.(int)$params['id_feature']); // don't care about the id_lang + foreach (Language::getLanguages(false) as $language) + { + // Data are validated by method "hookPostProcessFeature" + $id_lang = (int)$language['id_lang']; + Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_feature_lang + VALUES ('.(int)$params['id_feature'].', '.$id_lang.', \''.Tools::link_rewrite(Tools::getValue('url_name_'.$id_lang)).'\', + \''.pSQL(htmlspecialchars(Tools::getValue('meta_title_'.$id_lang))).'\')'); + } + } + + public function hookAfterSaveFeatureValue($params) + { + if (!$params['id_feature_value']) + return; + + Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang WHERE id_feature_value = '.(int)$params['id_feature_value']); // don't care about the id_lang + foreach (Language::getLanguages(false) as $language) + { + // Data are validated by method "hookPostProcessFeatureValue" + $id_lang = (int)$language['id_lang']; + Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_feature_value_lang + VALUES ('.(int)$params['id_feature_value'].', '.$id_lang.', \''.Tools::link_rewrite(Tools::getValue('url_name_'.$id_lang)).'\', + \''.pSQL(htmlspecialchars(Tools::getValue('meta_title_'.$id_lang))).'\')'); + } + } + + public function hookAfterDeleteFeatureValue($params) + { + if (!$params['id_feature_value']) + return; + Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang WHERE id_feature_value = '.(int)$params['id_feature_value']); + } + + public function hookPostProcessFeatureValue($params) + { + $this->hookPostProcessAttributeGroup($params); + } + + public function hookFeatureValueForm($params) + { + $languages = Language::getLanguages(false); + $default_form_language = (int)(Configuration::get('PS_LANG_DEFAULT')); + $langValue = array(); + + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS( + 'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_feature_value_lang + WHERE id_feature_value = '.(int)$params['id_feature_value']); + if ($result) + foreach ($result as $data) + $langValue[$data['id_lang']] = array('url_name' => $data['url_name'], 'meta_title' => $data['meta_title']); + $return = '
    + +
    + '; + foreach ($languages as $language) + $return .= ' +
    + + '.$this->l('Invalid characters:').' <>;=#{}_  +

    '.$this->l('Specific format in url block layered generation').'

    +
    '; + $return .= $this->displayFlags($languages, $default_form_language, 'flag_fields', 'url_name', true, true); + $return .= ' +
    +
    + +
    '; + foreach ($languages as $language) + $return .= ' +
    + +

    '.$this->l('Specific format for meta title').'

    +
    '; + $return .= $this->displayFlags($languages, $default_form_language, 'flag_fields', 'meta_title', true, true); + $return .= ' +
    +
    '; + return $return; + } + + public function hookAfterSaveAttribute($params) + { + if (!$params['id_attribute']) + return; + + Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_lang WHERE id_attribute = '.(int)$params['id_attribute']); // don't care about the id_lang + foreach (Language::getLanguages(false) as $language) + { + // Data are validated by method "hookPostProcessAttribute" + $id_lang = (int)$language['id_lang']; + Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_attribute_lang + VALUES ('.(int)$params['id_attribute'].', '.$id_lang.', \''.Tools::link_rewrite(Tools::getValue('url_name_'.$id_lang)).'\', + \''.pSQL(htmlspecialchars(Tools::getValue('meta_title_'.$id_lang))).'\')'); + } + } + + public function hookAfterDeleteAttribute($params) + { + if (!$params['id_attribute']) + return; + Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_lang WHERE id_attribute = '.(int)$params['id_attribute']); + } + + public function hookPostProcessAttribute($params) + { + $this->hookPostProcessAttributeGroup($params); + } + + public function hookAttributeForm($params) + { + $languages = Language::getLanguages(false); + $default_form_language = (int)(Configuration::get('PS_LANG_DEFAULT')); + $langValue = array(); + + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS( + 'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_attribute_lang + WHERE id_attribute = '.(int)$params['id_attribute']); + if ($result) + foreach ($result as $data) + $langValue[$data['id_lang']] = array('url_name' => $data['url_name'], 'meta_title' => $data['meta_title']); + $return = '
    + +
    + '; + foreach ($languages as $language) + $return .= ' +
    + + '.$this->l('Invalid characters:').' <>;=#{}_  +

    '.$this->l('Specific format in url block layered generation').'

    +
    '; + $return .= $this->displayFlags($languages, $default_form_language, 'flag_fields', 'url_name', true, true); + $return .= ' +
    +
    + +
    '; + foreach ($languages as $language) + $return .= ' +
    + +

    '.$this->l('Specific format for meta title').'

    +
    '; + $return .= $this->displayFlags($languages, $default_form_language, 'flag_fields', 'meta_title', true, true); + $return .= ' +
    +
    '; + return $return; + } + + public function hookPostProcessFeature($params) + { + $this->hookPostProcessAttributeGroup($params); } public function hookAfterDeleteFeature($params) @@ -383,6 +633,37 @@ class BlockLayered extends Module Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group WHERE id_attribute_group = '.(int)$params['id_attribute_group']); Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_attribute_group VALUES ('.(int)$params['id_attribute_group'].', '.(int)Tools::getValue('layered_indexable').')'); + + Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group_lang WHERE id_attribute_group = '.(int)$params['id_attribute_group']); // don't care about the id_lang + foreach (Language::getLanguages(false) as $language) + { + // Data are validated by method "hookPostProcessAttributeGroup" + $id_lang = (int)$language['id_lang']; + Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'layered_indexable_attribute_group_lang + VALUES ('.(int)$params['id_attribute_group'].', '.$id_lang.', \''.Tools::link_rewrite(Tools::getValue('url_name_'.$id_lang)).'\', + \''.pSQL(htmlspecialchars(Tools::getValue('meta_title_'.$id_lang))).'\')'); + } + } + + public function hookPostProcessAttributeGroup($params) + { + // Limit to one call + static $once = false; + if ($once) + return; + $once = true; + + $errors = array(); + foreach (Language::getLanguages(false) as $language) + { + $id_lang = $language['id_lang']; + if (Tools::getValue('url_name_'.$id_lang)) + if (Tools::link_rewrite(Tools::getValue('url_name_'.$id_lang)) != strtolower( Tools::getValue('url_name_'.$id_lang))) + { + // Here use the reference "errors" to stop saving process + $params['errors'][] = Tools::displayError(sprintf($this->l('"%s" is not a valid url'), Tools::getValue('url_name_'.$id_lang))); + } + } } public function hookAfterDeleteAttributeGroup($params) @@ -391,17 +672,58 @@ class BlockLayered extends Module return; Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group WHERE id_attribute_group = '.(int)$params['id_attribute_group']); + Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_indexable_attribute_group_lang WHERE id_attribute_group = '.(int)$params['id_attribute_group']); } public function hookAttributeGroupForm($params) { + $languages = Language::getLanguages(false); + $default_form_language = (int)(Configuration::get('PS_LANG_DEFAULT')); $indexable = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT indexable FROM '._DB_PREFIX_.'layered_indexable_attribute_group WHERE id_attribute_group = '.(int)$params['id_attribute_group']); + $langValue = array(); + + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS( + 'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_attribute_group_lang + WHERE id_attribute_group = '.(int)$params['id_attribute_group']); + if ($result) + foreach ($result as $data) + $langValue[$data['id_lang']] = array('url_name' => $data['url_name'], 'meta_title' => $data['meta_title']); + if($indexable === false) $on = true; else $on = (bool)$indexable; - return ' + $return = '
    + +
    + '; + foreach ($languages as $language) + $return .= ' +
    + + '.$this->l('Invalid characters:').' <>;=#{}_  +

    '.$this->l('Specific format in url block layered generation').'

    +
    '; + $return .= $this->displayFlags($languages, $default_form_language, 'flag_fields', 'url_name', true, true); + $return .= ' +
    +
    + +
    '; + foreach ($languages as $language) + $return .= ' +
    + +

    '.$this->l('Specific format for meta title').'

    +
    '; + $return .= $this->displayFlags($languages, $default_form_language, 'flag_fields', 'meta_title', true, true); + $return .= ' +
    +
    +
    @@ -409,25 +731,67 @@ class BlockLayered extends Module

    '.$this->l('Use this attribute in url generated by the module block layered navigation').'

    '; + return $return; } public function hookFeatureForm($params) { + $languages = Language::getLanguages(false); + $default_form_language = (int)(Configuration::get('PS_LANG_DEFAULT')); $indexable = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT indexable FROM '._DB_PREFIX_.'layered_indexable_feature WHERE id_feature = '.(int)$params['id_feature']); + $langValue = array(); + + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS( + 'SELECT url_name, meta_title, id_lang FROM '._DB_PREFIX_.'layered_indexable_feature_lang + WHERE id_feature = '.(int)$params['id_feature']); + if ($result) + foreach ($result as $data) + $langValue[$data['id_lang']] = array('url_name' => $data['url_name'], 'meta_title' => $data['meta_title']); + + if($indexable === false) $on = true; else $on = (bool)$indexable; - return ' + $return = '
    + +
    + '; + foreach ($languages as $language) + $return .= ' +
    + + '.$this->l('Invalid characters:').' <>;=#{}_  +

    '.$this->l('Specific format in url block layered generation').'

    +
    '; + $return .= $this->displayFlags($languages, $default_form_language, 'flag_fields', 'url_name', true, true); + $return .= ' +
    +
    + +
    '; + foreach ($languages as $language) + $return .= ' +
    + +

    '.$this->l('Specific format for meta title').'

    +
    '; + $return .= $this->displayFlags($languages, $default_form_language, 'flag_fields', 'meta_title', true, true); + $return .= ' +
    +
    -

    '.$this->l('Use this feature in url generated by the module block layered navigation').'

    +

    '.$this->l('Use this attribute in url generated by the module block layered navigation').'

    '; + return $return; } /* @@ -456,10 +820,10 @@ class BlockLayered extends Module else $nbProducts = (int)Db::getInstance()->getValue( 'SELECT COUNT(*) FROM `'._DB_PREFIX_.'product` p - LEFT JOIN `'._DB_PREFIX_.'price_static_index` psi ON (psi.id_product = p .id_product) + LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product) WHERE `active` = 1 AND psi.id_product IS NULL'); - $maxExecutionTime = ini_get('max_execution_time') * 0.9; // 90% of safety margin + $maxExecutionTime = @ini_get('max_execution_time'); if ($maxExecutionTime > 5 || $maxExecutionTime <= 0) $maxExecutionTime = 5; @@ -470,11 +834,11 @@ class BlockLayered extends Module $cursor = (int)self::_index((int)$cursor, $full, $smart); $timeElapsed = microtime(true) - $startTime; } - while($cursor < $nbProducts AND (Tools::getMemoryLimit() * 0.9) > memory_get_peak_usage() AND $timeElapsed < $maxExecutionTime); + while ($cursor < $nbProducts AND (Tools::getMemoryLimit()) > memory_get_peak_usage() AND $timeElapsed < $maxExecutionTime); if (($nbProducts > 0 AND !$full OR $cursor < $nbProducts AND $full) AND !$ajax) { - if (!Tools::file_get_contents(Tools::getProtocol().Tools::getHttpHost().'/modules/blocklayered/blocklayered-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&cursor='.(int)$cursor.'&full='.(int)$full)) + if (!Tools::file_get_contents(Tools::getProtocol().Tools::getHttpHost().'/modules/blocklayered/blocklayered-indexer.php?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&cursor='.(int)$cursor.'&full='.(int)$full)) self::_indexer((int)$cursor, (int)$full); return $cursor; } @@ -512,7 +876,7 @@ class BlockLayered extends Module $query = ' SELECT p.id_product FROM `'._DB_PREFIX_.'product` p - LEFT JOIN `'._DB_PREFIX_.'price_static_index` psi ON (psi.id_product = p.id_product) + LEFT JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product) WHERE `active` = 1 AND psi.id_product is null ORDER by id_product LIMIT 0,'.(int)$length; @@ -527,9 +891,11 @@ class BlockLayered extends Module static $groups = null; if (is_null($groups)) + { $groups = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT id_group FROM `'._DB_PREFIX_.'group_reduction`'); if(!$groups) $groups = array(); + } static $currencyList = null; if (is_null($currencyList)) @@ -539,7 +905,7 @@ class BlockLayered extends Module $maxPrice = array(); if ($smart) - Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'price_static_index` WHERE `id_product` = '.(int)$idProduct); + Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'layered_price_index` WHERE `id_product` = '.(int)$idProduct); $maxTaxRate = Db::getInstance()->getValue(' SELECT max(t.rate) max_rate @@ -619,7 +985,7 @@ class BlockLayered extends Module $values[] = '('.(int)$idProduct.', '.(int)$currency['id_currency'].', '.(int)$minPrice[$currency['id_currency']].', '.(int)$maxPrice[$currency['id_currency']].')'; Db::getInstance()->Execute(' - INSERT INTO `'._DB_PREFIX_.'price_static_index` (id_product, id_currency, price_min, price_max) + INSERT INTO `'._DB_PREFIX_.'layered_price_index` (id_product, id_currency, price_min, price_max) VALUES '.implode(',', $values)); } @@ -646,24 +1012,22 @@ class BlockLayered extends Module $categoryTitle = (empty($category->meta_title[$idLang])?$category->name[$idLang]:$category->meta_title[$idLang]); // Generate meta title and meta description - $selectedFilters = $this->getSelectedFilters(); - $filterBlock = self::getFilterBlock($selectedFilters); + $filterBlock = self::getFilterBlock($this->getSelectedFilters()); $title = ''; if (is_array($filterBlock['title_values'])) foreach ($filterBlock['title_values'] as $key => $val) $title .= $key.' '.implode('/', $val).' – '; $title = rtrim($title, ' – '); - $metaComplement = $title; - $metaKeyWordsComplement = substr(str_replace(' – ', ', ', strtolower($title)), 1000); - if (!empty($metaComplement)) + if (!empty($title)) { - $smarty->assign('meta_title', ucfirst(strtolower(str_replace(' - '.Configuration::get('PS_SHOP_NAME'), ' – '.$metaComplement.' - '.Configuration::get('PS_SHOP_NAME'), $categoryMetas['meta_title'])))); - $smarty->assign('meta_description', rtrim($categoryTitle.' – '.$metaComplement.' – '.$categoryMetas['meta_description'], ' – ')); + $smarty->assign('meta_title', ucfirst(strtolower(preg_replace('/^'.$categoryTitle.'/', $categoryTitle.' – '.$title, $categoryMetas['meta_title'])))); + $smarty->assign('meta_description', rtrim($categoryTitle.' – '.$title.' – '.$categoryMetas['meta_description'], ' – ')); } else $smarty->assign('meta_title', ucfirst(strtolower($categoryMetas['meta_title']))); + $metaKeyWordsComplement = substr(str_replace(' – ', ', ', strtolower($title)), 1000); if (!empty($metaKeyWordsComplement)) $smarty->assign('meta_keywords', rtrim($categoryTitle.', '.$metaKeyWordsComplement.', '.$categoryMetas['meta_keywords'], ', ')); @@ -715,7 +1079,6 @@ class BlockLayered extends Module if (Tools::isSubmit('SubmitFilter')) { - if(!Tools::getValue('layered_tpl_name')) $html .= '
    @@ -733,7 +1096,7 @@ class BlockLayered extends Module { Db::getInstance()->Execute('TRUNCATE TABLE '._DB_PREFIX_.'layered_filter'); $categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT id_category FROM '._DB_PREFIX_.'category'); - foreach ($categories AS $category) + foreach ($categories as $category) $_POST['categoryBox'][] = (int)$category['id_category']; } @@ -741,20 +1104,20 @@ class BlockLayered extends Module { /* Clean categoryBox before use */ if (isset($_POST['categoryBox']) AND is_array($_POST['categoryBox'])) - foreach ($_POST['categoryBox'] AS &$categoryBoxTmp) + foreach ($_POST['categoryBox'] as &$categoryBoxTmp) $categoryBoxTmp = (int)$categoryBoxTmp; Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'layered_category WHERE id_category IN ('.implode(',', $_POST['categoryBox']).')'); $filterValues = array(); - foreach ($_POST['categoryBox'] AS $idc) + foreach ($_POST['categoryBox'] as $idc) $filterValues['categories'][] = (int)$idc; $sqlToInsert = 'INSERT INTO '._DB_PREFIX_.'layered_category (id_category, id_value, type, position) VALUES '; - foreach ($_POST['categoryBox'] AS $id_category_layered) + foreach ($_POST['categoryBox'] as $id_category_layered) { $n = 0; - foreach ($_POST AS $key => $value) + foreach ($_POST as $key => $value) if (substr($key, 0, 17) == 'layered_selection' AND $value == 'on') { $filterValues[$key] = $value; @@ -851,22 +1214,25 @@ class BlockLayered extends Module if($category['id_category'] != 1) $categoryList[] = $category['id_category']; - $html .= ' - '.$this->l('Index all missing prices').' + '.$this->l('Index all missing prices').'
    - '.$this->l('Re-build entire price index').' + '.$this->l('Re-build entire price index').'
    - '.$this->l('Build url index').' + '.$this->l('Build attribute index').' +
    + '.$this->l('Build url index').'

    '.$this->l('You can set a cron job that will re-build price index using the following URL:').'
    '.Tools::getProtocol().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&full=1
    '.$this->l('You can set a cron job that will re-build url index using the following URL:').'
    '.Tools::getProtocol().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-url-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&truncate=1 +
    + '.$this->l('You can set a cron job that will re-build attribute index using the following URL:').'
    '.Tools::getProtocol().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-attribute-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'

    '.$this->l('A nightly rebuild is recommended.').'
diff --git a/modules/blockpermanentlinks/blockpermanentlinks.tpl b/modules/blockpermanentlinks/blockpermanentlinks.tpl index 1db6b6fa8..fcf3567f4 100644 --- a/modules/blockpermanentlinks/blockpermanentlinks.tpl +++ b/modules/blockpermanentlinks/blockpermanentlinks.tpl @@ -42,4 +42,4 @@ writeBookmarkLink('{$come_from}', '{$shop_name|addslashes|addslashes}', '{l s='bookmark this page' mod='blockpermanentlinks'}', '{$img_dir}icon/star.gif'); 
- + \ No newline at end of file diff --git a/modules/blockrss/blockrss.php b/modules/blockrss/blockrss.php index 6a12ed143..a9e0bf823 100644 --- a/modules/blockrss/blockrss.php +++ b/modules/blockrss/blockrss.php @@ -44,7 +44,7 @@ class Blockrss extends Module $this->displayName = $this->l('RSS feed block'); $this->description = $this->l('Adds a block displaying an RSS feed.'); - $this->version = '1.0'; + $this->version = '1.1'; $this->author = 'PrestaShop'; $this->error = false; $this->valid = false; @@ -65,34 +65,51 @@ class Blockrss extends Module if (Tools::isSubmit('submitBlockRss')) { + $errors = array(); $urlfeed = strval(Tools::getValue('urlfeed')); $title = strval(Tools::getValue('title')); $nbr = (int)(Tools::getValue('nbr')); + if ($urlfeed AND !Validate::isUrl($urlfeed)) $errors[] = $this->l('Invalid feed URL'); elseif (!$title OR empty($title) OR !Validate::isGenericName($title)) $errors[] = $this->l('Invalid title'); elseif (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr)) $errors[] = $this->l('Invalid number of feeds'); + elseif (stristr($urlfeed, $_SERVER['HTTP_HOST'].__PS_BASE_URI__)) + $errors[] = $this->l('You have selected a feed URL on your own website. Please choose another URL'); + elseif (!($contents = @file_get_contents($urlfeed))) + $errors[] = $this->l('Feed is unreacheable, check your URL'); + /* Even if the feed was reachable, We need to make sure that the feed is well formated */ else { - if (stristr($urlfeed, $_SERVER['HTTP_HOST'].__PS_BASE_URI__)) - $errors[] = $this->l('Error: You have selected a feed URL on your own website. Please choose another URL (eg. http://news.google.com/?output=rss).'); + try + { + $xmlFeed = new XML_Feed_Parser($contents); + } + catch (XML_Feed_Parser_Exception $e) + { + $errors[] = $this->l('Invalid feed:').' '.$e->getMessage(); + } + } + + if (!sizeof($errors)) + { Configuration::updateValue('RSS_FEED_URL', $urlfeed); Configuration::updateValue('RSS_FEED_TITLE', $title); Configuration::updateValue('RSS_FEED_NBR', $nbr); - } - if (isset($errors) AND sizeof($errors)) - $output .= $this->displayError(implode('
', $errors)); - else + $output .= $this->displayConfirmation($this->l('Settings updated')); + } + else + $output .= $this->displayError(implode('
', $errors)); } else { $errors = array(); if (stristr(Configuration::get('RSS_FEED_URL'), $_SERVER['HTTP_HOST'].__PS_BASE_URI__)) - $errors[] = $this->l('Error: You have selected a feed URL on your own website. Please choose another URL (eg. http://news.google.com/?output=rss).'); + $errors[] = $this->l('You have selected a feed URL on your own website. Please choose another URL'); if (sizeof($errors)) $output .= $this->displayError(implode('
', $errors)); @@ -115,7 +132,7 @@ class Blockrss extends Module
-

'.$this->l('Add the URL of the feed you want to use').'

+

'.$this->l('Add the URL of the feed you want to use (sample: http://news.google.com/?output=rss)').'

@@ -141,10 +158,17 @@ class Blockrss extends Module // Getting data $rss_links = array(); if ($url && ($contents = @file_get_contents($url))) + try + { if (@$src = new XML_Feed_Parser($contents)) for ($i = 0; $i < ($nb ? $nb : 5); $i++) if (@$item = $src->getEntryByOffset($i)) $rss_links[] = array('title' => $item->title, 'url' => $item->link); + } + catch (XML_Feed_Parser_Exception $e) + { + Tools::dieOrLog(Tools::displayError('Error: invalid RSS feed in blockrss module').' '.$e->getMessage(), false); + } // Display smarty $this->context->smarty->assign(array('title' => ($title ? $title : $this->l('RSS feed')), 'rss_links' => $rss_links)); @@ -161,6 +185,4 @@ class Blockrss extends Module { $this->context->controller->addCSS(($this->_path).'blockrss.css', 'all'); } -} - - +} \ No newline at end of file diff --git a/modules/blockrss/config.xml b/modules/blockrss/config.xml index 899e7be8d..e8a24a7b8 100755 --- a/modules/blockrss/config.xml +++ b/modules/blockrss/config.xml @@ -2,7 +2,7 @@ blockrss - + diff --git a/modules/ebay/config.xml b/modules/ebay/config.xml index 2f7992d34..19df444fd 100755 --- a/modules/ebay/config.xml +++ b/modules/ebay/config.xml @@ -2,7 +2,7 @@ ebay - + diff --git a/modules/ebay/eBayRequest.php b/modules/ebay/eBayRequest.php index 29ec725ea..0ebf7fa22 100755 --- a/modules/ebay/eBayRequest.php +++ b/modules/ebay/eBayRequest.php @@ -57,7 +57,7 @@ class eBayRequest private $compatibilityLevel; - + private $debug = true; /******************************************************************/ /** Constructor And Request Methods *******************************/ @@ -125,6 +125,14 @@ class eBayRequest // Close the connection curl_close($connection); + // Debug + if ($this->debug == true) + { + if (!file_exists(dirname(__FILE__).'/log/request.php')) + file_put_contents(dirname(__FILE__).'/log/request.php', "'."\n"; foreach ($datas['variationsList'] as $group => $v) + if (isset($group) && !empty($group)) { $requestXml .= ' '."\n"; $requestXml .= ' '.$group.''."\n"; @@ -1049,7 +1058,7 @@ class eBayRequest $requestXml .= ' '.$CreateTimeFrom.''."\n"; $requestXml .= ' '.$CreateTimeTo.''."\n"; $requestXml .= ' Seller'."\n"; - $requestXml .= ' Completed'."\n"; + //$requestXml .= ' Completed'."\n"; $requestXml .= ' '."\n"; $requestXml .= ' 100'."\n"; $requestXml .= ' '.$page.''."\n"; diff --git a/modules/ebay/ebay.php b/modules/ebay/ebay.php index a1b5ada85..8d08f8af6 100755 --- a/modules/ebay/ebay.php +++ b/modules/ebay/ebay.php @@ -59,7 +59,7 @@ class Ebay extends Module { $this->name = 'ebay'; $this->tab = 'market_place'; - $this->version = '1.2.4'; + $this->version = '1.2.5'; $this->author = 'PrestaShop'; parent::__construct (); $this->displayName = $this->l('eBay'); @@ -329,7 +329,7 @@ class Ebay extends Module // init Var $dateNew = date('Y-m-d').'T'.date('H:i:s').'.000Z'; - if (Configuration::get('EBAY_ORDER_LAST_UPDATE') < date('Y-m-d', strtotime('-45 minutes')).'T'.date('H:i:s', strtotime('-45 minutes')).'.000Z') + if (Configuration::get('EBAY_ORDER_LAST_UPDATE') < date('Y-m-d', strtotime('-30 minutes')).'T'.date('H:i:s', strtotime('-30 minutes')).'.000Z') { // Lock Configuration::updateValue('EBAY_ORDER_LAST_UPDATE', $dateNew); @@ -351,7 +351,9 @@ class Ebay extends Module } if ($orderList) - foreach ($orderList as $order) + { + foreach ($orderList as $korder => $order) + { if ($order['status'] == 'Complete' && $order['amount'] > 0.1 && isset($order['product_list']) && count($order['product_list'])) { if (!Db::getInstance()->getValue('SELECT `id_ebay_order` FROM `'._DB_PREFIX_.'ebay_order` WHERE `id_order_ref` = \''.pSQL($order['id_order_ref']).'\'')) @@ -473,10 +475,23 @@ class Ebay extends Module // Register the ebay order ref Db::getInstance()->autoExecute(_DB_PREFIX_.'ebay_order', array('id_order_ref' => pSQL($order['id_order_ref']), 'id_order' => (int)$id_order), 'INSERT'); } + else + $orderList[$korder]['errors'][] = $this->l('Could not add product to cart (maybe your stock quantity is 0)'); } + else + $orderList[$korder]['errors'][] = $this->l('Could not found products in database'); } + else + $orderList[$korder]['errors'][] = $this->l('Invalid e-mail'); } + else + $orderList[$korder]['errors'][] = $this->l('Order already imported'); } + else + $orderList[$korder]['errors'][] = $this->l('Status not complete or amount less than 0.1 or no product matching'); + } + file_put_contents(dirname(__FILE__).'/log/orders.php', "hookaddproduct($params); } - public function hookupdateProductAttribute($params) { $this->hookaddproduct($params); } + public function hookupdateProductAttribute($params) + { + $id_product = Db::getInstance()->getValue('SELECT `id_product` FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product_attribute` = '.(int)$params['id_product_attribute']); + $params['product'] = new Product($id_product); + $this->hookaddproduct($params); + } public function hookdeleteproduct($params) { $this->hookaddproduct($params); } public function hookheader($params) { $this->hookbackOfficeTop($params); } public function hookbackOfficeFooter($params) { $this->hookbackOfficeTop($params); } @@ -548,7 +568,7 @@ class Ebay extends Module // Displaying Information from Prestashop - $stream_context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 2))); + $stream_context = @stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 2))); $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); if (!Validate::isCleanHtml($prestashopContent)) $prestashopContent = ''; @@ -710,14 +730,16 @@ class Ebay extends Module - + +
- + +


@@ -882,6 +904,12 @@ class Ebay extends Module if (!Configuration::get('EBAY_PAYPAL_EMAIL')) return '

'.$this->l('You have to configure "General Settings" tab before using this tab.').'


'; + // Load categories only if necessary + if (Db::getInstance()->getValue('SELECT COUNT(`id_ebay_category_configuration`) FROM `'._DB_PREFIX_.'ebay_category_configuration`') > 4 && Tools::getValue('section') != 'category') + return '

'.$this->l('Your categories have already been configured.').'

+
+

'; + // Display eBay Categories if (!Configuration::get('EBAY_CATEGORY_LOADED')) { @@ -1358,7 +1386,7 @@ class Ebay extends Module // Empty error result Configuration::updateValue('EBAY_SYNC_LAST_PRODUCT', 0); - @unlink('../modules/ebay/ajax/_ebaySyncError.log.php'); + @unlink(dirname(__FILE__).'/log/syncError.php'); if ($_POST['ebay_sync_mode'] == 'A') { @@ -1450,10 +1478,10 @@ class Ebay extends Module else { echo 'OK|'.$this->displayConfirmation($this->l('Settings updated').' ('.$this->l('Option').' '.Configuration::get('EBAY_SYNC_MODE').' : '.($nbProductsTotal - $nbProductsLess).' / '.$nbProductsTotal.' '.$this->l('product(s) sync with eBay').')'); - if (file_exists('_ebaySyncError.log.php')) + if (file_exists(dirname(__FILE__).'/log/syncError.php')) { global $tab_error; - include('_ebaySyncError.log.php'); + include(dirname(__FILE__).'/log/syncError.php'); foreach ($tab_error as $error) { $productsDetails = '
'.$this->l('Product(s) concerned').' :'; @@ -1462,7 +1490,7 @@ class Ebay extends Module echo $this->displayError($error['msg'].'
'.$productsDetails); } echo ''; - @unlink('_ebaySyncError.log.php'); + @unlink(dirname(__FILE__).'/log/syncError.php'); } } } @@ -1479,10 +1507,10 @@ class Ebay extends Module $categoryDefaultCache = array(); // Get errors back - if (file_exists('_ebaySyncError.log.php')) + if (file_exists(dirname(__FILE__).'/log/syncError.php')) { global $tab_error; - include('_ebaySyncError.log.php'); + include(dirname(__FILE__).'/log/syncError.php'); } // Up the time limit @@ -1816,10 +1844,76 @@ class Ebay extends Module } if ($count_error > 0) - file_put_contents('_ebaySyncError.log.php', ''); + file_put_contents(dirname(__FILE__).'/log/syncError.php', ''); } + + + /******************************************************************/ + /** Orders History Methods *******************************************/ + /******************************************************************/ + + private function _displayOrdersHistory() + { + // Check if the module is configured + if (!Configuration::get('EBAY_PAYPAL_EMAIL')) + return '

'.$this->l('You have to configure "General Settings" tab before using this tab.').'


'; + + + $dateLastImport = '-'; + if (file_exists(dirname(__FILE__).'/log/orders.php')) + include(dirname(__FILE__).'/log/orders.php'); + $html = '

'.$this->l('Last orders Importation').' :

'.$dateLastImport.'



+

'.$this->l('Orders History').' :

'; + + if (isset($orderList) && count($orderList) > 0) + foreach ($orderList as $order) + { + $html .= ' +

+ '.$this->l('Order Ref eBay').' : '.$order['id_order_ref'].'
+ '.$this->l('Id Order Seller').' : '.$order['id_order_seller'].'
+ '.$this->l('Amount').' : '.$order['amount'].'
+ '.$this->l('Status').' : '.$order['status'].'
+ '.$this->l('Date').' : '.$order['date'].'
+ '.$this->l('E-mail').' : '.$order['email'].'
+ '.$this->l('Products').' :
'; + if (isset($order['product_list']) && count($order['product_list']) > 0) + { + $html .= ' + + + '; + foreach ($order['product_list'] as $product) + $html .= ' + + + '; + $html .= '
'.$this->l('Id Product').''.$this->l('Id Product Attribute').''.$this->l('Quantity').''.$this->l('Price').'
'.$product['id_product'].''.$product['id_product'].''.$product['quantity'].''.$product['price'].'
'; + } + if (isset($order['errors']) && count($order['errors']) > 0) + { + $html .= ''.$this->l('Status Import').' : KO
'; + $html .= ''.$this->l('Failure details').' :
'; + foreach ($order['errors'] as $error) + $html .= $error.'t
'; + } + else + $html .= ''.$this->l('Status Import').' : OK'; + $html .= '


'; + } + + + return $html; + } + + + /******************************************************************/ /** Help Config Methods *******************************************/ /******************************************************************/ diff --git a/modules/ebay/fr.php b/modules/ebay/fr.php index ed96f706c..2a277ef86 100755 --- a/modules/ebay/fr.php +++ b/modules/ebay/fr.php @@ -9,6 +9,11 @@ $_MODULE['<{ebay}prestashop>ebay_8acabcc788c316f92b7850c76265b49b'] = 'Vous deve $_MODULE['<{ebay}prestashop>ebay_d591cbc447d01e5a6165096ebfdf804e'] = 'Vous devez activer l\'extension cURL sur votre serveur si vous désirez utiliser ce module.'; $_MODULE['<{ebay}prestashop>ebay_1b18bd5d9d85f4f667614345ee20e3b2'] = 'Vous devez activer l\'option allow_url_fopen sur votre serveur si vous désirez utiliser ce module.'; $_MODULE['<{ebay}prestashop>ebay_8e64bc164aee46723ed2d70273c6f8ab'] = 'Vous devez enregistrer le module sur eBay'; +$_MODULE['<{ebay}prestashop>ebay_5f8d9c30e0606a91c5d7b6e1bf1217ac'] = 'N\'a pas pu ajouté les produits au panier (peut être votre stock est il à 0)'; +$_MODULE['<{ebay}prestashop>ebay_25fff46a6fe5b9512e2f4054f4ff6060'] = 'N\'a pas pu trouvé les produits dans votre catalogue'; +$_MODULE['<{ebay}prestashop>ebay_eaa0d1591e6369a298dcd6cb1a8eba8a'] = 'E-mail invalide'; +$_MODULE['<{ebay}prestashop>ebay_a11a07346e4343b393b7a6d29924043e'] = 'Commande déjà importé'; +$_MODULE['<{ebay}prestashop>ebay_2e7adc61fa0cedcf1d442feafbaea1de'] = 'Le statut n\'est pas à \"Complete\" ou le montant de la commande est inférieur à 0.1 ou aucun produit n\'a pu être trouvé dans votre catalogue'; $_MODULE['<{ebay}prestashop>ebay_98f54d8bba6523829eeb8fd7ab9a2088'] = 'Continuer quand même ?'; $_MODULE['<{ebay}prestashop>ebay_2e4f4d8b849fb72905addc231d160e8b'] = 'Status du module eBay'; $_MODULE['<{ebay}prestashop>ebay_85f9d92e0551772437b934b7222d63cb'] = 'Le module eBay est fonctionnel.'; @@ -25,6 +30,7 @@ $_MODULE['<{ebay}prestashop>ebay_3225a10b07f1580f10dee4abc3779e6c'] = 'Paramètr $_MODULE['<{ebay}prestashop>ebay_dc2f736ed903b4f6f72a36b763cd7717'] = 'Configuration des catégories'; $_MODULE['<{ebay}prestashop>ebay_0f5f872ba4c6575319e6beee6ebcc481'] = 'Template de la fiche produit'; $_MODULE['<{ebay}prestashop>ebay_47ba6504eb5b1e3a95ea3dbd960904db'] = 'Mise en ligne des produits'; +$_MODULE['<{ebay}prestashop>ebay_1a6f6b88447d4c3a86da93913a1b844d'] = 'Historique des commandes'; $_MODULE['<{ebay}prestashop>ebay_6a26f548831e6a8c26bfbbd9f6ec61e0'] = 'Aide'; $_MODULE['<{ebay}prestashop>ebay_e5beb503fe9553f0ed5be3c324fc9cb7'] = 'Pour exporter vos produits sur eBay, vous devez créer un compte pro sur eBay (voir la partie Aide) et configurer le module eBay-Prestashop.'; $_MODULE['<{ebay}prestashop>ebay_230b8b5e65ef7731d72a42b1ddb0293f'] = 'Identifiant eBay'; @@ -49,6 +55,8 @@ $_MODULE['<{ebay}prestashop>ebay_458d329d5eb1caf63615141fb51e8329'] = 'Votre cod $_MODULE['<{ebay}prestashop>ebay_c888438d14855d7d96a2724ee9c306bd'] = 'Configuration mise à jour'; $_MODULE['<{ebay}prestashop>ebay_b9284bff13acffdd879ef4ac7fca5234'] = 'Configuration non mise à jour.'; $_MODULE['<{ebay}prestashop>ebay_67e19ffdaa0a11e69349810403a9727e'] = 'Vous devez configurer l\'onglet \"Paramètres\" avant d\'utiliser cet onglet.'; +$_MODULE['<{ebay}prestashop>ebay_0706a152f5e26f0cbce3de5269c54f30'] = 'Vos catégories ont déjà été configurés'; +$_MODULE['<{ebay}prestashop>ebay_2b827fb3fb7f3fb4304b286764b18f1e'] = 'Voir les catégories'; $_MODULE['<{ebay}prestashop>ebay_1fe6b0032a7882ef20d08a5386441e33'] = 'Pour mettre en ligne vos produits sur eBay, vous devez associer chacune des catégories de votre boutique à une catégorie eBay. Vous pouvez également définir une variation du prix sur eBay.'; $_MODULE['<{ebay}prestashop>ebay_1bffdb0b10182ea51f7baa97ee2d19a8'] = 'Vous pouvez utiliser le bouton ci-dessous pour associer automatiquement les catégories qui n\'ont pas encore d\'association avec des catégories suggérées par eBay.'; $_MODULE['<{ebay}prestashop>ebay_36be9eda23888bf12f74d6cd9d46ba1d'] = 'Suggérer des catégories'; @@ -81,3 +89,18 @@ $_MODULE['<{ebay}prestashop>ebay_caab0e2c2f3ae0d242b0b36f22d9acc5'] = 'Vous alle $_MODULE['<{ebay}prestashop>ebay_70b240eb3db5174e1c9520cabe2ae781'] = 'produits sur eBay. Voulez-vous confirmer ?'; $_MODULE['<{ebay}prestashop>ebay_547c708291fe196592dd1e4db7b206a5'] = 'produit(s) mis en ligne sur eBay'; $_MODULE['<{ebay}prestashop>ebay_1761efb946aa43c14af989665dae691a'] = 'Produit(s) concerné(s)'; +$_MODULE['<{ebay}prestashop>ebay_04a338309915f11c8b8052a1c1ff7d84'] = 'Dernière importation des commandes'; +$_MODULE['<{ebay}prestashop>ebay_45ad2eef89200b7037c5062688740213'] = 'Historiques des commandes'; +$_MODULE['<{ebay}prestashop>ebay_1b5f52a88052dce1423a8c0cb19d6ee9'] = 'Référence commande eBay'; +$_MODULE['<{ebay}prestashop>ebay_af63fd747d7a33367a4399d0c21c30d3'] = 'Référence commande vendeur'; +$_MODULE['<{ebay}prestashop>ebay_b2f40690858b404ed10e62bdf422c704'] = 'Montant'; +$_MODULE['<{ebay}prestashop>ebay_ec53a8c4f07baed5d8825072c89799be'] = 'Statut'; +$_MODULE['<{ebay}prestashop>ebay_44749712dbec183e983dcd78a7736c41'] = 'Date'; +$_MODULE['<{ebay}prestashop>ebay_1e884e3078d9978e216a027ecd57fb34'] = 'E-mail'; +$_MODULE['<{ebay}prestashop>ebay_068f80c7519d0528fb08e82137a72131'] = 'Produits'; +$_MODULE['<{ebay}prestashop>ebay_2bff0c18dad806b7e121a0013c7f08a6'] = 'Identifiant produit'; +$_MODULE['<{ebay}prestashop>ebay_b86883a8dc6c44cb39371e3b7aea594f'] = 'Identifiant attribut produit'; +$_MODULE['<{ebay}prestashop>ebay_694e8d1f2ee056f98ee488bdc4982d73'] = 'Quantité'; +$_MODULE['<{ebay}prestashop>ebay_3601146c4e948c32b6424d2c0a7f0118'] = 'Prix'; +$_MODULE['<{ebay}prestashop>ebay_eacb7a77450c68e3936ff0475c010cdb'] = 'Status de l\'import'; +$_MODULE['<{ebay}prestashop>ebay_59fc75ecf1ce372c9ed534d5e545ff88'] = 'Détails de l\'échec de l\'import'; diff --git a/modules/ebay/log/.htaccess b/modules/ebay/log/.htaccess new file mode 100755 index 000000000..93169e4eb --- /dev/null +++ b/modules/ebay/log/.htaccess @@ -0,0 +1,2 @@ +Order deny,allow +Deny from all diff --git a/modules/ebay/log/index.php b/modules/ebay/log/index.php new file mode 100755 index 000000000..1e5d1c442 --- /dev/null +++ b/modules/ebay/log/index.php @@ -0,0 +1,36 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 6594 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/modules/fedexcarrier/RateService_v10.wsdl b/modules/fedexcarrier/RateService_v10.wsdl index 26ea702ec..899d47fdd 100644 --- a/modules/fedexcarrier/RateService_v10.wsdl +++ b/modules/fedexcarrier/RateService_v10.wsdl @@ -4864,7 +4864,7 @@ - + \ No newline at end of file diff --git a/modules/fedexcarrier/config.xml b/modules/fedexcarrier/config.xml index 3e2b10939..c7599ae8c 100755 --- a/modules/fedexcarrier/config.xml +++ b/modules/fedexcarrier/config.xml @@ -2,7 +2,7 @@ fedexcarrier - + diff --git a/modules/fedexcarrier/fedexcarrier.php b/modules/fedexcarrier/fedexcarrier.php index 50980c9f7..79651aabe 100644 --- a/modules/fedexcarrier/fedexcarrier.php +++ b/modules/fedexcarrier/fedexcarrier.php @@ -56,7 +56,7 @@ class FedexCarrier extends CarrierModule { $this->name = 'fedexcarrier'; $this->tab = 'shipping_logistics'; - $this->version = '1.2'; + $this->version = '1.2.1'; $this->author = 'PrestaShop'; $this->limited_countries = array('us'); diff --git a/modules/gcheckout/fr.php b/modules/gcheckout/fr.php index ae6cedc0c..5f10fad29 100644 --- a/modules/gcheckout/fr.php +++ b/modules/gcheckout/fr.php @@ -19,10 +19,13 @@ $_MODULE['<{gcheckout}prestashop>gcheckout_4402acab1c8f90dcf4a31dc96833bd86'] = $_MODULE['<{gcheckout}prestashop>gcheckout_82b8bb0d807e6d2e43a068f954c3559f'] = 'L\'ID marchand semble incorrect'; $_MODULE['<{gcheckout}prestashop>gcheckout_9dd37c2106ceacbf0a40778b2109c386'] = 'La clé marchand semble incorrecte'; $_MODULE['<{gcheckout}prestashop>gcheckout_f4f70727dc34561dfde1a3c529b6205c'] = 'Paramètres'; +$_MODULE['<{gcheckout}prestashop>gcheckout_cd1c5e22d4513c1912be45c9ce9ddbe2'] = 'La version de l\'API utilisée par ce module est la 2.0'; $_MODULE['<{gcheckout}prestashop>gcheckout_a1ffd2dc2538ea3093532029514d42ac'] = 'Utilisez le mode bac à sable pour tester le module avant de l\'utiliser en mode réel. N\'oubliez pas de changer vos clés et ID marchand selon le mode !'; $_MODULE['<{gcheckout}prestashop>gcheckout_650be61892bf690026089544abbd9d26'] = 'Mode'; $_MODULE['<{gcheckout}prestashop>gcheckout_7f80fcc452c2f1ed2bb51b39d0864df1'] = 'Réel'; $_MODULE['<{gcheckout}prestashop>gcheckout_2652eec977dcb2a5aea85f5bec235b05'] = 'Bac à sable'; +$_MODULE['<{gcheckout}prestashop>gcheckout_96fb435ae559f8a759f22f0823d57f7d'] = 'Ne pas oublier de spécifier la devise utilisée dans les onglets de paiement dans la partie de devises'; +$_MODULE['<{gcheckout}prestashop>gcheckout_386c339d37e737a436499d423a77df0c'] = 'Devises'; $_MODULE['<{gcheckout}prestashop>gcheckout_76055653a95e0a559b734ec322d89632'] = 'Vous trouverez ces identifiants dans votre compte Google Checkout > Settings > Integration. Les modes réel et bac à sable ont tous les deux besoin de ces clés.'; $_MODULE['<{gcheckout}prestashop>gcheckout_229a7ec501323b94db7ff3157a7623c9'] = 'ID marchand'; $_MODULE['<{gcheckout}prestashop>gcheckout_795acb9a0c89791314d3032fe65eeb92'] = 'Clé marchand'; diff --git a/modules/importerosc/fr.php b/modules/importerosc/fr.php index f68c35499..598010dff 100644 --- a/modules/importerosc/fr.php +++ b/modules/importerosc/fr.php @@ -12,3 +12,11 @@ $_MODULE['<{importerosc}prestashop>importerosc_a89a64592edf58aee0fc749735902cea' $_MODULE['<{importerosc}prestashop>importerosc_375e6e17d4bd18a5163d3a7d13b80b4b'] = 'Merci de choisir la devise par défaut'; $_MODULE['<{importerosc}prestashop>importerosc_294f0969b5f80f1bae24a7183eb338d5'] = 'Merci de choisir l\'url de la boutique'; $_MODULE['<{importerosc}prestashop>importerosc_86545d77ce5790e924190d9b5a7ac1b6'] = 'Group par défaut OsCommerce'; +$_MODULE['<{importerosc}prestashop>importerosc_9aa1b03934893d7134a660af4204f2a9'] = 'Serveur'; +$_MODULE['<{importerosc}prestashop>importerosc_770b2f7556eecbe5000cfcbddc9f9885'] = '(Ex: mysql.mydomain.com)'; +$_MODULE['<{importerosc}prestashop>importerosc_8f9bfe9d1345237cb3b2b205864da075'] = 'Utilisateur'; +$_MODULE['<{importerosc}prestashop>importerosc_dc647eb65e6711e155375218212b3964'] = 'Mot de passe'; +$_MODULE['<{importerosc}prestashop>importerosc_14ae0ea02f571a833786d13d9ca6a897'] = '(Mot de passe peut être vide)'; +$_MODULE['<{importerosc}prestashop>importerosc_e307db07b3975fef922a80d07455ee5e'] = 'Base de données'; +$_MODULE['<{importerosc}prestashop>importerosc_dac130bdd2c5492a8108a4145bd9f04a'] = 'Préfixe base de données'; +$_MODULE['<{importerosc}prestashop>importerosc_6bdc02625540b5264cffe801c37a82dd'] = '(Le préfixe est optionnel. Si toute votre base de données commence par \"pref_\", votre préfixe est \"pref_\")'; diff --git a/modules/importerosc/importerosc.php b/modules/importerosc/importerosc.php index 4932f3c7b..2ee229e35 100644 --- a/modules/importerosc/importerosc.php +++ b/modules/importerosc/importerosc.php @@ -47,7 +47,7 @@ class importerosc extends ImportModule public function install() { - if (!parent::install() OR !$this->registerHook('beforeAuthentication')) + if (!parent::install() || !$this->registerHook('beforeAuthentication')) return false; return true; } @@ -64,26 +64,23 @@ class importerosc extends ImportModule $langagues = $this->ExecuteS('SELECT * FROM `'.addslashes($this->prefix).'languages`'); $curencies = $this->ExecuteS('SELECT * FROM `'.addslashes($this->prefix).'currencies`'); - $html = ' + $html = '
- '; foreach($langagues AS $lang) $html .= ''; $html .= '
- -
- '; foreach($curencies AS $curency) - $html .= ''; + $html .= ''; $html .= '
'; - $html .= ' -
+ $html .= ' +
http:///

'.$this->l('Specify the root URL of your site oscommerce').'

'; - - - return $html; } diff --git a/modules/loyalty/fr.php b/modules/loyalty/fr.php index 99de87ccf..41e8640a3 100644 --- a/modules/loyalty/fr.php +++ b/modules/loyalty/fr.php @@ -25,6 +25,11 @@ $_MODULE['<{loyalty}prestashop>loyalty_ade45d72ab6ba1ab576d8b9deb0c2438'] = 'Poi $_MODULE['<{loyalty}prestashop>loyalty_9611a682e61c503c32e2dc58fdbc8ddf'] = 'Points annulés au statut suivant'; $_MODULE['<{loyalty}prestashop>loyalty_2a46cccdea2f18fdfdfacf99a98b758d'] = 'Les bons de réductions crées par le système de fidélité peuvent être utilisés dans les catégories d\'articles suivantes :'; $_MODULE['<{loyalty}prestashop>loyalty_8cf04a9734132302f96da8e113e80ce5'] = 'Accueil'; +$_MODULE['<{loyalty}prestashop>loyalty_ef7de3f485174ff47f061ad27d83d0ee'] = 'sélectionné'; +$_MODULE['<{loyalty}prestashop>loyalty_b56c3bda503a8dc4be356edb0cc31793'] = 'Réduire tout'; +$_MODULE['<{loyalty}prestashop>loyalty_5ffd7a335dd836b3373f5ec570a58bdc'] = 'Ouvrir tout'; +$_MODULE['<{loyalty}prestashop>loyalty_5e9df908eafa83cb51c0a3720e8348c7'] = 'Cocher tout'; +$_MODULE['<{loyalty}prestashop>loyalty_9747d23c8cc358c5ef78c51e59cd6817'] = 'Décocher tout'; $_MODULE['<{loyalty}prestashop>loyalty_c2a7db7dec4de1bdb143ccd790f5a62c'] = 'Cocher pour quelle(s) catégorie(s) seront utilisables les bons de réductions fidélité'; $_MODULE['<{loyalty}prestashop>loyalty_30e793698766edbaaf84a74d4c377f72'] = 'Statuts des points de fidélité'; $_MODULE['<{loyalty}prestashop>loyalty_4f2a91e15af2631ff9424564b8a45fb2'] = 'Initial'; diff --git a/modules/mailalerts/mailalerts.php b/modules/mailalerts/mailalerts.php index e14016fd9..d8792adf1 100644 --- a/modules/mailalerts/mailalerts.php +++ b/modules/mailalerts/mailalerts.php @@ -291,9 +291,7 @@ class MailAlerts extends Module $params['product'] = get_object_vars($params['product']); if (is_array($params['product']['name'])) - { $params['product']['name'] = $params['product']['name'][(int)Configuration::get('PS_LANG_DEFAULT')]; - } if (isset($params['product']['id_product'])) $params['product']['id'] = (int)$params['product']['id_product']; diff --git a/modules/mondialrelay/ajax.php b/modules/mondialrelay/ajax.php index d24ded16f..e81f3fee6 100755 --- a/modules/mondialrelay/ajax.php +++ b/modules/mondialrelay/ajax.php @@ -33,10 +33,6 @@ */ require_once(realpath(dirname(__FILE__).'/../../config/config.inc.php')); - -if (Tools::getValue('mrtoken') != sha1('mr'._COOKIE_KEY_.'mrAgain')) - die(); - require_once(realpath(dirname(__FILE__).'/../../init.php')); require(dirname(__FILE__).'/mondialrelay.php'); require(dirname(__FILE__).'/classes/MRCreateTickets.php'); @@ -44,10 +40,30 @@ require(dirname(__FILE__).'/classes/MRGetTickets.php'); require(dirname(__FILE__).'/classes/MRGetRelayPoint.php'); require(dirname(__FILE__).'/classes/MRManagement.php'); +MondialRelay::initModuleAccess(); + +// Access page List liable to the generated token +$accessPageList = array( + MondialRelay::getToken('front') => array( + 'MRGetRelayPoint', + 'addSelectedCarrierToDB'), + MondialRelay::getToken('back') => array( + 'MRGetTickets', + 'MRCreateTickets', + 'MRDeleteHistory', + 'uninstallDetail', + 'DeleteHistory')); + $method = Tools::getValue('method'); +$token = Tools::getValue('mrtoken'); $params = array(); $result = array(); +// If the method name assoacited to the token received doesn't match with +// the list, then we kill the request +if (!isset($accessPageList[$token]) || !in_array($method, $accessPageList[$token])) + exit(); + // Method name allow to instanciate his object to properly call the // implemented interface method and do his job switch($method) @@ -112,4 +128,4 @@ catch(Exception $e) } echo MondialRelay::jsonEncode($result); exit(0); -?> \ No newline at end of file +?> diff --git a/modules/mondialrelay/fr.php b/modules/mondialrelay/fr.php index bdbd272fa..92c79ede1 100755 --- a/modules/mondialrelay/fr.php +++ b/modules/mondialrelay/fr.php @@ -48,6 +48,7 @@ $_MODULE['<{mondialrelay}prestashop>mondialrelay_cb5e100e5a9a3e7f6d1fd9751221528 $_MODULE['<{mondialrelay}prestashop>mondialrelay_350c1cc4343826a89f08a33bb49c6d98'] = 'Configuration du Module Mondial Relay'; $_MODULE['<{mondialrelay}prestashop>mondialrelay_d21a9f93917604d5490ad529a7cf1ff9'] = 'Pour créer un transporteur Mondial Relay'; $_MODULE['<{mondialrelay}prestashop>mondialrelay_c6a2e6af5fff47adb3afd780b97d9b4b'] = 'Remplissez et sauvegarder vos paramètres Mondial Relay'; +$_MODULE['<{mondialrelay}prestashop>mondialrelay_94fbe32464fcfa902feed9f256439833'] = 'Créer un transporteur utilisant le formulaire \"ajouter un transporteur\" ci-dessous'; $_MODULE['<{mondialrelay}prestashop>mondialrelay_b962d8fb95f5a439f50502152f3bad71'] = 'Definissez un prix pour votre transporteur sur'; $_MODULE['<{mondialrelay}prestashop>mondialrelay_faf1247ae6846a9955a466d4f301bbe4'] = 'La page Transporteurs'; $_MODULE['<{mondialrelay}prestashop>mondialrelay_10d78806b84b97ebc774e9f6277af6ac'] = 'Pour générer vos étiquettes, vous devez avoir enregistré une adresse valide de votre boutique sur votre'; diff --git a/modules/mondialrelay/mondialrelay.js b/modules/mondialrelay/mondialrelay.js index 742cfdb5a..babb655b2 100755 --- a/modules/mondialrelay/mondialrelay.js +++ b/modules/mondialrelay/mondialrelay.js @@ -59,7 +59,6 @@ function getTickets(detailedExpeditionList) }, error: function(xhr, ajaxOptions, thrownError) { - //console.log(thrownError); displayBackGenerateSubmitButton(); } }); @@ -311,7 +310,6 @@ function PS_MRGetUninstallDetail() }, error: function(xhr, ajaxOptions, thrownError) { - //console.log(thrownError); // Put debug to see error detail } }); @@ -363,7 +361,6 @@ function PS_MRBackupDatabase() }, error: function(xhr, ajaxOptions, thrownError) { - //console.log(thrownError); // Put debug to see error detail } }); @@ -387,13 +384,9 @@ function PS_MRAddSelectedRelayPointInDB(relayPointNumber, id_carrier) 'mrtoken' : mrtoken}, success: function(json) { - // console.log(json); }, error: function(xhr, ajaxOptions, thrownError) { - //console.log(xhr); - //console.log(thrownError); - //console.log(ajaxOptions); } }); } @@ -415,13 +408,9 @@ function PS_MRAddSelectedCarrierInDB(id_carrier) 'mrtoken' : mrtoken}, success: function(json) { - //console.log(json); }, error: function(xhr, ajaxOptions, thrownError) { - //console.log(xhr); - //console.log(thrownError); - //console.log(ajaxOptions); } }); } @@ -521,7 +510,6 @@ function PS_MRDisplayErrorRelayPoint(errorList, blockContent) blockContent.fadeOut('fast', function() { - console.log($(this)); $(this).children('td').html(''); for (numError in errorList) { @@ -564,7 +552,6 @@ function PS_MRFetchRelayPoint(carrierSelected) }, error: function(xhr, ajaxOptions, thrownError) { - //console.log(thrownError); // Put debug to see error detail } }); @@ -607,6 +594,10 @@ function PS_MRGetRelayPoint(carrierSelected) */ function PS_MRCreateGmap(id_carrier) { + // This has been write this way because it needed to have a known block + // present everytime in the page. Body is the only one sure. + // It's an hidden block it's replaced in the good block when user select his + // own carrier $('body').prepend('\ \ \ diff --git a/modules/mondialrelay/mondialrelay.php b/modules/mondialrelay/mondialrelay.php index f7112d4cc..e9b077dcf 100755 --- a/modules/mondialrelay/mondialrelay.php +++ b/modules/mondialrelay/mondialrelay.php @@ -39,7 +39,8 @@ class MondialRelay extends Module public static $modulePath = ''; public static $moduleURL = ''; - static public $MRToken = ''; + static public $MRFrontToken = ''; + static public $MRBackToken = ''; // Added for 1.3 compatibility const ONLY_PRODUCTS = 1; @@ -171,6 +172,15 @@ class MondialRelay extends Module return true; } + /* + ** Return the token depend of the type + */ + static public function getToken($type = 'front') + { + return ($type == 'front') ? self::$MRFrontToken : (($type == 'back') ? + self::$MRBackToken : NULL); + } + /* ** Register hook depending of the Prestashop version used */ @@ -366,7 +376,8 @@ class MondialRelay extends Module public static function initModuleAccess() { self::$modulePath = _PS_MODULE_DIR_. 'mondialrelay/'; - self::$MRToken = sha1('mr'._COOKIE_KEY_.'mrAgain'); + self::$MRFrontToken = sha1('mr'._COOKIE_KEY_.'Front'); + self::$MRBackToken = sha1('mr'._COOKIE_KEY_.'Back'); $protocol = (Configuration::get('PS_SSL_ENABLED') || (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; @@ -409,7 +420,7 @@ class MondialRelay extends Module '; } @@ -613,7 +624,7 @@ class MondialRelay extends Module $this->context->smarty->assign( array( 'one_page_checkout' => (Configuration::get('PS_ORDER_PROCESS_TYPE') ? Configuration::get('PS_ORDER_PROCESS_TYPE') : 0), 'new_base_dir' => self::$moduleURL, - 'MRToken' => self::$MRToken, + 'MRToken' => self::$MRFrontToken, 'carriersextra' => $carriersList)); return $this->display(__FILE__, 'mondialrelay.tpl'); diff --git a/modules/moneybookers/fr.php b/modules/moneybookers/fr.php index 437ff16d3..969427532 100644 --- a/modules/moneybookers/fr.php +++ b/modules/moneybookers/fr.php @@ -44,9 +44,11 @@ $_MODULE['<{moneybookers}prestashop>moneybookers_3513f0ecb96b6c959454534578ee140 $_MODULE['<{moneybookers}prestashop>moneybookers_64d37ad3bf2f0aee7c8a321321c7e9d9'] = 'J\'ai déjà un compte Moneybookers'; $_MODULE['<{moneybookers}prestashop>moneybookers_b0e8c8326985417a5efdd6649f02e385'] = 'Grâce au partenariat PrestaShop/Moneybookers,'; $_MODULE['<{moneybookers}prestashop>moneybookers_d5086eeb1bc1994c5abf945fd79d4246'] = 'vous bénéficierez d\'un taux de commission préférentiel !'; +$_MODULE['<{moneybookers}prestashop>moneybookers_fd90882b9b7c8653dd645f5e986b5402'] = 'Frais disponible depuis le 21 mars 2011'; $_MODULE['<{moneybookers}prestashop>moneybookers_68db2cda800ddb2ae307c60b0a96252f'] = 'Solution de Paiement en ligne Moneybookers'; $_MODULE['<{moneybookers}prestashop>moneybookers_b9c758264b134743b13a85ca4055c629'] = 'Estimation du volume mensuel passant par Moneybookers'; $_MODULE['<{moneybookers}prestashop>moneybookers_7d294d4900ff1a38f5b0a89612916eac'] = 'Pour les marchands au-dessus de €100,000 des tarifs sur mesure peuvent être mis en place.'; +$_MODULE['<{moneybookers}prestashop>moneybookers_1467fcd161d2aee8146c7808c9377852'] = 'Pour voir la dernière mise à jour des frais détaillés'; $_MODULE['<{moneybookers}prestashop>moneybookers_936ccdb97115e9f35a11d35e3d5b5cad'] = 'Cliquez ici'; $_MODULE['<{moneybookers}prestashop>moneybookers_11c8ff1cde03aa19406dfe5971b92553'] = 'Porte-monnaie électronique Moneybookers'; $_MODULE['<{moneybookers}prestashop>moneybookers_223b661f7b13d33498a9274bb10e3538'] = 'Portail de Paiements Directs Moneybookers '; diff --git a/modules/moneybookers/moneybookers.php b/modules/moneybookers/moneybookers.php index 73f01501f..3084053c6 100644 --- a/modules/moneybookers/moneybookers.php +++ b/modules/moneybookers/moneybookers.php @@ -184,7 +184,7 @@ class MoneyBookers extends PaymentModule $contextOptions = $defaultContextOptions; // Create a stream context - $stream_context = stream_context_create($contextOptions); + $stream_context = @stream_context_create($contextOptions); if (($fp = @fopen($url, $mode, false, $stream_context))) { diff --git a/modules/pagesnotfound/fr.php b/modules/pagesnotfound/fr.php index 3ab8dc4be..7faa8bd61 100644 --- a/modules/pagesnotfound/fr.php +++ b/modules/pagesnotfound/fr.php @@ -5,6 +5,7 @@ $_MODULE = array(); $_MODULE['<{pagesnotfound}prestashop>pagesnotfound_251295238bdf7693252f2804c8d3707e'] = 'Pages introuvables'; $_MODULE['<{pagesnotfound}prestashop>pagesnotfound_3ae7050d9f8502e9b69448a6db73fab2'] = 'Affiche les pages demandées mais qui n\'existent pas'; $_MODULE['<{pagesnotfound}prestashop>pagesnotfound_50004bd606668bb842e80f51337b765d'] = 'Pages introuvables supprimées'; +$_MODULE['<{pagesnotfound}prestashop>pagesnotfound_23dbe39a97cb7e4e528f25f5795d317f'] = 'Pages non trouvées ont été supprimés.'; $_MODULE['<{pagesnotfound}prestashop>pagesnotfound_6cb944288ac528fcfd76b20156dddce1'] = 'Vous devez utiliser un fichier .htaccess redirigeant les erreurs 404 vers la page \"404.php\"'; $_MODULE['<{pagesnotfound}prestashop>pagesnotfound_193cfc9be3b995831c6af2fea6650e60'] = 'Page'; $_MODULE['<{pagesnotfound}prestashop>pagesnotfound_b6f05e5ddde1ec63d992d61144452dfa'] = 'Origine'; diff --git a/modules/paysafecard/fr.php b/modules/paysafecard/fr.php index 5d3f4e69f..d876d3dd7 100755 --- a/modules/paysafecard/fr.php +++ b/modules/paysafecard/fr.php @@ -2,6 +2,8 @@ global $_MODULE; $_MODULE = array(); +$_MODULE['<{paysafecard}prestashop>prepaidservices_3e8e30e75887d2f3b02da669ebd5b380'] = 'Un certificat a été trouvé pour cette configuration'; +$_MODULE['<{paysafecard}prestashop>prepaidservices_515f3d11e66f6fc5f7bb453e6030241a'] = 'Un mot de passe a déjà été enregistré'; $_MODULE['<{paysafecard}prestashop>disposition-error_393988def796f78c4b673b90548f3afa'] = 'La disposition est dans un état invalide'; $_MODULE['<{paysafecard}prestashop>disposition-error_5db89f2bf67f2c7dbd86cac101c3c1b8'] = '. Vous n\'êtes pas authorisé à récupérer le paiement.'; $_MODULE['<{paysafecard}prestashop>payment_da9c72b9e543135f3f59e3c8ac68ef35'] = 'Payer avec'; diff --git a/modules/prestafraud/prestafraud.php b/modules/prestafraud/prestafraud.php index 651d04cd8..a5f0bd955 100644 --- a/modules/prestafraud/prestafraud.php +++ b/modules/prestafraud/prestafraud.php @@ -583,7 +583,7 @@ class PrestaFraud extends Module } elseif (function_exists('file_get_contents')) { - $stream_context = stream_context_create(array('http' => array('timeout' => 5))); + $stream_context = @stream_context_create(array('http' => array('timeout' => 5))); return file_get_contents($this->_trustUrl.'?xml='.urlencode(str_replace("\r", "\n", '', $datas)), $stream_context); } else diff --git a/modules/productcomments/productcomments.php b/modules/productcomments/productcomments.php index f111b5b7f..0afd40da0 100644 --- a/modules/productcomments/productcomments.php +++ b/modules/productcomments/productcomments.php @@ -783,8 +783,13 @@ class ProductComments extends Module { foreach ($criterions AS $criterion) { + if(isset($grades[$criterion['id_product_comment_criterion']])) + { $list_product_grades[$criterion['id_product_comment_criterion']][$id_product] = $grades[$criterion['id_product_comment_criterion']]; $grade_total += (float)($grades[$criterion['id_product_comment_criterion']]); + } + else + $list_product_grades[$criterion['id_product_comment_criterion']][$id_product] = 0; if (!array_key_exists($criterion['id_product_comment_criterion'], $list_grades)) $list_grades[$criterion['id_product_comment_criterion']] = $criterion['name']; diff --git a/modules/productcomments/products-comparison.tpl b/modules/productcomments/products-comparison.tpl index 4005e022b..43615c0f2 100755 --- a/modules/productcomments/products-comparison.tpl +++ b/modules/productcomments/products-comparison.tpl @@ -28,19 +28,23 @@ @@ -64,7 +68,7 @@ {if isset($tab_grade[$id_product]) AND $tab_grade[$id_product]} {section loop=6 step=1 start=1 name=average} - + {/section} {else} - @@ -101,7 +105,7 @@
{dateFormat date=$comment.date_add|escape:'html':'UTF-8' full=0} - {$comment.firstname|escape:'html':'UTF-8'} {$comment.lastname|truncate:30:'...'|escape:'htmlall':'UTF-8'}. + {$comment.customer_name|escape:'html':'UTF-8'}.
{$comment.content|escape:'html':'UTF-8'|nl2br}
diff --git a/modules/shopimporter/ajax.php b/modules/shopimporter/ajax.php index 2be77de74..d540ae0b8 100644 --- a/modules/shopimporter/ajax.php +++ b/modules/shopimporter/ajax.php @@ -5,10 +5,12 @@ include_once('../../init.php'); include_once('../../modules/shopimporter/shopimporter.php'); ini_set('display_errors', 'off'); -if (!Tools::getValue('ajax') OR Tools::getValue('token') != sha1(_COOKIE_KEY_.'ajaxShopImporter')) +$moduleName = Tools::getValue('moduleName'); + +if (!Tools::getValue('ajax') || Tools::getValue('token') != sha1(_COOKIE_KEY_.'ajaxShopImporter') || !ctype_alnum($moduleName)) die; -$moduleName = Tools::getValue('moduleName'); + $className = Tools::getValue('className'); $getMethod = Tools::getValue('getMethod'); $limit = Tools::getValue('limit'); @@ -69,7 +71,7 @@ if (Tools::isSubmit('getData') || Tools::isSubmit('syncLang') || Tools::isSubmit { $return = call_user_func_array(array($importModule, $getMethod), array($limit, $nbr_import)); $shopImporter = new shopImporter(); - $shopImporter->generiqueImport($className, $return, (bool)$save); + $shopImporter->genericImport($className, $return, (bool)$save); } } } @@ -93,7 +95,7 @@ if (Tools::isSubmit('getDataWS') || Tools::isSubmit('syncLangWS') || Tools::isSu { $return = call_user_func_array(array($importModule, $getMethod), array($limit, $nbr_import)); $shopImporter = new shopImporter(); - $shopImporter->generiqueImport($className, $return, (bool)$save); + $shopImporter->genericImport($className, $return, (bool)$save); } die('{"hasError" : false, "error" : []}'); } catch (Exception $e) diff --git a/modules/shopimporter/fr.php b/modules/shopimporter/fr.php index 19172428b..4af6b6406 100644 --- a/modules/shopimporter/fr.php +++ b/modules/shopimporter/fr.php @@ -47,6 +47,7 @@ $_MODULE['<{shopimporter}prestashop>shopimporter_782c8b38bce4f2f6975ca7f33ac8189 $_MODULE['<{shopimporter}prestashop>shopimporter_f2931b8b1622867fcc461d7de388e319'] = 'Import des historique de commande'; $_MODULE['<{shopimporter}prestashop>shopimporter_32a6deec3cca312a54d6b8769c9b8dd7'] = 'n\'est pas disponible dans ce module'; $_MODULE['<{shopimporter}prestashop>shopimporter_1e411d25230ba738b9ae583bcb9b0b57'] = 'Connexion à la base de données OK '; +$_MODULE['<{shopimporter}prestashop>shopimporter_472f0b8c78cc382302e094c94856c951'] = 'La connexion au service Web est OK'; $_MODULE['<{shopimporter}prestashop>shopimporter_3596c777cbc8b72d678f34daabc9148b'] = 'Afficher les erreurs'; $_MODULE['<{shopimporter}prestashop>shopimporter_89a399eee52b2a6daaea92eba3e14cad'] = 'Lancer le test d\'import'; $_MODULE['<{shopimporter}prestashop>shopimporter_bf79359f8edda6f7df97ef57a4ee09b6'] = 'Lancer l\'import'; diff --git a/modules/shopimporter/shopimporter.js b/modules/shopimporter/shopimporter.js index badd18ad3..d98d9b15b 100644 --- a/modules/shopimporter/shopimporter.js +++ b/modules/shopimporter/shopimporter.js @@ -27,7 +27,6 @@ var shopImporter = { syncLangWS : function (onComplete) { - $.ajax({ type: 'GET', url: '../modules/shopimporter/ajax.php', @@ -45,7 +44,6 @@ var shopImporter = { } else onComplete(true); - }, error: function(XMLHttpRequest, textStatus, errorThrown) { @@ -75,7 +73,6 @@ var shopImporter = { } else onComplete(true); - }, error: function(XMLHttpRequest, textStatus, errorThrown) { @@ -99,13 +96,12 @@ var shopImporter = { { if (jsonData.hasError) { - $('#steps').html(''); + $('#steps').html('
'+jsonData.error+'
'); $('#currency_feedback').fadeIn('slow'); onComplete(false); } else onComplete(true); - }, error: function(XMLHttpRequest, textStatus, errorThrown) { @@ -114,7 +110,6 @@ var shopImporter = { onComplete(false); } }); - }, syncCurrency : function (onComplete) { @@ -135,7 +130,6 @@ var shopImporter = { } else onComplete(true); - }, error: function(XMLHttpRequest, textStatus, errorThrown) { @@ -149,8 +143,8 @@ var shopImporter = { checkAndSaveConfigWSDL : function (onComplete) { $('#checkAndSaveConfig').fadeOut('slow'); - $('#steps').html($('#steps').html()+''); - $('#steps').html($('#steps').html()+''); + $('#steps').html($('#steps').html()+'
'+wsOk+'
'); + $('#steps').html($('#steps').html()+''); $('#next').fadeIn('slow', function () { $('#next').unbind('click').click(function(){ $('#next').fadeOut('fast', function() { @@ -165,22 +159,18 @@ var shopImporter = { }, checkAndSaveConfigWS : function (save) { - //sync languages and currency this.syncLangWS(function(isOk) { if (isOk) { shopImporter.syncCurrencyWS(function(isOk) { - if (isOk) - { - if ($('#technical_error_feedback').length) $('#technical_error_feedback').fadeIn('slow'); $('#checkAndSaveConfig').fadeOut('slow'); - $('#steps').html($('#steps').html()+''); - $('#steps').html($('#steps').html()+''); + $('#steps').html($('#steps').html()+'
'+databaseOk+'
'); + $('#steps').html($('#steps').html()+''); $('#database_feedback').fadeIn('slow', function() { if (save) { @@ -209,14 +199,9 @@ var shopImporter = { }); } }); - } }); } }); - - - - }, checkAndSaveConfig : function (save) { @@ -225,8 +210,6 @@ var shopImporter = { if (isOk) { shopImporter.syncCurrency(function(isOk) { - if (isOk) - { $.ajax({ type: 'GET', url: '../modules/shopimporter/ajax.php', @@ -281,17 +264,13 @@ var shopImporter = { }, error: function(XMLHttpRequest, textStatus, errorThrown) { - $('#steps').html($('#steps').html()+''); + $('#steps').html($('#steps').html()+'
TECHNICAL ERROR

Details: '+XMLHttpRequest.responseText+'
'); $('#technical_error_feedback').fadeIn('slow'); - } }); - } }); } }); - - }, getDatasWS : function (methodName) @@ -308,7 +287,7 @@ var shopImporter = { if (typeof(methodName) != 'undefined') { - $('#steps').html($('#steps').html()+''); + $('#steps').html($('#steps').html()+'
'+methodName[1]+'
'); $('#ok_feedback_'+methodName[0]).css('display', ''); $('#checkAndSaveConfig').fadeIn('slow'); @@ -318,9 +297,6 @@ var shopImporter = { async: true, cache: false, dataType : "json", - //data: 'ajax=true&token='+this.token+'&getData&className='+methodName[2]+'&getMethod='+methodName[0]+'&moduleName='+this.moduleName+'&server='+this.server+'&user='+this.user+'&password='+this.password+'&database='+this.database+'&prefix='+prefix+'&limit='+this.limit+'&nbr_import='+this.nbr_import+'&save='+this.save+'&errors='+this.errors+'&hasErrors='+this.hasErrors+this.specificOptions+this.imagesOptions , - - data: 'ajax=true&token='+this.token+'&getDataWS&className='+methodName[2]+'&getMethod='+methodName[0]+'&moduleName='+this.moduleName+'&url='+this.url+'&loginws='+this.loginws+'&apikey='+this.apikey+'&limit='+this.limit+'&nbr_import='+this.nbr_import+'&save='+this.save+'&errors='+this.errors+'&hasErrors='+this.hasErrors+this.specificOptions+this.imagesOptions , success: function(jsonData) { @@ -404,7 +380,6 @@ var shopImporter = { }, error: function(XMLHttpRequest, textStatus, errorThrown) { - $('#steps').html($('#steps').html()+''); $('#technical_error_feedback').fadeIn('slow'); $('#checkAndSaveConfig').fadeIn('slow'); } @@ -562,10 +537,6 @@ var shopImporter = { $('#feedback_'+methodName[0]+'_errors_list > ul').html($('#feedback_'+methodName[0]+'_errors_list > ul').html() + jsonError); } } - else - { - - } }, error: function(XMLHttpRequest, textStatus, errorThrown) { @@ -584,12 +555,11 @@ var shopImporter = { { if (this.save) { - $('#steps').html($('#steps').html()+''); + $('#steps').html($('#steps').html()+'
'+importFinish+'
'); $('#ok_feedback_end').fadeIn('slow'); } else { - $('#steps').html($('#steps').html()+''); $('#submitImport').fadeIn('slow', function() { $(this).unbind('click').click(function() { @@ -617,7 +587,6 @@ var shopImporter = { }; - function enableShowErrors(methodName) { $(document).find('#feedback_'+methodName+'_errors_list').slideToggle(); @@ -669,7 +638,7 @@ function initConnexion (moduleName, url, loginws, apikey, token) $('#connectionInformation').removeAttr('style'); if (jsonData.hasError) { - $('#connectionInformation').attr("style","width: 400px;background-color: #FAE2E3;border: 1px solid #EC9B9B"); + $('#connectionInformation').attr('style','width: 400px;background-color: #FAE2E3;border: 1px solid #EC9B9B'); for (i=0;i'+jsonData.error[i]+''; $('#connectionInformation').slideDown('slow'); @@ -678,7 +647,7 @@ function initConnexion (moduleName, url, loginws, apikey, token) }else { - $('#connectionInformation').attr("style","width: 400px;background-color: #DFFAD3;border: 1px solid #72CB67"); + $('#connectionInformation').attr('style','width: 400px;background-color: #DFFAD3;border: 1px solid #72CB67'); $('#connectionInformation').slideDown('slow'); $('#connectionInformation').html('
    Connection successful
'); $('#connectionInformation').show(); @@ -689,7 +658,6 @@ function initConnexion (moduleName, url, loginws, apikey, token) error: function(XMLHttpRequest, textStatus, errorThrown) { alert('TECHNICAL ERROR\nDetails:\nError thrown: ' + XMLHttpRequest + '\n' + 'Text status: ' + textStatus); - } }); } @@ -702,7 +670,7 @@ function displaySpecificOptionsWsdl(moduleName,token) url: '../modules/shopimporter/ajax.php', async: false, cache: false, - dataType : "html", + dataType : 'html', data: 'ajax=true&token='+token+'&displaySpecificOptionsWsdl&moduleName='+moduleName , success: function(htmlData) { @@ -724,7 +692,7 @@ function validateSpecificOptions(moduleName, specificOptions) url: '../modules/shopimporter/ajax.php', async: false, cache: false, - dataType : "json", + dataType : 'json', data: 'ajax=true&token='+this.token+'&validateSpecificOptions&moduleName='+moduleName+specificOptions , success: function(jsonData) { @@ -766,7 +734,7 @@ function initConfigConnector() url: '../modules/shopimporter/ajax.php', async: false, cache: false, - dataType : "html", + dataType : 'html', data: 'ajax=true&token='+globalAjaxShopImporterToken+'&displayConfigConnector&moduleName='+$('#import_module_name').val() , success: function(html) @@ -800,9 +768,6 @@ $(document).ready(function(){ $(this).html(''); $('#steps').fadeIn(); }); - - - $('#importOptions').fadeOut('slow'); $('#displayOptions').show(); $('#checkAndSaveConfig').show(); @@ -832,8 +797,6 @@ $(document).ready(function(){ return false; }else{ $('#connectionInformation').hide(); - - } token = globalAjaxShopImporterToken; initConnexion($('#import_module_name').val(), $('#url').val(), $('#loginws').val(), $('#apikey').val(), token); @@ -873,7 +836,7 @@ $(document).ready(function(){ { if($('#import_module_name').attr('value') == 'importermagento') { - $.scrollTo($("#steps"), 300 , { + $.scrollTo($('#steps'), 300 , { onAfter:function(){ shopImporter.specificOptions = ''; $('#specificOptionsContent :input').each(function (){ @@ -899,7 +862,7 @@ $(document).ready(function(){ }); }else if ($('#import_module_name').attr('value') == 'importerosc') { - $.scrollTo($("#steps"), 300 , { + $.scrollTo($('#steps'), 300 , { onAfter:function(){ shopImporter.specificOptions = ''; $('#specificOptionsContent :input').each(function (){ @@ -923,7 +886,6 @@ $(document).ready(function(){ }); } } - }); $('#importOptionsYesNo :radio').change( function () { @@ -939,7 +901,7 @@ $(document).ready(function(){ else { $('#checkAndSaveConfig').fadeOut(); - $('#steps').html(''); + $('#steps').html('
'+oneThing+'
'); $('#one_thing_error_feedback').fadeIn('slow'); } }); diff --git a/modules/shopimporter/shopimporter.php b/modules/shopimporter/shopimporter.php index 9b93033a0..bce5b670a 100644 --- a/modules/shopimporter/shopimporter.php +++ b/modules/shopimporter/shopimporter.php @@ -289,7 +289,7 @@ class shopimporter extends ImportModule $exportModules = parent::getImportModulesOnDisk(); //get installed module only foreach($exportModules as $key => $module) - if ($module->name == $this->name OR !(bool)$module->id) + if ($module->name == $this->name || !(bool)$module->id) unset($exportModules[$key]); $html = ' @@ -418,7 +418,7 @@ class shopimporter extends ImportModule return $html; } - public function generiqueImport($className, $fields, $save = false) + public function genericImport($className, $fields, $save = false) { $return = ''; $json = array(); @@ -432,7 +432,7 @@ class shopimporter extends ImportModule $object = new $className(); $rules = call_user_func(array($className, 'getValidationRules'), $className); - if ((sizeof($rules['requiredLang']) OR sizeof($rules['sizeLang']) OR sizeof($rules['validateLang']) OR Tools::isSubmit('syncLang') OR Tools::isSubmit('syncCurrency'))) + if ((sizeof($rules['requiredLang']) || sizeof($rules['sizeLang']) || sizeof($rules['validateLang']) || Tools::isSubmit('syncLang') || Tools::isSubmit('syncCurrency'))) { $moduleName = Tools::getValue('moduleName'); if (file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php')) @@ -446,7 +446,7 @@ class shopimporter extends ImportModule $importModule->prefix = Tools::getValue('prefix'); $defaultLanguage = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $languages = $importModule->getLangagues(0); - if (Tools::isSubmit('syncLang') OR Tools::isSubmit('syncLangWS')) + if (Tools::isSubmit('syncLang') || Tools::isSubmit('syncLangWS')) { $defaultIdLand = $importModule->getDefaultIdLang(); $defaultLanguageImport = new Language(Language::getIdByIso($languages[$defaultIdLand]['iso_code'])); @@ -455,7 +455,7 @@ class shopimporter extends ImportModule '.$importModule->displayName.' : '.$defaultLanguageImport->name.'
'.$this->l('Please change default language in your configuration'); } - if (Tools::isSubmit('syncCurrency') OR Tools::isSubmit('syncCurrencyWS')) + if (Tools::isSubmit('syncCurrency') || Tools::isSubmit('syncCurrencyWS')) { $defaultIdCurrency = $importModule->getDefaultIdCurrency(); $currencies = $importModule->getCurrencies(0); @@ -499,15 +499,13 @@ class shopimporter extends ImportModule $json['hasError'] = true; $json['error'] = $errors; } - //die(''); - if ($save OR Tools::isSubmit('syncLang') OR Tools::isSubmit('syncLangWS')) - { + if ($save || Tools::isSubmit('syncLang') || Tools::isSubmit('syncLangWS')) + { //add language if not exist in prestashop if ($className == 'Language') { - - if (Tools::isSubmit('syncLang') OR Tools::isSubmit('syncLangWS')) + if (Tools::isSubmit('syncLang') || Tools::isSubmit('syncLangWS')) $add = true; else $add = false; @@ -540,7 +538,7 @@ class shopimporter extends ImportModule } die(Tools::jsonEncode($json)); } - public function generiqueImportWS($className, $fields, $save = false) + public function genericImportWS($className, $fields, $save = false) { $return = ''; @@ -557,7 +555,7 @@ class shopimporter extends ImportModule $rules = call_user_func(array($className, 'getValidationRules'), $className); - if ((sizeof($rules['requiredLang']) OR sizeof($rules['sizeLang']) OR sizeof($rules['validateLang']) OR Tools::isSubmit('syncLangWS') OR Tools::isSubmit('syncCurrency'))) + if ((sizeof($rules['requiredLang']) || sizeof($rules['sizeLang']) || sizeof($rules['validateLang']) || Tools::isSubmit('syncLangWS') || Tools::isSubmit('syncCurrency'))) { $moduleName = Tools::getValue('moduleName'); if (file_exists('../../modules/'.$moduleName.'/'.$moduleName.'.php')) @@ -565,12 +563,6 @@ class shopimporter extends ImportModule require_once('../../modules/'.$moduleName.'/'.$moduleName.'.php'); $importModule = new $moduleName(); - /* $importModule->server = Tools::getValue('server'); - $importModule->user = Tools::getValue('user'); - $importModule->passwd = Tools::getValue('password'); - $importModule->database = Tools::getValue('database'); - $importModule->prefix = Tools::getValue('prefix'); - */ $defaultLanguage = new Language((int)Configuration::get('PS_LANG_DEFAULT')); @@ -629,12 +621,12 @@ class shopimporter extends ImportModule $json['hasError'] = true; $json['error'] = $errors; } - if ($save OR Tools::isSubmit('syncLang') OR Tools::isSubmit('syncLangWS')) + if ($save || Tools::isSubmit('syncLang') || Tools::isSubmit('syncLangWS')) { //add language if not exist in prestashop if ($className == 'Language') { - if (Tools::isSubmit('syncLang') OR Tools::isSubmit('syncLangWS')) + if (Tools::isSubmit('syncLang') || Tools::isSubmit('syncLangWS')) $add = true; else $add = false; @@ -938,7 +930,7 @@ class shopimporter extends ImportModule foreach ($this->supportedImports[$className]['alterTable'] AS $name => $type) { $moduleName = Tools::getValue('moduleName'); - Db::getInstance()->ExecuteS("SHOW COLUMNS FROM `"._DB_PREFIX_.pSQL($from)."` LIKE '".$name.'_'.$moduleName."'"); + Db::getInstance()->ExecuteS("SHOW COLUMNS FROM `"._DB_PREFIX_.pSQL($from)."` LIKE '".pSQL($name).'_'.pSQL($moduleName)."'"); if (!Db::getInstance()->numRows() AND !array_key_exists($name.'_'.$moduleName, $result)) $queryTmp .= ' ADD `'.$name.'_'.$moduleName.'` '.$type.' NOT NULL,'; } @@ -1065,13 +1057,13 @@ class shopimporter extends ImportModule else $returnErrors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), $field, $className).' '.$this->l('is invalid'); - if ((sizeof($rules['requiredLang']) OR sizeof($rules['sizeLang']) OR sizeof($rules['validateLang']))) + if ((sizeof($rules['requiredLang']) || sizeof($rules['sizeLang']) || sizeof($rules['validateLang']))) { $matchIdLang = $this->getMatchIdLang(0); /* Checking for multilingual required fields */ foreach ($rules['requiredLang'] AS $fieldLang) { - if (($empty = $fields[$fieldLang][$matchIdLang[$defaultLanguage->id]]) === false OR empty($empty)) + if (($empty = $fields[$fieldLang][$matchIdLang[$defaultLanguage->id]]) === false || empty($empty)) if ($hasErrors == 2) { if (array_key_exists($fieldLang, $rules['sizeLang'])) diff --git a/modules/socolissimo/socolissimo.php b/modules/socolissimo/socolissimo.php index 7562c981f..e3401793b 100644 --- a/modules/socolissimo/socolissimo.php +++ b/modules/socolissimo/socolissimo.php @@ -684,7 +684,7 @@ class Socolissimo extends CarrierModule { if (Configuration::get('SOCOLISSIMO_SUP')) { - $ctx = stream_context_create(array('http' => array('timeout' => 1))); + $ctx = @stream_context_create(array('http' => array('timeout' => 1))); $return = @file_get_contents(Configuration::get('SOCOLISSIMO_SUP_URL'), 0, $ctx); if(ini_get('allow_url_fopen') == 0) diff --git a/modules/trustedshops/fr.php b/modules/trustedshops/fr.php index 23a4e0d79..c589a0709 100644 --- a/modules/trustedshops/fr.php +++ b/modules/trustedshops/fr.php @@ -130,6 +130,7 @@ $_MODULE['<{trustedshops}prestashop>tsbuyerprotection_23a58bf9274bedb19375e527a0 $_MODULE['<{trustedshops}prestashop>tsbuyerprotection_fd5291d7f0624933870702ff183bb14e'] = 'module de paiement'; $_MODULE['<{trustedshops}prestashop>tsbuyerprotection_b3b1a406e097bc87c8745db26e11904e'] = 'Le mettre à jour'; $_MODULE['<{trustedshops}prestashop>tsbuyerprotection_c9ba5f6e6d58162530424afaa68bf496'] = 'Configuration de la tâche cron'; +$_MODULE['<{trustedshops}prestashop>tsbuyerprotection_12a4fc31ae8a9e4038df56961a5aec9b'] = 'Si vous utilisez un certificat Trusted Shops EXCELLENCE dans votre magasin, mis en place d\'une tâche cron sur votre serveur web.'; $_MODULE['<{trustedshops}prestashop>tsbuyerprotection_f811271eb84f3df1a430c3c78b6e7640'] = 'Lancez le fichier'; $_MODULE['<{trustedshops}prestashop>tsbuyerprotection_06ec9154ce96a389f7b1d884e021818b'] = 'avec un intervalle de 10 minutes.'; $_MODULE['<{trustedshops}prestashop>tsbuyerprotection_f89b7100efcc136900c909690e43f008'] = 'La ligne correspondante dans votre fichier cron apparaît ainsi :'; diff --git a/modules/upscarrier/config.xml b/modules/upscarrier/config.xml index 54a9489cd..04bf4ba23 100755 --- a/modules/upscarrier/config.xml +++ b/modules/upscarrier/config.xml @@ -2,7 +2,7 @@ upscarrier - + diff --git a/modules/upscarrier/upscarrier.php b/modules/upscarrier/upscarrier.php index 460ac8eb9..05f541918 100644 --- a/modules/upscarrier/upscarrier.php +++ b/modules/upscarrier/upscarrier.php @@ -55,7 +55,7 @@ class UpsCarrier extends CarrierModule { $this->name = 'upscarrier'; $this->tab = 'shipping_logistics'; - $this->version = '1.2'; + $this->version = '1.2.1'; $this->author = 'PrestaShop'; $this->limited_countries = array('us'); @@ -1798,6 +1798,7 @@ class UpsCarrier extends CarrierModule foreach ($wsParams['package_list'] as $p) { + if ($p['weight'] < 0.5) $p['weight'] = 0.5; $search = array('[[PackagingTypeCode]]', '[[PackageWeight]]', '[[WeightUnit]]', '[[Width]]', '[[Height]]', '[[Length]]', '[[DimensionUnit]]'); $replace = array($p['packaging_type'], $p['weight'], $this->_weightUnit, $p['width'], $p['height'], $p['depth'], $this->_dimensionUnit); $xmlPackageList .= str_replace($search, $replace, $xmlPackageTemplate); diff --git a/modules/uspscarrier/fr.php b/modules/uspscarrier/fr.php index 8720c1a38..fafc2c926 100644 --- a/modules/uspscarrier/fr.php +++ b/modules/uspscarrier/fr.php @@ -2,6 +2,7 @@ global $_MODULE; $_MODULE = array(); +$_MODULE['<{uspscarrier}prestashop>uspscarrier_ec6bd501021318b872a9eddd897a9cc2'] = 'Calcul des frais U.S.P.S'; $_MODULE['<{uspscarrier}prestashop>uspscarrier_098087ab799def1028233142cafeeafd'] = 'Propose à vos clients le transporteur USPS (US Postal)'; $_MODULE['<{uspscarrier}prestashop>uspscarrier_883fa0069f4b0454e2277dd567ab3991'] = '\'Unité de poids (LB ou KG)\''; $_MODULE['<{uspscarrier}prestashop>uspscarrier_5a3ceec65d417f5d92c26dbf0dccc00d'] = '\'Unité de mesure (CM ou IN)\''; @@ -69,6 +70,8 @@ $_MODULE['<{uspscarrier}prestashop>uspscarrier_8d2ee0603dfce09b57d60db628cde269' $_MODULE['<{uspscarrier}prestashop>uspscarrier_795de10b1bdcb843b3703c63ad577fc6'] = 'Choisissez le type de paquet par défaut'; $_MODULE['<{uspscarrier}prestashop>uspscarrier_93c8645dbbc33cf8d126266a827a5501'] = 'Machinable'; $_MODULE['<{uspscarrier}prestashop>uspscarrier_67cd0f5256c40c16a6cfd6effe3ab06b'] = 'Choisissez si cela peut être traité par une machine ou non par défaut'; +$_MODULE['<{uspscarrier}prestashop>uspscarrier_f297d2cb126758a96ae196f1865f74ec'] = 'Mode de calcul'; +$_MODULE['<{uspscarrier}prestashop>uspscarrier_fc805e1616e45e041e8bef86a9e3180d'] = 'Utiliser le mode de calcul \"Tous les éléments dans un seul paquet\" utilisera automatiquement la taille des emballages par défaut, le type d\'emballage et de livraison. Les configurations spécifiques pour les catégories ou de produit ne seront pas utilisés.'; $_MODULE['<{uspscarrier}prestashop>uspscarrier_5cdd307ba6e260beb4801c0c10e22a3a'] = 'Service de livraison'; $_MODULE['<{uspscarrier}prestashop>uspscarrier_78945de8de090e90045d299651a68a9b'] = 'Disponible'; $_MODULE['<{uspscarrier}prestashop>uspscarrier_2d25c72c1b18e562f6654fff8e11711e'] = 'Non disponible'; diff --git a/themes/prestashop/address.tpl b/themes/prestashop/address.tpl index 8e17d6a09..b255d03fd 100644 --- a/themes/prestashop/address.tpl +++ b/themes/prestashop/address.tpl @@ -142,7 +142,6 @@ $(function(){ldelim} {foreach from=$ordered_adr_fields item=field_name} {if $field_name eq 'company'}

-

@@ -187,10 +186,7 @@ $(function(){ldelim} *

- + {/if} {if $field_name eq 'Country:name' || $field_name eq 'country'}

@@ -237,6 +233,7 @@ $(function(){ldelim}

{/if} {/foreach} +

{if $stateExist eq "false"}

diff --git a/themes/prestashop/css/global.css b/themes/prestashop/css/global.css index 0f443e48b..6daa7906f 100644 --- a/themes/prestashop/css/global.css +++ b/themes/prestashop/css/global.css @@ -1175,6 +1175,9 @@ tr.cart_total_price { font-weight: bold } margin: 1em 0 } +#guest-tracking p.center { width: 100%; text-align: center; } +#guest-tracking p.center input.exclusive_large { display: inline; } + /* views block */ #views_block { margin: 0 auto; diff --git a/themes/prestashop/guest-tracking.tpl b/themes/prestashop/guest-tracking.tpl index 518f4385f..a9ecb3fbd 100644 --- a/themes/prestashop/guest-tracking.tpl +++ b/themes/prestashop/guest-tracking.tpl @@ -1,5 +1,5 @@ {* -* 2007-2011 PrestaShop +* 2007-2011 PrestaShop * * NOTICE OF LICENSE * @@ -24,10 +24,10 @@ * International Registered Trademark & Property of PrestaShop SA *} -{capture name=path}{l s='Guest tracking'}{/capture} +{capture name=path}{l s='Guests: Track your order'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} -

{l s='Guest Tracking'}

+

{l s='Guests: Track your order'}

{if isset($order)}
@@ -35,36 +35,39 @@ {include file="$tpl_dir./order-detail.tpl"}
- -

{l s='For more advantages...'}

- + +

{l s='Create your customer account'}

+ {include file="$tpl_dir./errors.tpl"} - + {if isset($transformSuccess)}

{l s='Your guest account has been successfully transformed into a customer account. You can now log in on this'} {l s='page'}

{else}
-

{l s='Transform your guest account to a customer account and enjoy :'}

+

{l s='Transform your guest account into a customer account and enjoy:'}

    -
  • {l s='Personalized and secure access'}
  • -
  • {l s='Fast and easy check out'}
  • +
  • {l s='Personal and secure access'}
  • +
  • {l s='Quick and easy check out'}
  • {l s='Easier merchandise return'}

- + - -

+ +

{/if} {else} {include file="$tpl_dir./errors.tpl"} + {if isset($show_login_link) && $show_login_link} +

{l s='Information'}{l s='Click here to log-in to your customer account'}

+ {/if}

{l s='To track your order, please enter the following information:'}

@@ -73,13 +76,13 @@ {l s='For example: 010123'}

- +

- -

+ +

{/if} diff --git a/themes/prestashop/order-opc-new-account.tpl b/themes/prestashop/order-opc-new-account.tpl index d7890faaf..2170c75ff 100644 --- a/themes/prestashop/order-opc-new-account.tpl +++ b/themes/prestashop/order-opc-new-account.tpl @@ -263,9 +263,9 @@ {elseif $field_name eq "state" || $field_name eq 'State:name'} {$stateExist = true} -
    {if $p != 1} {assign var='p_previous' value=$p-1} -
  • « {l s='Previous'}
  • +
  • « {l s='Previous'}
  • {else}
  • « {l s='Previous'}
  • {/if} {if $start>3} -
  • 1
  • +
  • 1
  • ...
  • {/if} {section name=pagination start=$start loop=$stop+1 step=1} {if $p == $smarty.section.pagination.index}
  • {$p|escape:'htmlall':'UTF-8'}
  • {else} -
  • {$smarty.section.pagination.index|escape:'htmlall':'UTF-8'}
  • +
  • {$smarty.section.pagination.index|escape:'htmlall':'UTF-8'}
  • {/if} {/section} {if $pages_nb>$stop+2} @@ -65,7 +75,7 @@ {/if} {if $pages_nb > 1 AND $p != $pages_nb} {assign var='p_next' value=$p+1} -
  • {l s='Next'} »
  • +
  • {l s='Next'} »
  • {else}
  • {l s='Next'} »
  • {/if} diff --git a/tools/pear_xml_parser/Parser.php b/tools/pear_xml_parser/Parser.php index 6173582a0..470b04914 100644 --- a/tools/pear_xml_parser/Parser.php +++ b/tools/pear_xml_parser/Parser.php @@ -39,7 +39,7 @@ require_once (_PS_PEAR_XML_PARSER_PATH_.'Parser/Exception.php'); * to the entire feed. * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser */ class XML_Feed_Parser implements Iterator @@ -87,13 +87,13 @@ class XML_Feed_Parser implements Iterator function __construct($feed, $strict = false, $suppressWarnings = false, $tidy = false) { $this->model = new DOMDocument; - if (! $this->model->loadXML($feed)) { + if (! @$this->model->loadXML($feed)) { /* PrestaShop - no error display */ if (extension_loaded('tidy') && $tidy) { $tidy = new tidy; $tidy->parseString($feed, array('input-xml' => true, 'output-xml' => true)); $tidy->cleanRepair(); - if (! $this->model->loadXML((string) $tidy)) { + if (! @$this->model->loadXML((string) $tidy)) { /* PrestaShop - no error display */ throw new XML_Feed_Parser_Exception('Invalid input: this is not ' . 'valid XML'); } diff --git a/tools/pear_xml_parser/Parser/Atom.php b/tools/pear_xml_parser/Parser/Atom.php index f36db71c5..bccbdae1e 100644 --- a/tools/pear_xml_parser/Parser/Atom.php +++ b/tools/pear_xml_parser/Parser/Atom.php @@ -30,7 +30,7 @@ * person - defaults to name, but parameter based access * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser */ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type @@ -39,7 +39,7 @@ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type * The URI of the RelaxNG schema used to (optionally) validate the feed * @var string */ - private $relax = 'atom.rnc'; + protected $relax = 'atom.rng'; /** * We're likely to use XPath, so let's keep it global @@ -117,7 +117,7 @@ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type $this->model = $model; if ($strict) { - if (! $this->model->relaxNGValidateSource($this->relax)) { + if (! $this->relaxNGValidate()) { throw new XML_Feed_Parser_Exception('Failed required validation'); } } @@ -148,7 +148,7 @@ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type if ($entries->length > 0) { $xmlBase = $entries->item(0)->baseURI; - $entry = new $this->itemElement($entries->item(0), $this, $xmlBase); + $entry = new $this->itemClass($entries->item(0), $this, $xmlBase); if (in_array('evaluate', get_class_methods($this->xpath))) { $offset = $this->xpath->evaluate("count(preceding-sibling::atom:entry)", $entries->item(0)); @@ -232,6 +232,7 @@ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type } return false; } + return $this->parseTextConstruct($content); } @@ -258,12 +259,11 @@ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type if (strpos($type, 'text/') === 0) { $type = 'text'; } + switch ($type) { case 'text': - return $content->nodeValue; - break; case 'html': - return str_replace('<', '<', $content->nodeValue); + return $content->textContent; break; case 'xhtml': $container = $content->getElementsByTagName('div'); @@ -277,7 +277,7 @@ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type foreach ($contents->childNodes as $node) { $result .= $this->traverseNode($node); } - return utf8_decode($result); + return $result; } break; case preg_match('@^[a-zA-Z]+/[a-zA-Z+]*xml@i', $type) > 0: @@ -362,4 +362,4 @@ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type } } -?> \ No newline at end of file +?> diff --git a/tools/pear_xml_parser/Parser/AtomElement.php b/tools/pear_xml_parser/Parser/AtomElement.php index ca5084220..dc5a03a49 100644 --- a/tools/pear_xml_parser/Parser/AtomElement.php +++ b/tools/pear_xml_parser/Parser/AtomElement.php @@ -26,7 +26,7 @@ * XML_Feed_Parser_Atom with which it shares many methods. * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser */ class XML_Feed_Parser_AtomElement extends XML_Feed_Parser_Atom diff --git a/tools/pear_xml_parser/Parser/Exception.php b/tools/pear_xml_parser/Parser/Exception.php index 41198b22a..c0f5b464f 100644 --- a/tools/pear_xml_parser/Parser/Exception.php +++ b/tools/pear_xml_parser/Parser/Exception.php @@ -31,7 +31,7 @@ require_once(dirname(__FILE__).'/../../pear/PEAR.php'); * to help with identification of the source of exceptions. * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser */ class XML_Feed_Parser_Exception extends PEAR_Exception diff --git a/tools/pear_xml_parser/Parser/RSS09.php b/tools/pear_xml_parser/Parser/RSS09.php index 07664097f..6e4f8679d 100644 --- a/tools/pear_xml_parser/Parser/RSS09.php +++ b/tools/pear_xml_parser/Parser/RSS09.php @@ -25,7 +25,7 @@ * This class handles RSS0.9 feeds. * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser * @todo Find a Relax NG URI we can use */ @@ -35,7 +35,7 @@ class XML_Feed_Parser_RSS09 extends XML_Feed_Parser_Type * The URI of the RelaxNG schema used to (optionally) validate the feed * @var string */ - private $relax = ''; + protected $relax = ''; /** * We're likely to use XPath, so let's keep it global @@ -209,6 +209,13 @@ class XML_Feed_Parser_RSS09 extends XML_Feed_Parser_Type $link = $links->item($offset); return $this->addBase($link->nodeValue, $link); } + + /** + * Not implemented - no available validation. + */ + public function relaxNGValidate() { + return true; +} } -?> \ No newline at end of file +?> diff --git a/tools/pear_xml_parser/Parser/RSS09Element.php b/tools/pear_xml_parser/Parser/RSS09Element.php index 0441221fa..72730a399 100644 --- a/tools/pear_xml_parser/Parser/RSS09Element.php +++ b/tools/pear_xml_parser/Parser/RSS09Element.php @@ -26,7 +26,7 @@ * XML_Feed_Parser_RSS09 with which it shares many methods. * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser */ class XML_Feed_Parser_RSS09Element extends XML_Feed_Parser_RSS09 diff --git a/tools/pear_xml_parser/Parser/RSS1.php b/tools/pear_xml_parser/Parser/RSS1.php index 648129cb8..722290851 100644 --- a/tools/pear_xml_parser/Parser/RSS1.php +++ b/tools/pear_xml_parser/Parser/RSS1.php @@ -25,7 +25,7 @@ * This class handles RSS1.0 feeds. * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser * @todo Find a Relax NG URI we can use */ @@ -35,7 +35,7 @@ class XML_Feed_Parser_RSS1 extends XML_Feed_Parser_Type * The URI of the RelaxNG schema used to (optionally) validate the feed * @var string */ - private $relax = 'rss10.rnc'; + protected $relax = 'rss10.rng'; /** * We're likely to use XPath, so let's keep it global @@ -121,9 +121,7 @@ class XML_Feed_Parser_RSS1 extends XML_Feed_Parser_Type { $this->model = $model; if ($strict) { - $validate = $this->model->relaxNGValidate(self::getSchemaDir . - DIRECTORY_SEPARATOR . $this->relax); - if (! $validate) { + if (! $this->relaxNGValidate()) { throw new XML_Feed_Parser_Exception('Failed required validation'); } } @@ -274,4 +272,4 @@ class XML_Feed_Parser_RSS1 extends XML_Feed_Parser_Type } } -?> \ No newline at end of file +?> diff --git a/tools/pear_xml_parser/Parser/RSS11.php b/tools/pear_xml_parser/Parser/RSS11.php index e514e892d..996a9e0bc 100644 --- a/tools/pear_xml_parser/Parser/RSS11.php +++ b/tools/pear_xml_parser/Parser/RSS11.php @@ -26,7 +26,7 @@ * http://inamidst.com/rss1.1/ * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser * @todo Support for RDF:List * @todo Ensure xml:lang is accessible to users @@ -37,7 +37,7 @@ class XML_Feed_Parser_RSS11 extends XML_Feed_Parser_Type * The URI of the RelaxNG schema used to (optionally) validate the feed * @var string */ - private $relax = 'rss11.rnc'; + protected $relax = 'rss11.rng'; /** * We're likely to use XPath, so let's keep it global @@ -123,9 +123,7 @@ class XML_Feed_Parser_RSS11 extends XML_Feed_Parser_Type $this->model = $model; if ($strict) { - $validate = $this->model->relaxNGValidate(self::getSchemaDir . - DIRECTORY_SEPARATOR . $this->relax); - if (! $validate) { + if (! $this->relaxNGValidate()) { throw new XML_Feed_Parser_Exception('Failed required validation'); } } @@ -273,4 +271,4 @@ class XML_Feed_Parser_RSS11 extends XML_Feed_Parser_Type } } -?> \ No newline at end of file +?> diff --git a/tools/pear_xml_parser/Parser/RSS11Element.php b/tools/pear_xml_parser/Parser/RSS11Element.php index 9922cb719..073a12123 100644 --- a/tools/pear_xml_parser/Parser/RSS11Element.php +++ b/tools/pear_xml_parser/Parser/RSS11Element.php @@ -26,7 +26,7 @@ * XML_Feed_Parser_RSS11 with which it shares many methods. * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser */ class XML_Feed_Parser_RSS11Element extends XML_Feed_Parser_RSS11 @@ -65,7 +65,7 @@ class XML_Feed_Parser_RSS11Element extends XML_Feed_Parser_RSS11 protected $compatMap = array( 'content' => array('content'), 'updated' => array('lastBuildDate'), - 'published' => array('pubdate'), + 'published' => array('date'), 'subtitle' => array('description'), 'updated' => array('date'), 'author' => array('creator'), @@ -148,4 +148,4 @@ class XML_Feed_Parser_RSS11Element extends XML_Feed_Parser_RSS11 } } -?> \ No newline at end of file +?> diff --git a/tools/pear_xml_parser/Parser/RSS1Element.php b/tools/pear_xml_parser/Parser/RSS1Element.php index 7cf02ca00..d080508be 100644 --- a/tools/pear_xml_parser/Parser/RSS1Element.php +++ b/tools/pear_xml_parser/Parser/RSS1Element.php @@ -26,7 +26,7 @@ * XML_Feed_Parser_RSS1 with which it shares many methods. * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser */ class XML_Feed_Parser_RSS1Element extends XML_Feed_Parser_RSS1 @@ -65,7 +65,7 @@ class XML_Feed_Parser_RSS1Element extends XML_Feed_Parser_RSS1 protected $compatMap = array( 'content' => array('content'), 'updated' => array('lastBuildDate'), - 'published' => array('pubdate'), + 'published' => array('date'), 'subtitle' => array('description'), 'updated' => array('date'), 'author' => array('creator'), @@ -113,4 +113,4 @@ class XML_Feed_Parser_RSS1Element extends XML_Feed_Parser_RSS1 } } -?> \ No newline at end of file +?> diff --git a/tools/pear_xml_parser/Parser/RSS2.php b/tools/pear_xml_parser/Parser/RSS2.php index ada5f1cac..77c72afb8 100644 --- a/tools/pear_xml_parser/Parser/RSS2.php +++ b/tools/pear_xml_parser/Parser/RSS2.php @@ -25,7 +25,7 @@ * This class handles RSS2 feeds. * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser */ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type @@ -34,7 +34,7 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type * The URI of the RelaxNG schema used to (optionally) validate the feed * @var string */ - private $relax = 'rss20.rnc'; + protected $relax = 'rss20.rng'; /** * We're likely to use XPath, so let's keep it global @@ -116,7 +116,7 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type $this->model = $model; if ($strict) { - if (! $this->model->relaxNGValidate($this->relax)) { + if (! $this->relaxNGValidate()) { throw new XML_Feed_Parser_Exception('Failed required validation'); } } @@ -194,7 +194,7 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type */ protected function getImage() { - $images = $this->model->getElementsByTagName('image'); + $images = $this->xpath->query("//image"); if ($images->length > 0) { $image = $images->item(0); $desc = $image->getElementsByTagName('description'); @@ -331,4 +331,4 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type } } -?> \ No newline at end of file +?> diff --git a/tools/pear_xml_parser/Parser/RSS2Element.php b/tools/pear_xml_parser/Parser/RSS2Element.php index 0022fd74e..33fa98349 100644 --- a/tools/pear_xml_parser/Parser/RSS2Element.php +++ b/tools/pear_xml_parser/Parser/RSS2Element.php @@ -26,7 +26,7 @@ * called by XML_Feed_Parser_RSS2 with which it shares many methods. * * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ * @package XML_Feed_Parser */ class XML_Feed_Parser_RSS2Element extends XML_Feed_Parser_RSS2 diff --git a/tools/pear_xml_parser/Parser/Type.php b/tools/pear_xml_parser/Parser/Type.php index 47b658926..15649452a 100644 --- a/tools/pear_xml_parser/Parser/Type.php +++ b/tools/pear_xml_parser/Parser/Type.php @@ -27,7 +27,7 @@ * * @package XML_Feed_Parser * @author James Stewart - * @version Release: 1.0.2 + * @version Release: @package_version@ */ abstract class XML_Feed_Parser_Type { @@ -49,6 +49,11 @@ abstract class XML_Feed_Parser_Type */ public $entries = array(); + /** + * Store mappings between entry IDs and their position in the feed + */ + public $idMappings = array(); + /** * Proxy to allow use of element names as method names * @@ -195,7 +200,7 @@ abstract class XML_Feed_Parser_Type $this->entries[$offset] = new $this->itemClass( $entries->item($offset), $this, $xmlBase); if ($id = $this->entries[$offset]->id) { - @$this->idMappings[$id] = $this->entries[$offset]; + $this->idMappings[$id] = $this->entries[$offset]; } } else { throw new XML_Feed_Parser_Exception('No entries found'); @@ -219,7 +224,7 @@ abstract class XML_Feed_Parser_Type protected function getDate($method, $arguments) { $time = $this->model->getElementsByTagName($method); - if ($time->length == 0) { + if ($time->length == 0 || empty($time->item(0)->nodeValue)) { return false; } return strtotime($time->item(0)->nodeValue); @@ -307,12 +312,12 @@ abstract class XML_Feed_Parser_Type $return = ''; foreach ($node->attributes as $attribute) { if ($attribute->name == 'src' or $attribute->name == 'href') { - $attribute->value = $this->addBase($attribute->value, $attribute); + $attribute->value = $this->addBase(htmlentities($attribute->value, NULL, 'utf-8'), $attribute); } if ($attribute->name == 'base') { continue; } - $return .= $attribute->name . '="' . $attribute->value .'" '; + $return .= $attribute->name . '="' . htmlentities($attribute->value, NULL, 'utf-8') .'" '; } if (! empty($return)) { return ' ' . trim($return); @@ -320,13 +325,34 @@ abstract class XML_Feed_Parser_Type return ''; } + /** + * Convert HTML entities based on the current character set. + * + * @param String + * @return String + */ + function processEntitiesForNodeValue($node) + { + if (function_exists('iconv')) { + $current_encoding = $node->ownerDocument->encoding; + $value = iconv($current_encoding, 'UTF-8', $node->nodeValue); + } else if ($current_encoding == 'iso-8859-1') { + $value = utf8_encode($node->nodeValue); + } else { + $value = $node->nodeValue; + } + + $decoded = html_entity_decode($value, NULL, 'UTF-8'); + return htmlentities($decoded, NULL, 'UTF-8'); + } + /** * Part of our xml:base processing code * * We need a couple of methods to access XHTML content stored in feeds. * This is because we dereference all xml:base references before returning * the element. This method recurs through the tree descending from the node - * and builds our string + * and builds our string. * * @param DOMElement $node The DOM node we are processing * @return string @@ -349,7 +375,7 @@ abstract class XML_Feed_Parser_Type } if ($node instanceof DOMText) { - $content .= htmlentities($node->nodeValue); + $content .= $this->processEntitiesForNodeValue($node); } /* Add the closing of this node to the content */ @@ -436,6 +462,14 @@ abstract class XML_Feed_Parser_Type $config = new PEAR_Config; return $config->get('data_dir') . '/XML_Feed_Parser/schemas'; } + + public function relaxNGValidate() { + $dir = self::getSchemaDir(); + + $path = $dir . '/' . $this->relax; + + return $this->model->relaxNGValidate($path); +} } -?> \ No newline at end of file +?>