diff --git a/src/ManageList.php b/src/ManageList.php index 567ed06..05ed2df 100644 --- a/src/ManageList.php +++ b/src/ManageList.php @@ -31,33 +31,30 @@ use Dotclear\Helper\Html\Html; */ class ManageList extends adminGenericListV2 { - public function display(adminGenericFilterV2 $filter, string $enclose = ''): void + public function display(adminGenericFilterV2 $filter, string $enclose = '%s'): void { + // nullsafe if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) { return; } + // prepare page + $blocks = explode('%s', $enclose); + $pager = new dcPager((int) $filter->value('page'), (int) $this->rs_count, (int) $filter->value('nb'), 10); + $tz = dcCore::app()->auth->getInfo('user_tz') ?? (dcCore::app()->blog->settings->get('system')->get('blog_timezone') ?? 'UTC'); + + // no record if ($this->rs->isEmpty()) { - echo '
' . ( - $filter->show() ? - __('No widgets matching the filter.') : __('No widget') - ) . '
'; + echo sprintf( + '%s
', + $filter->show() ? __('No widgets matching the filter.') : __('No widget') + ); return; } - $pager = new dcPager((int) $filter->value('page'), (int) $this->rs_count, (int) $filter->value('nb'), 10); - - $content = '' . __('Post title') . ' | ', 'post_dt' => '' . __('Post date') . ' | ', 'option_title' => '' . __('Widget title') . ' | ', @@ -66,49 +63,65 @@ class ManageList extends adminGenericListV2 'post_type' => '' . __('Type') . ' | ', ]); - $this->userColumns(My::id(), $cols); + $this->userColumns(My::id(), $thead); - $content .= implode(iterator_to_array($cols)) . '
---|
' . (new Checkbox(['widgets[]'], (bool) $this->rs->f('option_id')))->value($this->rs->f('option_id'))->disabled(!$this->rs->isEditable())->render() . ' | ', - 'name' => '' . + // table body line + $tbody = new ArrayObject([ + 'check' => ' | ' . + (new Checkbox(['widgets[]'], (bool) in_array($this->rs->f('option_id'), $_REQUEST['widgets'] ?? []))) + ->__call('value', [$this->rs->f('option_id')]) + ->__call('disabled', [!$this->rs->isEditable()]) + ->render() . + ' | ', + 'name' => '' . Html::escapeHTML($this->rs->f('post_title')) . ' | ', 'post_dt' => '' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('post_dt'), $tz) . ' | ', 'option_title' => '' . $w_title . ' | ', 'option_creadt' => '' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('option_upddt'), $tz) . ' | ', 'user_id' => '' . $this->rs->f('user_id') . ' | ', 'post_type' => '' . $this->rs->f('post_type') . ' | ', - ]); - $this->userColumns(My::id(), $cols); + $this->userColumns(My::id(), $tbody); - $content .= '