From: Alexander Ebert Date: Sun, 26 May 2013 22:54:26 +0000 (+0200) Subject: Fixed calculation of page menu item show order X-Git-Tag: 2.0.0_Beta_1~46^2~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cf06c4f799771e1a476817b52735c1d4fc61b0f8;p=GitHub%2FWoltLab%2FWCF.git Fixed calculation of page menu item show order --- diff --git a/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemAction.class.php b/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemAction.class.php index 86ee719224..1fb77609f9 100644 --- a/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemAction.class.php +++ b/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemAction.class.php @@ -53,6 +53,9 @@ class PageMenuItemAction extends AbstractDatabaseObjectAction implements ISortab $this->parameters['data']['packageID'] = PACKAGE_ID; } + // calculate show order + $this->parameters['data']['showOrder'] = PageMenuItemEditor::getShowOrder($this->parameters['data']['showOrder'], $this->parameters['data']['menuPosition'], $this->parameters['data']['parentMenuItem']); + $menuItem = parent::create(); if ($menuItem->menuPosition == 'header') { diff --git a/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemEditor.class.php b/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemEditor.class.php index 5e834d6910..8f946165cb 100644 --- a/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemEditor.class.php +++ b/wcfsetup/install/files/lib/data/page/menu/item/PageMenuItemEditor.class.php @@ -21,16 +21,6 @@ class PageMenuItemEditor extends DatabaseObjectEditor implements IEditableCached */ protected static $baseClass = 'wcf\data\page\menu\item\PageMenuItem'; - /** - * @see wcf\data\IEditableObject::create() - */ - public static function create(array $parameters = array()) { - // calculate show order - $parameters['showOrder'] = self::getShowOrder($parameters['showOrder'], $parameters['menuPosition'], $parameters['parentMenuItem']); - - return parent::create($parameters); - } - /** * @see wcf\data\IEditableObject::delete() */ @@ -105,7 +95,7 @@ class PageMenuItemEditor extends DatabaseObjectEditor implements IEditableCached * @param string $menuPosition * @return integer */ - protected static function getShowOrder($showOrder, $menuPosition, $parentMenuItem = '') { + public static function getShowOrder($showOrder, $menuPosition, $parentMenuItem = '') { if ($showOrder == 0) { // get next number in row $sql = "SELECT MAX(showOrder) AS showOrder diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php index f262551be3..b0af1d24c3 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php @@ -314,10 +314,6 @@ abstract class AbstractXMLPackageInstallationPlugin extends AbstractPackageInsta * @return integer */ protected function getShowOrder($showOrder, $parentName = null, $columnName = null, $tableNameExtension = '') { - if ($this instanceof PageMenuPackageInstallationPlugin) { - file_put_contents(WCF_DIR.'__pageMenu.log', "\tWARNING: Accessed AbstractXMLPackageInstallationPlugin::getShowOrder() (page menu pip has own method: " . (method_exists('wcf\system\package\plugin\PageMenuPackageInstallationPlugin', 'getShowOrder') ? 'yes' : 'no') . ")\n", FILE_APPEND); - } - if ($showOrder === null) { // get greatest showOrder value $conditions = new PreparedStatementConditionBuilder(); diff --git a/wcfsetup/install/files/lib/system/package/plugin/PageMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/PageMenuPackageInstallationPlugin.class.php index 71a3c8976c..fc18abe5f0 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PageMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PageMenuPackageInstallationPlugin.class.php @@ -85,10 +85,6 @@ class PageMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationP * @return integer */ protected function getMenuItemPosition(array $data) { - file_put_contents(WCF_DIR.'__pageMenu.log', "Resolving menu position for '" . $data['menuItem'] . "' (" . $data['menuPosition'] . ") ...\n", FILE_APPEND); - file_put_contents(WCF_DIR.'__pageMenu.log', " showOrder = ".($data['showOrder'] === null ? 'null' : $data['showOrder']) . "\n", FILE_APPEND); - file_put_contents(WCF_DIR.'__pageMenu.log', " parentMenuItem = ". $data['parentMenuItem'] . "\n", FILE_APPEND); - if ($data['showOrder'] === null) { // get greatest showOrder value $conditions = new PreparedStatementConditionBuilder(); @@ -101,11 +97,9 @@ class PageMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationP $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); $maxShowOrder = $statement->fetchArray(); - //return (!$maxShowOrder) ? 1 : ($maxShowOrder['showOrder'] + 1); - $showOrder = (!$maxShowOrder) ? 1 : ($maxShowOrder['showOrder'] + 1); + return (!$maxShowOrder) ? 1 : ($maxShowOrder['showOrder'] + 1); } else { - file_put_contents(WCF_DIR.'__pageMenu.log', "\tINCREASING SHOW ORDER\n", FILE_APPEND); // increase all showOrder values which are >= $showOrder $sql = "UPDATE wcf".WCF_N."_".$this->tableName." SET showOrder = showOrder + 1 @@ -123,11 +117,7 @@ class PageMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationP $statement->execute($parameters); // return the wanted showOrder level - //return $data['showOrder']; - $showOrder = $data['showOrder']; + return $data['showOrder']; } - - file_put_contents(WCF_DIR.'__pageMenu.log', " calculated show order = ". $showOrder . "\n\n", FILE_APPEND); - return $showOrder; } }