/** * import slider from TP servers * @since: 5.0.5 */ private static function importSliderOnlineTemplateHandle($viewBack = null, $updateAnim = true, $updateStatic = true, $single_slide = false) { dmp(__("downloading template slider from server...", 'revslider')); $uid = esc_attr(RevSliderFunctions::getPostVariable('uid')); if ($uid == '') { dmp(__("ID missing, something went wrong. Please try again!", 'revslider')); echo RevSliderFunctions::getHtmlLink($viewBack, __("Go Back", 'revslider')); exit; } else { $tmp = new RevSliderTemplate(); $package = esc_attr(RevSliderFunctions::getPostVariable('package')); $package = $package == 'true' ? true : false; //get all in the same package as the uid if ($package === true) { $uids = $tmp->get_package_uids($uid); } else { $uids = (array) $uid; } if (!empty($uids)) { foreach ($uids as $uid) { set_time_limit(60); //reset the time limit $filepath = $tmp->_download_template($uid); //can be single or multiple, depending on $package beeing false or true //send request to TP server and download file if (is_array($filepath) && isset($filepath['error'])) { dmp($filepath['error']); echo RevSliderFunctions::getHtmlLink($viewBack, __("Go Back", 'revslider')); exit; } if ($filepath !== false) { //check if Slider Template was already imported. If yes, remove the old Slider Template as we now do an "update" (in reality we delete and insert again) //get all template sliders $tmp_slider = $tmp->getThemePunchTemplateSliders(); foreach ($tmp_slider as $tslider) { if (isset($tslider['uid']) && $uid == $tslider['uid']) { if (!isset($tslider['installed'])) { //slider is installed //delete template Slider! $mSlider = new RevSlider(); $mSlider->initByID($tslider['id']); $mSlider->deleteSlider(); //remove the update flag from the slider $tmp->remove_is_new($uid); } break; } } $slider = new RevSlider(); $response = $slider->importSliderFromPost($updateAnim, $updateStatic, $filepath, $uid, $single_slide); $tmp->_delete_template($uid); if ($single_slide === false) { if (empty($viewBack)) { $sliderID = $response["sliderID"]; $viewBack = self::getViewUrl(self::VIEW_SLIDER, "id=" . $sliderID); if (empty($sliderID)) { $viewBack = self::getViewUrl(self::VIEW_SLIDERS); } } } //handle error if ($response["success"] == false) { $message = $response["error"]; dmp("<b>Error: " . $message . "</b>"); echo RevSliderFunctions::getHtmlLink($viewBack, __("Go Back", 'revslider')); } else { //handle success, js redirect. if (count($uids) > 1) { dmp(__("Slider Import Success", 'revslider')); } else { dmp(__("Slider Import Success, redirecting...", 'revslider')); } } } else { if (is_array($filepath)) { dmp($filepath['error']); } else { dmp(__("Could not download from server. Please try again later!", 'revslider')); } echo RevSliderFunctions::getHtmlLink($viewBack, __("Go Back", 'revslider')); exit; } } echo "<script>location.href='{$viewBack}'</script>"; } else { dmp(__("Could not download package. Please try again later!", 'revslider')); exit; } } exit; }
/** * delete slider from input data * @since: 5.2.5 */ public function duplicateSliderPackageFromData($data) { $tmpl = new RevSliderTemplate(); $slider_uid = RevSliderFunctions::getVal($data, "slideruid"); $uids = $tmpl->get_package_uids($slider_uid); foreach ($uids as $sid => $uid) { if ($sid < 0) { //one or more still needs to be downloaded... return __('Please install Package first to use this feature', 'revslider'); } } foreach ($uids as $sliderID => $uid) { $slider = new RevSlider(); $slider->initByID($sliderID); $slider->duplicateSlider(RevSliderFunctions::getVal($data, "title"), true); } return true; }