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->get('types')) && in_array($action->get('id'), $_POST['actions'])) { $preferences[$type][] = $action->get('id'); } } } $core->blog->settings->improve->put('preferences', serialize($preferences), 'string', null, true, true); dcPage::addSuccessNotice(__('Configuration successfully updated')); } $allow_distrib = (bool) $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 = []; $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; } dcUtils::lexicalKeySort($combo_modules); $combo_modules = array_merge([__('Select a module') => '-'], $combo_modules); $module = $_REQUEST['module'] ?? ''; if (!in_array($module, $combo_modules)) { $module = '-'; } if (!empty($_POST['fix'])) { if (empty($_POST['actions'])) { dcPage::addWarningNotice(__('No action selected')); } elseif ($module == '-') { dcPage::addWarningNotice(__('No module selected')); } else { try { $time = $improve->fixModule( $type, $module, $type == 'plugin' ? $core->plugins->getModules($module) : $core->themes->getModules($module), $_POST['actions'] ); $log_id = $improve->writeLogs(); $core->blog->triggerBlog(); if ($improve->hasLog('error')) { $notice = ['type' => 'error', 'msg' => __('Fix of "%s" complete in %s secondes with errors')]; } elseif ($improve->hasLog('warning')) { $notice = ['type' => 'warning', 'msg' => __('Fix of "%s" complete in %s secondes with warnings')]; } elseif ($improve->hasLog('success')) { $notice = ['type' => 'success', 'msg' => __('Fix of "%s" complete in %s secondes')]; } else { $notice = ['type' => 'success', 'msg' => __('Fix of "%s" complete in %s secondes without messages')]; } dcPage::addNotice($notice['type'], sprintf($notice['msg'], $module, $time)); $core->adminurl->redirect('admin.plugin.improve', ['type' => $type, 'module' => $module, 'upd' => $log_id]); } catch (Exception $e) { $core->error->add($e->getMessage()); } } } $action = null; $header = ''; $breadcrumb = []; if (!empty($_REQUEST['config'])) { $breadcrumb = [ __('Configure module') => '' ]; if (null !== ($action = $improve->module($_REQUEST['config']))) { $header = $action->header(); } } else { $breadcrumb[$type == 'theme' ? __('Themes actions') : __('Plugins actions')] = ''; } # display header echo '' . __('improve') . '' . dcPage::jsLoad(dcPage::getPF('improve/js/index.js')) . $header . '' . dcPage::breadcrumb(array_merge([ __('Plugins') => '', __('improve') => '' ], $breadcrumb)) . dcPage::notices(); # Menu list if (empty($_REQUEST['config'])) { echo '
' . '

' . form::combo('type', [__('Plugins') => 'plugin', __('Themes') => 'theme'], $type) . ' ' . '' . form::hidden('p', 'improve') . '

' . '
'; } if (!empty($_REQUEST['config'])) { $back_url = $_REQUEST['redir'] ?? $core->adminurl->get('admin.plugin.improve', ['type' => $type]); if (null !== $action) { $redir = $_REQUEST['redir'] ?? $core->adminurl->get('admin.plugin.improve', ['type' => $type, 'config' => $action->get('id')]); $res = $action->configure($redir); echo '

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

' . __('Back') . '

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

' . (empty($res) ? '

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

' : $res) . '

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

' . '
'; } else { echo '

' . __('Unknow module') . '

' . __('Back') . '

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

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

'; } else { echo '
' . '' . ''; foreach ($improve->modules() as $action) { if (!in_array($type, $action->get('types'))) { continue; } echo '' . '' . '' . '' . '' . (DC_DEBUG ? '' : '') . ''; } echo '
' . __('Action') . '' . '' . __('Description') . '' . '' . __('Configuration') . '' . (DC_DEBUG ? '' . __('Priority') . '' : '') . '
' . form::checkbox( ['actions[]', 'action_' . $action->get('id')], $action->get('id'), in_array($action->get('id'), $preferences[$type]) && $action->isConfigured(), '', '', !$action->isConfigured() ) . '' . '' . '' . $action->get('desc') . '' . ( false === $action->get('config') ? '' : 'get('name')) . '">' . __('Configure') . '' ) . '' . $action->get('priority') . '

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


'; if (!empty($_REQUEST['upd']) && !$core->blog->settings->improve->nodetails) { $logs = $improve->parseLogs($_REQUEST['upd']); if (!empty($logs)) { echo '

' . __('Details') . '

'; foreach ($logs as $path => $types) { echo '
' . $path . '
'; foreach ($types as $type => $tools) { echo '
'; } echo ''; } echo '
'; } } } } echo '';