BBCodes.UserMentionProcessor implemented

main
Inga 🏳‍🌈 13 years ago
parent 7a59df325e
commit 43a8cdee27
  1. 5
      FLocal.Common/BBCodes/User.cs
  2. 21
      FLocal.Common/BBCodes/helpers/UserMentionProcessor.cs
  3. 1
      FLocal.Common/FLocal.Common.csproj

@ -12,10 +12,7 @@ namespace FLocal.Common.BBCodes {
}
public override string Format(IPostParsingContext context, ITextFormatter formatter) {
var user = dataobjects.User.LoadByName(this.DefaultOrValue);
context.OnUserMention(user);
var url = new URL.users.user.Info(user.id.ToString(), null);
return String.Format("<a class=\"separate UG_{0}\" href=\"{1}\">{2}</a>", this.Safe(user.userGroup.name), url.canonical, this.Safe(user.name));
return UserMentionProcessor.ProcessUserMention(context, this.DefaultOrValue);
}
}

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLocal.Common.BBCodes {
class UserMentionProcessor {
private static string Safe(string str) {
return System.Web.HttpUtility.HtmlEncode(str);
}
public static string ProcessUserMention(IPostParsingContext context, string username) {
var user = dataobjects.User.LoadByName(username);
context.OnUserMention(user);
var url = new URL.users.user.Info(user.id.ToString(), null);
return String.Format("<a class=\"separate UG_{0}\" href=\"{1}\">{2}</a>", Safe(user.userGroup.name), url.canonical, Safe(user.name));
}
}
}

@ -68,6 +68,7 @@
<Compile Include="BBCodes\Code.cs" />
<Compile Include="BBCodes\FUrl.cs" />
<Compile Include="BBCodes\helpers\TexProcessor.cs" />
<Compile Include="BBCodes\helpers\UserMentionProcessor.cs" />
<Compile Include="BBCodes\Image.cs" />
<Compile Include="BBCodes\List.cs" />
<Compile Include="BBCodes\ListElem.cs" />

Loading…
Cancel
Save