24
24
MetaRecord
25
25
};
26
26
use Dotclear \Helper \Html \Form \{
27
+ Checkbox ,
27
28
Datetime ,
28
29
Form ,
29
30
Hidden ,
31
+ Input ,
30
32
Label ,
33
+ Note ,
31
34
Option ,
32
35
Para ,
33
36
Text ,
@@ -124,11 +127,15 @@ public static function adminAfterPostSave(Cursor $cur, int $post_id): void
124
127
self ::delPostExpired ($ post_id );
125
128
126
129
if (!empty ($ _POST ['post_expired_date ' ])
127
- && (!empty ($ _POST ['post_expired_status ' ])
128
- || !empty ($ _POST ['post_expired_category ' ])
129
- || !empty ($ _POST ['post_expired_selected ' ])
130
- || !empty ($ _POST ['post_expired_comment ' ])
131
- || !empty ($ _POST ['post_expired_trackback ' ]))) {
130
+ && (
131
+ !empty ($ _POST ['post_expired_status ' ])
132
+ || !empty ($ _POST ['post_expired_category ' ])
133
+ || !empty ($ _POST ['post_expired_selected ' ])
134
+ || !empty ($ _POST ['post_expired_comment ' ])
135
+ || !empty ($ _POST ['post_expired_trackback ' ])
136
+ || !empty ($ _POST ['post_expired_password ' ])
137
+ )
138
+ ) {
132
139
self ::setPostExpired ($ post_id , new ArrayObject ($ _POST ));
133
140
}
134
141
}
@@ -152,13 +159,17 @@ public static function callbackAdd(dcPostsActions $pa, ArrayObject $post): void
152
159
throw new Exception (__ ('No entry selected ' ));
153
160
}
154
161
155
- // Add epired date
162
+ // Add expired date
156
163
if (!empty ($ post ['post_expired_date ' ])
157
- && (!empty ($ post ['post_expired_status ' ])
158
- || !empty ($ post ['post_expired_category ' ])
159
- || !empty ($ post ['post_expired_selected ' ])
160
- || !empty ($ post ['post_expired_comment ' ])
161
- || !empty ($ post ['post_expired_trackback ' ]))) {
164
+ && (
165
+ !empty ($ post ['post_expired_status ' ])
166
+ || !empty ($ post ['post_expired_category ' ])
167
+ || !empty ($ post ['post_expired_selected ' ])
168
+ || !empty ($ post ['post_expired_comment ' ])
169
+ || !empty ($ post ['post_expired_trackback ' ])
170
+ || !empty ($ post ['post_expired_password ' ])
171
+ )
172
+ ) {
162
173
foreach ($ posts_ids as $ post_id ) {
163
174
self ::delPostExpired ($ post_id );
164
175
self ::setPostExpired ($ post_id , $ post );
@@ -242,12 +253,14 @@ private static function delPostExpired(int $post_id): void
242
253
private static function setPostExpired (int $ post_id , ArrayObject $ post ): void
243
254
{
244
255
$ post_expired = [
245
- 'status ' => '' ,
246
- 'category ' => '' ,
247
- 'selected ' => '' ,
248
- 'comment ' => '' ,
249
- 'trackback ' => '' ,
250
- 'date ' => self ::dateFromUser ($ post ['post_expired_date ' ]),
256
+ 'status ' => '' ,
257
+ 'category ' => '' ,
258
+ 'selected ' => '' ,
259
+ 'comment ' => '' ,
260
+ 'trackback ' => '' ,
261
+ 'password ' => '' ,
262
+ 'newpassword ' => '' ,
263
+ 'date ' => self ::dateFromUser ($ post ['post_expired_date ' ]),
251
264
];
252
265
253
266
if (!empty ($ post ['post_expired_status ' ])) {
@@ -265,6 +278,12 @@ private static function setPostExpired(int $post_id, ArrayObject $post): void
265
278
if (!empty ($ post ['post_expired_trackback ' ])) {
266
279
$ post_expired ['trackback ' ] = (string ) $ post ['post_expired_trackback ' ];
267
280
}
281
+ if (!empty ($ post ['post_expired_password ' ])) {
282
+ $ post_expired ['password ' ] = (string ) $ post ['post_expired_password ' ];
283
+ }
284
+ if (!empty ($ post ['post_expired_newpassword ' ])) {
285
+ $ post_expired ['newpassword ' ] = (string ) $ post ['post_expired_newpassword ' ];
286
+ }
268
287
269
288
dcCore::app ()->meta ->setPostMeta (
270
289
$ post_id ,
@@ -303,20 +322,20 @@ private static function fieldsPostExpired(string $post_type, ?int $post_id = nul
303
322
}
304
323
305
324
$ fields ['post_expired_date ' ] = (new Para ())->items ([
306
- (new Label (__ ('Date: ' )))->for ('post_expired_date ' ),
325
+ (new Label (__ ('Date: ' ), Label:: OUTSIDE_LABEL_BEFORE ))->for ('post_expired_date ' ),
307
326
(new Datetime ('post_expired_date ' , Html::escapeHTML (self ::dateToUser ($ post_expired ['date ' ] ?? 'now ' ))))->class (empty ($ post_expired ['date ' ]) ? 'invalid ' : '' ),
308
327
]);
309
328
310
329
$ fields ['post_expired_status ' ] = (new Para ())->items ([
311
330
(new Text ('strong ' , __ ('On this date, change: ' ))),
312
331
(new Text ('br ' )),
313
- (new Label (__ ('Status: ' )))->for ('post_expired_status ' ),
332
+ (new Label (__ ('Status: ' ), Label:: OUTSIDE_LABEL_BEFORE ))->for ('post_expired_status ' ),
314
333
(new Select ('post_expired_status ' ))->default (empty ($ post_expired ['status ' ]) ? '' : $ post_expired ['status ' ])->items (self ::statusCombo ()),
315
334
]);
316
335
317
336
if ($ post_type == 'post ' ) {
318
337
$ fields ['post_expired_category ' ] = (new Para ())->items ([
319
- (new Label (__ ('Category: ' )))->for ('post_expired_category ' ),
338
+ (new Label (__ ('Category: ' ), Label:: OUTSIDE_LABEL_BEFORE ))->for ('post_expired_category ' ),
320
339
(new Select ('post_expired_category ' ))->default (empty ($ post_expired ['category ' ]) ? '' : $ post_expired ['category ' ])->items (self ::categoriesCombo (
321
340
dcCore::app ()->blog ->getCategories (
322
341
['post_type ' => 'post ' ]
@@ -325,21 +344,29 @@ private static function fieldsPostExpired(string $post_type, ?int $post_id = nul
325
344
]);
326
345
327
346
$ fields ['post_expired_selected ' ] = (new Para ())->items ([
328
- (new Label (__ ('Selection: ' )))->for ('post_expired_selected ' ),
347
+ (new Label (__ ('Selection: ' ), Label:: OUTSIDE_LABEL_BEFORE ))->for ('post_expired_selected ' ),
329
348
(new Select ('post_expired_selected ' ))->default (empty ($ post_expired ['selected ' ]) ? '' : $ post_expired ['selected ' ])->items (self ::selectedCombo ()),
330
349
]);
331
350
}
332
351
333
352
$ fields ['post_expired_comment ' ] = (new Para ())->items ([
334
- (new Label (__ ('Comments status: ' )))->for ('post_expired_comment ' ),
353
+ (new Label (__ ('Comments status: ' ), Label:: OUTSIDE_LABEL_BEFORE ))->for ('post_expired_comment ' ),
335
354
(new Select ('post_expired_comment ' ))->default (empty ($ post_expired ['comment ' ]) ? '' : $ post_expired ['comment ' ])->items (self ::commentCombo ()),
336
355
]);
337
356
338
357
$ fields ['post_expired_trackback ' ] = (new Para ())->items ([
339
- (new Label (__ ('Trackbacks status: ' )))->for ('post_expired_trackback ' ),
358
+ (new Label (__ ('Trackbacks status: ' ), Label:: OUTSIDE_LABEL_BEFORE ))->for ('post_expired_trackback ' ),
340
359
(new Select ('post_expired_trackback ' ))->default (empty ($ post_expired ['trackback ' ]) ? '' : $ post_expired ['trackback ' ])->items (self ::trackbackCombo ()),
341
360
]);
342
361
362
+ $ fields ['post_expired_password ' ] = (new Para ())->items ([
363
+ (new Checkbox ('post_expired_password ' , !empty ($ post_expired ['password ' ])))->value (1 ),
364
+ (new Label (__ ('Change password ' ), Label::OUTSIDE_LABEL_AFTER ))->for ('post_expired_password ' )->class ('classic ' ),
365
+ (new Label (__ ('New password: ' ), Label::OUTSIDE_LABEL_BEFORE ))->for ('post_expired_newpassword ' ),
366
+ (new Input ('post_expired_newpassword ' ))->size (65 )->maxlenght (255 )->class ('maximal ' )->value (empty ($ post_expired ['newpassword ' ]) ? '' : $ post_expired ['newpassword ' ]),
367
+ (new Note ())->text (__ ('Leave empty to remove it ' ))->class ('form-note ' ),
368
+ ]);
369
+
343
370
if ($ render ) {
344
371
foreach ($ fields as $ k => $ v ) {
345
372
$ fields [$ k ] = $ v ->render ();
0 commit comments