From 642ea68a4137b8e680326361bd0406bd2e0d5e74 Mon Sep 17 00:00:00 2001
From: Jean-Christian Denis
' . - form::datetime('post_expired_date', [ - 'default' => html::escapeHTML(self::dateToUser($post_expired['date'] ?? 'now')), - 'class' => (empty($post_expired['date']) ? 'invalid' : ''), - ]) - . '
'; + $fields['post_expired_date'] = (new Para())->items([ + (new Label(__('Date:')))->for('post_expired_date'), + (new Datetime('post_expired_date', Html::escapeHTML(self::dateToUser($post_expired['date'] ?? 'now'))))->class(empty($post_expired['date']) ? 'invalid' : ''), + ]); - $fields['post_expired_status'] = '' . - form::combo( - 'post_expired_status', - self::statusCombo(), - empty($post_expired['status']) ? - '' : $post_expired['status'] - ) . '
'; + $fields['post_expired_status'] = (new Para())->items([ + (new Text('strong', __('On this date, change:'))), + (new Text('br')), + (new Label(__('Status:')))->for('post_expired_status'), + (new Select('post_expired_status'))->default(empty($post_expired['status']) ? '' : $post_expired['status'])->items(self::statusCombo()), + ]); if ($post_type == 'post') { - $fields['post_expired_category'] = '' . - form::combo( - 'post_expired_category', - self::categoriesCombo( - dcCore::app()->blog->getCategories( - ['post_type' => 'post'] - ) - ), - empty($post_expired['category']) ? - '' : $post_expired['category'] - ) . '
'; + $fields['post_expired_category'] = (new Para())->items([ + (new Label(__('Category:')))->for('post_expired_category'), + (new Select('post_expired_category'))->default(empty($post_expired['category']) ? '' : $post_expired['category'])->items(self::categoriesCombo( + dcCore::app()->blog->getCategories( + ['post_type' => 'post'] + ) + )), + ]); - $fields['post_expired_selected'] = '' . - form::combo( - 'post_expired_selected', - self::selectedCombo(), - empty($post_expired['selected']) ? - '' : $post_expired['selected'] - ) . '
'; + $fields['post_expired_selected'] = (new Para())->items([ + (new Label(__('Selection:')))->for('post_expired_selected'), + (new Select('post_expired_selected'))->default(empty($post_expired['selected']) ? '' : $post_expired['selected'])->items(self::selectedCombo()), + ]); } - $fields['post_expired_comment'] = '' . - form::combo( - 'post_expired_comment', - self::commentCombo(), - empty($post_expired['comment']) ? - '' : $post_expired['comment'] - ) . '
'; + $fields['post_expired_comment'] = (new Para())->items([ + (new Label(__('Comments status:')))->for('post_expired_comment'), + (new Select('post_expired_comment'))->default(empty($post_expired['comment']) ? '' : $post_expired['comment'])->items(self::commentCombo()), + ]); - $fields['post_expired_trackback'] = '' . - form::combo( - 'post_expired_trackback', - self::trackbackCombo(), - empty($post_expired['trackback']) ? - '' : $post_expired['trackback'] - ) . '
'; + $fields['post_expired_trackback'] = (new Para())->items([ + (new Label(__('Trackbacks status:')))->for('post_expired_trackback'), + (new Select('post_expired_trackback'))->default(empty($post_expired['trackback']) ? '' : $post_expired['trackback'])->items(self::trackbackCombo()), + ]); + + if ($render) { + foreach ($fields as $k => $v) { + $fields[$k] = $v->render(); + } + } return $fields; } @@ -358,8 +356,8 @@ class BackendBehaviors ['post_type' => 'post'] ); while ($categories->fetch()) { - $categories_combo[] = new formSelectOption( - str_repeat(' ', ((int) $categories->f('level')) - 1) . '• ' . html::escapeHTML($categories->f('cat_title')), + $categories_combo[] = new Option( + str_repeat(' ', ((int) $categories->f('level')) - 1) . '• ' . Html::escapeHTML($categories->f('cat_title')), '!' . $categories->f('cat_id') ); }