From 4893cc79c70ed8053dcd245c59f9d59cf9260a0e Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Sat, 4 Dec 2010 22:08:21 +0000 Subject: [PATCH] Implemented MaxUploadImageDimensions setting --- Common/dataobjects/AccountSettings.cs | 24 ++++++++++++++++++- Common/dataobjects/AnonymousUserSettings.cs | 15 +++++++++++- Common/dataobjects/IUserSettings.cs | 19 ++++++++++++++- IISMainHandler/designs/Modern.cs | 2 +- IISMainHandler/handlers/AbstractGetHandler.cs | 2 ++ .../handlers/request/SettingsHandler.cs | 4 +++- build-all.bat | 4 ++-- templates/Full/Settings.xslt | 11 +++++++++ templates/Modern/Settings.xslt | 11 +++++++++ templates/Modern/elems/Main.xslt | 7 ++++++ templates/Modern/elems/UploadInfo.xslt | 4 ++-- 11 files changed, 94 insertions(+), 9 deletions(-) diff --git a/Common/dataobjects/AccountSettings.cs b/Common/dataobjects/AccountSettings.cs index d524664..50c58c8 100644 --- a/Common/dataobjects/AccountSettings.cs +++ b/Common/dataobjects/AccountSettings.cs @@ -23,6 +23,8 @@ namespace FLocal.Common.dataobjects { public const string FIELD_SKINID = "SkinId"; public const string FIELD_MODERNSKINID = "ModernSkinId"; public const string FIELD_MACHICHARAID = "MachicharaId"; + public const string FIELD_MAXUPLOADIMAGEWIDTH = "MaxUploadImageWidth"; + public const string FIELD_MAXUPLOADIMAGEHEIGHT = "MaxUploadImageHeight"; public static readonly TableSpec instance = new TableSpec(); public string name { get { return TABLE; } } public string idName { get { return FIELD_ID; } } @@ -117,6 +119,22 @@ namespace FLocal.Common.dataobjects { } } + private int _maxUploadImageWidth; + public int maxUploadImageWidth { + get { + this.LoadIfNotLoaded(); + return this._maxUploadImageWidth; + } + } + + private int _maxUploadImageHeight; + public int maxUploadImageHeight { + get { + this.LoadIfNotLoaded(); + return this._maxUploadImageHeight; + } + } + public bool isPostVisible(Post post) { if(post.layer.name == PostLayer.NAME_HIDDEN) return false; if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_NONE) return false; @@ -134,6 +152,8 @@ namespace FLocal.Common.dataobjects { this._skinId = int.Parse(data[TableSpec.FIELD_SKINID]); this._modernSkinId = int.Parse(data[TableSpec.FIELD_MODERNSKINID]); this._machicharaId = int.Parse(data[TableSpec.FIELD_MACHICHARAID]); + this._maxUploadImageWidth = int.Parse(data[TableSpec.FIELD_MAXUPLOADIMAGEWIDTH]); + this._maxUploadImageHeight = int.Parse(data[TableSpec.FIELD_MAXUPLOADIMAGEHEIGHT]); } private static Dictionary accountid2id = new Dictionary(); @@ -173,7 +193,7 @@ namespace FLocal.Common.dataobjects { } } - public static void Save(Account account, int postsPerPage, int threadsPerPage, int usersPerPage, int uploadsPerPage, Skin skin, ModernSkin modernSkin, Machichara machichara) { + public static void Save(Account account, int postsPerPage, int threadsPerPage, int usersPerPage, int uploadsPerPage, Skin skin, ModernSkin modernSkin, Machichara machichara, int maxUploadImageWidth, int maxUploadImageHeight) { Dictionary dataToUpdate = new Dictionary { { TableSpec.FIELD_POSTSPERPAGE, new ScalarFieldValue(postsPerPage.ToString()) }, { TableSpec.FIELD_THREADSPERPAGE, new ScalarFieldValue(threadsPerPage.ToString()) }, @@ -182,6 +202,8 @@ namespace FLocal.Common.dataobjects { { TableSpec.FIELD_SKINID, new ScalarFieldValue(skin.id.ToString()) }, { TableSpec.FIELD_MODERNSKINID, new ScalarFieldValue(modernSkin.id.ToString()) }, { TableSpec.FIELD_MACHICHARAID, new ScalarFieldValue(machichara.id.ToString()) }, + { TableSpec.FIELD_MAXUPLOADIMAGEWIDTH, new ScalarFieldValue(maxUploadImageWidth.ToString()) }, + { TableSpec.FIELD_MAXUPLOADIMAGEHEIGHT, new ScalarFieldValue(maxUploadImageHeight.ToString()) }, }; Dictionary dataToInsert = new Dictionary(dataToUpdate) { { TableSpec.FIELD_ACCOUNTID, new ScalarFieldValue(account.id.ToString()) }, diff --git a/Common/dataobjects/AnonymousUserSettings.cs b/Common/dataobjects/AnonymousUserSettings.cs index 39f45a5..fdea9f1 100644 --- a/Common/dataobjects/AnonymousUserSettings.cs +++ b/Common/dataobjects/AnonymousUserSettings.cs @@ -65,6 +65,19 @@ namespace FLocal.Common.dataobjects { if(post.layer.name != PostLayer.NAME_NORMAL) return false; return true; } - + + + public int maxUploadImageWidth { + get { + return 800; + } + } + + public int maxUploadImageHeight { + get { + return 600; + } + } + } } diff --git a/Common/dataobjects/IUserSettings.cs b/Common/dataobjects/IUserSettings.cs index 695a215..3c614b7 100644 --- a/Common/dataobjects/IUserSettings.cs +++ b/Common/dataobjects/IUserSettings.cs @@ -37,6 +37,14 @@ namespace FLocal.Common.dataobjects { bool isPostVisible(Post post); + int maxUploadImageWidth { + get; + } + + int maxUploadImageHeight { + get; + } + } public static class IUserSettings_Extension { @@ -49,7 +57,16 @@ namespace FLocal.Common.dataobjects { new XElement("uploadsPerPage", settings.uploadsPerPage), new XElement("skinId", settings.skin.id), new XElement("modernSkinId", settings.modernSkin.id), - new XElement("machicharaId", settings.machichara.id) + new XElement("machicharaId", settings.machichara.id), + new XElement("maxUploadImageWidth", settings.maxUploadImageWidth), + new XElement("maxUploadImageHeight", settings.maxUploadImageHeight) + ); + } + + public static XElement exportUploadSettingsToXml(this IUserSettings settings, UserContext context) { + return new XElement("uploadSettings", + new XElement("maxWidth", settings.maxUploadImageWidth), + new XElement("maxHeight", settings.maxUploadImageHeight) ); } diff --git a/IISMainHandler/designs/Modern.cs b/IISMainHandler/designs/Modern.cs index 142e37c..2f0839e 100644 --- a/IISMainHandler/designs/Modern.cs +++ b/IISMainHandler/designs/Modern.cs @@ -12,7 +12,7 @@ namespace FLocal.IISHandler.designs { string FLocal.Common.IOutputParams.preprocessBodyIntermediate(string bodyIntermediate) { return bodyIntermediate. - Replace("", "", "", "\" alt=\""). Replace("", "\"/>"); } diff --git a/IISMainHandler/handlers/AbstractGetHandler.cs b/IISMainHandler/handlers/AbstractGetHandler.cs index 21b33ed..a5f80c8 100644 --- a/IISMainHandler/handlers/AbstractGetHandler.cs +++ b/IISMainHandler/handlers/AbstractGetHandler.cs @@ -5,6 +5,7 @@ using System.Text; using System.Xml.Linq; using FLocal.Common; using FLocal.Common.URL; +using FLocal.Common.dataobjects; namespace FLocal.IISHandler.handlers { @@ -30,6 +31,7 @@ namespace FLocal.IISHandler.handlers { context.userSettings.skin.exportToXml(), context.userSettings.modernSkin.exportToXml(), context.userSettings.machichara.exportToXml(), + context.userSettings.exportUploadSettingsToXml(context), context.exportRequestParameters(), }; } diff --git a/IISMainHandler/handlers/request/SettingsHandler.cs b/IISMainHandler/handlers/request/SettingsHandler.cs index 9a19fed..fb85330 100644 --- a/IISMainHandler/handlers/request/SettingsHandler.cs +++ b/IISMainHandler/handlers/request/SettingsHandler.cs @@ -27,6 +27,8 @@ namespace FLocal.IISHandler.handlers.request { Skin skin = Skin.LoadById(int.Parse(context.httprequest.Form["skinId"])); ModernSkin modernSkin = ModernSkin.LoadById(int.Parse(context.httprequest.Form["modernSkinId"])); Machichara machichara = Machichara.LoadById(int.Parse(context.httprequest.Form["machicharaId"])); + int maxUploadImageWidth = int.Parse(context.httprequest.Form["maxUploadImageWidth"]); + int maxUploadImageHeight = int.Parse(context.httprequest.Form["maxUploadImageHeight"]); if((postsPerPage < 1) || (postsPerPage > 200)) throw new FLocalException("wrong number for postsPerPage"); if((threadsPerPage < 1) || (threadsPerPage > 200)) throw new FLocalException("wrong number for threadsPerPage"); @@ -35,7 +37,7 @@ namespace FLocal.IISHandler.handlers.request { if(!context.account.checkPassword(currentPassword)) throw new FLocalException("Wrong password. You should enter your current password in order to change settings."); - AccountSettings.Save(context.session.account, postsPerPage, threadsPerPage, usersPerPage, uploadsPerPage, skin, modernSkin, machichara); + AccountSettings.Save(context.session.account, postsPerPage, threadsPerPage, usersPerPage, uploadsPerPage, skin, modernSkin, machichara, maxUploadImageWidth, maxUploadImageHeight); if(newPassword != null && newPassword != "") { context.account.updatePassword(newPassword); diff --git a/build-all.bat b/build-all.bat index 70a3144..783e060 100644 --- a/build-all.bat +++ b/build-all.bat @@ -5,5 +5,5 @@ Builder IISMainHandler release move /Y IISMainHandler\product-release.msi ..\IISMainHandler-release.msi Builder IISMainHandler debug move /Y IISMainHandler\product-debug.msi ..\IISMainHandler-debug.msi -rem Builder IISUploadHandler release -rem move /Y IISUploadHandler\product-release.msi ..\IISUploadHandler-release.msi \ No newline at end of file +Builder IISUploadHandler release +move /Y IISUploadHandler\product-release.msi ..\IISUploadHandler-release.msi \ No newline at end of file diff --git a/templates/Full/Settings.xslt b/templates/Full/Settings.xslt index e47d8da..2b6fd1e 100644 --- a/templates/Full/Settings.xslt +++ b/templates/Full/Settings.xslt @@ -89,6 +89,17 @@ function changeMachichara(newMachichara) {

+

+ Максимальный размер картинки: +
+ + + + x + + + +

Цветовая схема дизайна Modern:
diff --git a/templates/Modern/Settings.xslt b/templates/Modern/Settings.xslt index 3f3e999..b2221af 100644 --- a/templates/Modern/Settings.xslt +++ b/templates/Modern/Settings.xslt @@ -89,6 +89,17 @@ function changeMachichara(newMachichara) {

+

+ Максимальный размер картинки: +
+ + + + x + + + +

Цветовая схема:
diff --git a/templates/Modern/elems/Main.xslt b/templates/Modern/elems/Main.xslt index da424e2..6bd2e62 100644 --- a/templates/Modern/elems/Main.xslt +++ b/templates/Modern/elems/Main.xslt @@ -28,6 +28,13 @@ + <xsl:call-template name="specificTitle"/> <xsl:text> - </xsl:text> diff --git a/templates/Modern/elems/UploadInfo.xslt b/templates/Modern/elems/UploadInfo.xslt index 40ee2ec..3c64da3 100644 --- a/templates/Modern/elems/UploadInfo.xslt +++ b/templates/Modern/elems/UploadInfo.xslt @@ -3,7 +3,7 @@ <xsl:import href="UserInfoBar.xslt"/> <xsl:template match="upload"> - <xsl:param name="dimensionsLimit">max-width:800px;max-height:600px;</xsl:param> + <xsl:param name="className">uploadImage</xsl:param> <div class="uploadcontainer" style="clear:both"> <a><xsl:attribute name="name">Upload<xsl:value-of select="id"/></xsl:attribute></a> <div class="userbarcontainer" style="float:left"> @@ -31,7 +31,7 @@ </font> <div class="uploadbody"> <img> - <xsl:attribute name="style"><xsl:value-of select="$dimensionsLimit"/></xsl:attribute> + <xsl:attribute name="class"><xsl:value-of select="$className"/></xsl:attribute> <xsl:attribute name="src">/Upload/Item/<xsl:value-of select="id"/>/</xsl:attribute> </img> <br/>