From d6981d6288d32904548457eb3f900df607a31d2b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 3 Jan 2013 21:22:28 +0100 Subject: [PATCH] Added support for i18n style descriptions (ACP missing) See #890 --- com.woltlab.wcf/woltlab-basic-style.tgz | Bin 594 -> 616 bytes .../lib/data/style/StyleEditor.class.php | 62 +++++++++++++++++- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/com.woltlab.wcf/woltlab-basic-style.tgz b/com.woltlab.wcf/woltlab-basic-style.tgz index fdcc511c7da6d17e5b6e1d8559b9525f24a88b0d..93f2ff84d787389956ff726bc8e5c25e6e5628d4 100644 GIT binary patch delta 602 zcmV-g0;T=Z1n2|_ABzYGROsbU0+9(De_e0dFcjsr{S|k4E{VfeHWa8>S*bKSO@fX} zRUb@p0jnlKwkfb*zl+01s&###eVCN<68q-(oa^}JTAPhTcRiP-kAu%x5Cl+yEm;0( z;Wq*w{0a;FYNN)2I)xfEff6ef_-KTeboTI!N{cjUIljvrz$8jzkxX08-SE2nf7!Wg zpNFVh*!G0QXLwWqm0bUP#_k*rC=P0#NG~1Q5j-B@TSvbW66_+$T%QlhlIkv-3 z4_DpJu=6k?nLZ!GSFT0$_}C7;e*?)biBU&NEVfyJ-O2FQwT9)5#k?+~js& zVSc6TvvTE2My8jR6{U-f64ROa`$P5S;~PspaO?^xB208ny7%J_`lvN3f9PdL06&*w zqCr2ST9Is7X1XiFHr1fZLT^8%GxUy!81ki=rHV%T;mh;vNL`r2Y@pdVSmfYc=Kv4aO+aXw+&& o|9>}}-v5sk`ybr_zxFxX%fO?5ra*xL1q$r(2mH&2+W-y#0PFKE-2eap delta 580 zcmV-K0=xa_1kwZvABzYG000000FenBe^GDRFc9Xo{0cA6C2>N44TV&!U8yuWO@fX} zRUe$>AXc3O*`~mL{p^G$VdY`cil%COFNx3JeRn>eZ6UV|%uT`?#{$>QWUBm9+ zcEfgX*HLKq+??NbI}LoqoJy>OBpkg??mvNdq4pj<0~a()2Zn8813?;Q5lt5Zf8%a? z-TG);_)SmfK0%6`ih&VJx$Ilkdc8K+8Iz0zW|$>LG2Pz?x=(4F8DChA+G*?lc037V zNJxvOs_|_u=94YB(J}%#_TS1n4sne>8l2^gXL0X_p8@$mvpNRXI&#K(ov1!U+|np#n)| zj$lq!Ozw=?T=UFax2}{c6Isi{!M4+~am)EskoBZyh1qh;=^~b|QywM3O-`;j+Jn&$ zQc;s0eY-L#M=qr^{NT5pT9NiEl7oo{dcmlT7EFJa!o9%>*B{M%Qd-RU58GXJ|SwtHQSm8IM19(XTKczgWm{a^OUJ9-0tRK2Yp1M8ii S)Dup4d;9`bY-YCr3;+OEBobQy diff --git a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php index e1509d6e78..dd3a12bb2f 100644 --- a/wcfsetup/install/files/lib/data/style/StyleEditor.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleEditor.class.php @@ -1,5 +1,6 @@ xpath(); $data = array( - 'name' => '', 'description' => '', 'version' => '', 'image' => '', 'copyright' => '', 'default' => false, + 'name' => '', 'description' => array(), 'version' => '', 'image' => '', 'copyright' => '', 'default' => false, 'license' => '', 'authorName' => '', 'authorURL' => '', 'templates' => '', 'images' => '', 'variables' => '', 'date' => '0000-00-00', 'icons' => '', 'iconsPath' => '', 'imagesPath' => '' ); @@ -175,6 +177,12 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $data['default'] = true; break; + case 'description': + if ($element->hasAttribute('language')) { + $data['description'][$element->getAttribute('language')] = $element->nodeValue; + } + break; + case 'stylename': $data['name'] = $element->nodeValue; break; @@ -188,7 +196,6 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject break; case 'copyright': - case 'description': case 'image': case 'license': $data[$element->tagName] = $element->nodeValue; @@ -286,7 +293,6 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject $styleData = array( 'styleName' => $data['name'], 'variables' => $data['variables'], - 'styleDescription' => $data['description'], 'styleVersion' => $data['version'], 'styleDate' => $data['date'], 'copyright' => $data['copyright'], @@ -514,11 +520,23 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject // save style if ($style !== null) { + // handle descriptions + if (!empty($data['description'])) { + $styleData['styleDescription'] = 'wcf.style.styleDescription'.$style->styleID; + self::saveLocalizedDescriptions($style, $data['description']); + } + $style->update($styleData); } else { $styleData['packageID'] = $packageID; $style = new StyleEditor(self::create($styleData)); + + // handle descriptions + if (!empty($data['description'])) { + $styleData['styleDescription'] = 'wcf.style.styleDescription'.$style->styleID; + self::saveLocalizedDescriptions($style, $data['description']); + } } if ($data['default']) { @@ -528,6 +546,44 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject return $style; } + protected static function saveLocalizedDescriptions(StyleEditor $styleEditor, array $descriptions) { + // localize package information + $sql = "INSERT INTO wcf".WCF_N."_language_item + (languageID, languageItem, languageItemValue, languageCategoryID, packageID) + VALUES (?, ?, ?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + + // get language list + $languageList = new LanguageList(); + $languageList->sqlLimit = 0; + $languageList->readObjects(); + + // workaround for WCFSetup + if (!PACKAGE_ID) { + $sql = "SELECT * + FROM wcf".WCF_N."_language_category + WHERE languageCategory = ?"; + $statement2 = WCF::getDB()->prepareStatement($sql); + $statement2->execute(array('wcf.style')); + $languageCategory = $statement2->fetchObject('wcf\data\language\category\LanguageCategory'); + } + else { + $languageCategory = LanguageFactory::getInstance()->getCategory('wcf.style'); + } + + foreach ($languageList as $language) { + if (isset($descriptions[$language->landugeCode])) { + $statement->execute(array( + $language->languageID, + 'wcf.style.styleDescription'.$styleEditor->styleID, + $descriptions[$language->languageCode], + $languageCategory->languageCategoryID, + $styleEditor->packageID + )); + } + } + } + /** * Returns available location path. * -- 2.20.1