From: Alexander Ebert Date: Mon, 30 Nov 2015 13:52:24 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/next-lantia' into next-lantia X-Git-Tag: 3.0.0_Beta_1~2030^2~224 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a592ef42450801e9e25a8fced3790d49ff0a5701;p=GitHub%2FWoltLab%2FWCF.git Merge remote-tracking branch 'origin/next-lantia' into next-lantia # Conflicts: # wcfsetup/install/files/lib/data/menu/MenuEditor.class.php --- a592ef42450801e9e25a8fced3790d49ff0a5701 diff --cc wcfsetup/install/files/lib/data/menu/MenuEditor.class.php index a7d166aa32,a5dc047f9d..3ca4a5e461 --- a/wcfsetup/install/files/lib/data/menu/MenuEditor.class.php +++ b/wcfsetup/install/files/lib/data/menu/MenuEditor.class.php @@@ -16,60 -14,7 +16,60 @@@ use wcf\system\WCF */ class MenuEditor extends DatabaseObjectEditor { /** - * @see \wcf\data\DatabaseObjectDecorator::$baseClass + * @inheritDoc */ - protected static $baseClass = 'wcf\data\menu\Menu'; + protected static $baseClass = Menu::class; + + /** + * @inheritDoc + */ + public static function create(array $parameters = []) { + $title = ''; + if (is_array($parameters['title'])) { + $title = $parameters['title']; + $parameters['title'] = ''; + } + + $menu = parent::create($parameters); + + if (is_array($title)) { + if (count($title) > 1) { + $sql = "SELECT languageCategoryID + FROM wcf".WCF_N."_language_category + WHERE languageCategory = ?"; + $statement = WCF::getDB()->prepareStatement($sql, 1); + $statement->execute(['wcf.menu']); + $languageCategoryID = $statement->fetchSingleColumn(); + + $sql = "INSERT INTO wcf".WCF_N."_language_item + (languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID) + VALUES (?, ?, ?, ?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + + WCF::getDB()->beginTransaction(); + foreach ($title as $languageCode => $value) { + $statement->execute([ + LanguageFactory::getInstance()->getLanguageByCode($languageCode)->languageID, + 'wcf.menu.menu' . $menu->menuID, + $value, + 1, + $languageCategoryID, + $menu->packageID + ]); + } + WCF::getDB()->commitTransaction(); + + $title = 'wcf.menu.menu' . $menu->menuID; + } + else { + $title = reset($title); + } + + //$menuEditor = new MenuItemEditor($menu); + $menuEditor = new self($menu); + $menuEditor->update(['title' => $title]); + } + + return $menu; + } }