2014-08-21 23:08:34 +08:00
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
(function (module, require) {
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
'use strict';
|
2014-09-02 08:15:31 +08:00
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
var
|
2014-08-25 23:49:01 +08:00
|
|
|
_ = require('_'),
|
|
|
|
ko = require('ko'),
|
2014-08-25 15:10:51 +08:00
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
Enums = require('Enums'),
|
|
|
|
Utils = require('Utils'),
|
|
|
|
LinkBuilder = require('LinkBuilder'),
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2014-08-27 23:59:44 +08:00
|
|
|
Settings = require('Storage:Settings'),
|
|
|
|
Data = require('Storage:Admin:Data')
|
2014-08-21 23:08:34 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function AdminSettingsGeneral()
|
|
|
|
{
|
|
|
|
this.mainLanguage = Data.mainLanguage;
|
|
|
|
this.mainTheme = Data.mainTheme;
|
|
|
|
|
|
|
|
this.language = Data.language;
|
|
|
|
this.theme = Data.theme;
|
|
|
|
|
|
|
|
this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings;
|
|
|
|
this.capaThemes = Data.capaThemes;
|
|
|
|
this.capaGravatar = Data.capaGravatar;
|
|
|
|
this.capaAdditionalAccounts = Data.capaAdditionalAccounts;
|
|
|
|
this.capaAdditionalIdentities = Data.capaAdditionalIdentities;
|
|
|
|
|
2014-08-27 23:59:44 +08:00
|
|
|
this.mainAttachmentLimit = ko.observable(Utils.pInt(Settings.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
|
|
|
|
this.uploadData = Settings.settingsGet('PhpUploadSizes');
|
2014-08-21 23:08:34 +08:00
|
|
|
this.uploadDataDesc = this.uploadData && (this.uploadData['upload_max_filesize'] || this.uploadData['post_max_size']) ?
|
|
|
|
[
|
|
|
|
this.uploadData['upload_max_filesize'] ? 'upload_max_filesize = ' + this.uploadData['upload_max_filesize'] + '; ' : '',
|
|
|
|
this.uploadData['post_max_size'] ? 'post_max_size = ' + this.uploadData['post_max_size'] : ''
|
|
|
|
].join('')
|
|
|
|
: '';
|
|
|
|
|
|
|
|
this.themesOptions = ko.computed(function () {
|
|
|
|
return _.map(Data.themes(), function (sTheme) {
|
|
|
|
return {
|
|
|
|
'optValue': sTheme,
|
|
|
|
'optText': Utils.convertThemeName(sTheme)
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.mainLanguageFullName = ko.computed(function () {
|
|
|
|
return Utils.convertLangName(this.mainLanguage());
|
|
|
|
}, this);
|
|
|
|
|
2014-08-27 23:59:44 +08:00
|
|
|
this.weakPassword = !!Settings.settingsGet('WeakPassword');
|
2014-08-21 23:08:34 +08:00
|
|
|
|
|
|
|
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
|
|
|
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
|
|
|
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
|
|
|
}
|
|
|
|
|
|
|
|
AdminSettingsGeneral.prototype.onBuild = function ()
|
|
|
|
{
|
2014-08-25 15:10:51 +08:00
|
|
|
var
|
|
|
|
self = this,
|
2014-08-27 23:59:44 +08:00
|
|
|
Remote = require('Storage:Admin:Remote')
|
2014-08-25 15:10:51 +08:00
|
|
|
;
|
|
|
|
|
2014-08-21 23:08:34 +08:00
|
|
|
_.delay(function () {
|
|
|
|
|
|
|
|
var
|
|
|
|
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
|
|
|
|
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
|
|
|
|
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self)
|
|
|
|
;
|
|
|
|
|
|
|
|
self.mainAttachmentLimit.subscribe(function (sValue) {
|
|
|
|
Remote.saveAdminConfig(f1, {
|
|
|
|
'AttachmentLimit': Utils.pInt(sValue)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
self.language.subscribe(function (sValue) {
|
|
|
|
Remote.saveAdminConfig(f2, {
|
|
|
|
'Language': Utils.trim(sValue)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
self.theme.subscribe(function (sValue) {
|
|
|
|
Remote.saveAdminConfig(f3, {
|
|
|
|
'Theme': Utils.trim(sValue)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
self.capaAdditionalAccounts.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaAdditionalAccounts': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
self.capaAdditionalIdentities.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaAdditionalIdentities': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
self.capaGravatar.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaGravatar': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
self.capaThemes.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'CapaThemes': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
self.allowLanguagesOnSettings.subscribe(function (bValue) {
|
|
|
|
Remote.saveAdminConfig(null, {
|
|
|
|
'AllowLanguagesOnSettings': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}, 50);
|
|
|
|
};
|
|
|
|
|
|
|
|
AdminSettingsGeneral.prototype.selectLanguage = function ()
|
|
|
|
{
|
2014-08-27 23:59:44 +08:00
|
|
|
require('App:Knoin').showScreenPopup(require('View:Popup:Languages'));
|
2014-08-21 23:08:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
AdminSettingsGeneral.prototype.phpInfoLink = function ()
|
|
|
|
{
|
|
|
|
return LinkBuilder.phpInfo();
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = AdminSettingsGeneral;
|
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
}(module, require));
|