/*
OpenCollective - http://www.netbrick.net/
Copyright (c) 2004
by Tyler Jensen ( tylerj@netbrick.net ) of NetBrick Inc. ( http://www.netbrick.net )
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
*/
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Text;
using System.Web;
using OpenCollective.Data;
using OpenCollective.Engine;
namespace OpenCollective.Engine
{
/// <summary>
/// Summary description for WikiHistory.
/// </summary>
public class WikiHistory
{
static WikiHistory() { }
public static string GetTopicHistory(string appUrlPath, string wikiName, string topicName, string commandParam, bool isTalk, int size, int page)
{
//TODO - <input type="radio" value="1" name="RadioGroup"><input type="radio" value="2" name="RadioGroup">
string talkflg = isTalk ? "?talk" : "";
WikiTopic topic = null;
if(isTalk)
topic = TopicManager.GetWikiTopicTalk(wikiName, topicName);
else
topic = TopicManager.GetWikiTopic(wikiName, topicName);
StringBuilder sb = new StringBuilder(13);
sb.Append("<hr><table width=\"700\" align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\">\n");
sb.Append("<tr><td class=\"diffhd\" valign=\"bottom\" width=\"30\"><b>Src</b></td>"
+ "<td class=\"diffhd\" valign=\"bottom\" width=\"30\"><b>Dest</b></td>"
+ "<td class=\"diffhd\" valign=\"bottom\" width=\"130\"><b>Version Date</b></td>"
+ "<td class=\"diffhd\" valign=\"bottom\" width=\"100\"><b>Author</b></td>"
+ "<td class=\"diffhd\" valign=\"bottom\" width=\"400\"><b>Edit Summary</b></td></tr>\n");
//add current
string isMinorCurFlag = topic.IsMinor ? "(<b>m</b>) " : "";
sb.Append("<tr><td valign=\"top\"><input type=\"radio\" value=\"0\" name=\"srcGroup\"</td>"
+ "<td valign=\"top\"><input type=\"radio\" value=\"0\" name=\"destGroup\"</td>"
+ "<td><a href=\"" + appUrlPath + "/wiki/" + wikiName + "/" + topicName + ".wiki" + talkflg +"\">"
+ topic.Updated.ToShortDateString() + " at " + topic.Updated.ToShortTimeString().ToLower() + "</a></td>"
+ "<td><a href=\"" + appUrlPath + "/wiki/Users/" + topic.Author + ".wiki\">" + topic.Author + "</a></td>"
+ "<td>" + isMinorCurFlag + HttpUtility.HtmlEncode(topic.EditSummary) + "</a></td></tr>");
DataSet ds = null;
if(isTalk)
ds = DataAccess.GetTalkHistory(wikiName, topicName);
else
ds = DataAccess.GetTopicHistory(wikiName, topicName);
//h.WikiHistID, t.WikiTopicID, h.Author, h.Updated, h.IsMinor, h.EditSummary
if(ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
{
if(ds.Tables[0].Rows.Count >= page)
{
int lastRow = page + size;
if(ds.Tables[0].Rows.Count < lastRow)
lastRow = ds.Tables[0].Rows.Count;
for(int i = page - 1; i < lastRow; i++)
{
DataRow row = ds.Tables[0].Rows[i];
DateTime updated = (DateTime)row["Updated"];
string histID = row["WikiHistID"].ToString();
string author = row["Author"].ToString();
string editsum = row["EditSummary"].ToString();
bool isMinor = (bool)row["IsMinor"];
string isMinorFlag = "";
if(isMinor) isMinorFlag = "(<b>m</b>) ";
string oldtalk = isTalk ? "talk" : "";
sb.Append("<tr><td valign=\"top\"><input type=\"radio\" value=\"" + histID + "\" name=\"srcGroup\"</td>"
+ "<td valign=\"top\"><input type=\"radio\" value=\"" + histID + "\" name=\"destGroup\"</td>"
+ "<td><a href=\"" + appUrlPath + "/wiki/" + wikiName + "/" + topicName + ".wiki?old" + oldtalk + "=" + histID + "\">"
+ updated.ToShortDateString() + " at " + updated.ToShortTimeString().ToLower() + "</a></td>"
+ "<td><a href=\"" + appUrlPath + "/wiki/Users/" + author + ".wiki\">" + author + "</a></td>"
+ "<td>" + isMinorFlag + HttpUtility.HtmlEncode(editsum) + "</a></td></tr>");
}
}
}
sb.Append("</table>");
/*
sb.Append("<tr><td valign=\"top\">" + cnt.ToString("00000") + "</td>");
sb.Append("<td class=\"diffwhite\" valign=\"top\">"
+ HttpUtility.HtmlEncode(((TextLine)source.GetByIndex(drs.SourceIndex + i)).Line) + "</td>");
sb.Append("<td class=\"diffwhite\" valign=\"top\">"
+ HttpUtility.HtmlEncode(((TextLine)dest.GetByIndex(drs.DestIndex + i)).Line) + "</td></tr>\n");
*/
return sb.ToString();
}
}
}