Merge remote-tracking branch 'origin/next-lantia' into next-lantia
authorAlexander Ebert <ebert@woltlab.com>
Mon, 30 Nov 2015 13:52:24 +0000 (14:52 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 30 Nov 2015 13:52:24 +0000 (14:52 +0100)
# Conflicts:
# wcfsetup/install/files/lib/data/menu/MenuEditor.class.php

1  2 
wcfsetup/install/files/lib/data/menu/MenuEditor.class.php

index a7d166aa326acfba024839517ccfaf96f1e1f546,a5dc047f9d1aa596ee4b7d0dc29a23ffe6027fae..3ca4a5e4615f494c8fefeb1b2b812a384ea087fc
@@@ -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;
 +      }
  }