Skip to content

Commit 7e9abf5

Browse files
CyperghostBurntimeX
authored andcommitted
Additional parameter for internal menu items
1 parent bdad539 commit 7e9abf5

8 files changed

Lines changed: 58 additions & 4 deletions

File tree

XSD/menuItem.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<xs:element name="page" type="woltlab_varchar" minOccurs="1" maxOccurs="1" />
4444
<xs:element name="parent" type="woltlab_varchar" minOccurs="0" maxOccurs="1" />
4545
<xs:element name="externalURL" type="woltlab_varchar" minOccurs="0" maxOccurs="1" />
46+
<xs:element name="additionalInternalURL" type="woltlab_varchar" minOccurs="0" maxOccurs="1" />
4647
</xs:choice>
4748
</xs:extension>
4849
</xs:complexContent>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/**
4+
* Updates the database layout during the update from 6.2 to 6.3.
5+
*
6+
* @author Olaf Braun
7+
* @copyright 2001-2025 WoltLab GmbH
8+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
9+
*/
10+
11+
use wcf\system\database\table\column\NotNullVarchar255DatabaseTableColumn;
12+
use wcf\system\database\table\PartialDatabaseTable;
13+
14+
return [
15+
PartialDatabaseTable::create('wcf1_menu_item')
16+
->columns([
17+
NotNullVarchar255DatabaseTableColumn::create('additionalInternalURL')
18+
->defaultValue(''),
19+
]),
20+
];

wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ protected function createForm()
210210
->fieldId('pageID')
211211
->values(\array_keys($pageHandlers))
212212
),
213+
TextFormField::create('additionalInternalURL')
214+
->label('wcf.acp.menu.item.additionalInternalURL')
215+
->description('wcf.acp.menu.item.additionalInternalURL.description')
216+
->maximumLength(255)
217+
->addDependency(
218+
ValueFormFieldDependency::create('isInternalLinkDependency')
219+
->fieldId('isInternalLink')
220+
->values([1])
221+
),
213222
TextFormField::create('externalURL')
214223
->label('wcf.acp.menu.item.externalURL')
215224
->maximumLength(255)

wcfsetup/install/files/lib/data/menu/item/MenuItem.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* @property-read int $isDisabled is `1` if the menu item is disabled and thus not shown in the menu, otherwise `0`
3333
* @property-read int $originIsSystem is `1` if the menu item has been delivered by a package, otherwise `0` (if the menu item has been created by an admin in the ACP)
3434
* @property-read int $packageID id of the package the which delivers the menu item or `1` if it has been created in the ACP
35+
* @property-read string $additionalInternalURL
3536
*/
3637
class MenuItem extends DatabaseObject implements ITitledObject
3738
{
@@ -93,12 +94,12 @@ public function getURL()
9394
if ($this->pageObjectID) {
9495
$handler = $this->getMenuPageHandler();
9596
if ($handler && $handler instanceof ILookupPageHandler) {
96-
return $handler->getLink($this->pageObjectID);
97+
return $handler->getLink($this->pageObjectID) . $this->additionalInternalURL;
9798
}
9899
}
99100

100101
if ($this->pageID) {
101-
return $this->getPage()->getLink();
102+
return $this->getPage()->getLink() . $this->additionalInternalURL;
102103
} else {
103104
return WCF::getLanguage()->get($this->externalURL);
104105
}

wcfsetup/install/files/lib/system/package/plugin/MenuItemPackageInstallationPlugin.class.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,14 @@ protected function prepareImport(array $data)
155155
}
156156

157157
$externalURL = (!empty($data['elements']['externalURL'])) ? $data['elements']['externalURL'] : '';
158+
$additionalInternalURL = $data['elements']['additionalInternalURL'] ?? '';
158159

159160
if ($pageID === null && empty($externalURL)) {
160161
throw new SystemException("The menu item '" . $data['attributes']['identifier'] . "' must either have an associated page or an external url set.");
161162
} elseif ($pageID !== null && !empty($externalURL)) {
162163
throw new SystemException("The menu item '" . $data['attributes']['identifier'] . "' can either have an associated page or an external url, but not both.");
164+
} elseif ($pageID === null && !empty($additionalInternalURL)) {
165+
throw new SystemException("The menu item '" . $data['attributes']['identifier'] . "' can not have an additional internal URL set if it does not have an associated page.");
163166
}
164167

165168
return [
@@ -171,6 +174,7 @@ protected function prepareImport(array $data)
171174
'parentItemID' => $parentItemID,
172175
'showOrder' => $this->getItemOrder($menuID, $parentItemID),
173176
'title' => $this->getI18nValues($data['elements']['title']),
177+
'additionalInternalURL' => $additionalInternalURL,
174178
];
175179
}
176180

@@ -390,6 +394,14 @@ protected function addFormFields(IFormDocument $form)
390394
->values(['internal'])
391395
),
392396

397+
TextFormField::create('additionalInternalURL')
398+
->label('wcf.acp.pip.menuItem.additionalInternalURL')
399+
->maximumLength(255)
400+
->addDependency(
401+
ValueFormFieldDependency::create('linkType')
402+
->fieldId('linkType')
403+
->values(['internal'])
404+
),
393405
TextFormField::create('externalURL')
394406
->label('wcf.acp.pip.menuItem.externalURL')
395407
->description('wcf.acp.pip.menuItem.externalURL.description')
@@ -469,7 +481,7 @@ protected function fetchElementData(\DOMElement $element, $saveData)
469481
$data['title'][LanguageFactory::getInstance()->getLanguageByCode($title->getAttribute('language'))->languageID] = $title->nodeValue;
470482
}
471483

472-
foreach (['externalURL', 'menu', 'page', 'parent'] as $optionalElementName) {
484+
foreach (['externalURL', 'menu', 'page', 'parent', 'additionalInternalURL'] as $optionalElementName) {
473485
$optionalElement = $element->getElementsByTagName($optionalElementName)->item(0);
474486
if ($optionalElement !== null) {
475487
$data[$optionalElementName] = $optionalElement->nodeValue;
@@ -594,6 +606,10 @@ protected function prepareXmlElement(\DOMDocument $document, IFormDocument $form
594606
[
595607
'page' => '',
596608
'externalURL' => '',
609+
'additionalInternalURL' => [
610+
'defaultValue' => '',
611+
'cdata' => true,
612+
],
597613
'showOrder' => null,
598614
],
599615
$form

wcfsetup/install/lang/de.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,8 @@ Sie erreichen das Fehlerprotokoll unter: {link controller='ExceptionLogView' isE
12301230
<item name="wcf.acp.menu.item.parentItem"><![CDATA[Übergeordneter Menüpunkt]]></item>
12311231
<item name="wcf.acp.menu.link.other"><![CDATA[Sonstiges]]></item>
12321232
<item name="wcf.acp.menu.item.pageObjectID.error.invalid"><![CDATA[Die eingetragene ID ist ungültig.]]></item>
1233+
<item name="wcf.acp.menu.item.additionalInternalURL"><![CDATA[Zusätzliche interne URL-Parameter]]></item>
1234+
<item name="wcf.acp.menu.item.additionalInternalURL.description"><![CDATA[Zusätzliche Parameter die an die URL angehangen werden können. Idealweise sollten dieser mit <kbd>&</kbd> oder <kbd>#</kbd> beginnen.]]></item>
12331235
<item name="wcf.acp.menu.link.contact"><![CDATA[Kontaktformular]]></item>
12341236
<item name="wcf.acp.menu.link.contact.options"><![CDATA[Eingabefelder]]></item>
12351237
<item name="wcf.acp.menu.link.contact.recipients"><![CDATA[Empfänger]]></item>
@@ -2547,6 +2549,7 @@ Die Datenbestände werden sorgfältig gepflegt, aber es ist nicht ausgeschlossen
25472549
<item name="wcf.acp.pip.objectType.integerCondition.propertyName.description"><![CDATA[Name der Objekteigenschaft und Spalte der <kbd>{$tableName}</kbd>-Datenbanktabelle, der für diese Bedingung verwendet wird.]]></item>
25482550
<item name="wcf.acp.pip.objectType.integerCondition.propertyName.error.noIntegerColumn"><![CDATA[Die angegebene Spalte der Datenbanktabelle <kbd>{$tableName}</kbd> ist keine Spalte vom Typ <kbd>INT</kbd>.]]></item>
25492551
<item name="wcf.acp.pip.objectType.integerCondition.propertyName.error.nonExistent"><![CDATA[Die angegebene Spalte existiert nicht in der Datenbanktabelle <kbd>{$tableName}</kbd>.]]></item>
2552+
<item name="wcf.acp.pip.menuItem.additionalInternalURL"><![CDATA[Zusätzliche interne URL-Parameter]]></item>
25502553
<item name="wcf.acp.pip.menuItem.externalURL"><![CDATA[Externe URL]]></item>
25512554
<item name="wcf.acp.pip.menuItem.externalURL.description"><![CDATA[Wenn der Benutzer auf den Menüpunkt klickt, wird er auf die angegebene Website weitergeleitet.]]></item>
25522555
<item name="wcf.acp.pip.menuItem.identifier"><![CDATA[Bezeichner des Menüpunktes]]></item>

wcfsetup/install/lang/en.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,8 @@ You can access the error log at: {link controller='ExceptionLogView' isEmail=tru
12061206
<item name="wcf.acp.menu.item.parentItem"><![CDATA[Parent Menu Item]]></item>
12071207
<item name="wcf.acp.menu.link.other"><![CDATA[Other]]></item>
12081208
<item name="wcf.acp.menu.item.pageObjectID.error.invalid"><![CDATA[ID is invalid.]]></item>
1209+
<item name="wcf.acp.menu.item.additionalInternalURL"><![CDATA[Additional internal URL parameters]]></item>
1210+
<item name="wcf.acp.menu.item.additionalInternalURL.description"><![CDATA[Additional parameters that can be appended to the URL. Ideally, these should starts with <kbd>&</kbd> or <kbd>#</kbd>.]]></item>
12091211
<item name="wcf.acp.menu.link.contact"><![CDATA[Contact Form]]></item>
12101212
<item name="wcf.acp.menu.link.contact.options"><![CDATA[Option Fields]]></item>
12111213
<item name="wcf.acp.menu.link.contact.recipients"><![CDATA[Recipient]]></item>
@@ -2347,6 +2349,7 @@ If you have <strong>already bought the licenses for the listed apps</strong>, th
23472349
<item name="wcf.acp.pip.menuItem.showOrder.description"><![CDATA[The entered value determines in which order the menu items with the same parent are shown.]]></item>
23482350
<item name="wcf.acp.pip.menuItem.externalURL"><![CDATA[External URL]]></item>
23492351
<item name="wcf.acp.pip.menuItem.externalURL.description"><![CDATA[When clicking on the menu item, the user is redirected to the entered website.]]></item>
2352+
<item name="wcf.acp.pip.menuItem.additionalInternalURL"><![CDATA[Additional internal URL parameters]]></item>
23502353
<item name="wcf.acp.pip.page.identifier"><![CDATA[Page Identifier]]></item>
23512354
<item name="wcf.acp.pip.page.identifier.description"><![CDATA[The identifier consists of least four segments separated by dots. Each segment must not be empty and may only contain the following characters: <kbd>[A-z0-9-_]</kbd>. In general, the first part of the menu identifier is the package identifier and the second part is the unqualified controller class without the controller type suffixes <kbd>Form</kbd> and <kbd>Page</kbd>. Example: <kbd>com.foo.bar.package.Baz</kbd>]]></item>
23522355
<item name="wcf.acp.pip.page.identifier.error.notUnique"><![CDATA[This identifier is already used by another page.]]></item>

wcfsetup/setup/db/install.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,8 @@ CREATE TABLE wcf1_menu_item (
835835
showOrder INT(10) NOT NULL DEFAULT 0,
836836
isDisabled TINYINT(1) NOT NULL DEFAULT 0,
837837
originIsSystem TINYINT(1) NOT NULL DEFAULT 0,
838-
packageID INT(10) NOT NULL
838+
packageID INT(10) NOT NULL,
839+
additionalInternalURL VARCHAR(255) NOT NULL DEFAULT ''
839840
);
840841

841842
DROP TABLE IF EXISTS wcf1_message_embedded_object;

0 commit comments

Comments
 (0)