blog->settings->improve->preferences); if (!is_array($preferences)) { $preferences = []; } $preferences = array_merge(['plugin' => [], 'theme' => []], $preferences); if (!empty($_POST['save_preferences'])) { $preferences[$type] = []; if (!empty($_POST['actions'])) { foreach($improve->modules() as $action) { if (in_array($type, $action->types) && in_array($action->id, $_POST['actions'])) { $preferences[$type][] = $action->id; } } } $core->blog->settings->improve->put('preferences', serialize($preferences), 'string', null, true, true); } $allow_distrib = (boolean) $core->blog->settings->improve->allow_distrib; $official = [ 'plugin' => explode(',', DC_DISTRIB_PLUGINS), 'theme' => explode(',', DC_DISTRIB_THEMES) ]; if (!isset($core->themes)) { $core->themes = new dcThemes($core); $core->themes->loadModules($core->blog->themes_path, null); } $combo_modules = [__('Select a module') => '-']; $modules = $type == 'plugin' ? $core->plugins->getModules() : $core->themes->getModules(); foreach($modules as $id => $m) { if (!$m['root_writable'] || !$allow_distrib && in_array($id, $official[$type])) { continue; } $combo_modules[$m['name']] = $id; } $module = $_POST['module'] ?? ''; if (!in_array($module, $combo_modules)) { $module = '-'; } if (!empty($_POST['fix'])) { if (empty($_POST['actions'])) { dcPage::addWarningNotice(__('No action selected')); } if ($module == '-') { dcPage::addWarningNotice(__('No module selected')); } else { try { $time_start = microtime(true); $improve->fix( $type, $module, $type == 'plugin' ? $core->plugins->getModules($module) : $core->themes->getModules($module), $_POST['actions'] ); $time_end = microtime(true); $core->blog->triggerBlog(); dcPage::addSuccessNotice(sprintf( __('Fix of %s complete in %s secondes'), $module, substr($time_end - $time_start, 0, 5) )); http::redirect($improve->getURL(['type' => $type])); } catch (Exception $e) { $core->error->add($e->getMessage()); } } } $breadcrumb = []; if (!empty($_REQUEST['config'])) { $breadcrumb = [ ($type == 'plugin' ? __('Plugins') : __('Themes')) => $improve->getURL(['type' => ($type == 'plugin' ? 'plugin' : 'theme')]), '' . __('Configure module') . '' => '' ]; } else { $breadcrumb = [ '' . ($type == 'plugin' ? __('Plugins') : __('Themes')) . '' => '', ($type == 'theme' ? __('Plugins') : __('Themes')) => $improve->getURL(['type' => ($type == 'theme' ? 'plugin' : 'theme')]) ]; } # display header echo '' . __('improve') . '' . dcPage::breadcrumb(array_merge([__('improve') => ''], $breadcrumb),['hl' => false]) . dcPage::notices(); if (!empty($_REQUEST['config'])) { $back_url = $_REQUEST['redir'] ?? $improve->getURL(['type' => $type]); if (null !== ($action = $improve->module($_REQUEST['config']))) { $redir = $_REQUEST['redir'] ?? $improve->getURL(['type' => $type, 'config' => $action->id]); $res = $action->configure($redir); echo '

' . sprintf(__('Configure module "%s"'), $action->name) . '

' . html::escapeHTML($action->desc) . '

' . __('Back') . '

' . (empty($res) ? '

' . __('Nothing to configure'). '

' : $res) . '

' . form::hidden('type', $type) . form::hidden('config', $action->id) . form::hidden('redir', $redir) . $core->formNonce() . '

' . ''; } else { echo '

' . __('Unknow module') . '

' . __('Back') . '

'; } } else { echo '

' . ($type == 'plugin' ? __('Plugins') : __('Themes')) . '

'; if (count($combo_modules) == 1) { echo '

' . __('No module to manage') . '

'; } else { echo ''; foreach($improve->modules() as $action) { if (!in_array($type, $action->types)) { continue; } $p = DC_DEBUG ? '' . $action->priority. ' ' : ''; echo '

' . $p . ''; if (false !== $action->config) { echo ' - name) . '">' . __('Configure module') . ''; } echo '

'; } echo '

' . form::combo('module', $combo_modules, $module) . '

' . form::hidden(['type'], $type) . $core->formNonce() . '


'; } } echo '';