/** this returns fieldset containing the configuration points you need to use autoupgrade * @return string */ private function _displayCurrentConfiguration() { $current_ps_config = $this->getcheckCurrentPsConfig(); $this->_html .= '<div class="bootstrap" id="currentConfigurationBlock"> <div class="panel"> <div class="panel-heading"> ' . $this->l('The pre-Upgrade checklist') . ' </div>'; if (!$this->configOk()) { $this->_html .= '<p class="alert alert-warning">' . $this->l('The checklist is not OK. You can only upgrade your shop once all indicators are green.') . '</p>'; } $this->_html .= '<div id="currentConfiguration"> <p class="alert alert-info">' . $this->l('Before starting the upgrade process, please make sure this checklist is all green.') . '</p>'; $pic_ok = '<img src="../img/admin/enabled.gif" alt="ok"/>'; $pic_nok = '<img src="../img/admin/disabled.gif" alt="nok"/>'; $pic_warn = '<img src="../img/admin/warning.gif" alt="warn"/>'; // module version : checkAutoupgradeLastVersion $this->_html .= '<table class="table" cellpadding="0" cellspacing="0"> <tr> <td>' . sprintf($this->l('The 1-click upgrade module is up-to-date (your current version is v%s)'), $this->getModuleVersion()) . ' ' . ($current_ps_config['module_version_ok'] ? '' : ' ' . (version_compare(_PS_VERSION_, '1.5.3.0', '>') ? '<strong><a href="index.php?controller=AdminModules&token=' . Tools14::getAdminTokenLite('AdminModules') . '&update=autoupgrade">' . $this->l('Update') . '</a></strong> - ' : '') . '<strong><a class="_blank" href="http://addons.prestashop.com/en/administration-tools-prestashop-modules/5496-1-click-upgrade-autoupgrade.html">' . $this->l('Download') . '</a><strong> ') . ' </td> <td>' . ($current_ps_config['module_version_ok'] ? $pic_ok : $pic_nok) . '</td> </tr>'; // root : getRootWritable() $this->_html .= ' <tr> <td>' . $this->l('Your store\'s root directory is writable (with appropriate CHMOD permissions)') . '</td> <td>' . ($current_ps_config['root_writable'] ? $pic_ok : $pic_nok . ' ' . $this->root_writable_report) . '</td> </tr>'; $admin_dir = trim(str_replace($this->prodRootDir, '', $this->adminDir), DIRECTORY_SEPARATOR); $report = ''; ConfigurationTest::test_dir($admin_dir . DIRECTORY_SEPARATOR . $this->autoupgradeDir, true, $report); if ($report) { $this->_html .= ' <tr> <td>' . $this->l('The "/admin/autoupgrade" directory is writable (appropriate CHMOD permissions)') . '</td> <td>' . ($current_ps_config['admin_au_writable'] ? $pic_ok : $pic_nok . ' ' . $report) . '</td> </tr>'; } //check safe_mod if (!($safe_mode = @ini_get('safe_mode'))) { $safe_mode = ''; } $safe_mode = in_array(Tools14::strtolower($safe_mode), array(1, 'on')); $this->_html .= ' <tr><td>' . $this->l('PHP\'s "Safe mode" option is turned off') . '</td> <td>' . (!$safe_mode ? $pic_ok : $pic_warn) . '</td></tr>'; $this->_html .= ' <tr><td>' . $this->l('PHP\'s "allow_url_fopen" option is turned on, or cURL is installed') . '</td> <td>' . (ConfigurationTest::test_fopen() || ConfigurationTest::test_curl() ? $pic_ok : $pic_nok) . '</td></tr>'; // shop enabled $this->_html .= ' <tr><td>' . $this->l('Your store is in maintenance mode') . ' ' . (!$current_ps_config['shop_deactivated'] ? '<br><form method="post" action="' . $this->currentIndex . '&token=' . $this->token . '"><input type="submit" class="button" name="putUnderMaintenance" value="' . $this->l('Click here to put your shop under maintenance') . '"></form>' : '') . '</td> <td>' . ($current_ps_config['shop_deactivated'] ? $pic_ok : $pic_nok) . '</td></tr>'; $this->_html .= ' <tr><td>' . $this->l('PrestaShop\'s caching features are disabled') . '</td> <td>' . ($current_ps_config['cache_deactivated'] ? $pic_ok : $pic_nok) . '</td></tr>'; // for informaiton, display time limit $max_exec_time = ini_get('max_execution_time'); $this->_html .= ' <tr><td>' . sprintf($this->l('PHP\'s max_execution_time setting has a high value or is disabled entirely (current value: %s)'), $max_exec_time == 0 ? $this->l('unlimited') : sprintf($this->l('%s seconds'), $max_exec_time)) . '</td> <td>' . ($max_exec_time == 0 ? $pic_ok : $pic_warn) . '</td></tr> </table> <br/> <p class="alert alert-info">' . $this->l('Please also make sure you make a full manual backup of your files and database.') . '</p> </div> </div> </div>'; }
protected function _displayForm($name, $fields, $tabname, $size, $icon) { global $currentIndex; $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT'); $languages = Language::getLanguages(false); $confValues = $this->getConf($fields, $languages); $divLangName = $this->getDivLang($fields); $required = false; echo ' <script type="text/javascript"> id_language = Number(' . $defaultLanguage . '); function addRemoteAddr(){ var length = $(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\').length; if (length > 0) $(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\',$(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\') +\',' . Tools14::getRemoteAddr() . '\'); else $(\'input[name=PS_MAINTENANCE_IP]\').attr(\'value\',\'' . Tools14::getRemoteAddr() . '\'); } </script> <form action="' . $currentIndex . '&submit' . $name . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data"> <fieldset><legend><img src="../img/admin/' . strval($icon) . '.gif" />' . $tabname . '</legend>'; foreach ($fields as $key => $field) { /* Specific line for e-mails settings */ if (get_class($this) == 'Adminemails' and $key == 'PS_MAIL_SERVER') { echo '<div id="smtp" style="display: ' . ((isset($confValues['PS_MAIL_METHOD']) and $confValues['PS_MAIL_METHOD'] == 2) ? 'block' : 'none') . ';">'; } if (isset($field['required']) and $field['required']) { $required = true; } $val = $this->getVal($confValues, $key); if (!in_array($field['type'], array('image', 'radio', 'container', 'container_end')) or isset($field['show'])) { echo '<div style="clear: both; padding-top:15px;">' . ($field['title'] ? '<label >' . $field['title'] . '</label>' : '') . '<div class="margin-form" style="padding-top:5px;">'; } /* Display the appropriate input type for each field */ switch ($field['type']) { case 'disabled': echo $field['disabled']; break; case 'select': echo ' <select name="' . $key . '"' . (isset($field['js']) === true ? ' onchange="' . $field['js'] . '"' : '') . ' id="' . $key . '">'; foreach ($field['list'] as $k => $value) { echo '<option value="' . (isset($value['cast']) ? $value['cast']($value[$field['identifier']]) : $value[$field['identifier']]) . '"' . ($val == $value[$field['identifier']] ? ' selected="selected"' : '') . '>' . $value['name'] . '</option>'; } echo ' </select>'; break; case 'selectLang': foreach ($languages as $language) { echo ' <div id="' . $key . '_' . $language['id_lang'] . '" style="margin-bottom:8px; display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left; vertical-align: top;"> <select name="' . $key . '_' . strtoupper($language['iso_code']) . '">'; foreach ($field['list'] as $k => $value) { echo '<option value="' . (isset($value['cast']) ? $value['cast']($value[$field['identifier']]) : $value[$field['identifier']]) . '"' . (htmlentities(Tools14::getValue($key . '_' . strtoupper($language['iso_code']), Configuration::get($key . '_' . strtoupper($language['iso_code'])) ? Configuration::get($key . '_' . strtoupper($language['iso_code'])) : ''), ENT_COMPAT, 'UTF-8') == $value[$field['identifier']] ? ' selected="selected"' : '') . '>' . $value['name'] . '</option>'; } echo ' </select> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, $key); break; case 'bool': echo '<label class="t" for="' . $key . '_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /></label> <input type="radio" name="' . $key . '" id="' . $key . '_on" value="1"' . ($val ? ' checked="checked"' : '') . (isset($field['js']['on']) ? $field['js']['on'] : '') . ' /> <label class="t" for="' . $key . '_on"> ' . $this->l('Yes') . '</label> <label class="t" for="' . $key . '_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" style="margin-left: 10px;" /></label> <input type="radio" name="' . $key . '" id="' . $key . '_off" value="0" ' . (!$val ? 'checked="checked"' : '') . (isset($field['js']['off']) ? $field['js']['off'] : '') . '/> <label class="t" for="' . $key . '_off"> ' . $this->l('No') . '</label>'; break; case 'radio': foreach ($field['choices'] as $cValue => $cKey) { echo '<input type="radio" name="' . $key . '" id="' . $key . $cValue . '_on" value="' . (int) $cValue . '"' . ($cValue == $val ? ' checked="checked"' : '') . (isset($field['js'][$cValue]) ? ' ' . $field['js'][$cValue] : '') . ' /><label class="t" for="' . $key . $cValue . '_on"> ' . $cKey . '</label><br />'; } echo '<br />'; break; case 'image': echo ' <table cellspacing="0" cellpadding="0"> <tr>'; if ($name == 'themes') { echo ' <td colspan="' . sizeof($field['list']) . '"> <b>' . $this->l('In order to use a new theme, please follow these steps:', get_class()) . '</b> <ul> <li>' . $this->l('Import your theme using this module:', get_class()) . ' <a href="index.php?tab=AdminModules&token=' . Tools14::getAdminTokenLite('AdminModules') . '&filtername=themeinstallator" style="text-decoration: underline;">' . $this->l('Theme installer', get_class()) . '</a></li> <li>' . $this->l('When your theme is imported, please select the theme in this page', get_class()) . '</li> </ul> </td> </tr> <tr> '; } $i = 0; foreach ($field['list'] as $theme) { echo '<td class="center" style="width: 180px; padding:0px 20px 20px 0px;"> <input type="radio" name="' . $key . '" id="' . $key . '_' . $theme['name'] . '_on" style="vertical-align: text-bottom;" value="' . $theme['name'] . '"' . (_THEME_NAME_ == $theme['name'] ? 'checked="checked"' : '') . ' /> <label class="t" for="' . $key . '_' . $theme['name'] . '_on"> ' . Tools14::strtolower($theme['name']) . '</label> <br /> <label class="t" for="' . $key . '_' . $theme['name'] . '_on"> <img src="../themes/' . $theme['name'] . '/preview.jpg" alt="' . Tools14::strtolower($theme['name']) . '"> </label> </td>'; if (isset($field['max']) and ($i + 1) % $field['max'] == 0) { echo '</tr><tr>'; } $i++; } echo '</tr> </table>'; break; case 'price': $default_currency = new Currency((int) Configuration::get("PS_CURRENCY_DEFAULT")); echo $default_currency->getSign('left') . '<input type="' . $field['type'] . '" size="' . (isset($field['size']) ? (int) $field['size'] : 5) . '" name="' . $key . '" value="' . ($field['type'] == 'password' ? '' : htmlentities($val, ENT_COMPAT, 'UTF-8')) . '" />' . $default_currency->getSign('right') . ' ' . $this->l('(tax excl.)'); break; case 'textLang': foreach ($languages as $language) { echo ' <div id="' . $key . '_' . $language['id_lang'] . '" style="margin-bottom:8px; display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left; vertical-align: top;"> <input type="text" size="' . (isset($field['size']) ? (int) $field['size'] : 5) . '" name="' . $key . '_' . $language['id_lang'] . '" value="' . htmlentities($this->getVal($confValues, $key . '_' . $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, $key); break; case 'file': if (isset($field['thumb']) and $field['thumb'] and $field['thumb']['pos'] == 'before') { echo '<img src="' . $field['thumb']['file'] . '" alt="' . $field['title'] . '" title="' . $field['title'] . '" /><br />'; } echo '<input type="file" name="' . $key . '" />'; break; case 'textarea': echo '<textarea name=' . $key . ' cols="' . $field['cols'] . '" rows="' . $field['rows'] . '">' . htmlentities($val, ENT_COMPAT, 'UTF-8') . '</textarea>'; break; case 'container': echo '<div id="' . $key . '">'; break; case 'container_end': echo (isset($field['content']) === true ? $field['content'] : '') . '</div>'; break; case 'maintenance_ip': echo '<input type="' . $field['type'] . '"' . (isset($field['id']) === true ? ' id="' . $field['id'] . '"' : '') . ' size="' . (isset($field['size']) ? (int) $field['size'] : 5) . '" name="' . $key . '" value="' . ($field['type'] == 'password' ? '' : htmlentities($val, ENT_COMPAT, 'UTF-8')) . '" />' . (isset($field['next']) ? ' ' . strval($field['next']) : '') . ' <a href="#" class="button" onclick="addRemoteAddr(); return false;">' . $this->l('Add my IP') . '</a>'; break; case 'text': default: echo '<input type="' . $field['type'] . '"' . (isset($field['id']) === true ? ' id="' . $field['id'] . '"' : '') . ' size="' . (isset($field['size']) ? (int) $field['size'] : 5) . '" name="' . $key . '" value="' . ($field['type'] == 'password' ? '' : htmlentities($val, ENT_COMPAT, 'UTF-8')) . '" />' . (isset($field['next']) ? ' ' . strval($field['next']) : ''); } echo (isset($field['required']) and $field['required'] and !in_array($field['type'], array('image', 'radio'))) ? ' <sup>*</sup>' : ''; echo isset($field['desc']) ? '<p style="clear:both">' . ((isset($field['thumb']) and $field['thumb'] and $field['thumb']['pos'] == 'after') ? '<img src="' . $field['thumb']['file'] . '" alt="' . $field['title'] . '" title="' . $field['title'] . '" style="float:left;" />' : '') . $field['desc'] . '</p>' : ''; if (!in_array($field['type'], array('image', 'radio', 'container', 'container_end')) or isset($field['show'])) { echo '</div></div>'; } } /* End of specific div for e-mails settings */ if (get_class($this) == 'Adminemails') { echo '<script type="text/javascript">if (getE(\'PS_MAIL_METHOD2_on\').checked) getE(\'smtp\').style.display = \'block\'; else getE(\'smtp\').style.display = \'none\';</script></div>'; } if (!is_writable(_PS_ADMIN_DIR_ . '/../config/settings.inc.php') and $name == 'themes') { echo '<p><img src="../img/admin/warning.gif" alt="" /> ' . $this->l('if you change the theme, the settings.inc.php file must be writable (CHMOD 755 / 777)') . '</p>'; } echo ' <div align="center" style="margin-top: 20px;"> <input type="submit" value="' . $this->l(' Save ', 'AdminPreferences') . '" name="submit' . ucfirst($name) . $this->table . '" class="button" /> </div> ' . ($required ? '<div class="small"><sup>*</sup> ' . $this->l('Required field', 'AdminPreferences') . '</div>' : '') . ' </fieldset> </form>'; if (get_class($this) == 'AdminPreferences') { echo '<script type="text/javascript">changeCMSActivationAuthorization();</script>'; } }
/** this returns fieldset containing the configuration points you need to use autoupgrade * @return string */ private function _displayCurrentConfiguration() { $current_ps_config = $this->getcheckCurrentPsConfig(); $this->_html .= ' <fieldset id="currentConfigurationBlock" class="width autoupgrade" style="float: left; width: 60%; margin-left: 30px;"> <legend>' . $this->l('The pre-Upgrade checklist') . '</legend>'; if (!$this->configOk()) { $this->_html .= '<div class="clear"><br></div><p class="warn">' . $this->l('The checklist is not ok. You can not upgrade your shop until every indicator will not be green.') . '</p>'; } $this->_html .= '<div id="currentConfiguration"> <p>' . $this->l('Before starting the upgrade process, please make sure this checklist is all green.') . '</p> <table class="table" cellpadding="0" cellspacing="0">'; $pic_ok = '<img src="../img/admin/enabled.gif" alt="ok"/>'; $pic_nok = '<img src="../img/admin/disabled.gif" alt="nok"/>'; $pic_warn = '<img src="../img/admin/warning.gif" alt="warn"/>'; // module version : checkAutoupgradeLastVersion $this->_html .= ' <tr> <td>' . sprintf($this->l('The 1-click upgrade module is up-to-date (your current version is v%s)'), $this->getModuleVersion()) . ' ' . ($current_ps_config['module_version_ok'] ? '' : ' ' . (version_compare(_PS_VERSION_, '1.5.3.0', '>') ? '<strong><a href="index.php?controller=AdminModules&token=' . Tools14::getAdminTokenLite('AdminModules') . '&update=autoupgrade">' . $this->l('Update') . '</a></strong> - ' : '') . '<strong><a class="_blank" href="http://addons.prestashop.com/en/administration-tools-prestashop-modules/5496-1-click-upgrade-autoupgrade.html">' . $this->l('Download') . '</a><strong> ') . ' </td> <td>' . ($current_ps_config['module_version_ok'] ? $pic_ok : $pic_nok) . '</td> </tr>'; // root : getRootWritable() $this->_html .= ' <tr> <td>' . $this->l('Your store root directory must be writeable (appropriate CHMOD permissions)') . '</td> <td>' . ($current_ps_config['root_writable'] ? $pic_ok : $pic_nok . ' ' . $this->root_writable_report) . '</td> </tr>'; //check safe_mod if (!($safe_mode = @ini_get('safe_mode'))) { $safe_mode = ''; } $safe_mode = in_array(Tools14::strtolower($safe_mode), array(1, 'on')); $this->_html .= ' <tr><td>' . $this->l('The PHP "Safe mode" option must be turned off') . '</td> <td>' . (!$safe_mode ? $pic_ok : $pic_warn) . '</td></tr>'; $this->_html .= ' <tr><td>' . $this->l('The PHP "allow_url_fopen" option must be turned on or CURL must be installed') . '</td> <td>' . (ConfigurationTest::test_fopen() || ConfigurationTest::test_curl() ? $pic_ok : $pic_nok) . '</td></tr>'; // shop enabled $this->_html .= ' <tr><td>' . $this->l('You must put your store under maintenance') . ' ' . (!$current_ps_config['shop_deactivated'] ? '<br><form method="post" action="' . $this->currentIndex . '&token=' . $this->token . '"><input type="submit" class="button" name="putUnderMaintenance" value="' . $this->l('Click here to put your shop under maintenance') . '"></form>' : '') . '</td> <td>' . ($current_ps_config['shop_deactivated'] ? $pic_ok : $pic_nok) . '</td></tr>'; $this->_html .= ' <tr><td>' . $this->l('You must disable the Caching features of PrestaShop') . '</td> <td>' . ($current_ps_config['cache_deactivated'] ? $pic_ok : $pic_nok) . '</td></tr>'; // for informaiton, display time limit $max_exec_time = ini_get('max_execution_time'); $this->_html .= ' <tr><td>' . sprintf($this->l('The PHP time limit must be either high or disabled (Current value: %s)'), $max_exec_time == 0 ? $this->l('unlimited') : $max_exec_time . ' ' . $this->l('seconds')) . '</td> <td>' . ($max_exec_time == 0 ? $pic_ok : $pic_warn) . '</td></tr> </table> <p>' . $this->l('Please also make sure you proceeded to a full manual backup of your files and database.') . '</p> </div> </fieldset>'; }