add options to sort modules and show distributed modules
This commit is contained in:
parent
52b16c0e3f
commit
7bc5d8989f
2 changed files with 23 additions and 3 deletions
|
@ -24,6 +24,7 @@ use Dotclear\Helper\Html\Form\{
|
|||
Label,
|
||||
Legend,
|
||||
Para,
|
||||
Select,
|
||||
Text
|
||||
};
|
||||
use Exception;
|
||||
|
@ -61,6 +62,8 @@ class Config extends dcNsProcess
|
|||
}
|
||||
dcCore::app()->blog->settings->get(My::id())->put('disabled', $pdisabled);
|
||||
dcCore::app()->blog->settings->get(My::id())->put('nodetails', !empty($_POST['nodetails']));
|
||||
dcCore::app()->blog->settings->get(My::id())->put('allow_distrib', !empty($_POST['allow_distrib']));
|
||||
dcCore::app()->blog->settings->get(My::id())->put('combosortby', $_POST['combosortby'] ?: 'name');
|
||||
|
||||
dcPage::addSuccessNotice(__('Configuration successfully updated'));
|
||||
|
||||
|
@ -103,6 +106,14 @@ class Config extends dcNsProcess
|
|||
(new Checkbox('nodetails', (bool) dcCore::app()->blog->settings->get(My::id())->get('nodetails')))->value('1'),
|
||||
(new Label(__('Hide details of rendered actions'), Label::OUTSIDE_LABEL_AFTER))->class('classic')->for('nodetails'),
|
||||
]),
|
||||
(new Para())->items([
|
||||
(new Checkbox('allow_distrib', (bool) dcCore::app()->blog->settings->get(My::id())->get('allow_distrib')))->value('1'),
|
||||
(new Label(__('Show dotclear distributed modules'), Label::OUTSIDE_LABEL_AFTER))->class('classic')->for('allow_distrib'),
|
||||
]),
|
||||
(new Para())->items([
|
||||
(new Label(__('Sort modules seletion by:')))->for('combosortby'),
|
||||
(new Select('combosortby'))->items([__('Name') => 'name', __('Id') => 'id'])->default(dcCore::app()->blog->settings->get(My::id())->get('combosortby')),
|
||||
]),
|
||||
]),
|
||||
])->render();
|
||||
}
|
||||
|
|
|
@ -129,13 +129,22 @@ class Manage extends dcNsProcess
|
|||
}
|
||||
|
||||
$combo_modules = [];
|
||||
foreach (self::$type == 'plugin' ? dcCore::app()->plugins->getDefines() : dcCore::app()->themes->getDefines() as $module) {
|
||||
$modules = self::$type == 'plugin' ? dcCore::app()->plugins->getDefines() : dcCore::app()->themes->getDefines();
|
||||
if (dcCore::app()->blog->settings->get(My::id())->get('combosortby') == 'id') {
|
||||
uasort($modules, fn ($a, $b) => strtolower($a->getId()) <=> strtolower($b->getId()));
|
||||
} else {
|
||||
uasort($modules, fn ($a, $b) => strtolower(dcUtils::removeDiacritics($a->get('name'))) <=> strtolower(dcUtils::removeDiacritics($b->get('name'))));
|
||||
}
|
||||
foreach ($modules as $module) {
|
||||
if (!$module->get('root_writable') || !dcCore::app()->blog->settings->get(My::id())->get('allow_distrib') && $module->get('distributed')) {
|
||||
continue;
|
||||
}
|
||||
$combo_modules[sprintf(__('%s (%s)'), __($module->get('name')), $module->getId())] = $module->getId();
|
||||
if (dcCore::app()->blog->settings->get(My::id())->get('combosortby') == 'id') {
|
||||
$combo_modules[sprintf(__('%s (%s)'), $module->getId(), __($module->get('name')))] = $module->getId();
|
||||
} else {
|
||||
$combo_modules[sprintf(__('%s (%s)'), __($module->get('name')), $module->getId())] = $module->getId();
|
||||
}
|
||||
}
|
||||
dcUtils::lexicalKeySort($combo_modules);
|
||||
|
||||
return array_merge([__('Select a module') => '-'], $combo_modules);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue