1
0

Show configuration form after saving

This commit is contained in:
onli
2014-08-18 16:59:26 +02:00
parent 3600354ab7
commit f545369922
2 changed files with 40 additions and 48 deletions

View File

@ -20,58 +20,51 @@ if (!serendipity_checkPermission('siteConfiguration') && !serendipity_checkPermi
$data = array(); $data = array();
switch ($_POST['installAction'] && serendipity_checkFormToken()) { if ($_POST['installAction'] == 'check' && serendipity_checkFormToken()) {
case 'check': $data['installAction'] = 'check';
$data['installAction'] = 'check'; $oldConfig = $serendipity;
$oldConfig = $serendipity; $res = serendipity_updateConfiguration();
$res = serendipity_updateConfiguration(); $data['res'] = $res;
$data['res'] = $res; if (is_array($res)) {
if (is_array($res)) { $data['diagnosticError'] = true;
$data['diagnosticError'] = true; } else {
} else { /* If we have new rewrite rules, then install them */
/* If we have new rewrite rules, then install them */ $permalinkOld = array(
$permalinkOld = array( $oldConfig['serendipityHTTPPath'],
$oldConfig['serendipityHTTPPath'], $oldConfig['serendipityPath'],
$oldConfig['serendipityPath'], $oldConfig['defaultBaseURL'],
$oldConfig['defaultBaseURL'], $oldConfig['indexFile'],
$oldConfig['indexFile'], $oldConfig['rewrite']);
$oldConfig['rewrite']);
$permalinkNew = array( $permalinkNew = array(
$serendipity['serendipityHTTPPath'], $serendipity['serendipityHTTPPath'],
$serendipity['serendipityPath'], $serendipity['serendipityPath'],
$serendipity['defaultBaseURL'], $serendipity['defaultBaseURL'],
$serendipity['indexFile'], $serendipity['indexFile'],
$serendipity['rewrite']); $serendipity['rewrite']);
// Compare all old permalink section values against new one. A change in any of those // Compare all old permalink section values against new one. A change in any of those
// will force to update the .htaccess for rewrite rules. // will force to update the .htaccess for rewrite rules.
$permconf = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE); $permconf = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE);
if (is_array($permconf) && is_array($permconf['permalinks']['items'])) { if (is_array($permconf) && is_array($permconf['permalinks']['items'])) {
foreach($permconf['permalinks']['items'] AS $permitem) { foreach($permconf['permalinks']['items'] AS $permitem) {
$permalinkOld[] = $oldConfig[$permitem['var']]; $permalinkOld[] = $oldConfig[$permitem['var']];
$permalinkNew[] = $serendipity[$permitem['var']]; $permalinkNew[] = $serendipity[$permitem['var']];
}
} }
if (serendipity_checkPermission('siteConfiguration') && serialize($permalinkOld) != serialize($permalinkNew)) {
$data['htaccessRewrite'] = true;
$data['serendipityPath'] = $serendipity['serendipityPath'];
$res = serendipity_installFiles($serendipity['serendipityPath']);
$data['res'] = $res;
serendipity_buildPermalinks();
} }
if (serendipity_checkPermission('siteConfiguration') && serialize($permalinkOld) != serialize($permalinkNew)) {
$data['htaccessRewrite'] = true;
$data['serendipityPath'] = $serendipity['serendipityPath'];
$res = serendipity_installFiles($serendipity['serendipityPath']);
$data['res'] = $res;
serendipity_buildPermalinks();
} }
}
break;
default:
$from = &$serendipity;
$t = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE);
$data['config'] = serendipity_printConfigTemplate($t, $from, false, true);
break;
} }
$data['config'] = serendipity_printConfigTemplate(serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE), $serendipity, false, true);
if (!is_object($serendipity['smarty'])) { if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init(); serendipity_smarty_init();
} }

View File

@ -1,3 +1,4 @@
<h2>{$CONST.CONFIGURATION}</h2>
{if $installAction == 'check'} {if $installAction == 'check'}
{if $diagnosticError} {if $diagnosticError}
<h2>{$CONST.DIAGNOSTIC_ERROR}</h2> <h2>{$CONST.DIAGNOSTIC_ERROR}</h2>
@ -17,7 +18,5 @@
{/if} {/if}
<span class="msg_success"><span class="icon-ok-circled"></span> {$CONST.WRITTEN_N_SAVED}</span> <span class="msg_success"><span class="icon-ok-circled"></span> {$CONST.WRITTEN_N_SAVED}</span>
{/if} {/if}
{else}
<h2>{$CONST.CONFIGURATION}</h2>
{$config}
{/if} {/if}
{$config}