}
});
-/**
- * Namespace for page menu.
- */
-WCF.ACP.PageMenu = { };
-
-/**
- * Allows menu items to be set as landing page.
- *
- * @param integer menuItemID
- */
-WCF.ACP.PageMenu.SetAsLandingPage = Class.extend({
- /**
- * menu item id
- * @var integer
- */
- _menuItemID: 0,
-
- /**
- * Initializes the WCF.ACP.PageMenu.SetAsLandingPage class.
- *
- * @param integer menuItemID
- */
- init: function(menuItemID) {
- this._menuItemID = menuItemID;
-
- $('#setAsLandingPage').click($.proxy(this._click, this));
- },
-
- /**
- * Handles button clicks.
- */
- _click: function() {
- var self = this;
- WCF.System.Confirmation.show(WCF.Language.get('wcf.acp.pageMenu.isLandingPage.confirmMessage'), function(action) {
- if (action === 'confirm') {
- new WCF.Action.Proxy({
- autoSend: true,
- data: {
- actionName: 'setAsLandingPage',
- className: 'wcf\\data\\page\\menu\\item\\PageMenuItemAction',
- objectIDs: [ self._menuItemID ]
- },
- success: $.proxy(self._success, self)
- });
- }
- });
- },
-
- /**
- * Handles successful AJAX requests.
- *
- * @param object data
- * @param string textStatus
- * @param jQuery jqXHR
- */
- _success: function(data, textStatus, jqXHR) {
- var $notification = new WCF.System.Notification(WCF.Language.get('wcf.acp.pageMenu.isLandingPage.success'));
- $notification.show(function() { window.location.reload(); });
- }
-});
-
/**
* Handles option selection.
*/
handleMenuPosition();
handleIsInternalLink();
-
- {if $action == 'edit' && $menuItem->isValidLandingPage()}
- WCF.Language.addObject({
- 'wcf.acp.pageMenu.isLandingPage.confirmMessage': '{lang}wcf.acp.pageMenu.isLandingPage.confirmMessage{/lang}',
- 'wcf.acp.pageMenu.isLandingPage.success': '{lang}wcf.acp.pageMenu.isLandingPage.success{/lang}'
- });
-
- new WCF.ACP.PageMenu.SetAsLandingPage({@$menuItem->menuItemID});
- {/if}
});
//]]>
</script>
<div class="contentNavigation">
<nav>
<ul>
- {if $action == 'edit' && $menuItem->isValidLandingPage()}
- <li id="setAsLandingPage"><a class="button"><img src="{@$__wcf->getPath()}icon/default.svg" /> <span>{lang}wcf.acp.pageMenu.setAsLandingPage{/lang}</span></a></li>
- {/if}
<li><a href="{link controller='PageMenuItemList'}{/link}" class="button"><img src="{@$__wcf->getPath()}icon/list.svg" alt="" /> <span>{lang}wcf.acp.pageMenu.list{/lang}</span></a></li>
</ul>
</nav>
$menuItem = parent::create();
- if ($menuItem->isLandingPage) {
- $menuItemEditor = new PageMenuItemEditor($menuItem);
- $menuItemEditor->setAsLandingPage();
+ if ($menuItem->menuPosition == 'header') {
+ PageMenuItemEditor::updateLandingPage();
}
return $menuItem;
}
/**
- * Validates parameters to set a menu item as landing page.
+ * @see wcf\data\AbstractDatabaseObjectAction::delete()
*/
- public function validateSetAsLandingPage() {
- WCF::getSession()->checkPermissions(array('admin.display.canManagePageMenu'));
+ public function delete() {
+ $returnValues = parent::delete();
- $this->menuItemEditor = $this->getSingleObject();
- if (!$this->menuItemEditor->isValidLandingPage()) {
- throw new PermissionDeniedException();
- }
+ PageMenuItemEditor::updateLandingPage();
+
+ return $returnValues;
}
/**
- * Sets a menu item as landing page.
+ * @see wcf\data\AbstractDatabaseObjectAction::update()
*/
- public function setAsLandingPage() {
- $this->menuItemEditor->setAsLandingPage();
+ public function update() {
+ parent::update();
+
+ PageMenuItemEditor::updateLandingPage();
}
/**
}
}
WCF::getDB()->commitTransaction();
+
+ // update landing page
+ if ($this->parameters['menuPosition'] == 'header') {
+ PageMenuItemEditor::updateLandingPage();
+ }
}
}
}
/**
- * Sets current page menu item as landing page.
+ * Sets first top header menu item as landing page.
*/
- public function setAsLandingPage() {
+ public static function updateLandingPage() {
$sql = "UPDATE wcf".WCF_N."_page_menu_item
SET isLandingPage = 0";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
- $this->update(array('isLandingPage' => 1));
+ $sql = "UPDATE wcf".WCF_N."_page_menu_item
+ SET isLandingPage = ?
+ WHERE menuPosition = ?
+ AND parentMenuItem = ?
+ AND menuItemController <> ?
+ ORDER BY showOrder ASC";
+ $statement = WCF::getDB()->prepareStatement($sql, 1);
+ $statement->execute(array(
+ 1,
+ 'header',
+ '',
+ ''
+ ));
self::resetCache();
}
<item name="wcf.acp.pageMenu.footer"><![CDATA[Fußzeile]]></item>
<item name="wcf.acp.pageMenu.header"><![CDATA[Hauptmenü]]></item>
<item name="wcf.acp.pageMenu.isDisabled"><![CDATA[Menüpunkt deaktivieren]]></item>
- <item name="wcf.acp.pageMenu.isLandingPage.confirmMessage"><![CDATA[Möchten Sie den Menüpunkt „{$menuItem}“ als Startseite Ihrer Website festlegen?]]></item>
- <item name="wcf.acp.pageMenu.isLandingPage.success"><![CDATA[„{$menuItem}“ ist nun als Startseite festgelegt]]></item>
<item name="wcf.acp.pageMenu.link"><![CDATA[Link]]></item>
<item name="wcf.acp.pageMenu.link.external"><![CDATA[Externer Link]]></item>
<item name="wcf.acp.pageMenu.link.internal"><![CDATA[Interner Link]]></item>