diff --git a/src/Manage.php b/src/Manage.php index 0e830fc..711b920 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -20,6 +20,10 @@ use dcPage; use dcThemes; use dcNsProcess; use Dotclear\Helper\File\Files; +use Dotclear\Helper\Html\Form\{ + Div, + Text +}; use Dotclear\Helper\Network\Http; use Exception; @@ -293,9 +297,13 @@ class Manage extends dcNsProcess if (dcCore::app()->error->flag() || !$is_configured) { echo - '
' . __('pacKman is not well configured.') . ' ' . - '' . __('Configuration') . '' . - '
'; + (new Div()) + ->separator(' ') + ->class('warning') + ->items([ + (new Text(null, sprintf(__('Module "%s" is not well configured.'), My::name()))), + ]) + ->render(); } else { Utils::modules( dcCore::app()->plugins->getDefines((new Settings())->hide_distrib ? ['distributed' => false] : []), diff --git a/src/Utils.php b/src/Utils.php index c840966..0b19323 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -20,6 +20,8 @@ use Dotclear\Helper\File\Files; use Dotclear\Helper\File\Path; use Dotclear\Helper\Html\Form\{ Checkbox, + Div, + Form, Hidden, Label, Para, @@ -101,56 +103,75 @@ class Utils $type = $type == 'themes' ? 'themes' : 'plugins'; - echo - '
' . - '

' . $title . '

' . - '
' . - '' . - '' . - '' . - '' . - '' . - ''; - - $i = 1; + $i = 1; + $tbody = []; self::sort($modules); foreach ($modules as $module) { - echo - '' . - (new Para(null, 'td'))->class('nowrap')->items([ - (new Checkbox(['modules[' . Html::escapeHTML($module->get('root')) . ']', 'modules_' . $type . $i], false))->value(Html::escapeHTML($module->getId())), - (new Label(Html::escapeHTML($module->getId()), Label::OUTSIDE_LABEL_AFTER))->for('modules_' . $type . $i)->class('classic'), - - ])->render() . - '' . - '' . - '' . - ''; + $tbody[] = (new Para(null, 'tr')) + ->class('line') + ->items([ + (new Para(null, 'td')) + ->class('nowrap') + ->items([ + (new Checkbox(['modules[' . Html::escapeHTML($module->get('root')) . ']', 'modules_' . $type . $i], false)) + ->value(Html::escapeHTML($module->getId())), + (new Label(Html::escapeHTML($module->getId()), Label::OUTSIDE_LABEL_AFTER)) + ->class('classic') + ->for('modules_' . $type . $i), + ]), + (new Text('td', Html::escapeHTML($module->get('version')))) + ->class('nowrap count'), + (new Text('td', Html::escapeHTML($module->get('name')))) + ->class('nowrap'), + (new Text('td', dirname((string) Path::real($module->get('root'), false)))) + ->class('nowrap maximal'), + ]); $i++; } echo - '
' . __('Id') . '' . __('Version') . '' . __('Name') . '' . __('Root') . '
' . - Html::escapeHTML($module->get('version')) . - '' . - __(Html::escapeHTML($module->get('name'))) . - '' . - dirname((string) Path::real($module->get('root'), false)) . - '
' . - '

' . - (new Para())->items([ - (new Hidden(['redir'], Html::escapeHTML($_REQUEST['redir'] ?? ''))), - (new Hidden(['p'], My::id())), - (new Hidden(['type'], $type)), - (new Hidden(['action'], 'packup')), - (new Submit(['packup']))->value(__('Pack up selected modules')), - dcCore::app()->formNonce(false), - ])->render() . - '
' . - - '
'; + (new Div('packman-' . $type)) + ->class('multi-part') + ->title($title) + ->items([ + (new Text('h3', $title)), + (new Form('packman-form-' . $type)) + ->method('post') + ->action('plugin.php') + ->fields([ + (new Para(null, 'table')) + ->class('clear') + ->items([ + (new Para(null, 'tr')) + ->items([ + (new Text('th', Html::escapeHTML(__('Id')))) + ->class('nowrap'), + (new Text('th', Html::escapeHTML(__('Version')))) + ->class('nowrap'), + (new Text('th', Html::escapeHTML(__('Name')))) + ->class('nowrap'), + (new Text('th', Html::escapeHTML(__('Root')))) + ->class('nowrap'), + ]), + (new Para(null, 'tbody')) + ->items($tbody), + ]), + (new Para()) + ->class('checkboxes-helpers'), + (new Para()) + ->items([ + (new Hidden(['redir'], Html::escapeHTML($_REQUEST['redir'] ?? ''))), + (new Hidden(['p'], My::id())), + (new Hidden(['type'], $type)), + (new Hidden(['action'], 'packup')), + (new Submit(['packup'])) + ->value(__('Pack up selected modules')), + dcCore::app()->formNonce(false), + ]), + ]), + ]) + ->render(); return true; } @@ -164,11 +185,6 @@ class Utils return null; } - echo - '
' . - '

' . $title . '

'; - $combo_action = [__('delete') => 'delete']; if ($type == 'plugins' || $type == 'themes') { @@ -187,17 +203,7 @@ class Utils $combo_action[sprintf(__('move to %s directory'), __('repository'))] = 'move_to_repository'; } - echo - '
' . - '' . - '' . - '' . - '' . - '' . - '' . - ''; - - $dup = []; + $dup = $tbody = []; $i = 1; self::sort($modules); foreach ($modules as $module) { @@ -207,51 +213,89 @@ class Utils $dup[$module->get('root')] = 1; - echo - '' . - (new Para(null, 'td'))->class('nowrap')->items([ - (new Checkbox(['modules[' . Html::escapeHTML($module->get('root')) . ']', 'r_modules_' . $type . $i], false))->value(Html::escapeHTML($module->getId())), - (new Label(Html::escapeHTML($module->getId()), Label::OUTSIDE_LABEL_AFTER))->for('r_modules_' . $type . $i)->class('classic')->title(Html::escapeHTML($module->get('root'))), - - ])->render() . - '' . - '' . - '' . - '' . - ''; + $tbody[] = (new Para(null, 'tr')) + ->class('line') + ->items([ + (new Para(null, 'td')) + ->class('nowrap') + ->items([ + (new Checkbox(['modules[' . Html::escapeHTML($module->get('root')) . ']', 'r_modules_' . $type . $i], false)) + ->value(Html::escapeHTML($module->getId())), + (new Label(Html::escapeHTML($module->getId()), Label::OUTSIDE_LABEL_AFTER)) + ->class('classic') + ->for('r_modules_' . $type . $i) + ->title(Html::escapeHTML($module->get('root'))), + ]), + (new Text('td', Html::escapeHTML($module->get('version')))) + ->class('nowrap count'), + (new Text('td', Html::escapeHTML($module->get('name')))) + ->class('nowrap'), + (new Para(null, 'td')) + ->class('nowrap') + ->items([ + (new Text('a', Html::escapeHTML(basename($module->get('root'))))) + ->class('packman-download') + ->extra( + 'href="' . dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), [ + 'package' => basename($module->get('root')), + 'repo' => $type, + ]) . '"' + ) + ->title(__('Download')), + ]), + (new Text('td', Html::escapeHTML(Date::str(__('%Y-%m-%d %H:%M'), (int) @filemtime($module->get('root')))))) + ->class('nowrap maximal'), + ]); $i++; } echo - '
' . __('Id') . '' . __('Version') . '' . __('Name') . '' . __('File') . '' . __('Date') . '
' . - Html::escapeHTML($module->get('version')) . - '' . - __(Html::escapeHTML($module->get('name'))) . - '' . - '' . - Html::escapeHTML(basename($module->get('root'))) . '' . - '' . - Html::escapeHTML(Date::str(__('%Y-%m-%d %H:%M'), (int) @filemtime($module->get('root')))) . - '
' . - '
' . - '

' . - (new Para())->class('col right')->items([ - (new Text('', __('Selected modules action:') . ' ')), - (new Select(['action']))->items($combo_action), - (new Submit(['packup']))->value(__('ok')), - (new Hidden(['p'], My::id())), - (new Hidden(['tab'], 'repository')), - (new Hidden(['type'], $type)), - dcCore::app()->formNonce(false), - ])->render() . - '
' . - '
' . - '
'; + (new Div('packman-repository-' . $type)) + ->class('multi-part') + ->title($title) + ->items([ + (new Text('h3', $title)), + (new Form('packman-form-repository-' . $type)) + ->method('post') + ->action('plugin.php') + ->fields([ + (new Para(null, 'table')) + ->class('clear') + ->items([ + (new Para(null, 'tr')) + ->items([ + (new Text('th', Html::escapeHTML(__('Id')))) + ->class('nowrap'), + (new Text('th', Html::escapeHTML(__('Version')))) + ->class('nowrap'), + (new Text('th', Html::escapeHTML(__('Name')))) + ->class('nowrap'), + (new Text('th', Html::escapeHTML(__('File')))) + ->class('nowrap'), + (new Text('th', Html::escapeHTML(__('Date')))) + ->class('nowrap'), + ]), + (new Para(null, 'tbody')) + ->items($tbody), + ]), + (new Para()) + ->class('checkboxes-helpers'), + (new Para())->class('col right') + ->items([ + (new Text(null, __('Selected modules action:') . ' ')), + (new Select(['action'])) + ->items($combo_action), + (new Submit(['packup'])) + ->value(__('ok')), + (new Hidden(['p'], My::id())), + (new Hidden(['tab'], 'repository')), + (new Hidden(['type'], $type)), + dcCore::app()->formNonce(false), + ]), + ]), + ]) + ->render(); return true; }