var $menuItemControllerContainer = $('#menuItemControllerContainer');
var $menuItemLinkContainer = $('#menuItemLinkContainer');
var $menuItemParametersContainer = $('#menuItemParametersContainer');
+ var $menuItemPageContainer = $('#menuItemPageContainer');
+ var $menuItemPage = $('#menuItemPage');
function handleMenuPosition() {
if ($menuPosition.val() === 'header') {
function handleIsInternalLink() {
if ($isInternalLink.is(':checked')) {
+ $menuItemPageContainer.show();
$menuItemControllerContainer.show();
$menuItemParametersContainer.show();
$menuItemLinkContainer.hide();
}
else {
+ $menuItemPageContainer.hide();
$menuItemControllerContainer.hide();
$menuItemParametersContainer.hide();
$menuItemLinkContainer.show();
}
}
+ function handleMenuPage() {
+ if ($menuItemPage.val() != '0') {
+ $menuItemControllerContainer.addClass('disabled');
+ $menuItemControllerContainer.find('input').disable();
+ }
+ else {
+ $menuItemControllerContainer.removeClass('disabled');
+ $menuItemControllerContainer.find('input').enable();
+ }
+ }
+
$menuPosition.change(handleMenuPosition);
$('input[name=isInternalLink]').change(handleIsInternalLink);
+ $menuItemPage.change(handleMenuPage);
handleMenuPosition();
handleIsInternalLink();
+ handleMenuPage();
});
//]]>
</script>
</dd>
</dl>
+ <dl id="menuItemPageContainer"{if $errorField == 'menuItemPage'} class="formError"{/if}>
+ <dt><label for="menuItemPage">{lang}wcf.acp.pageMenu.menuItemPage{/lang}</label></dt>
+ <dd>
+ <select name="menuItemPage" id="menuItemPage">
+ <option value="0">{lang}wcf.global.noSelection{/lang}</option>
+ {htmlOptions options=$pages selected=$menuItemPage}
+ </select>
+ {if $errorField == 'menuItemPage'}
+ <small class="innerError">
+ {if $errorType == 'empty'}
+ {lang}wcf.global.form.error.empty{/lang}
+ {elseif $errorType == 'noValidSelection'}
+ {lang}wcf.global.form.error.noValidSelection{/lang}
+ {else}
+ {lang}wcf.acp.pageMenu.menuItemPage.error.{$errorType}{/lang}
+ {/if}
+ </small>
+ {/if}
+ <small>{lang}wcf.acp.pageMenu.menuItemPage.description{/lang}</small>
+ </dd>
+ </dl>
+
<dl id="menuItemControllerContainer"{if $errorField == 'menuItemController'} class="formError"{/if}>
<dt><label for="menuItemController">{lang}wcf.acp.pageMenu.menuItemController{/lang}</label></dt>
<dd>
- <input type="text" name="menuItemController" id="menuItemController" value="{$menuItemController}" class="long" />
+ <input type="text" name="menuItemController" id="menuItemController" value="{if !$pages[$menuItemPage]|isset}{$menuItemController}{/if}" class="long" />
{if $errorField == 'menuItemController'}
<small class="innerError">
{if $errorType == 'empty'}
use wcf\form\AbstractForm;
use wcf\system\exception\UserInputException;
use wcf\system\language\I18nHandler;
+use wcf\system\page\PageManager;
use wcf\system\WCF;
use wcf\util\StringUtil;
*/
public $showOrder = 0;
+ /**
+ * available page object types
+ * @var array<\wcf\data\object\type\ObjectType>
+ */
+ public $pageObjectTypes = array();
+
+ /**
+ * id of the page object type that belongs to the menu item's controller
+ * @var integer
+ */
+ public $menuItemPage = 0;
+
/**
* @see \wcf\page\IPage::readParameters()
*/
I18nHandler::getInstance()->register('pageMenuItem');
$this->readAvailableParentMenuItems();
+
+ $this->pageObjectTypes = PageManager::getInstance()->getObjectTypes();
}
/**
if (isset($_POST['isDisabled'])) $this->isDisabled = true;
if (isset($_POST['isInternalLink'])) $this->isInternalLink = (bool) $_POST['isInternalLink'];
if (isset($_POST['menuItemController'])) $this->menuItemController = StringUtil::trim($_POST['menuItemController']);
+ if (isset($_POST['menuItemPage'])) $this->menuItemPage = intval($_POST['menuItemPage']);
if (isset($_POST['menuItemParameters'])) $this->menuItemParameters = StringUtil::trim($_POST['menuItemParameters']);
if (isset($_POST['menuPosition'])) $this->menuPosition = StringUtil::trim($_POST['menuPosition']);
if (isset($_POST['parentMenuItem'])) $this->parentMenuItem = StringUtil::trim($_POST['parentMenuItem']);
// validate menu item controller
if ($this->isInternalLink) {
- if (empty($this->menuItemController)) {
- throw new UserInputException('menuItemController');
+ if ($this->menuItemPage) {
+ $valid = false;
+ foreach ($this->pageObjectTypes as $page) {
+ if ($page->objectTypeID == $this->menuItemPage) {
+ $this->menuItemController = $page->className;
+ $valid = true;
+ break;
+ }
+ }
+
+ if (!$valid) {
+ throw new UserInputException('menuItemPage', 'noValidSelection');
+ }
+ }
+ else if (empty($this->menuItemController)) {
+ throw new UserInputException('menuItemPage');
}
if (!class_exists($this->menuItemController)) {
'menuItemController' => $this->menuItemController,
'menuItemParameters' => $this->menuItemParameters,
'menuItemLink' => $this->menuItemLink,
+ 'menuItemPage' => $this->menuItemPage,
'menuPosition' => $this->menuPosition,
+ 'pages' => PageManager::getInstance()->getSelection(),
'pageMenuItem' => $this->pageMenuItem,
'parentMenuItem' => $this->parentMenuItem,
'showOrder' => $this->showOrder
$this->pageMenuItem = $this->menuItem->menuItem;
$this->parentMenuItem = $this->menuItem->parentMenuItem;
$this->showOrder = $this->menuItem->showOrder;
+
+ foreach ($this->pageObjectTypes as $page) {
+ if ($page->className == $this->menuItemController) {
+ $this->menuItemPage = $page->objectTypeID;
+ }
+ }
}
}
<item name="wcf.acp.pageMenu.link.internal"><![CDATA[Interner Link]]></item>
<item name="wcf.acp.pageMenu.list"><![CDATA[Menüpunkte auflisten]]></item>
<item name="wcf.acp.pageMenu.menuItemController"><![CDATA[Controller]]></item>
- <item name="wcf.acp.pageMenu.menuItemController.description"><![CDATA[Bitte geben Sie den vollständigen Klassennamen inklusive Namespace an, zum Beispiel „wcf\page\DashboardPage“.]]></item>
+ <item name="wcf.acp.pageMenu.menuItemController.description"><![CDATA[Sollte die gewünschte Seite in der obigen Auswahl nicht vorhanden sein, können Sie manuell den entsprechenden Controller angeben. Bitte geben Sie dabei den vollständigen Klassennamen inklusive Namespace an, zum Beispiel „wcf\page\DashboardPage“.]]></item>
<item name="wcf.acp.pageMenu.menuItemController.error.notValid"><![CDATA[Die angegebene Klasse konnte nicht gefunden werden]]></item>
<item name="wcf.acp.pageMenu.menuItemLink"><![CDATA[Link]]></item>
<item name="wcf.acp.pageMenu.menuPosition"><![CDATA[Position]]></item>
<item name="wcf.acp.pageMenu.parentMenuItem"><![CDATA[Übergeordneter Menüpunkt]]></item>
<item name="wcf.acp.pageMenu.showOrder"><![CDATA[Reihenfolge]]></item>
<item name="wcf.acp.pageMenu.menuItemParameters"><![CDATA[Parameter]]></item>
+ <item name="wcf.acp.pageMenu.menuItemPage"><![CDATA[Seite]]></item>
+ <item name="wcf.acp.pageMenu.menuItemPage.description"><![CDATA[Wählen Sie die interne Seite aus, die Sie verlinken möchten.]]></item>
</category>
<category name="wcf.acp.pluginStore">
<item name="wcf.acp.pageMenu.link.internal"><![CDATA[Internal link]]></item>
<item name="wcf.acp.pageMenu.list"><![CDATA[List Menu Items]]></item>
<item name="wcf.acp.pageMenu.menuItemController"><![CDATA[Controller]]></item>
- <item name="wcf.acp.pageMenu.menuItemController.description"><![CDATA[PHP class name including namespace, e.g. “wcf\page\DashboardPage”.]]></item>
+ <item name="wcf.acp.pageMenu.menuItemController.description"><![CDATA[If a page is not available in the selection above, you can enter the related controller manually. Enter the PHP class name including namespace, e.g. “wcf\page\DashboardPage”.]]></item>
<item name="wcf.acp.pageMenu.menuItemController.error.notValid"><![CDATA[Unable to find the provided class name]]></item>
<item name="wcf.acp.pageMenu.menuItemLink"><![CDATA[Link]]></item>
<item name="wcf.acp.pageMenu.menuPosition"><![CDATA[Position]]></item>
<item name="wcf.acp.pageMenu.parentMenuItem"><![CDATA[Parent Menu Item]]></item>
<item name="wcf.acp.pageMenu.showOrder"><![CDATA[Display Order]]></item>
<item name="wcf.acp.pageMenu.menuItemParameters"><![CDATA[Parameters]]></item>
+ <item name="wcf.acp.pageMenu.menuItemPage"><![CDATA[Page]]></item>
+ <item name="wcf.acp.pageMenu.menuItemPage.description"><![CDATA[Choose the internal page you want to link.]]></item>
</category>
<category name="wcf.acp.rebuildData">