コード例 #1
0
 public function getContent()
 {
     $this->_html = '';
     /* add css file */
     $this->_addCSS();
     /* add js file */
     $this->_addJS();
     /* SLIDER EDITION */
     if (Tools::isSubmit('submitEditSlide')) {
         //check if we are deleting a image
         if (Tools::getIsset('actionSlide') && Tools::getIsset('actionSlide') == 'deleteImage') {
             $slider = new ResponsiveSliderClass(Tools::getValue('idSlide'));
             $slider->urlimage = '';
             if ($slider->save()) {
                 $response = '
                 <div class="conf confirm">
                     ' . $this->l('The image slide has been updated.') . '
                 </div>';
                 $this->_html .= $response;
             } else {
                 $response = '
                 <div class="conf error">
                     <img src="../img/admin/disabled.gif" alt="" title="" />
                     ' . $this->l('An error has occured during the update of the slide.') . '
                 </div>';
                 $this->_html .= $response;
             }
         } else {
             $slider = new ResponsiveSliderClass(Tools::getValue('idSlide'));
             $slider->copyFromPost();
             $slider->uploadImages($_FILES, $this->local_path);
             if ($slider->save()) {
                 $this->_html .= '
                 <div class="conf confirm">
                     ' . $this->l('The slide') . ' ' . $slider->title[$this->context->cookie->id_lang] . ' ' . $this->l('has been updated.') . '
                 </div>';
             } else {
                 $this->_html .= '
                 <div class="conf error">
                     <img src="../img/admin/disabled.gif" alt="" title="" />
                     ' . $this->l('An error has occured during the update of the slide.') . '
                 </div>';
             }
         }
     }
     /* END SLIDER EDITION */
     /* SLIDER ADDITION */
     if (Tools::isSubmit('submitAddSlide')) {
         //get data from post method
         $slider = new ResponsiveSliderClass();
         $slider->copyFromPost();
         $slider->uploadImages($_FILES, $this->local_path);
         $slider->position = ResponsiveSliderClass::getMaxPosition();
         $slider->id_shop = $this->context->shop->id;
         if ($slider->save()) {
             $this->_html .= '
             <div class="conf confirm">
                 ' . $this->l('The slide') . ' ' . $slider->title[$this->context->cookie->id_lang] . ' ' . $this->l('has been added to your slider.') . '
             </div>';
         } else {
             $this->_html .= '
             <div class="conf error">
                 <img src="../img/admin/disabled.gif" alt="" title="" />
                 ' . $this->l('An error has occured during the addition of the slide.') . '
             </div>';
         }
     }
     /* END SLIDER ADDITION */
     /* CONFIGURATION EDITION */
     if (Tools::isSubmit('submitConfiguration')) {
         //responsive slider configuration array
         $responsiveSliderConfiguration = array();
         //basic configuration
         $responsiveSliderConfiguration['RESPONSIVESLIDER_ANIMATION'] = Tools::getValue('animation');
         $responsiveSliderConfiguration['RESPONSIVESLIDER_SLIDESHOWSPEED'] = (int) Tools::getValue('slideshowSpeed');
         $responsiveSliderConfiguration['RESPONSIVESLIDER_ANIMATIONSPEED'] = (int) Tools::getValue('animationSpeed');
         $responsiveSliderConfiguration['RESPONSIVESLIDER_CONTROLNAV'] = (int) Tools::getValue('controlNav');
         //configuration update
         Configuration::updateValue('RESPONSIVESLIDER_CONFIGURATION', serialize($responsiveSliderConfiguration));
         $this->_html .= '
         <div class="conf confirm">
             ' . $this->l('The slider configuration has been updated.') . '
         </div>';
     }
     /* END CONFIGURATION EDITION */
     $this->_html .= '<h2 id="module-title">' . $this->displayName . '</h2>
             <div style="display:none;" id="ajax-response"></div>';
     if (is_writable($this->local_path . 'images/')) {
         $this->_displayForm();
     } else {
         $this->_html .= '
         <div class="conf error">
             ' . $this->l('The folder images in the module responsiveslider is not writable. Please allow the system to write in the images folder') . '
         </div>';
     }
     return $this->_html;
 }