| Index: Janus.4.sln
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: Janus/Core/JanusProtocolSupport/FormatMessageHelper.cs
===================================================================
--- Janus/Core/JanusProtocolSupport/FormatMessageHelper.cs (revision 0)
+++ Janus/Core/JanusProtocolSupport/FormatMessageHelper.cs (working copy)
@@ -0,0 +1,188 @@
+?namespace Rsdn.Janus
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text.RegularExpressions;
+
+ using JetBrains.Annotations;
+
+ public static class FormatMessageHelper
+ {
+ /// <summary>
+ /// Форматирует оценки.
+ /// </summary>
+ /// <param name="rate">Сумма оценок.</param>
+ /// <param name="smile">Количество улыбок.</param>
+ /// <param name="agree">Количество согласных.</param>
+ /// <param name="disagree">Количество не согласных.</param>
+ /// <returns>Форматированное представление оценок.</returns>
+ public static string FormatRates(int rate, int smile, int agree, int disagree)
+ {
+ var list = new List<string>(4);
+
+ if (smile != 0)
+ {
+ list.Add(smile + ":)");
+ }
+
+ if (agree != 0)
+ {
+ list.Add(agree + "+");
+ }
+
+ if (disagree != 0)
+ {
+ list.Add(disagree + "-");
+ }
+
+ if (rate != 0)
+ {
+ list.Add(rate.ToString());
+ }
+
+ return String.Join("/", list.ToArray());
+ }
+
+ /// <summary>
+ /// Возвращает первое не пустое значение,
+ /// иначе - Аноним
+ /// </summary>
+ /// <param name="nick">Псевдоним пользователя.</param>
+ /// <param name="realName">Реальное имя пользователя.</param>
+ /// <param name="userName">Имя пользователя.</param>
+ /// <returns>Первое не пустое "имя" пользователя, иначе - Аноним.</returns>
+ public static string GetUserDisplayName(string nick, string realName, string userName)
+ {
+ if (!String.IsNullOrEmpty(nick))
+ {
+ return nick;
+ }
+
+ if (!String.IsNullOrEmpty(realName))
+ {
+ return realName;
+ }
+
+ if (!String.IsNullOrEmpty(userName))
+ {
+ return userName;
+ }
+
+ return SR.Forum.UserNickAnonymous;
+ }
+
+ /// <summary>
+ /// Преобразовывает тип пользователя в строку.
+ /// </summary>
+ /// <param name="userClass">Тип пользователя. <see cref="UserClass"/></param>
+ /// <param name="isHtml">Использовать подсветку.</param>
+ /// <returns>Строковое представление ипа пользователя.</returns>
+ public static string FormatUserClass(UserClass userClass, bool isHtml)
+ {
+ string result = String.Empty;
+
+ switch (userClass)
+ {
+ case UserClass.Admin:
+ result = "admin";
+ if (isHtml)
+ {
+ result = "<font color='darkred'>" + result + "</font>";
+ }
+ break;
+
+ case UserClass.Moderator:
+ result = "moderator";
+ if (isHtml)
+ {
+ result = "<font color='red'>" + result + "</font>";
+ }
+ break;
+
+ case UserClass.Team:
+ result = "rsdn";
+ if (isHtml)
+ {
+ result = "<font color='blue'>" + result + "</font>";
+ }
+ break;
+
+ case UserClass.Expert:
+ result = "expert";
+ if (isHtml)
+ {
+ result = "<font color='green'>" + result + "</font>";
+ }
+ break;
+ }
+
+ return result.Length > 0 ? "[" + result + "]" : result;
+ }
+
+ /// <summary>
+ /// Форматирует тултип сообщения, указывая на тему, автора и дату постинга.
+ /// </summary>
+ /// <param name="subject">The subject.</param>
+ /// <param name="date">The date.</param>
+ /// <param name="nick">The nick.</param>
+ /// <returns>Тултип сообщения.</returns>
+ [NotNull]
+ public static string FormatMsgLinkTitle(string subject, DateTime date, string nick)
+ {
+ string formattedDate = date.ToString(Config.Instance.ForumDisplayConfig.DateFormat);
+
+ return String.Format("\"{0}\",\r{1}, {2}", subject, nick, formattedDate);
+ }
+
+ /// <summary>
+ /// Следующие пара методов выдернуты из исходников IT (с заметными доработками правда),
+ /// так что все возможные вопросы к нему
+ /// Перенес из MessageUtilities
+ /// </summary>
+ /// <param name="subjIn">The subj in.</param>
+ /// <returns></returns>
+ public static string ReSubj(string subjIn)
+ {
+ string res;
+ //Чистый subj без Re-префиксов
+ string subj = Regex.Replace(subjIn, @"^Re(\[[0-9]+\]){0,1}: ", "");
+
+ if (subjIn.Length >= 4 && subjIn.Substring(0, 4) == "Re: ")
+ {
+ res = "Re[2]: " + subj;
+ }
+ else if (subjIn.Length >= 3 && subjIn.Substring(0, 3) == "Re[")
+ {
+ int si = subjIn.IndexOf("[");
+ try
+ {
+ int nn = Int32.Parse(subjIn.Substring(si + 1, subjIn.IndexOf("]") - si - 1));
+ nn++;
+ res = "Re[" + nn + "]: " + subj;
+ }
+ catch (Exception)
+ {
+ //На случай исключения принимаем Re равным 0
+ res = "Re: " + subj;
+ }
+ }
+ else
+ {
+ res = "Re: " + subj;
+ }
+
+ return res;
+ }
+
+ /// <summary>
+ /// Возвращает дату в виде строки
+ /// Формат даты задется в настройках
+ /// </summary>
+ /// <param name="date">Входная дата.</param>
+ /// <returns>дата в заданном формате</returns>
+ public static string GetDateAsString(DateTime date)
+ {
+ return date.ToString(Config.Instance.ForumDisplayConfig.DateFormat);
+ }
+ }
+}
\ No newline at end of file
Index: Janus/Core/JanusProtocolSupport/HTMLPageBuilder/HtmlPageBuilder.cs
===================================================================
--- Janus/Core/JanusProtocolSupport/HTMLPageBuilder/HtmlPageBuilder.cs (revision 1539)
+++ Janus/Core/JanusProtocolSupport/HTMLPageBuilder/HtmlPageBuilder.cs (working copy)
@@ -6,7 +6,7 @@
using System.Web;
using BLToolkit.Data.Linq;
-
+using Rsdn.Janus.DataModel;
using Rsdn.SmartApp;
namespace Rsdn.Janus
@@ -28,7 +28,8 @@
private readonly IJanusDatabaseManager _dbManager = null;
// ReSharper restore ConvertToConstant, RedundantDefaultFieldInitializer
- public HtmlPageBuilder(IServiceProvider serviceProvider) : base(serviceProvider)
+ public HtmlPageBuilder(IServiceProvider serviceProvider)
+ : base(serviceProvider)
{
_serviceProvider = serviceProvider;
}
@@ -78,19 +79,22 @@
private string GetUserDisplayName(IDataContext db, int userID)
{
- return
- db
- .Users(u => u.ID == userID)
+ IQueryable<IUser> users = db.Users(u => u.ID == userID);
+ int count = users.Count();
+ if (count > 0)
+ {
+ IQueryable<string> queryable = users
.Select(
u =>
FormatAuthor(
u.ID,
u.UserClass,
u.DisplayName(),
- false))
- .Single();
+ false));
+ return queryable.Single();
+ }
+ return "Nothing";
}
-
#region Вывод сообщения об исключении
private const string _templateException = "ExceptionPage.html";
@@ -231,11 +235,11 @@
userId.ToString());
return string.Format(template,
- JanusFormatMessage.GetUserImagePath(_serviceProvider, userClass),
+ ImagesHelper.GetUserImagePath(_serviceProvider, userClass),
string.Format(_templateAlt, SR.TGColumnAuthor, showName),
showName,
userInfoUri,
- JanusFormatMessage.FormatUserClass(userClass, true));
+ FormatMessageHelper.FormatUserClass(userClass, true));
}
private string FormatDate(DateTime dt)
@@ -249,7 +253,7 @@
return
string.Format(
_templateHeaderItemForDate,
- JanusFormatMessage.GetWeekDayImagePath(
+ ImagesHelper.GetWeekDayImagePath(
_serviceProvider,
Convert.ToInt32(dt.DayOfWeek),
isOutdate),
@@ -267,7 +271,7 @@
{
// Rate
// rate calc for headers and rate frame
- var text = JanusFormatMessage.FormatRates(
+ var text = FormatMessageHelper.FormatRates(
rating, smiles, agrees, disagrees);
if (text.Length == 0)
@@ -295,7 +299,7 @@
anchor
? _templateHeaderItemAnchor
: _templateHeaderItem,
- JanusFormatMessage.GetMessageImagePath(
+ ImagesHelper.GetMessageImagePath(
_serviceProvider,
isRead,
isMarked,
@@ -335,7 +339,7 @@
return
string.Format(
_templateHeaderItem,
- JanusFormatMessage.GetForumImagePath(_serviceProvider, false),
+ ImagesHelper.GetForumImagePath(_serviceProvider, false),
string.Empty,
FormatForumName(forumName, forumDescription, false));
}
@@ -360,7 +364,7 @@
// 0 - rate text, 1 - path to rate icon
return string.Format(_templateRatePart, rt,
- JanusFormatMessage.GetRateImagePath(_serviceProvider, rateType));
+ ImagesHelper.GetRateImagePath(_serviceProvider, rateType));
}
private string FormatRateItemWithDate(
@@ -640,10 +644,10 @@
sbSubtotal.AppendFormat(
_tlUsersList,
- JanusFormatMessage.GetUserImagePath(provider, user.UserClass),
+ ImagesHelper.GetUserImagePath(provider, user.UserClass),
user.UserID,
user.UserName,
- JanusFormatMessage.FormatUserClass(user.UserClass, true));
+ FormatMessageHelper.FormatUserClass(user.UserClass, true));
usersCount++;
}
}
@@ -663,7 +667,7 @@
private const string _templateOrigin = @"<div class='o'>{0}</div>";
private const string _templateUserInfo = "UserInfo.html";
private const string _templateUserInfoNotFound = "UserInfoNotFound.html";
- //private const string _templatePrefixImage = "<img>";
+ //private const string _templatePrefixImage = "<img>";
public string GetUserInfoText(int uid)
{
@@ -757,7 +761,7 @@
FormatAuthor(
user.ID,
user.UserClass,
- JanusFormatMessage.GetUserDisplayName(user.Nick, user.RealName, user.Name),
+ FormatMessageHelper.GetUserDisplayName(user.Nick, user.RealName, user.Name),
true),
user.Name,
user.Nick,
@@ -773,28 +777,28 @@
FormatUri(JanusProtocolResourceType.UserMessagesStat, parameter),
firstInfo,
lastInfo,
- JanusFormatMessage.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserInfo),
- JanusFormatMessage.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserRating),
- JanusFormatMessage.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserOutrating),
- JanusFormatMessage.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserMessages),
- JanusFormatMessage.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserMessagesStat));
+ ImagesHelper.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserInfo),
+ ImagesHelper.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserRating),
+ ImagesHelper.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserOutrating),
+ ImagesHelper.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserMessages),
+ ImagesHelper.GetResourceImagePath(_serviceProvider, JanusProtocolResourceType.UserMessagesStat));
}
}
#endregion
#region Сборка до кучи с учетом настроек *
//private static string _html =
- // "<html><head><title>{0}</title></head><body>{1}</body></html>";
+ // "<html><head><title>{0}</title></head><body>{1}</body></html>";
//public string GetAllUserInfo(int uid)
//{
- // StringBuilder sb = new StringBuilder();
- // // Основное инфо
- // sb.Append(GetUserInfoText(uid));
+ // StringBuilder sb = new StringBuilder();
+ // // Основное инфо
+ // sb.Append(GetUserInfoText(uid));
- // return String.Format(_html,
- // SR.UserInfo,
- // sb.ToString());
+ // return String.Format(_html,
+ // SR.UserInfo,
+ // sb.ToString());
//}
#endregion
Index: Janus/Core/JanusProtocolSupport/ImagesHelper.cs
===================================================================
--- Janus/Core/JanusProtocolSupport/ImagesHelper.cs (revision 0)
+++ Janus/Core/JanusProtocolSupport/ImagesHelper.cs (working copy)
@@ -0,0 +1,174 @@
+?namespace Rsdn.Janus
+{
+ using System;
+ using SmartApp;
+
+ public static class ImagesHelper
+ {
+ /// <summary>
+ /// Возвращает путь к иконке, ассоциированной с классом пользователя.
+ /// </summary>
+ /// <param name="provider"></param>
+ /// <param name="userClass">Класс пользователя.</param>
+ /// <returns>Путь к иконке, ассоциированной с классом пользователя.</returns>
+ public static string GetUserImagePath(IServiceProvider provider, UserClass userClass)
+ {
+ string name = userClass != UserClass.User ? userClass.ToString() : String.Empty;
+
+ return GetImageUri(provider, @"MessageTree\User" + name, StyleImageType.ConstSize);
+ }
+
+ /// <summary>
+ /// Возвращает путь к иконке сообщения.
+ /// </summary>
+ /// <param name="provider"></param>
+ /// <param name="isRead">Сообщение прочитано</param>
+ /// <param name="isMarked">Помечено ли сообщение флагом (очками).</param>
+ /// <param name="isArticle">Является ли сообщение статьей.</param>
+ /// <returns>Путь к иконке сообщения.</returns>
+ public static string GetMessageImagePath(IServiceProvider provider, bool isRead, bool isMarked, bool isArticle)
+ {
+ const string Marked = "Marked";
+ const string Article = "Article";
+ const string Unread = "Unread";
+
+ string path;
+ string article = String.Empty;
+ string marked = String.Empty;
+ string read = "";
+
+ if (isArticle)
+ {
+ article = Article;
+ }
+
+ if (isMarked)
+ {
+ marked = Marked;
+ }
+
+ if (!isRead)
+ {
+ if (isMarked)
+ {
+ read = Unread + "2";
+ }
+ else
+ {
+ read = Unread;
+ }
+ }
+
+ path = String.Format("Msg{0}{1}{2}", article, read, marked);
+ //if (isArticle)
+ //{
+ // path = isRead
+ // ? isMarked ? "MsgArticleMarked" : "MsgArticle"
+ // : isMarked ? "MsgArticleUnread2Marked" : "MsgArticleUnread";
+ //}
+ //else
+ //{
+ // path = isRead
+ // ? isMarked ? "MsgMarked" : "Msg"
+ // : isMarked ? "MsgUnread2Marked" : "MsgUnread";
+ //}
+
+ return GetImageUri(provider, @"MessageTree\" + path, StyleImageType.ConstSize);
+ }
+
+ /// <summary>
+ /// Gets the week day image path.
+ /// </summary>
+ /// <param name="provider">The provider.</param>
+ /// <param name="weekDay">The week day.</param>
+ /// <param name="outdated">if set to <c>true</c> [outdated].</param>
+ /// <returns></returns>
+ public static string GetWeekDayImagePath(IServiceProvider provider, int weekDay, bool outdated)
+ {
+ string text = String.Format(@"MessageTree\WD{0}{1}",
+ outdated ? "OUT" : String.Empty,
+ weekDay);
+
+ IStyleImageManager styleImageManager = provider.GetRequiredService<IStyleImageManager>();
+
+ return styleImageManager.GetImageUri(text, StyleImageType.ConstSize);
+ }
+
+ /// <summary>
+ /// Возвращает путь к иконке с оценкой.
+ /// </summary>
+ /// <param name="provider"></param>
+ /// <param name="rate">Оценка.</param>
+ /// <returns>Путь к иконке с оценкой.</returns>
+ public static string GetRateImagePath(IServiceProvider provider, MessageRates rate)
+ {
+ switch (rate)
+ {
+ case MessageRates.Rate1:
+ case MessageRates.Rate2:
+ case MessageRates.Rate3:
+ return GetImageUri(provider, @"MessageViewer\" + rate, StyleImageType.Small);
+ }
+
+ return GetImageUri(provider, @"MessageViewer\Rate" + rate, StyleImageType.Small) ?? String.Empty;
+ }
+
+ /// <summary>
+ /// Возвращает путь к иконке форума.
+ /// </summary>
+ /// <param name="provider"></param>
+ /// <param name="isUnread">В форуме есть не прочитанные сообщения.</param>
+ public static string GetForumImagePath(IServiceProvider provider, bool isUnread)
+ {
+ string path =
+ isUnread
+ ? @"NavTree\ForumUnread"
+ : @"NavTree\Forum";
+
+ return GetImageUri(provider, path, StyleImageType.ConstSize);
+ }
+
+ /// <summary>
+ /// Возвращает путь к иконке, ассоциированной с ресурсом.
+ /// </summary>
+ /// <param name="provider"></param>
+ /// <param name="resourceType">Тип ресурса.</param>
+ /// <returns>Путь к иконке, которая ассоциирована с ресурсом.</returns>
+ public static string GetResourceImagePath(IServiceProvider provider, JanusProtocolResourceType resourceType)
+ {
+ string name;
+
+ switch (resourceType)
+ {
+ case JanusProtocolResourceType.FaqList: name = "faqall"; break;
+ case JanusProtocolResourceType.ArticleList: name = "articleall"; break;
+ case JanusProtocolResourceType.UserInfo: name = "ExtBrowser"; break;
+ case JanusProtocolResourceType.UserRating: name = "userratein"; break;
+ case JanusProtocolResourceType.UserOutrating: name = "userrateout"; break;
+ case JanusProtocolResourceType.UserMessages: name = "ShowAllMsgs"; break;
+ case JanusProtocolResourceType.UserMessagesStat: name = "sh_all_msgs"; break;
+ case JanusProtocolResourceType.TeamList: name = "admin"; break;
+ case JanusProtocolResourceType.MessageRate:
+ return GetImageUri(provider, "RateGroup", StyleImageType.ConstSize);
+ default:
+ return GetImageUri(provider, @"ForumImages\webref", StyleImageType.ConstSize);
+ }
+
+ return GetImageUri(provider, name, StyleImageType.Small);
+ }
+
+ /// <summary>
+ /// Получить путь до картинки.
+ /// </summary>
+ /// <param name="provider"></param>
+ /// <param name="name">Имя картинки.</param>
+ /// <param name="imageType">Тип картинки.</param>
+ /// <returns>Путь до картинки.</returns>
+ public static string GetImageUri(IServiceProvider provider, string name, StyleImageType imageType)
+ {
+ IStyleImageManager styleImageManager = provider.GetRequiredService<IStyleImageManager>();
+
+ return styleImageManager.GetImageUri(name, imageType);
+ }
+ }
+}
\ No newline at end of file
Index: Janus/Core/JanusProtocolSupport/UrlHelper.cs
===================================================================
--- Janus/Core/JanusProtocolSupport/UrlHelper.cs (revision 0)
+++ Janus/Core/JanusProtocolSupport/UrlHelper.cs (working copy)
@@ -0,0 +1,176 @@
+?namespace Rsdn.Janus
+{
+ using System;
+ using System.Text.RegularExpressions;
+ using Rsdn.Framework.Formatting;
+
+ public static class UrlHelper
+ {
+ /// <summary>
+ /// Проверяем присутствует ли в заданном адресе имя домена
+ /// </summary>
+ /// <param name="urlMatch">Результаты предварительноцй проверки URL.</param>
+ /// <param name="urlAddress">Проверяемый URL адрес.</param>
+ /// <returns>
+ /// <c>true</c> если имя домена присутствует; иначе, <c>false</c>.
+ /// </returns>
+ // Данная функция видится "неустойчивой". Лучше убрать чем укономить время дополнительного разбора.
+ //public static bool IsDomainPresent(Match urlMatch, string urlAddress)
+ //{
+ // string testUri = urlAddress;
+ // if (!IsSchemePresent(urlMatch))
+ // {
+ // testUri = "http://" + testUri;
+ // }
+
+ // bool ret = IsDomainPresentInternal(testUri);
+
+ // return ret;
+ //}
+
+ /// <summary>
+ /// Проверяем присутствует ли в заданном адресе имя домена
+ /// </summary>
+ /// <param name="urlAddress">Проверяемый URL адрес.</param>
+ /// <returns>
+ /// <c>true</c> если имя домена присутствует; иначе, <c>false</c>.
+ /// </returns>
+ public static bool IsDomainPresent(string urlAddress)
+ {
+ string testUri = urlAddress;
+
+ testUri = AddUrlScheme(testUri);
+
+ bool ret = IsDomainPresentInternal(testUri);
+
+ return ret;
+ }
+
+ /// <summary>
+ /// Добавляем префикс, если нужно
+ /// </summary>
+ /// <param name="sourceUri">Исходный URI</param>
+ /// <returns>готовый к проверке адрес</returns>
+ public static string AddUrlScheme(string sourceUri)
+ {
+ const string httpPrefix = "http:";
+ const string httpSuffix = "//";
+
+ if (!IsSchemePresent(sourceUri))
+ {
+ if (!string.IsNullOrEmpty(sourceUri)
+ && (sourceUri.Length < httpPrefix.Length
+ || sourceUri.IndexOf(httpPrefix, 0, httpPrefix.Length) < 0)
+ )
+ {
+ if (sourceUri.Length < httpSuffix.Length
+ || sourceUri.IndexOf(httpSuffix, 0, httpSuffix.Length) < 0)
+ {
+ sourceUri = httpSuffix + sourceUri;
+ }
+
+ sourceUri = httpPrefix + sourceUri;
+ }
+ }
+ return sourceUri;
+ }
+
+ /// <summary>
+ /// Проверяем присутствует ли в заданном адресе имя домена
+ /// входной адрес должен иметь "схему"
+ /// </summary>
+ ///<param name="testUri">Проверяемый URL адрес</param>
+ ///<returns>
+ /// <c>true</c> если имя домена присутствует; иначе, <c>false</c>.
+ /// </returns>
+ private static bool IsDomainPresentInternal(string testUri)
+ {
+ bool ret = IsValidUrl(testUri);
+ if (ret)
+ {
+ Uri uri = new Uri(testUri);
+ string host = uri.DnsSafeHost;
+
+ string[] strings = host.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries);
+
+ // проверяем есть ли точка в имени носта и делит ли она имя хотябы на две части
+ if (strings.Length < 2)
+ {
+ ret = false;
+ }
+ }
+
+ return ret;
+ }
+
+ /// <summary>
+ /// Determines whether [is valid URL] [the specified test URI].
+ /// </summary>
+ /// <param name="testUri">The test URI.</param>
+ /// <returns>
+ /// <c>true</c> if [is valid URL] [the specified test URI]; otherwise, <c>false</c>.
+ /// </returns>
+ public static bool IsValidUrl(string testUri)
+ {
+ bool ret = true;
+ try
+ {
+ Uri uri = new Uri(testUri);
+ }
+ catch (Exception)
+ {
+ ret = false;
+ }
+
+ return ret;
+ }
+
+ /// <summary>
+ /// Determines whether [is scheme present] [the specified URL match].
+ /// </summary>
+ /// <param name="urlMatch">The URL match.</param>
+ /// <returns>
+ /// <c>true</c> if [is scheme present] [the specified URL match]; otherwise, <c>false</c>.
+ /// </returns>
+ public static bool IsSchemePresent(Match urlMatch)
+ {
+ return urlMatch.Groups["scheme"].Success;
+ }
+
+ /// <summary>
+ /// Determines whether [is scheme present] [the specified URL].
+ /// </summary>
+ /// <param name="url">The URL.</param>
+ /// <returns>
+ /// <c>true</c> if [is scheme present] [the specified URL]; otherwise, <c>false</c>.
+ /// </returns>
+ /// <exception cref="System.ArgumentNullException">input is null.</exception>
+ public static bool IsSchemePresent(string url)
+ {
+ Match match = TextFormatter.ParseUrl(url);
+ //Match match = TextFormatter.ParseUrl(url);
+ return IsSchemePresent(match);
+ }
+
+ /// <summary>
+ /// Gets the hostname.
+ /// </summary>
+ /// <param name="urlMatch">The URL match.</param>
+ /// <returns></returns>
+ public static string GetHostname(Match urlMatch)
+ {
+ return urlMatch.Groups["hostname"].Value;
+ }
+
+ /// <summary>
+ /// Получить внутренний формат ссылки для соответствующего <paramref name="resourceType"/>
+ /// </summary>
+ /// <param name="resourceType">Тип ресурса.</param>
+ /// <param name="parameters">Параметр ссылки.</param>
+ /// <returns>Внутренний формат ссылки.</returns>
+ public static string FormatUri(JanusProtocolResourceType resourceType, string parameters)
+ {
+ return JanusProtocolDispatcher.FormatURI(resourceType, parameters);
+ }
+ }
+}
\ No newline at end of file
Index: Janus/Core/JanusProtocolSupport/XmlPageBuilder/XsltFormatUtils.cs
===================================================================
--- Janus/Core/JanusProtocolSupport/XmlPageBuilder/XsltFormatUtils.cs (revision 1539)
+++ Janus/Core/JanusProtocolSupport/XmlPageBuilder/XsltFormatUtils.cs (working copy)
@@ -41,29 +41,26 @@
[UsedImplicitly]
public string GetUserImagePath(UserClass userClass)
{
- return JanusFormatMessage
- .GetUserImagePath(_serviceProvider, userClass);
+ return ImagesHelper.GetUserImagePath(_serviceProvider, userClass);
}
[UsedImplicitly]
public string GetWeekDayImagePath(int weekDay, bool isOutdated)
{
- return JanusFormatMessage
- .GetWeekDayImagePath(_serviceProvider, weekDay, isOutdated);
+ return ImagesHelper.GetWeekDayImagePath(_serviceProvider, weekDay, isOutdated);
}
[UsedImplicitly]
public string GetMessageImagePath(bool isRead,
bool isMarked, bool isArticle)
{
- return JanusFormatMessage
- .GetMessageImagePath(_serviceProvider, isRead, isMarked, isArticle);
+ return ImagesHelper.GetMessageImagePath(_serviceProvider, isRead, isMarked, isArticle);
}
[UsedImplicitly]
public string GetRateImagePath(MessageRates rate)
{
- return JanusFormatMessage.GetRateImagePath(_serviceProvider, rate);
+ return ImagesHelper.GetRateImagePath(_serviceProvider, rate);
}
[UsedImplicitly]
@@ -76,8 +73,7 @@
[UsedImplicitly]
public string FormatUserClass(UserClass userClass)
{
- var uc = JanusFormatMessage
- .FormatUserClass(userClass, true);
+ string uc = FormatMessageHelper.FormatUserClass(userClass, true);
return uc.Length != 0 ? " " + uc : string.Empty;
}
Index: Janus/Core/ObjectModel/MsgBase.cs
===================================================================
--- Janus/Core/ObjectModel/MsgBase.cs (revision 1539)
+++ Janus/Core/ObjectModel/MsgBase.cs (working copy)
@@ -219,13 +219,13 @@
public string GetFormattedRating()
{
- return JanusFormatMessage.FormatRates(Rating, Smiles, Agrees, Disagrees);
+ return FormatMessageHelper.FormatRates(Rating, Smiles, Agrees, Disagrees);
}
protected string GetFormattedRatingForReplies()
{
- return JanusFormatMessage.FormatRates(RepliesRate, RepliesSmiles, RepliesAgree,
- RepliesDisagree);
+ return FormatMessageHelper.FormatRates(RepliesRate, RepliesSmiles, RepliesAgree,
+ RepliesDisagree);
}
#endregion
@@ -413,7 +413,7 @@
cellData[_rateThisColumn].Text = GetFormattedRating();
- cellData[_dateColumn].Text = JanusFormatMessage.GetDateString(Date);
+ cellData[_dateColumn].Text = FormatMessageHelper.GetDateAsString(Date);
cellData[_dateColumn].CellImageType = CellImageType.Image;
cellData[_dateColumn].Image = _imgManager.GetMessageDateImage(Date);
Index: Janus/Core/UI/AboutJanusForm.cs
===================================================================
--- Janus/Core/UI/AboutJanusForm.cs (revision 1539)
+++ Janus/Core/UI/AboutJanusForm.cs (working copy)
@@ -9,6 +9,8 @@
using System.Text;
using System.Windows.Forms;
+using Rsdn.Framework.Formatting;
+
namespace Rsdn.Janus
{
/// <summary>
@@ -19,13 +21,13 @@
#region Declarations
- private readonly IServiceProvider _provider;
+ private readonly IServiceProvider _provider;
private const string _resourcePrefix = "Rsdn.Janus.Core.UI.";
- private bool _isShowing = true;
- private bool _useEffect = true;
-
+ private bool _isShowing = true;
+ private bool _useEffect = true;
+
#endregion
#region Constructor(s)
@@ -58,7 +60,7 @@
private void CustomInitializeComponent()
{
_webBrowser.BackColor = Color.Black;
- _versionLabel.Text = ApplicationInfo.NameWithVersion;
+ _versionLabel.Text = ApplicationInfo.NameWithVersion;
if (!Environment.OSVersion.IsModernOS())
_useEffect = false;
@@ -159,7 +161,7 @@
break;
}
}
-
+
return result;
}
@@ -324,7 +326,7 @@
12284, 2962, 15309, 5743, 5161, 28760, 19717, 73,
3242, 6921, 343, 2668, 7107, 1938, 3655, 3655,
10596, 16874, 1, 20712, 21120, 4964, 8546, 11709,
- 5623, 9088, 33647, 61389, 44901, 507, 52960
+ 5623, 9088, 33647, 61389, 44901, 507, 52960, 95947
};
using (var db = _provider.CreateDBContext())
{
@@ -344,20 +346,19 @@
foreach (var user in users)
{
columnsCount++;
- var userHomePage =
- string.Format(
- user.HomePage.StartsWith("http://")
- ? "{0}'>{1}"
- : "http://{0}'>{1}",
- user.HomePage,
- user.HomePage);
+ string homePageUrl = TextFormatter.ParseUrl(user.HomePage);
+ var userHomePage = string.Format(homePageUrl.StartsWith("http://")
+ ? "{0}'>{1}"
+ : "http://{0}'>{1}",
+ homePageUrl,
+ homePageUrl);
sb.AppendFormat(
_devTableRow,
columnsCount % 2 == 0 ? "#F4FFF4" : "#E4FFF4",
user.ID,
user.Name,
- JanusFormatMessage.FormatUserClass(user.UserClass, true),
+ FormatMessageHelper.FormatUserClass(user.UserClass, true),
"",
userHomePage);
}
Index: Janus/Core/UI/MainForm.cs
===================================================================
--- Janus/Core/UI/MainForm.cs (revision 1539)
+++ Janus/Core/UI/MainForm.cs (working copy)
@@ -60,6 +60,7 @@
if (disposing)
{
_navigationComboBoxGenerator.Dispose();
+
if (_mainMenuGenerator != null)
{
_mainMenuGenerator.Dispose();
@@ -115,9 +116,9 @@
_toolBarGenerator = new StripMenuGenerator(_serviceProvider, _toolStrip, "MainForm.Toolbar");
}
- protected override void OnClosing(CancelEventArgs e)
+ protected override void OnFormClosing(FormClosingEventArgs e)
{
- base.OnClosing(e);
+ base.OnFormClosing(e);
if (_serviceProvider.GetRequiredService<ISynchronizer>().IsActive())
{
Index: Janus/Features/ForumViewer/Export/MessageExporter.cs
===================================================================
--- Janus/Features/ForumViewer/Export/MessageExporter.cs (revision 1539)
+++ Janus/Features/ForumViewer/Export/MessageExporter.cs (working copy)
@@ -9,7 +9,6 @@
using Rsdn.Framework.Formatting;
using Rsdn.Janus.Framework.Imaging;
-using Rsdn.Janus.ObjectModel;
using Rsdn.SmartApp;
namespace Rsdn.Janus
@@ -126,7 +125,7 @@
/// </summary>
private static string FormatUserClass(UserClass userClass, bool isHtml)
{
- return JanusFormatMessage.FormatUserClass(userClass, isHtml);
+ return FormatMessageHelper.FormatUserClass(userClass, isHtml);
}
#endregion
Index: Janus/Features/ForumViewer/MessageEditor/MessageForm.cs
===================================================================
--- Janus/Features/ForumViewer/MessageEditor/MessageForm.cs (revision 1539)
+++ Janus/Features/ForumViewer/MessageEditor/MessageForm.cs (working copy)
@@ -560,7 +560,7 @@
{
_forumsComboBox.Enabled = false;
_quoteAnalyzer = new QuoteAnalyzer(_messageInfo.Message);
- _subjectTextBox.Text = JanusFormatMessage.ReSubj(_messageInfo.Subject);
+ _subjectTextBox.Text = FormatMessageHelper.ReSubj(_messageInfo.Subject);
ActiveControl = _messageEditor;
}
@@ -782,7 +782,7 @@
var text = HttpUtility.HtmlEncode(_subjectTextBox.Text);
return string.Format(_templateHeaderItem,
- JanusFormatMessage.GetMessageImagePath(_serviceManager, true, false, false),
+ ImagesHelper.GetMessageImagePath(_serviceManager, true, false, false),
string.Format(_templateAlt, SR.TGColumnSubject, text),
text);
}
Index: Janus/Features/ForumViewer/MessageViewer/ModeratingForm.cs
===================================================================
--- Janus/Features/ForumViewer/MessageViewer/ModeratingForm.cs (revision 1539)
+++ Janus/Features/ForumViewer/MessageViewer/ModeratingForm.cs (working copy)
@@ -76,7 +76,7 @@
m =>
new ModInfo(
m.ForumID,
- JanusFormatMessage.GetModeratorialActionName(
+ GetModeratorialActionName(
m.ForumID,
_forumID,
m.ServerForum.Name,
@@ -89,6 +89,38 @@
_userCol.Width = _actionCol.Width = _createCol.Width = -1;
}
+ /// <summary>
+ /// Возвращает текст для действий модератора.
+ /// </summary>
+ /// <param name="forumId">Ид форума.</param>
+ /// <param name="msgForumId">Ид сообщения.</param>
+ /// <param name="forumName">Имя форума.</param>
+ /// <param name="forumDescription">Описание форума.</param>
+ /// <returns></returns>
+ public static string GetModeratorialActionName(int forumId, int msgForumId, string forumName, string forumDescription)
+ {
+ switch (forumId)
+ {
+ case 0:
+ return SR.Forum.Moderatorial.Delete;
+ case -2:
+ return SR.Forum.Moderatorial.ExtractBranch;
+ case -7:
+ return SR.Forum.Moderatorial.CloseTopic;
+ case -8:
+ return SR.Forum.Moderatorial.OpenTopic;
+ default:
+ string forumNameText = Config.Instance.ForumDisplayConfig.ShowFullForumNames
+ ? forumDescription
+ : forumName;
+
+ string actionName = forumId != msgForumId
+ ? SR.Forum.Moderatorial.MoveToForum.FormatStr(forumNameText)
+ : SR.Forum.Moderatorial.LeaveIntact;
+ return actionName;
+ }
+ }
+
private int GetModImageIndex(int forumId, int msgForumId)
{
switch (forumId)
@@ -116,7 +148,7 @@
{
mod.UserName,
mod.ActionDesc,
- JanusFormatMessage.GetDateString(mod.Create)
+ FormatMessageHelper.GetDateAsString(mod.Create)
})
{
BackColor =
Index: Janus/Janus.csproj
===================================================================
--- Janus/Janus.csproj (revision 1539)
+++ Janus/Janus.csproj (working copy)
@@ -584,6 +584,9 @@
<DesignTime>True</DesignTime>
<DependentUpon>SchemaManagementResources.resx</DependentUpon>
</Compile>
+ <Compile Include="Core\JanusProtocolSupport\FormatMessageHelper.cs" />
+ <Compile Include="Core\JanusProtocolSupport\ImagesHelper.cs" />
+ <Compile Include="Core\JanusProtocolSupport\UrlHelper.cs" />
<Compile Include="Core\JanusProtocolSupport\XmlPageBuilder\XsltFormatUtils.cs" />
<Compile Include="Core\JBrowserManagement\BrowserHelper.cs" />
<Compile Include="Core\JBrowserManagement\JBrowserActiveMessageService.cs" />
|