UserInfo handlers refactored; UserHeader improved

main
Inga 🏳‍🌈 14 years ago
parent b94a29b8d8
commit a6208a90eb
  1. 2
      Builder/IISMainHandler/build.txt
  2. 1
      IISMainHandler/IISMainHandler.csproj
  3. 49
      IISMainHandler/handlers/response/AbstractUserGetHandler.cs
  4. 27
      IISMainHandler/handlers/response/UserInfoHandler.cs
  5. 10
      IISMainHandler/handlers/response/UserPollsParticipatedHandler.cs
  6. 10
      IISMainHandler/handlers/response/UserPostsHandler.cs
  7. 9
      IISMainHandler/handlers/response/UserRepliesHandler.cs
  8. 10
      IISMainHandler/handlers/response/UserThreadsHandler.cs
  9. 29
      templates/Full/UserInfo.xslt
  10. 3
      templates/Full/elems/MyHeader.xslt
  11. 18
      templates/Full/elems/UserHeader.xslt

@ -145,6 +145,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="handlers\request\UserDataHandler.cs" />
<Compile Include="handlers\response\AbstractUserGetHandler.cs" />
<Compile Include="handlers\response\UserDataHandler.cs" />
<Compile Include="handlers\response\UserThreadsHandler.cs" />
</ItemGroup>

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Xml.Linq;
using FLocal.Common;
using FLocal.Common.dataobjects;
using FLocal.Core;
using FLocal.Core.DB;
using FLocal.Core.DB.conditions;
namespace FLocal.IISHandler.handlers.response {
abstract class AbstractUserGetHandler : AbstractGetHandler {
abstract protected IEnumerable<XElement> getUserSpecificData(WebContext context, User user);
sealed override protected IEnumerable<XElement> getSpecificData(WebContext context) {
User user;
{
int userId;
if(int.TryParse(context.requestParts[2], out userId)) {
user = User.LoadById(userId);
} else {
user = User.LoadByName(context.requestParts[2]);
}
}
Account account = null;
if(context.session != null) {
try {
account = Account.LoadByUser(user);
} catch(NotFoundInDBException) {
}
}
Session lastSession = null;
if(account != null && !account.isDetailedStatusHidden) {
lastSession = Session.GetLastSession(account);
}
return new XElement[] {
user.exportToXmlForViewing(context),
(account == null) ? null : new XElement("accountId", account.id.ToString()), //for PM history, PM send etc
(lastSession == null) ? null : new XElement("lastActivity", lastSession.lastActivity.ToXml()),
}.Union(this.getUserSpecificData(context, user));
}
}
}

@ -12,7 +12,7 @@ using FLocal.Core.DB.conditions;
namespace FLocal.IISHandler.handlers.response {
class UserInfoHandler : AbstractGetHandler {
class UserInfoHandler : AbstractUserGetHandler {
override protected string templateName {
get {
@ -20,31 +20,8 @@ namespace FLocal.IISHandler.handlers.response {
}
}
override protected IEnumerable<XElement> getSpecificData(WebContext context) {
User user;
{
int userId;
if(int.TryParse(context.requestParts[2], out userId)) {
user = User.LoadById(userId);
} else {
user = User.LoadByName(context.requestParts[2]);
}
}
Account account = null;
if(context.session != null) {
try {
account = Account.LoadByUser(user);
} catch(NotFoundInDBException) {
}
}
Session lastSession = null;
if(account != null && !account.isDetailedStatusHidden) {
lastSession = Session.GetLastSession(account);
}
override protected IEnumerable<XElement> getUserSpecificData(WebContext context, User user) {
return new XElement[] {
user.exportToXmlForViewing(context),
(account == null) ? null : new XElement("accountId", account.id.ToString()), //for PM history, PM send etc
(lastSession == null) ? null : new XElement("lastActivity", lastSession.lastActivity.ToXml())
};
}

@ -12,7 +12,7 @@ using FLocal.Core.DB.conditions;
namespace FLocal.IISHandler.handlers.response {
class UserPollsParticipatedHandler : AbstractGetHandler {
class UserPollsParticipatedHandler : AbstractUserGetHandler {
override protected string templateName {
get {
@ -20,8 +20,7 @@ namespace FLocal.IISHandler.handlers.response {
}
}
override protected IEnumerable<XElement> getSpecificData(WebContext context) {
User user = User.LoadById(int.Parse(context.requestParts[2]));
override protected IEnumerable<XElement> getUserSpecificData(WebContext context, User user) {
PageOuter pageOuter = PageOuter.createFromGet(
context.requestParts,
context.userSettings.postsPerPage,
@ -46,15 +45,12 @@ namespace FLocal.IISHandler.handlers.response {
) select int.Parse(stringId)
);
XElement[] result = new XElement[] {
user.exportToXmlForViewing(context),
return new XElement[] {
new XElement("polls",
from vote in votes select vote.poll.exportToXml(context),
pageOuter.exportToXml(2, 5, 2)
)
};
return result;
}
}

@ -12,7 +12,7 @@ using FLocal.Core.DB.conditions;
namespace FLocal.IISHandler.handlers.response {
class UserPostsHandler : AbstractGetHandler {
class UserPostsHandler : AbstractUserGetHandler {
override protected string templateName {
get {
@ -20,8 +20,7 @@ namespace FLocal.IISHandler.handlers.response {
}
}
override protected IEnumerable<XElement> getSpecificData(WebContext context) {
User user = User.LoadById(int.Parse(context.requestParts[2]));
override protected IEnumerable<XElement> getUserSpecificData(WebContext context, User user) {
PageOuter pageOuter = PageOuter.createFromGet(
context.requestParts,
context.userSettings.postsPerPage,
@ -29,15 +28,12 @@ namespace FLocal.IISHandler.handlers.response {
);
IEnumerable<Post> posts = user.getPosts(pageOuter);
XElement[] result = new XElement[] {
user.exportToXmlForViewing(context),
return new XElement[] {
new XElement("posts",
from post in posts select post.exportToXml(context),
pageOuter.exportToXml(2, 5, 2)
)
};
return result;
}
}

@ -12,7 +12,7 @@ using FLocal.Core.DB.conditions;
namespace FLocal.IISHandler.handlers.response {
class UserRepliesHandler : AbstractGetHandler {
class UserRepliesHandler : AbstractUserGetHandler {
override protected string templateName {
get {
@ -20,8 +20,7 @@ namespace FLocal.IISHandler.handlers.response {
}
}
override protected IEnumerable<XElement> getSpecificData(WebContext context) {
User user = User.LoadById(int.Parse(context.requestParts[2]));
override protected IEnumerable<XElement> getUserSpecificData(WebContext context, User user) {
PageOuter pageOuter = PageOuter.createFromGet(
context.requestParts,
context.userSettings.postsPerPage,
@ -29,15 +28,13 @@ namespace FLocal.IISHandler.handlers.response {
);
IEnumerable<Post> posts = user.getReplies(pageOuter);
XElement[] result = new XElement[] {
return new XElement[] {
user.exportToXmlForViewing(context),
new XElement("posts",
from post in posts select post.exportToXml(context),
pageOuter.exportToXml(2, 5, 2)
)
};
return result;
}
}

@ -12,7 +12,7 @@ using FLocal.Core.DB.conditions;
namespace FLocal.IISHandler.handlers.response {
class UserThreadsHandler : AbstractGetHandler {
class UserThreadsHandler : AbstractUserGetHandler {
override protected string templateName {
get {
@ -20,8 +20,7 @@ namespace FLocal.IISHandler.handlers.response {
}
}
override protected IEnumerable<XElement> getSpecificData(WebContext context) {
User user = User.LoadById(int.Parse(context.requestParts[2]));
override protected IEnumerable<XElement> getUserSpecificData(WebContext context, User user) {
PageOuter pageOuter = PageOuter.createFromGet(
context.requestParts,
context.userSettings.postsPerPage,
@ -29,15 +28,12 @@ namespace FLocal.IISHandler.handlers.response {
);
IEnumerable<Thread> threads = user.getThreads(pageOuter);
XElement[] result = new XElement[] {
user.exportToXmlForViewing(context),
return new XElement[] {
new XElement("threads",
from thread in threads select thread.exportToXml(context),
pageOuter.exportToXml(1, 5, 1)
)
};
return result;
}
}

@ -179,35 +179,6 @@
<xsl:text>Not implemented</xsl:text>
</td>
</tr>
<tr>
<td valign="top" colspan="3" align="center" class="darktable">
<a>
<xsl:if test="accountId">
<xsl:attribute name="href">/My/Conversations/PMSend/<xsl:value-of select="accountId"/>/</xsl:attribute>
</xsl:if>
<img src="/static/images/sendprivate.gif" border="0" style="vertical-align: text-bottom" />
<xsl:text> Ïîñëàòü ëè÷íîå ñîîáùåíèå</xsl:text>
</a>
<xsl:text> | </xsl:text>
<a>
<xsl:if test="accountId">
<xsl:attribute name="href">/My/Conversations/Conversation/<xsl:value-of select="accountId"/>/</xsl:attribute>
</xsl:if>
<img src="/static/images/sundial.gif" border="0" style="vertical-align: text-bottom" />
<xsl:text> Èñòîðèÿ</xsl:text>
</a>
<xsl:text> | </xsl:text>
<a>
<img src="/static/images/addtobook.gif" align="top" style="vertical-align: text-bottom" />
<xsl:text> Äîáàâèòü â àäðåñíóþ êíèãó</xsl:text>
</a>
<xsl:text> | </xsl:text>
<a>
<img src="/static/images/graph.gif" align="top" border="0" style="vertical-align: text-bottom" />
<xsl:text> Ñòàòèñòèêà</xsl:text>
</a>
</td>
</tr>
</table>
</td>
</tr>

@ -52,7 +52,7 @@
<xsl:if test="not(session/sessionKey)">true</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:text> | &gt;&gt;</xsl:text>
<xsl:text> | </xsl:text>
<xsl:call-template name="headerLink">
<xsl:with-param name="url">/Users/User/<xsl:value-of select="session/user/id"/>/Info/</xsl:with-param>
<xsl:with-param name="text">Ïðîôèëü</xsl:with-param>
@ -60,6 +60,7 @@
<xsl:if test="not(session/sessionKey)">true</xsl:if>
</xsl:with-param>
</xsl:call-template>
<img src="/static/images/external.png" border="0"/>
<xsl:text> | </xsl:text>
<a target="_top">
<xsl:if test="session/sessionKey">

@ -33,6 +33,24 @@
<xsl:with-param name="url"><xsl:value-of select="$baseLink"/>PollsParticipated/</xsl:with-param>
<xsl:with-param name="text">Îïðîñû</xsl:with-param>
</xsl:call-template>
<xsl:text> | </xsl:text>
<xsl:call-template name="headerLink">
<xsl:with-param name="url">/My/Conversations/Conversation/<xsl:value-of select="accountId"/>/</xsl:with-param>
<xsl:with-param name="text">Èñòîðèÿ</xsl:with-param>
<xsl:with-param name="isDisabled">
<xsl:if test="not(accountId)">true</xsl:if>
</xsl:with-param>
</xsl:call-template>
<img src="/static/images/external.png" border="0"/>
<xsl:text> | </xsl:text>
<xsl:call-template name="headerLink">
<xsl:with-param name="url">/My/Conversations/PMSend/<xsl:value-of select="accountId"/>/</xsl:with-param>
<xsl:with-param name="text">Íàïèñàòü</xsl:with-param>
<xsl:with-param name="isDisabled">
<xsl:if test="not(accountId)">true</xsl:if>
</xsl:with-param>
</xsl:call-template>
<img src="/static/images/external.png" border="0"/>
</td>
</tr>
</table>

Loading…
Cancel
Save