Example #1
0
 private function importData($data)
 {
     if (empty($data)) {
         return false;
     }
     $import_data = json_decode($data, true);
     if (!is_array($import_data)) {
         if ($this->isVerbose) {
             _e('Import data is not valid.', MPSL_TEXTDOMAIN) . "<br/>";
         }
         return false;
     }
     if (isset($import_data['sliders'])) {
         $importedMedia = $this->importUploads($import_data['uploads']);
         if (!empty($importedMedia)) {
             if ($this->isVerbose) {
                 echo '<br/>' . __('Uploads imported', MPSL_TEXTDOMAIN) . '<br/><hr/><br/>';
             }
         }
         // replace placeholders in data with new attachment ids
         $this->updateAttachmentIds($import_data, $importedMedia);
         foreach ($import_data['sliders'] as $slider_data) {
             global $mpslAdmin;
             $slider = new MPSLSliderOptions();
             $slider->overrideOptions($slider_data['options'], false);
             $slider->makeAliasUnique();
             $sliderId = $slider->create();
             if (false !== $sliderId) {
                 if ($this->isVerbose) {
                     printf(__('Slider "%s" options imported.', MPSL_TEXTDOMAIN), $slider->getAlias());
                     echo '<br/>';
                 }
                 foreach ($slider_data['slides'] as $slide_data) {
                     $slide = new MPSLSlideOptions();
                     $slide->overrideOptions($slide_data['options'], false);
                     $slide->setLayers($slide_data['layers']);
                     $result = $slide->import($sliderId);
                     if (false !== $result) {
                         if ($this->isVerbose) {
                             printf(__('Slide "%s" of slider "%s" imported.', MPSL_TEXTDOMAIN), $slide->getTitle(), $slider->getAlias());
                             echo '<br/>';
                         }
                     } else {
                         if ($this->isVerbose) {
                             global $wpdb;
                             printf(__('Slide "%s" of slider "%s" is not imported. Error: %s', MPSL_TEXTDOMAIN), $slide->getTitle(), $slider->getAlias(), $wpdb->last_error);
                             echo '<br/>';
                         }
                     }
                 }
             } else {
                 if ($this->isVerbose) {
                     global $wpdb;
                     printf(__('Slider "%s" is not imported. Error: %s', MPSL_TEXTDOMAIN), $slider->getAlias(), $wpdb->last_error);
                     echo '<br/>';
                 }
             }
         }
     }
     return true;
 }
Example #2
0
 function duplicateSlideCallback()
 {
     mpslVerifyNonce();
     if (isset($_POST['id'])) {
         $id = (int) $_POST['id'];
         require_once $this->pluginDir . 'SlideOptions.php';
         $slide = new MPSLSlideOptions($id);
         $slide->duplicateSlide($id);
     } else {
         mpslSetError(__('Slide ID is not set.', MPSL_TEXTDOMAIN));
     }
     die;
 }
Example #3
0
 public function getExportSliderData(&$internalResources)
 {
     $slidesData = array();
     $slides = $this->getSlides();
     foreach ((array) $slides as $slide) {
         $slideObj = new MPSLSlideOptions((int) $slide['id']);
         $slideData['options'] = $slideObj->getOptionValuesForExport($internalResources);
         $slideData['layers'] = $slideObj->getLayersForExport($internalResources);
         $slidesData[] = $slideData;
     }
     $exportSliderData = array('options' => $this->getOptionValues(), 'slides' => $slidesData);
     return $exportSliderData;
 }