function smartyModifierPPSafeoutput($string, $type = null) { if ($type === null) { $type = 'html'; } switch ($type) { case 'html': return PP::safeOutput($string); case 'js': case 'javascript': return PP::safeOutputJS($string); case 'value': return PP::safeOutputValue($string); default: return $string; } }
/** Called in Back Office when user clicks "Configure" */ public function getContent() { if (Configuration::get('PS_DISABLE_NON_NATIVE_MODULE')) { return '<div class="module_error alert alert-danger">' . $this->l('Non PrestaShop modules disabled.') . '</div>'; } $this->active_languages = $this->context->controller->getLanguages(); $this->default_language_id = $this->context->controller->default_form_language; $setup = $this->setupInstance(); if (!(int) Tools::getValue('pp')) { $setup->checkIntegration(); } $tab = '0'; $output0 = $output1 = $output2 = $output3 = $output4 = ''; $templates = null; $properties = null; if (Tools::isSubmit('submitRestoreDefaults')) { $tab = '0'; $setup->insertData(true); } elseif (Tools::isSubmit('cancelSaveTemplate')) { $tab = '0'; } elseif (Tools::isSubmit('cancelSaveProperty')) { $tab = '1'; } elseif (Tools::isSubmit('submitSaveTemplate')) { $result = $this->saveTemplate(); if ($result['error'] == '') { $tab = '0'; } else { $templates = $result['templates']; $output4 = $this->displayError($result['error']); $tab = '4'; } } elseif (Tools::isSubmit('submitSaveProperty')) { $result = $this->saveProperty(); if ($result['error'] == '') { $tab = '1'; } else { $properties = $result['properties']; $output4 = $this->displayError($result['error']); $tab = '4'; } } elseif (Tools::isSubmit('submitConfigSettings')) { $tab = '2'; Configuration::updateValue('PP_MEASUREMENT_SYSTEM', (int) Tools::getValue('measurement_system', 1)); Configuration::updateValue('PP_MEASUREMENT_SYSTEM_FO', (int) Tools::getValue('measurement_system_fo', 0)); Configuration::updateValue('PP_POWEREDBY', (int) Tools::getValue('poweredby', 0)); Configuration::updateValue('PP_TEMPLATE_NAME_IN_CATALOG', (int) Tools::getValue('template_name_in_catalog', 1)); Configuration::updateValue('PP_SHOW_POSITIONS', (int) Tools::getValue('show_positions', 0)); $output2 = $this->displayConfirmation($this->l('Settings updated')); } elseif (Tools::isSubmit('submitSetup')) { $tab = '2'; $setup->runSetup(); } elseif (Tools::isSubmit('submitIntegration')) { $tab = '2'; $setup->runIntegrationTest(); } elseif (Tools::isSubmit('clickClearCache')) { $tab = '2'; PSM::clearCache(); } elseif (Tools::isSubmit('submitStatistics')) { $tab = '3'; } elseif (Tools::isSubmit('clickEditTemplate')) { $tab = '4'; } elseif (Tools::isSubmit('clickDeleteTemplate')) { $tab = '0'; $this->deleteTemplate(); } elseif (Tools::isSubmit('clickHiddenStatusTemplate')) { $tab = '0'; $this->changeHiddenStatus(); } elseif (Tools::isSubmit('clickEditProperty')) { $tab = '4'; } elseif (Tools::isSubmit('clickDeleteProperty')) { $tab = '1'; $this->deleteProperty(); } $html = ''; if (version_compare(_PS_VERSION_, $this->ps_versions_compliancy['min']) < 0 || version_compare(_PS_VERSION_, $this->ps_versions_compliancy['max']) > 0) { $html .= $this->displayError($this->l('This module is not fully compatible with the installed PrestaShop version.') . ' ' . $this->compatibilityText() . '<br>' . $this->l('Please upgrade to the newer version.') . '<br>'); } if (count($this->integration_test_result) != 0) { $html .= $this->displayError($this->l('Integration test failed.')); $tab = '2'; } $tabs = array(); $tabs[0] = array('type' => 'templates', 'name' => $this->l('Templates'), 'html' => $output0 . $this->getTemplatesTabHtml()); $tabs[1] = array('type' => 'properties', 'name' => $this->l('Properties'), 'html' => $output1 . $this->getPropertiesTabHtml()); $tabs[2] = array('type' => 'settings', 'name' => $this->l('Settings'), 'html' => $output2 . $this->getSettingsTabHtml(Tools::isSubmit('submitIntegration') || Tools::isSubmit('submitSetup'))); $tabs[3] = array('type' => 'statistics', 'name' => $this->l('Statistics'), 'html' => $output3 . $this->getStatisticsTabHtml(Tools::isSubmit('submitStatistics'))); if ($tab == 4 && (Tools::isSubmit('clickEditTemplate') || Tools::isSubmit('submitSaveTemplate'))) { $mode = Tools::getValue('mode'); if ($mode == 'add') { $title = $this->l('Add template'); } elseif ($mode == 'copy') { $title = $this->l('Add template'); } else { $mode = 'edit'; $title = $this->l('Edit template'); } $tabs[4] = array('type' => 'modifyTemplate', 'name' => $title, 'html' => $output4 . $this->getEditTemplateTabHtml($templates, $mode, $title)); } elseif ($tab == 4 && (Tools::isSubmit('clickEditProperty') || Tools::isSubmit('submitSaveProperty'))) { $mode = Tools::getValue('mode'); if ($mode == 'add') { $type = (int) Tools::getValue('type'); if ($type == self::PROPERTY_TYPE_GENERAL) { $title = $this->l('Add property attribute'); } elseif ($type == self::PROPERTY_TYPE_BUY_BLOCK_TEXT) { $title = $this->l('Add property text'); } else { $title = $this->l('Add property dimension'); } } else { $mode = 'edit'; $title = $this->l('Edit property'); } $tabs[4] = array('type' => 'modifyProperty', 'name' => $title, 'html' => $output4 . $this->getEditPropertyTabHtml($properties, $mode, $title)); } //$helper->fields_value['tab'] = $tab; $helper = $this->createTemplate('pproperties'); $helper->tpl_vars['html'] = $html; $helper->tpl_vars['tabs'] = $tabs; $helper->tpl_vars['active'] = $tab; $helper->tpl_vars['version'] = $this->version; $helper->tpl_vars['ppe_id'] = PSM::getPSMId($this); $helper->tpl_vars['_path'] = $this->getPathUri(); $helper->tpl_vars['s_user_guide'] = $this->l('user guide'); $helper->tpl_vars['s_version'] = $this->l('Version'); $helper->tpl_vars['s_pp_info_ignore'] = $this->l("don't show this message again"); $helper->tpl_vars['token_adminpproperties'] = Tools::getAdminTokenLite('AdminPproperties'); $helper->tpl_vars['jstranslations'] = PP::safeOutputJS(array('rerun' => $this->l('Re-run Setup'), 'integration_module_success_IntegrationModuleIgnore' => $this->l('ignored - please re-run setup'), 'integration_module_success_IntegrationModuleIntegrate' => $this->l('integation activated - please re-run setup'), 'integration_module_rerun_IntegrationModuleCheckForUpdates' => $this->l('please re-run setup'), 'integration_module_downloaded_IntegrationModuleCheckForUpdates' => $this->l('update downloaded - please re-run setup'), 'integration_module_no_updates_IntegrationModuleCheckForUpdates' => $this->l('no updates available - please contact customer support'), 'integration_module_error' => $this->l('error occurred'))); if (!Module::isInstalled('psmextmanager') && Module::getInstanceByName('psmextmanager')) { $helper->tpl_vars['psmextmanager_install'] = $this->context->link->getAdminLink('AdminModules') . '&install=psmextmanager&tab_module=administration&module_name=psmextmanager&anchor=Psmextmanager'; } return $helper->generate(); }