66use wcf \system \condition \type \AbstractConditionType ;
77use wcf \system \condition \type \IContextualConditionType ;
88use wcf \system \condition \type \IMigrateConditionType ;
9- use wcf \system \form \builder \field \SingleSelectionFormField ;
9+ use wcf \system \form \builder \field \MultipleSelectionFormField ;
1010use wcf \system \request \RequestHandler ;
1111
1212/**
1515 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
1616 * @since 6.3
1717 *
18- * @implements IContextualConditionType<string>
19- * @extends AbstractConditionType<string>
18+ * @implements IContextualConditionType<string[] >
19+ * @extends AbstractConditionType<string[] >
2020 */
2121final class ActivePageRequestConditionType extends AbstractConditionType implements IContextualConditionType, IMigrateConditionType
2222{
@@ -33,19 +33,18 @@ public function getLabel(): string
3333 }
3434
3535 #[\Override]
36- public function getFormField (string $ id ): SingleSelectionFormField
36+ public function getFormField (string $ id ): MultipleSelectionFormField
3737 {
38- // SelectFormField stores its value as a string,
39- // so we need to convert it to an integer in the `matches` method.
40- return SingleSelectionFormField::create ($ id )
38+ return MultipleSelectionFormField::create ($ id )
4139 ->options ((new PageNodeTree ())->getNodeList (), true )
40+ ->filterable ()
4241 ->required ();
4342 }
4443
4544 #[\Override]
4645 public function matches (): bool
4746 {
48- return RequestHandler::getInstance ()->getActivePageID () === ( int ) $ this ->filter ;
47+ return \in_array ( RequestHandler::getInstance ()->getActivePageID (), $ this ->filter ) ;
4948 }
5049
5150 #[\Override]
@@ -54,18 +53,15 @@ public function migrateConditionData(array &$conditionData): array
5453 $ reverseLogic = $ conditionData ['pageIDs_reverseLogic ' ] ?? false ;
5554 $ pageIDs = $ conditionData ['pageIDs ' ] ?? [];
5655
57- if ($ reverseLogic || \count ( $ pageIDs ) > 1 ) {
56+ if ($ reverseLogic ) {
5857 // `NotOnPageRequestConditionType` should migrate the data.
5958 return [];
6059 }
6160
62- $ conditions = [];
63- foreach ($ pageIDs as $ pageID ) {
64- $ conditions [] = [
65- 'identifier ' => $ this ->getIdentifier (),
66- 'value ' => (string )$ pageID ,
67- ];
68- }
61+ $ conditions [] = [
62+ 'identifier ' => $ this ->getIdentifier (),
63+ 'value ' => \array_map ('strval ' , $ pageIDs ),
64+ ];
6965
7066 unset($ conditionData ['pageIDs ' ], $ conditionData ['pageIDs_reverseLogic ' ]);
7167
0 commit comments