/** * */ public function postProcess() { if (Tools::getValue('exportProfile')) { if ($this->profile->id) { $export = array(); $export['layout'] = $this->profile->layout; $export['widget'] = $this->profile->widget; $export_file = fopen(_PAGEBUILDER_EXPORT_DIR_ . $this->profile->name . '.txt', 'w') or die('Unable to open file!'); fwrite($export_file, serialize($export)); fclose($export_file); $this->context->smarty->assign(array('export_msg' => $this->l('Successful export: ') . _PAGEBUILDER_EXPORT_DIR_ . $this->profile->name . '.txt')); } } /* import data */ if (Tools::isSubmit('submitpspagebuilderImport') && isset($_FILES['import_file'])) { $tmp = $_FILES['import_file']['tmp_name']; $content = trim(Tools::file_get_contents($tmp)); if ($content) { $data = unserialize($content); if (isset($data['layout']) && isset($data['widget'])) { $profile = new PsPagebuilderprofile(); $profile->layout = $data['layout']; $name = trim(Tools::getValue('import_name')); $profile->name = $name ? $name : 'profile-' . time(); $profile->widget = $data['widget']; if ($profile->id <= 0) { if (!$profile->add()) { $this->displayError($this->l('The slide could not be added.')); } } else { $this->errors[] = Tools::displayError('You do not have permission to add this.'); } } } $this->module->clearBLHLCache(); } if (Tools::getIsset('duplicateprofile')) { if ($this->tabAccess['add'] === '1') { $this->processDuplicate(); } else { $this->errors[] = Tools::displayError('You do not have permission to add this.'); } $this->module->clearBLHLCache(); } if (Tools::isSubmit('savelayoutbuilder')) { $profile = new PsPagebuilderprofile(Tools::getValue('id_pagebuilderprofile')); $profile->layout = Tools::getValue('wpolayout'); $wpowidget = Tools::getValue('wpowidget'); if ($wpowidget) { foreach ($wpowidget as &$value) { $value['config'] = Tools::stripslashes($value['config']); } } $profile->widget = serialize($wpowidget); $name = trim(Tools::getValue('name')); $profile->name = $name ? $name : 'profile-' . time(); $errors = array(); if ($profile->id && !$profile->update()) { $errors[] = $this->displayError($this->l('The slide could not be updated.')); } else { if ($profile->id <= 0 && !$profile->add()) { $errors[] = $this->displayError($this->l('The slide could not be added.')); } } $this->module->clearBLHLCache(); Tools::redirectAdmin(AdminController::$currentIndex . '&id_pagebuilderprofile=' . $profile->id . '&token=' . Tools::getAdminTokenLite('AdminPspagebuilderProfile')); } if (Tools::getValue('setdefault')) { $profile = new PsPagebuilderprofile(Tools::getValue('id_pagebuilderprofile')); $profile->setDefault(); $this->module->clearBLHLCache(); Tools::redirectAdmin(AdminController::$currentIndex . '&id_pagebuilderprofile=' . $profile->id . '&token=' . Tools::getAdminTokenLite('AdminPspagebuilderProfile')); } }