<section class="section">
<h2 class="sectionTitle">{lang}wcf.global.form.data{/lang}</h2>
- <dl>
- <dt></dt>
- <dd>
- <label>
- <input type="checkbox" name="isMultilingual" value="1"{if $media->isMultilingual} checked{/if}>
- <span>{lang}wcf.media.isMultilingual{/lang}</span>
- </label>
- </dd>
- </dl>
-
- {include file='languageChooser' label='wcf.media.languageID'}
+ {if $availableLanguages|count > 1}
+ <dl>
+ <dt></dt>
+ <dd>
+ <label>
+ <input type="checkbox" name="isMultilingual" value="1"{if $media->isMultilingual} checked{/if}>
+ <span>{lang}wcf.media.isMultilingual{/lang}</span>
+ </label>
+ </dd>
+ </dl>
+
+ {include file='languageChooser' label='wcf.media.languageID'}
+ {/if}
<dl>
<dt><label for="title_{@$media->mediaID}">{lang}wcf.global.title{/lang}</label></dt>
<input type="text" id="title_{@$media->mediaID}" name="title" class="long">
</dd>
</dl>
- {include file='multipleLanguageInputJavascript' elementIdentifier='title'|concat:'_':$media->mediaID forceSelection=true}
+ {if $availableLanguages|count > 1}
+ {include file='multipleLanguageInputJavascript' elementIdentifier='title'|concat:'_':$media->mediaID forceSelection=true}
+ {/if}
<dl>
<dt><label for="caption_{@$media->mediaID}">{lang}wcf.media.caption{/lang}</label></dt>
<textarea id="caption_{@$media->mediaID}" name="caption" cols="40" rows="3"></textarea>
</dd>
</dl>
- {include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
+ {if $availableLanguages|count > 1}
+ {include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
+ {/if}
<dl>
<dt><label for="altText_{@$media->mediaID}">{lang}wcf.media.altText{/lang}</label></dt>
<input type="text" id="altText_{@$media->mediaID}" name="altText" class="long">
</dd>
</dl>
- {include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true}
+ {if $availableLanguages|count > 1}
+ {include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true}
+ {/if}
{event name='dataFields'}
</section>
<section class="section">
<h2 class="sectionTitle">{lang}wcf.global.form.data{/lang}</h2>
-
- <dl>
- <dt></dt>
- <dd>
- <label>
- <input type="checkbox" name="isMultilingual" value="1"{if $media->isMultilingual} checked{/if}>
- <span>{lang}wcf.media.isMultilingual{/lang}</span>
- </label>
- </dd>
- </dl>
-
- {include file='languageChooser' label='wcf.media.languageID'}
+
+ {if $availableLanguages|count > 1}
+ <dl>
+ <dt></dt>
+ <dd>
+ <label>
+ <input type="checkbox" name="isMultilingual" value="1"{if $media->isMultilingual} checked{/if}>
+ <span>{lang}wcf.media.isMultilingual{/lang}</span>
+ </label>
+ </dd>
+ </dl>
+
+ {include file='languageChooser' label='wcf.media.languageID'}
+ {/if}
<dl>
<dt><label for="title_{@$media->mediaID}">{lang}wcf.global.title{/lang}</label></dt>
<input type="text" id="title_{@$media->mediaID}" name="title" class="long">
</dd>
</dl>
- {include file='multipleLanguageInputJavascript' elementIdentifier='title'|concat:'_':$media->mediaID forceSelection=true}
+ {if $availableLanguages|count > 1}
+ {include file='multipleLanguageInputJavascript' elementIdentifier='title'|concat:'_':$media->mediaID forceSelection=true}
+ {/if}
<dl>
<dt><label for="caption_{@$media->mediaID}">{lang}wcf.media.caption{/lang}</label></dt>
<textarea id="caption_{@$media->mediaID}" name="caption" cols="40" rows="3"></textarea>
</dd>
</dl>
- {include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
+ {if $availableLanguages|count > 1}
+ {include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
+ {/if}
<dl>
<dt><label for="altText_{@$media->mediaID}">{lang}wcf.media.altText{/lang}</label></dt>
<input type="text" id="altText_{@$media->mediaID}" name="altText" class="long">
</dd>
</dl>
- {include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true}
+ {if $availableLanguages|count > 1}
+ {include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true}
+ {/if}
{event name='dataFields'}
</section>
}
this._media = null;
+ this._availableLanguageCount = 1;
this._dialogs = new Dictionary();
}
var captionError = DomTraverse.childByClass(caption.parentNode.parentNode, 'innerError');
var titleError = DomTraverse.childByClass(title.parentNode.parentNode, 'innerError');
- this._media.isMultilingual = ~~elBySel('input[name=isMultilingual]', content).checked;
- this._media.languageID = this._media.isMultilingual ? null : LanguageChooser.getLanguageId('languageID');
+ if (this._availableLanguageCount > 1) {
+ this._media.isMultilingual = ~~elBySel('input[name=isMultilingual]', content).checked;
+ this._media.languageID = this._media.isMultilingual ? null : LanguageChooser.getLanguageId('languageID');
+ }
+ else {
+ this._media.languageID = LANGUAGE_ID;
+ }
this._media.altText = {};
this._media.caption = {};
this._media.title = {};
- if (this._media.isMultilingual) {
+ if (this._availableLanguageCount > 1 && this._media.isMultilingual) {
if (!LanguageInput.validate('altText_' + this._media.mediaID, true)) {
hasError = true;
if (!altTextError) {
},
source: {
after: (function(content, data) {
+ this._availableLanguageCount = ~~data.returnValues.availableLanguageCount;
+
var didLoadMediaData = false;
if (data.returnValues.mediaData) {
this._media = data.returnValues.mediaData;
// make sure that the language chooser is initialized first
setTimeout(function() {
- LanguageChooser.setLanguageId('languageID', this._media.languageID || LANGUAGE_ID);
+ if (this._availableLanguageCount > 1) {
+ LanguageChooser.setLanguageId('languageID', this._media.languageID || LANGUAGE_ID);
+ }
var title = elBySel('input[name=title]', content);
var altText = elBySel('input[name=altText]', content);
- if (this._media.isMultilingual) {
+ if (this._availableLanguageCount > 1 && this._media.isMultilingual) {
LanguageInput.setValues('altText_' + this._media.mediaID, Dictionary.fromObject(this._media.altText || { }));
LanguageInput.setValues('caption_' + this._media.mediaID, Dictionary.fromObject(this._media.caption || { }));
LanguageInput.setValues('title_' + this._media.mediaID, Dictionary.fromObject(this._media.title || { }));
elBySel('textarea[name=caption]', content).value = this._media.caption ? this._media.caption[LANGUAGE_ID] : '';
}
- var isMultilingual = elBySel('input[name=isMultilingual]', content);
- isMultilingual.addEventListener('change', this._updateLanguageFields.bind(this));
-
- this._updateLanguageFields(null, isMultilingual);
+ if (this._availableLanguageCount > 1) {
+ var isMultilingual = elBySel('input[name=isMultilingual]', content);
+ isMultilingual.addEventListener('change', this._updateLanguageFields.bind(this));
+
+ this._updateLanguageFields(null, isMultilingual);
+ }
var keyPress = this._keyPress.bind(this);
altText.addEventListener('keypress', keyPress);
I18nHandler::getInstance()->assignVariables();
return [
+ 'availableLanguageCount' => count(LanguageFactory::getInstance()->getLanguages()),
'mediaData' => $this->getI18nMediaData($mediaList)[$this->getSingleObject()->mediaID],
'template' => WCF::getTPL()->fetch('mediaEditor', 'wcf', [
'__aclSimplePrefix' => 'mediaEditor_' . $media->mediaID . '_',
- 'aclValues' => SimpleAclHandler::getInstance()->getValues('com.woltlab.wcf.media', $media->mediaID),
'__languageChooserPrefix' => 'mediaEditor_' . $media->mediaID . '_',
+ 'aclValues' => SimpleAclHandler::getInstance()->getValues('com.woltlab.wcf.media', $media->mediaID),
+ 'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
'languageID' => WCF::getUser()->languageID,
'languages' => LanguageFactory::getInstance()->getLanguages(),
'media' => $media
$this->readInteger('languageID', true, 'data');
$this->readBoolean('isMultilingual', true, 'data');
- // languageID: convert zero to null
- if (!$this->parameters['data']['languageID']) $this->parameters['data']['languageID'] = null;
-
- // isMultilingual: convert boolean to integer
- $this->parameters['data']['isMultilingual'] = intval($this->parameters['data']['isMultilingual']);
+ if (count(LanguageFactory::getInstance()->getLanguages()) > 1) {
+ // languageID: convert zero to null
+ if (!$this->parameters['data']['languageID']) $this->parameters['data']['languageID'] = null;
+
+ // isMultilingual: convert boolean to integer
+ $this->parameters['data']['isMultilingual'] = intval($this->parameters['data']['isMultilingual']);
+ }
+ else {
+ $this->parameters['data']['isMultilingual'] = 0;
+ $this->parameters['data']['languageID'] = WCF::getLanguage()->languageID;
+ }
// if data is not multilingual, a language id has to be given
if (!$this->parameters['data']['isMultilingual'] && !$this->parameters['data']['languageID']) {