Layer dataobject implemented

main
Inga 🏳‍🌈 15 years ago
parent 8802b8d03a
commit 499b6f2574
  1. 2
      Builder/IISMainHandler/build.txt
  2. 2
      Builder/IISUploadHandler/build.txt
  3. 1
      Common/Common.csproj
  4. 6
      Common/dataobjects/Board.cs
  5. 12
      Common/dataobjects/Post.cs
  6. 75
      Common/dataobjects/PostLayer.cs
  7. 5
      Common/dataobjects/Thread.cs
  8. 4
      Common/dataobjects/User.cs
  9. 2
      IISMainHandler/handlers/request/CreateThreadHandler.cs
  10. 2
      IISMainHandler/handlers/request/ReplyHandler.cs
  11. 3
      IISMainHandler/handlers/response/CreateThreadHandler.cs
  12. 3
      IISMainHandler/handlers/response/ReplyHandler.cs
  13. 0
      static/images/message-garbage-notread.gif
  14. 0
      static/images/message-garbage-read.gif
  15. 0
      static/images/message-normal-notread.gif
  16. 0
      static/images/message-normal-read.gif
  17. 0
      static/images/message-offtop-notread.gif
  18. 0
      static/images/message-offtop-read.gif
  19. 6
      templates/Full/NewThread.xslt
  20. 21
      templates/Full/PostReply.xslt
  21. 4
      templates/Full/elems/PostInfo.xslt
  22. 10
      templates/Full/elems/TextEditor.xslt
  23. 4
      templates/Full/elems/ThreadInfo.xslt

@ -63,6 +63,7 @@
<Compile Include="dataobjects\IUserSettings.cs" />
<Compile Include="dataobjects\AnonymousUserSettings.cs" />
<Compile Include="dataobjects\Post.cs" />
<Compile Include="dataobjects\PostLayer.cs" />
<Compile Include="dataobjects\Session.cs" />
<Compile Include="dataobjects\Thread.cs" />
<Compile Include="dataobjects\Upload.cs" />

@ -308,9 +308,9 @@ namespace FLocal.Common.dataobjects {
}
}
public Thread CreateThread(User poster, string title, string body, int desiredLayerId) {
public Thread CreateThread(User poster, string title, string body, PostLayer desiredLayer) {
int actualLayerId = Math.Max(poster.getMinAllowedLayer(this), desiredLayerId);
PostLayer actualLayer = poster.getActualLayer(this, desiredLayer);
AbstractChange threadInsert = new InsertChange(
Thread.TableSpec.instance,
new Dictionary<string,AbstractFieldValue> {
@ -331,7 +331,7 @@ namespace FLocal.Common.dataobjects {
Config.Transactional(transaction => {
threadInsertSet.Add(threadInsert);
threadInsertSet.Apply(transaction);
foreach(AbstractChange change in Thread.getNewPostChanges(this, threadInsert.getId().Value, null, poster, actualLayerId, title, body).Value) {
foreach(AbstractChange change in Thread.getNewPostChanges(this, threadInsert.getId().Value, null, poster, actualLayer, title, body).Value) {
dataInsertSet.Add(change);
}
dataInsertSet.Apply(transaction);

@ -90,6 +90,11 @@ namespace FLocal.Common.dataobjects {
return this._layerId;
}
}
public PostLayer layer {
get {
return PostLayer.LoadById(this.layerId);
}
}
private string _title;
public string title {
@ -175,6 +180,7 @@ namespace FLocal.Common.dataobjects {
new XElement("lastChangeDate", this.postDate.ToXml()),
new XElement("revision", this.revision),
new XElement("layerId", this.layerId),
new XElement("layerName", this.layer.name),
new XElement("title", this.title),
new XElement("body", context.outputParams.preprocessBodyIntermediate(this.body)),
new XElement("bodyShort", this.bodyShort),
@ -191,15 +197,15 @@ namespace FLocal.Common.dataobjects {
return result;
}
public Post Reply(User poster, string title, string body, int desiredLayerId) {
public Post Reply(User poster, string title, string body, PostLayer desiredLayer) {
if(this.thread.isLocked) {
throw new FLocalException("thread locked");
}
int actualLayerId = Math.Max(poster.getMinAllowedLayer(this.thread.board), desiredLayerId);
PostLayer actualLayer = poster.getActualLayer(this.thread.board, desiredLayer);
var changes = Thread.getNewPostChanges(this.thread.board, this.threadId, this, poster, actualLayerId, title, body);
var changes = Thread.getNewPostChanges(this.thread.board, this.threadId, this, poster, actualLayer, title, body);
ChangeSetUtil.ApplyChanges(changes.Value.ToArray());
return Post.LoadById(changes.Key.getId().Value);

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FLocal.Core;
using FLocal.Core.DB;
using FLocal.Core.DB.conditions;
namespace FLocal.Common.dataobjects {
public class PostLayer : SqlObject<PostLayer> {
public const string NAME_NORMAL = "normal";
public const string NAME_OFFTOP = "offtop";
public const string NAME_GARBAGE = "garbage";
public const string NAME_HIDDEN = "hidden";
public class TableSpec : ISqlObjectTableSpec {
public const string TABLE = "Layers";
public const string FIELD_ID = "Id";
public const string FIELD_NAME = "Name";
public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; } }
public string idName { get { return FIELD_ID; } }
public void refreshSqlObject(int id) { Refresh(id); }
}
protected override ISqlObjectTableSpec table { get { return TableSpec.instance; } }
private string _name;
public string name {
get {
this.LoadIfNotLoaded();
return this._name;
}
}
protected override void doFromHash(Dictionary<string, string> data) {
this._name = data[TableSpec.FIELD_NAME];
}
private static readonly object allLayers_Locker = new object();
public static IEnumerable<PostLayer> allLayers {
get {
return
from id in Cache<IEnumerable<int>>.instance.get(
allLayers_Locker,
() => {
IEnumerable<int> ids = from stringId in Config.instance.mainConnection.LoadIdsByConditions(
TableSpec.instance,
new FLocal.Core.DB.conditions.EmptyCondition(),
Diapasone.unlimited
) select int.Parse(stringId);
Category.LoadByIds(ids);
return ids;
}
)
let layer = PostLayer.LoadById(id)
orderby layer.id
select layer;
}
}
internal static void allLayers_Reset() {
Cache<IEnumerable<int>>.instance.delete(allLayers_Locker);
}
public XElement exportToXml(UserContext context) {
return new XElement("layer",
new XElement("id", this.id),
new XElement("name", this.name)
);
}
}
}

@ -174,6 +174,7 @@ namespace FLocal.Common.dataobjects {
new XElement("totalViews", this.totalViews),
new XElement("bodyShort", this.firstPost.bodyShort),
new XElement("layerId", this.firstPost.layerId),
new XElement("layerName", this.firstPost.layer.name),
context.formatTotalPosts(this.totalPosts)
);
if(includeFirstPost) {
@ -358,7 +359,7 @@ namespace FLocal.Common.dataobjects {
});
}
internal static KeyValuePair<AbstractChange, IEnumerable<AbstractChange>> getNewPostChanges(Board board, int threadId, Post parentPost, User poster, int layerId, string title, string body) {
internal static KeyValuePair<AbstractChange, IEnumerable<AbstractChange>> getNewPostChanges(Board board, int threadId, Post parentPost, User poster, PostLayer layer, string title, string body) {
string parentPostId = null;
if(parentPost != null) parentPostId = parentPost.id.ToString();
bool isNewThread = (parentPost == null);
@ -371,7 +372,7 @@ namespace FLocal.Common.dataobjects {
{ Post.TableSpec.FIELD_POSTDATE, new ScalarFieldValue(DateTime.Now.ToUTCString()) },
{ Post.TableSpec.FIELD_REVISION, new ScalarFieldValue("0") },
{ Post.TableSpec.FIELD_LASTCHANGEDATE, new ScalarFieldValue(DateTime.Now.ToUTCString()) },
{ Post.TableSpec.FIELD_LAYERID, new ScalarFieldValue(layerId.ToString()) },
{ Post.TableSpec.FIELD_LAYERID, new ScalarFieldValue(layer.id.ToString()) },
{ Post.TableSpec.FIELD_TITLE, new ScalarFieldValue(title) },
{ Post.TableSpec.FIELD_BODY, new ScalarFieldValue(UBBParser.UBBToIntermediate(body)) },
}

@ -197,8 +197,8 @@ namespace FLocal.Common.dataobjects {
);
}
public int getMinAllowedLayer(Board board) {
return 1;
public PostLayer getActualLayer(Board board, PostLayer desiredLayer) {
return desiredLayer;
}
}

@ -16,7 +16,7 @@ namespace FLocal.IISHandler.handlers.request {
context.session.account.user,
this.getTitle(context),
this.getBody(context),
int.Parse(context.httprequest.Form["layerId"])
PostLayer.LoadById(int.Parse(context.httprequest.Form["layerId"]))
);
Post newPost = newThread.firstPost;

@ -18,7 +18,7 @@ namespace FLocal.IISHandler.handlers.request {
context.session.account.user,
this.getTitle(context),
this.getBody(context),
int.Parse(context.httprequest.Form["layerId"])
PostLayer.LoadById(int.Parse(context.httprequest.Form["layerId"]))
);
newPost.thread.markAsRead(context.session.account, newPost, newPost);

@ -23,6 +23,9 @@ namespace FLocal.IISHandler.handlers.response {
return new XElement[] {
board.exportToXml(context, false),
new XElement("layers",
from layer in PostLayer.allLayers select layer.exportToXml(context)
),
};
}
}

@ -25,6 +25,9 @@ namespace FLocal.IISHandler.handlers.response {
post.thread.board.exportToXml(context, false),
post.thread.exportToXml(context, false),
post.exportToXmlWithoutThread(context, false),
new XElement("layers",
from layer in PostLayer.allLayers select layer.exportToXml(context)
),
};
}
}

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 165 B

Before

Width:  |  Height:  |  Size: 161 B

After

Width:  |  Height:  |  Size: 161 B

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 153 B

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 153 B

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 152 B

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 152 B

@ -34,9 +34,9 @@
<input type="text" tabindex="1" name="title" maxlength="70" class="formboxes" size="60"/>
<span class="small">Ñëîé ñîîáùåíèÿ:</span>
<select class="formboxes" name="layerId">
<option value="1" >Íîðìàëüíîå ñîîáùåíèå</option>
<option value="2" >Ôëóä/îôôòîïèê</option>
<option value="3" >Ìóñîð</option>
<xsl:apply-templates select="layers/layer">
<!--xsl:with-param name="defaultLayerId"><xsl:value-of select="post/layerId"/></xsl:with-param-->
</xsl:apply-templates>
</select>
<br/>
<br/>

@ -46,24 +46,9 @@
</input>
<span class="small">Ñëîé ñîîáùåíèÿ:</span>
<select class="formboxes" name="layerId">
<option value="1">
<xsl:if test="post/layerId='1'">
<xsl:attribute name="selected"/>
</xsl:if>
<xsl:text>Íîðìàëüíîå ñîîáùåíèå</xsl:text>
</option>
<option value="2">
<xsl:if test="post/layerId='2'">
<xsl:attribute name="selected"/>
</xsl:if>
<xsl:text>Ôëóä/îôôòîïèê</xsl:text>
</option>
<option value="3">
<xsl:if test="post/layerId='3'">
<xsl:attribute name="selected"/>
</xsl:if>
<xsl:text>Ìóñîð</xsl:text>
</option>
<xsl:apply-templates select="layers/layer">
<xsl:with-param name="defaultLayerId"><xsl:value-of select="post/layerId"/></xsl:with-param>
</xsl:apply-templates>
</select>
<br/>
<br/>

@ -21,10 +21,10 @@
<img border="0" alt="" style="vertical-align: text-bottom">
<xsl:choose>
<xsl:when test="isUnread='true'">
<xsl:attribute name="src">/static/images/message-<xsl:value-of select="layerId"/>-notread.gif</xsl:attribute>
<xsl:attribute name="src">/static/images/message-<xsl:value-of select="layerName"/>-notread.gif</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="src">/static/images/message-<xsl:value-of select="layerId"/>-read.gif</xsl:attribute>
<xsl:attribute name="src">/static/images/message-<xsl:value-of select="layerName"/>-read.gif</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</img>

@ -241,5 +241,15 @@ function insertInBody(str) {
</table>
</xsl:template>
<xsl:template match="layer">
<xsl:param name="defaultLayerId"/>
<option>
<xsl:attribute name="value"><xsl:value-of select="id"/></xsl:attribute>
<xsl:if test="id=$defaultLayerId">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="name"/>
</option>
</xsl:template>
</xsl:stylesheet>

@ -16,10 +16,10 @@
<img alt="*" hspace="5" style="vertical-align: text-bottom">
<xsl:choose>
<xsl:when test="afterLastRead&lt;=lastPostId">
<xsl:attribute name="src">/static/images/message-<xsl:value-of select="layerId"/>-notread.gif</xsl:attribute>
<xsl:attribute name="src">/static/images/message-<xsl:value-of select="layerName"/>-notread.gif</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="src">/static/images/message-<xsl:value-of select="layerId"/>-read.gif</xsl:attribute>
<xsl:attribute name="src">/static/images/message-<xsl:value-of select="layerName"/>-read.gif</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</img>

Loading…
Cancel
Save