<?php
namespace wcf\data\style;
+use wcf\data\language\LanguageList;
use wcf\data\package\Package;
use wcf\data\template\group\TemplateGroup;
use wcf\data\template\group\TemplateGroupEditor;
use wcf\system\image\ImageHandler;
use wcf\system\io\Tar;
use wcf\system\io\TarWriter;
+use wcf\system\language\LanguageFactory;
use wcf\system\package\PackageArchive;
use wcf\system\style\StyleCompiler;
use wcf\system\Regex;
$xpath = $xml->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' => ''
);
$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;
break;
case 'copyright':
- case 'description':
case 'image':
case 'license':
$data[$element->tagName] = $element->nodeValue;
$styleData = array(
'styleName' => $data['name'],
'variables' => $data['variables'],
- 'styleDescription' => $data['description'],
'styleVersion' => $data['version'],
'styleDate' => $data['date'],
'copyright' => $data['copyright'],
// 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']) {
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.
*