Implemented MaxUploadImageDimensions setting

main
Inga 🏳‍🌈 14 years ago
parent d43b3b9c69
commit 4893cc79c7
  1. 24
      Common/dataobjects/AccountSettings.cs
  2. 15
      Common/dataobjects/AnonymousUserSettings.cs
  3. 19
      Common/dataobjects/IUserSettings.cs
  4. 2
      IISMainHandler/designs/Modern.cs
  5. 2
      IISMainHandler/handlers/AbstractGetHandler.cs
  6. 4
      IISMainHandler/handlers/request/SettingsHandler.cs
  7. 4
      build-all.bat
  8. 11
      templates/Full/Settings.xslt
  9. 11
      templates/Modern/Settings.xslt
  10. 7
      templates/Modern/elems/Main.xslt
  11. 4
      templates/Modern/elems/UploadInfo.xslt

@ -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<int, int?> accountid2id = new Dictionary<int, int?>();
@ -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<string, AbstractFieldValue> dataToUpdate = new Dictionary<string,AbstractFieldValue> {
{ 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<string, AbstractFieldValue> dataToInsert = new Dictionary<string,AbstractFieldValue>(dataToUpdate) {
{ TableSpec.FIELD_ACCOUNTID, new ScalarFieldValue(account.id.ToString()) },

@ -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;
}
}
}
}

@ -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)
);
}

@ -12,7 +12,7 @@ namespace FLocal.IISHandler.designs {
string FLocal.Common.IOutputParams.preprocessBodyIntermediate(string bodyIntermediate) {
return bodyIntermediate.
Replace("<f:img><f:src>", "<img src=\"").
Replace("<f:img><f:src>", "<img class=\"uploadImage\" src=\"").
Replace("</f:src><f:alt>", "\" alt=\"").
Replace("</f:alt></f:img>", "\"/>");
}

@ -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(),
};
}

@ -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);

@ -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
Builder IISUploadHandler release
move /Y IISUploadHandler\product-release.msi ..\IISUploadHandler-release.msi

@ -89,6 +89,17 @@ function changeMachichara(newMachichara) {
<xsl:attribute name="value"><xsl:value-of select="settings/uploadsPerPage"/></xsl:attribute>
</input>
</p>
<p>
<xsl:text>Ìàêñèìàëüíûé ðàçìåð êàðòèíêè:</xsl:text>
<br/>
<input type="text" name="maxUploadImageWidth" size="4">
<xsl:attribute name="value"><xsl:value-of select="settings/maxUploadImageWidth"/></xsl:attribute>
</input>
<xsl:text> x </xsl:text>
<input type="text" name="maxUploadImageHeight" size="4">
<xsl:attribute name="value"><xsl:value-of select="settings/maxUploadImageHeight"/></xsl:attribute>
</input>
</p>
<p>
<xsl:text>Öâåòîâàÿ ñõåìà äèçàéíà Modern:</xsl:text>
<br/>

@ -89,6 +89,17 @@ function changeMachichara(newMachichara) {
<xsl:attribute name="value"><xsl:value-of select="settings/uploadsPerPage"/></xsl:attribute>
</input>
</p>
<p>
<xsl:text>Ìàêñèìàëüíûé ðàçìåð êàðòèíêè:</xsl:text>
<br/>
<input type="text" name="maxUploadImageWidth" size="4">
<xsl:attribute name="value"><xsl:value-of select="settings/maxUploadImageWidth"/></xsl:attribute>
</input>
<xsl:text> x </xsl:text>
<input type="text" name="maxUploadImageHeight" size="4">
<xsl:attribute name="value"><xsl:value-of select="settings/maxUploadImageHeight"/></xsl:attribute>
</input>
</p>
<p>
<xsl:text>Öâåòîâàÿ ñõåìà:</xsl:text>
<br/>

@ -28,6 +28,13 @@
</xsl:attribute>
<xsl:text> </xsl:text>
</script>
<style>
<xsl:text>.uploadImage { max-width:</xsl:text>
<xsl:value-of select="uploadSettings/maxWidth"/>
<xsl:text>px; max-height:</xsl:text>
<xsl:value-of select="uploadSettings/maxHeight"/>
<xsl:text>px; }</xsl:text>
</style>
<title>
<xsl:call-template name="specificTitle"/>
<xsl:text> - </xsl:text>

@ -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/>

Loading…
Cancel
Save