<packageinformation>
<packagename>WoltLab Community Framework</packagename>
<packagedescription>Free web-framework, designed and developed for complex community applications.</packagedescription>
+ <packagedescription language="de">Freies Web-Framework, das für komplexe Community-Anwendungen entworfen und entwickelt wurde.</packagedescription>
<isapplication>1</isapplication>
<isunique>1</isunique>
<version>2.0.0 Alpha 1</version> <!-- codename: maelstrom -->
<td class="columnID columnSessionAccessLogID"><p>{@$sessionAccessLog->sessionAccessLogID}</p></td>
<td class="columnURL columnIpAddress"{if $sessionAccessLog->ipAddress != $sessionLog->ipAddress} style="color: red"{/if}><p>{$sessionAccessLog->ipAddress}</p></td>
<td class="columnDate columnTime"><p>{@$sessionAccessLog->time|time}</p></td>
- <td class="columnTitle columnPackageName"><p>{$sessionAccessLog->packageName}</p></td>
+ <td class="columnTitle columnPackageName"><p>{$sessionAccessLog->packageName|language}</p></td>
<td class="columnText columnClassName"><p>{$sessionAccessLog->className}</p></td>
<td class="columnURL columnRequestURI" title="{$sessionAccessLog->requestURI}"><p>{if !$sessionAccessLog->hasProtectedURI()}<a href="{$sessionAccessLog->requestURI}{@SID_ARG_2ND}">{$sessionAccessLog->requestURI|truncate:50}</a>{else}{$sessionAccessLog->requestURI|truncate:50}{/if}</p></td>
<td class="columnTextolumnRequestMethod"><p>{$sessionAccessLog->requestMethod}</p></td>
<header class="wcf-container wcf-mainHeading">
<img src="{@$__wcf->getPath()}icon/working1.svg" alt="" class="wcf-containerIcon" />
<hgroup class="wcf-containerContent">
- <h1>{$archive->getPackageInfo('packageName')}</h1>
- <h2>{$archive->getPackageInfo('packageDescription')}</h2>
+ <h1>{$archive->getLocalizedPackageInfo('packageName')}</h1>
+ <h2>{$archive->getLocalizedPackageInfo('packageDescription')}</h2>
</hgroup>
</header>
<img src="{@$__wcf->getPath()}icon/package1.svg" alt="" title="{lang}wcf.acp.package.type.other{/lang}" class="jsTooltip" />
{/if}
</td>
- <td id="packageName{@$package->packageID}" class="columnTitle" title="{$package->packageDescription}">
+ <td id="packageName{@$package->packageID}" class="columnTitle" title="{$package->packageDescription|language}">
<a href="{link controller='PackageView' id=$package->packageID}{/link}"><span>{$package->getName()}{if $package->instanceNo > 1 && $package->instanceName == ''} (#{#$package->instanceNo}){/if}</span></a>
</td>
<td class="columnText"><p>{if $package->authorURL}<a href="{@$__wcf->getPath()}acp/dereferrer.php?url={$package->authorURL|rawurlencode}" class="wcf-externalURL">{$package->author}</a>{else}{$package->author}{/if}</p></td>
<div>
<a href="{link controller='PackageView' id=$packageID}{/link}" title="{$package->getName()}" style="background-image: url('{@$__wcf->getPath()}icon/packagePlugin1.svg');">
<h1>{$package->getName()}</h1>
- <small>{$package->packageDescription|truncate:150}</small>
+ <small>{$package->packageDescription|language|truncate:150}</small>
</a>
</div>
<img src="{@$__wcf->getPath()}icon/delete1.svg" alt="" class="wcf-containerIcon" />
<hgroup class="wcf-containerContent">
<h1>{lang}wcf.acp.package.uninstall{/lang}: {$packageObj->getName()}</h1>
- <h2>{$packageObj->packageDescription}</h2>
+ <h2>{$packageObj->packageDescription|language}</h2>
</hgroup>
</header>
<img src="{@$__wcf->getPath()}icon/package1.svg" alt="" title="{lang}wcf.acp.package.list.other{/lang}" class="jsTooltip" />
{/if}
</td>
- <td class="columnTitle" title="{$package.packageDescription}"><p><a href="{link controller='PackageView' id=$package.packageID}{/link}">{$package.packageName}{if $package.instanceNo > 1 && $package.instanceName == ''} (#{#$package.instanceNo}){/if}</a></p></td>
+ <td class="columnTitle" title="{$package.packageDescription|language}"><p><a href="{link controller='PackageView' id=$package.packageID}{/link}">{$package.packageName|language}{if $package.instanceNo > 1 && $package.instanceName == ''} (#{#$package.instanceNo}){/if}</a></p></td>
<td class="columnText"><p>{if $package.authorURL}<a href="{@$__wcf->getPath()}acp/dereferrer.php?url={$package.authorURL|rawurlencode}" class="wcf-externalURL">{$package.author}</a>{else}{$package.author}{/if}</p></td>
<td class="columnText"><p>{$package.packageVersion}</p></td>
<td class="columnDate"><p>{@$package.packageDate|date}</p></td>
<img src="{@$__wcf->getPath()}icon/packageApplication1.svg" alt="" class="wcf-containerIcon" /><!-- ToDo: Add possibility to show a custom app icon if given! -->
<hgroup class="wcf-containerContent">
<h1>{$package->getName()}</h1>
- <h2>{$package->packageDescription}</h2>
+ <h2>{$package->packageDescription|language}</h2>
</hgroup>
</header>
{event name='propertyFields'}
</fieldset>
- {if $package->packageDescription}
+ {if $package->packageDescription|language}
<hgroup class="wcf-subHeading">
<h1>{lang}wcf.acp.package.description{/lang}</h1>
</hgroup>
- <p>{$package->packageDescription}</p>
+ <p>{$package->packageDescription|language}</p>
{/if}
</div>
<img src="{@$__wcf->getPath()}icon/package1.svg" alt="" title="{lang}wcf.acp.package.type.other{/lang}" class="jsTooltip" />
{/if}
</td>
+<<<<<<< HEAD
<td class="columnTitle" title="{$requiredPackage->packageDescription}"><p><a href="{link controller='PackageView' id=$requiredPackage->packageID}{/link}">{$requiredPackage->packageName}{if $requiredPackage->instanceNo > 1 && $requiredPackage->instanceName == ''} (#{#$requiredPackage->instanceNo}){/if}</a></p></td>
<td class="columnText">{if $requiredPackage->authorURL}<p><a href="{@$__wcf->getPath()}acp/dereferrer.php?url={$requiredPackage->authorURL|rawurlencode}" class="wcf-externalURL">{$requiredPackage->author}</a>{else}{$requiredPackage->author}</p>{/if}</td>
<td class="columnText"><p>{$requiredPackage->packageVersion}</p></td>
<td class="columnDate"><p>{@$requiredPackage->packageDate|date}</p></td>
+=======
+ <td class="columnTitle" title="{$requiredPackage.packageDescription|language}"><p><a href="{link controller='PackageView' id=$requiredPackage.packageID}{/link}">{$requiredPackage.packageName|language}{if $requiredPackage.instanceNo > 1 && $requiredPackage.instanceName == ''} (#{#$requiredPackage.instanceNo}){/if}</a></p></td>
+ <td class="columnText">{if $requiredPackage.authorURL}<p><a href="{@$__wcf->getPath()}acp/dereferrer.php?url={$requiredPackage.authorURL|rawurlencode}" class="wcf-externalURL">{$requiredPackage.author}</a>{else}{$requiredPackage.author}</p>{/if}</td>
+ <td class="columnText"><p>{$requiredPackage.packageVersion}</p></td>
+ <td class="columnDate"><p>{@$requiredPackage.packageDate|date}</p></td>
+>>>>>>> Localized package infos stay localized after installation
{event name='requirementColumns'}
</tr>
<img src="{@$__wcf->getPath()}icon/package1.svg" alt="" title="{lang}wcf.acp.package.type.other{/lang}" class="jsTooltip" />
{/if}
</td>
- <td class="columnTitle" title="{$dependentPackage->packageDescription}"><p><a href="{link controller='PackageView' id=$dependentPackage->packageID}{/link}">{$dependentPackage->packageName}{if $dependentPackage->instanceNo > 1 && $dependentPackage->instanceName == ''} (#{#$dependentPackage->instanceNo}){/if}</a></p></td>
- <td class="columnText">{if $dependentPackage->authorURL}<p><a href="{@$__wcf->getPath()}acp/dereferrer.php?url={$dependentPackage->authorURL|rawurlencode}" class="wcf-externalURL">{$dependentPackage->author}</a>{else}{$dependentPackage->author}</p>{/if}</td>
+ <td class="columnTitle" title="{$dependentPackage->packageDescription|language}"><p><a href="{link controller='PackageView' id=$dependentPackage->packageID}{/link}">{$dependentPackage->packageName|language}{if $dependentPackage->instanceNo > 1 && $dependentPackage->instanceName == ''} (#{#$dependentPackage->instanceNo}){/if}</a></p></td>
+ <td class="columnText">{if $dependentPackage->authorURL}<p><a href="{@$__wcf->getPath()}acp/dereferrer.php?url={$dependentPackage.authorURL|rawurlencode}" class="wcf-externalURL">{$dependentPackage->author}</a>{else}{$dependentPackage->author}</p>{/if}</td>
<td class="columnText"><p>{$dependentPackage->packageVersion}</p></td>
<td class="columnDate"><p>{@$dependentPackage->packageDate|date}</p></td>
'processNo' => $processNo,
'userID' => WCF::getUser()->userID,
'package' => $this->archive->getPackageInfo('name'),
- 'packageName' => $this->archive->getPackageInfo('packageName'),
+ 'packageName' => $this->archive->getLocalizedPackageInfo('packageName'),
'packageID' => $packageID,
'archive' => (!empty($this->uploadPackage['tmp_name']) ? $this->uploadPackage['name'] : $this->downloadPackage),
'action' => ($this->package != null ? 'update' : 'install'),
* @return string
*/
public function getName() {
- return ($this->instanceName ? $this->instanceName : $this->packageName);
+ return WCF::getLanguage()->get($this->instanceName ? $this->instanceName : $this->packageName);
}
/**
'processNo' => $processNo,
'userID' => $admin->userID,
'package' => $packageName,
- 'packageName' => $archive->getPackageInfo('packageName'),
+ 'packageName' => $archive->getLocalizedPackageInfo('packageName'),
'archive' => TMP_DIR.'install/packages/'.$packageFile
));
}
try {
$archive = new PackageArchive(TMP_DIR.'install/packages/'.$packageFile);
$archive->openArchive();
- self::$setupPackageName = $archive->getPackageInfo('packageName');
+ self::$setupPackageName = $archive->getLocalizedPackageInfo('packageName');
$archive->getTar()->close();
break;
}
if (!isset($this->packageInfo['plugin'])) $this->packageInfo['plugin'] = '';
if (!isset($this->packageInfo['packageURL'])) $this->packageInfo['packageURL'] = '';
- // get package name in selected language
- $this->getLocalizedInformation('packageName');
-
- // get package description in selected language
- if (isset($this->packageInfo['packageDescription'])) {
- $this->getLocalizedInformation('packageDescription');
- }
-
- // get package license in selected language
- if (isset($this->packageInfo['license'])) {
- $this->getLocalizedInformation('license');
- }
-
- // get package information in selected language
- if (isset($this->packageInfo['readme'])) {
- $this->getLocalizedInformation('readme');
- }
-
// add plugin to requirements
if ($this->packageInfo['plugin'] && !isset($this->requirements[$this->packageInfo['plugin']])) {
$this->requirements[$this->packageInfo['plugin']] = array('name' => $this->packageInfo['plugin']);
}
}
- /**
- * Gets localized package information strings.
- *
- * @param string $key
- */
- protected function getLocalizedInformation($key) {
- if (isset($this->packageInfo[$key][WCF::getLanguage()->getFixedLanguageCode()])) {
- $this->packageInfo[$key] = $this->packageInfo[$key][WCF::getLanguage()->getFixedLanguageCode()];
- }
- else if (isset($this->packageInfo[$key]['default'])) {
- $this->packageInfo[$key] = $this->packageInfo[$key]['default'];
- }
- else {
- $this->packageInfo[$key] = array_shift($this->packageInfo[$key]);
- }
- }
-
/**
* Downloads the package archive.
*
return null;
}
+ /**
+ * Returns a localized information about this package.
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function getLocalizedPackageInfo($name) {
+ if (isset($this->packageInfo[$name][WCF::getLanguage()->getFixedLanguageCode()])) {
+ return $this->packageInfo[$name][WCF::getLanguage()->getFixedLanguageCode()];
+ }
+ else if (isset($this->packageInfo[$name]['default'])) {
+ return $this->packageInfo[$name]['default'];
+ }
+
+ return $this->getPackageInfo($name);
+ }
+
/**
* Returns a list of all requirements of this package.
*
namespace wcf\system\package;
use wcf\data\application\Application;
use wcf\data\application\ApplicationEditor;
+use wcf\data\language\category\LanguageCategory;
use wcf\data\language\LanguageEditor;
+use wcf\data\language\LanguageList;
use wcf\data\option\OptionEditor;
use wcf\data\package\installation\queue\PackageInstallationQueue;
use wcf\data\package\installation\queue\PackageInstallationQueueEditor;
use wcf\data\package\Package;
use wcf\data\package\PackageEditor;
use wcf\system\cache\CacheHandler;
+use wcf\system\database\statement\PreparedStatement;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\SystemException;
use wcf\system\form\container;
use wcf\system\form\element;
use wcf\system\form\FormDocument;
+use wcf\system\language\LanguageFactory;
use wcf\system\menu\acp\ACPMenu;
use wcf\system\request\LinkHandler;
use wcf\system\request\RouteHandler;
// create package entry
$package = PackageEditor::create($nodeData);
+ // localize package information
+ $sql = "INSERT INTO wcf".WCF_N."_language_item
+ (languageID, languageItem, languageItemValue, languageCategoryID, packageID)
+ VALUES (?, ?, ?, ?, ?)";
+ $statement = WCF::getDB()->prepareStatement($sql);
+
+ // 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.acp.package'));
+ $languageCategory = $statement2->fetchObject('wcf\data\language\category\LanguageCategory');
+ }
+ else {
+ $languageCategory = LanguageFactory::getInstance()->getCategory('wcf.acp.package');
+ }
+
+ // save package name
+ $this->saveLocalizedPackageInfo($statement, $languageCategory, $package, 'packageName');
+
+ // save package description
+ $this->saveLocalizedPackageInfo($statement, $languageCategory, $package, 'packageDescription');
+
+ // todo: license and readme
+
+ $packageEditor = new PackageEditor($package);
+ $packageEditor->update(array(
+ 'packageDescription' => 'wcf.acp.package.packageDescription.package'.$package->packageID,
+ 'packageName' => 'wcf.acp.package.packageName.package'.$package->packageID
+ ));
+
// update package id for current queue
$queueEditor = new PackageInstallationQueueEditor($this->queue);
$queueEditor->update(array(
return $installationStep;
}
+ /**
+ * Saves a localized package info.
+ *
+ * @param wcf\system\database\statement\PreparedStatement $statement
+ * @param wcf\data\language\category\LanguageCategory $languageCategory
+ * @param wcf\data\package\Package $package
+ * @param string $infoName
+ */
+ protected function saveLocalizedPackageInfo(PreparedStatement $statement, LanguageCategory $languageCategory, Package $package, $infoName) {
+ $infoValues = $this->getArchive()->getPackageInfo($infoName);
+
+ // get default value for languages without specified information
+ $defaultValue = '';
+ if (isset($infoValues['default'])) {
+ $defaultValue = $infoValues['default'];
+ }
+ else if (isset($infoValues['en'])) {
+ // fallback to English
+ $defaultValue = $infoValues['en'];
+ }
+ else if (isset($infoValues[WCF::getLanguage()->getFixedLanguageCode()])) {
+ // fallback to the language of the current user
+ $defaultValue = $infoValues[WCF::getLanguage()->getFixedLanguageCode()];
+ }
+ else if ($infoName == 'packageName') {
+ // fallback to the package identifier for the package name
+ $defaultValue = $this->archive->getPackageInfo('name');
+ }
+
+ // workaround for WCFSetup
+ if (!PACKAGE_ID) {
+ $languageList = new LanguageList();
+ $languageList->sqlLimit = 0;
+ $languageList->readObjects();
+ $languages = $languageList->getObjects();
+ }
+ else {
+ $languages = LanguageFactory::getInstance()->getLanguages();
+ }
+
+ foreach ($languages as $language) {
+ $value = $defaultValue;
+ if (isset($infoValues[$language->languageCode])) {
+ $value = $infoValues[$language->languageCode];
+ }
+
+ $statement->execute(array(
+ $language->languageID,
+ 'wcf.acp.package.'.$infoName.'.package'.$package->packageID,
+ $value,
+ $languageCategory->languageCategoryID,
+ 1
+ ));
+ }
+ }
+
/**
* Sets parent package and rebuilds dependencies for both.
*/
if (empty($this->queue->packageName)) {
$queueEditor = new PackageInstallationQueueEditor($this->queue);
$queueEditor->update(array(
- 'packageName' => $this->getArchive()->getPackageInfo('packageName')
+ 'packageName' => $this->getArchive()->getLocalizedPackageInfo('packageName')
));
// reload queue
'package',
serialize(array(
'package' => $this->installation->getArchive()->getPackageInfo('name'),
- 'packageName' => $this->installation->getArchive()->getPackageInfo('packageName'),
+ 'packageName' => $this->installation->getArchive()->getLocalizedPackageInfo('packageName'),
'instanceNo' => $instanceNo,
- 'packageDescription' => $this->installation->getArchive()->getPackageInfo('packageDescription'),
+ 'packageDescription' => $this->installation->getArchive()->getLocalizedPackageInfo('packageDescription'),
'packageVersion' => $this->installation->getArchive()->getPackageInfo('version'),
'packageDate' => $this->installation->getArchive()->getPackageInfo('date'),
'packageURL' => $this->installation->getArchive()->getPackageInfo('packageURL'),
'processNo' => $queue->processNo,
'userID' => WCF::getUser()->userID,
'package' => $archive->getPackageInfo('name'),
- 'packageName' => $archive->getPackageInfo('packageName'),
+ 'packageName' => $archive->getLocalizedPackageInfo('packageName'),
'archive' => $fileName,
'action' => $queue->action
));
$packages[] = array(
'archive' => $fileName,
'package' => $archive->getPackageInfo('name'),
- 'packageName' => $archive->getPackageInfo('packageName'),
+ 'packageName' => $archive->getLocalizedPackageInfo('packageName'),
'selected' => 0
);
}
protected function uninstallPackage(array $nodeData) {
PackageEditor::deleteAll(array($this->queue->packageID));
+ // remove localized package infos
+ // todo: license/readme
+ $sql = "DELETE FROM wcf".WCF_N."_language_item
+ WHERE languageItem IN (?, ?)";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array(
+ 'wcf.acp.package.packageName.package'.$this->queue->packageID,
+ 'wcf.acp.package.packageDescription.package'.$this->queue->packageID
+ ));
+
// reset package cache
CacheHandler::getInstance()->clearResource('packages');