namespace wcf\acp\form;
+use wcf\data\IStorableObject;
use wcf\data\menu\item\MenuItem;
use wcf\data\menu\item\MenuItemAction;
use wcf\data\menu\item\MenuItemNodeTree;
$parameters['data']['externalURL'] = '';
} else {
$parameters['data']['pageID'] = null;
- $parameters['data']['pageObjectID'] = null;
+ $parameters['data']['pageObjectID'] = 0;
}
unset($parameters['data']['isInternalLink']);
return $parameters;
+ },
+ function (IFormDocument $document, array $data, IStorableObject $object) {
+ \assert($object instanceof MenuItem);
+ $data['isInternalLink'] = $object->pageID !== null;
+
+ return $data;
}
)
);
#[\Override]
public function getI18nSaveTypes(): array
{
- return ['title' => 'wcf.menu.item.\w+'];
+ return [
+ 'title' => 'wcf.menu.item.\w+',
+ 'externalURL' => 'wcf.menu.item.externalURL\d+',
+ ];
}
#[\Override]
protected function getLanguageItem(DatabaseObject $object, string $regex): string
{
\assert($object instanceof MenuItem);
-
- return \str_replace(
- '\w+',
- $object->identifier ?: 'com.woltlab.wcf.generic' . $object->itemID,
- $regex
- );
+ if (\str_contains($regex, '\d+')) {
+ return \str_replace('\d+', $object->itemID, $regex);
+ } else {
+ return \str_replace(
+ '\w+',
+ $object->identifier ?: 'com.woltlab.wcf.generic' . $object->itemID,
+ $regex
+ );
+ }
}
}