diff --git a/modules/homeslider/HomeSlide.php b/modules/homeslider/HomeSlide.php index 532c6dd61..5011d24ea 100644 --- a/modules/homeslider/HomeSlide.php +++ b/modules/homeslider/HomeSlide.php @@ -84,17 +84,17 @@ class HomeSlide extends ObjectModel )); } - public function __construct($id_slide = NULL, $id_lang = NULL, $id_shop = NULL, Context $context = NULL) + public function __construct($id_slide = null, $id_lang = null, $id_shop = null, Context $context = null) { parent::__construct($id_slide, $id_lang, $id_shop); } - public function add($autodate = true, $nullValues = false) + public function add($autodate = true, $null_values = false) { $context = Context::getContext(); $id_shop = $context->shop->getID(); - $res = parent::add($autodate, $nullValues); + $res = parent::add($autodate, $null_values); $res &= Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'homeslider` (`id_shop`, `id_slide`) VALUES('.(int)$id_shop.', '.(int)$this->id.')' diff --git a/modules/homeslider/homeslider.php b/modules/homeslider/homeslider.php index e425d04bb..b6e32c00e 100644 --- a/modules/homeslider/homeslider.php +++ b/modules/homeslider/homeslider.php @@ -25,6 +25,11 @@ * International Registered Trademark & Property of PrestaShop SA */ +/** + * @since 1.5.0 + * @version 1.1 (2011-11-23) + */ + if (!defined('_PS_VERSION_')) exit; @@ -38,7 +43,7 @@ class HomeSlider extends Module { $this->name = 'homeslider'; $this->tab = 'front_office_features'; - $this->version = '1.0'; + $this->version = '1.1'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->secure_key = Tools::encrypt($this->name); @@ -213,7 +218,7 @@ class HomeSlider extends Module /* Display notice if there are no slides yet */ if (!$slides) - $this->_html .= '

'.$this->l("You did not add any slides yet.").'

'; + $this->_html .= '

'.$this->l('You did not add any slides yet.').'

'; else /* Display slides */ { $this->_html .= ' @@ -465,7 +470,10 @@ class HomeSlider extends Module else if (Tools::isSubmit('changeStatus') && Tools::isSubmit('id_slide')) { $slide = new HomeSlide((int)Tools::getValue('id_slide')); - $slide->active = (int)($slide->active == 0 ? 1 : 0); + if ($slide->active == 0) + $slide->active = 1; + else + $slide->active = 0; $res = $slide->update(); $this->_html = ($res ? $this->displayConfirmation($this->l('Configuration updated')) : $this->displayErro($this->l('Configuration could not be updated'))); } @@ -502,16 +510,19 @@ class HomeSlider extends Module if (Tools::getValue('description_'.$language['id_lang']) != '') $slide->description[$language['id_lang']] = pSQL(Tools::getValue('description_'.$language['id_lang'])); /* Uploads image and sets slide */ - if (isset($_FILES['image_'.$language['id_lang']]) && isset($_FILES['image_'.$language['id_lang']]['tmp_name']) && !empty($_FILES['image_'.$language['id_lang']]['tmp_name'])) + if (isset($_FILES['image_'.$language['id_lang']]) && + isset($_FILES['image_'.$language['id_lang']]['tmp_name']) && + !empty($_FILES['image_'.$language['id_lang']]['tmp_name'])) { + $temp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS'); if ($error = checkImage($_FILES['image_'.$language['id_lang']])) $errors .= $error; - else if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') || !move_uploaded_file($_FILES['image_'.$language['id_lang']]['tmp_name'], $tmpName)) + else if (!$temp_name || !move_uploaded_file($_FILES['image_'.$language['id_lang']]['tmp_name'], $temp_name)) return false; - else if (!imageResize($tmpName, dirname(__FILE__).'/images/'.Tools::encrypt($_FILES['image_'.$language['id_lang']]['name']).'.jpg')) + else if (!imageResize($temp_name, dirname(__FILE__).'/images/'.Tools::encrypt($_FILES['image_'.$language['id_lang']]['name']).'.jpg')) $errors .= $this->displayError($this->l('An error occurred during the image upload.')); - if (isset($tmpName)) - unlink($tmpName); + if (isset($temp_name)) + unlink($temp_name); $slide->image[$language['id_lang']] = pSQL(Tools::encrypt($_FILES['image_'.($language['id_lang'])]['name']).'.jpg'); } if (Tools::getValue('image_old_'.$language['id_lang']) != '') @@ -568,7 +579,7 @@ class HomeSlider extends Module { if (!$this->getSlides(true)) return; - $this->context->controller->addJS(_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js'); + $this->context->controller->addJqueryUI('ui.sortable'); $this->context->controller->addJS($this->_path.'js/jquery.bxSlider.min.js'); $this->context->controller->addCSS($this->_path.'bx_styles.css'); $this->context->controller->addJS($this->_path.'js/homeslider.js'); @@ -576,6 +587,9 @@ class HomeSlider extends Module public function hookBackOfficeTop() { + if (Tools::getValue('controller') != 'AdminModules' && Tools::getValue('configure') != $this->name) + return; + /* Style & js for fieldset 'slides configuration' */ $html = ' - +