Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Wiki MOD

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
AnonJr Posted - 11 December 2013 : 09:37:30
I wrote a very simple Wiki MOD for the intranet site at work and I've been meaning for some time* to package this up as a MOD for Snitz proper.

It works (though there are a few minor bugs I'd like to fix) - the problem is it is built around the very customized version of Snitz we are using.

I'd be happy to post what I have and let whoever needed something to do clean it up into a proper MOD for the current version of Snitz. Anyone interested?
15   L A T E S T    R E P L I E S    (Newest First)
Classicmotorcycling Posted - 12 October 2014 : 22:20:11

How did you go with this. It looks like a great MOD to play with?

AnonJr Posted - 01 October 2014 : 17:16:20
The "ClassInformation" and "ClassTitle" field types are being treated the same as "hidden" and "preview".

I deeply suspect (but cannot remember) that I didn't just use those two for semantic reasons - e.g. I didn't want to look back later and wonder why I was passing the title through "hidden" or "preview"...
Carefree Posted - 01 October 2014 : 16:24:54
You also changed the ChkString function. Not sure what else yet. Still looking.
AnonJr Posted - 01 October 2014 : 11:44:16
It happens.

I figured the CSS should give way to some styling that would fit whatever was set by the admin.

As for the change to the members table, I wouldn't think any was needed - just use the mLev to check: if they're an admin, full permissions; if they're a mod, access to "internal" and editing; if they're anything else - leave a config variable so the admin can choose if logged in members can edit or not.

And the pop_preview shouldn't be missing anything... though I used a lot of one-off files similar to the core Snitz files, so it may just be better to work some of the regular options back in. I'd have to get back in to the core code base again to see what needs changing.

There are a few bugs that I'm aware of and have not yet fixed - like quotes in titles break some of the links.

There are a few enhancements I've had slated, but have not yet added - like:
- adding a way to find orphaned pages
- adding a way to list pages with blind links
- adding a way to link to a particular revision in the edit history
- adding a way to see a list of all pages that link to the current one

There are a few more of both that are tied a lot more to the intranet site in particular.
Carefree Posted - 01 October 2014 : 01:58:24
I overlooked this for nine months? Brain death....

OK, took a look at it. Converted to Snitz 3.4.07 formatting for most part; fixed a few things (removed duplicated dimension statements, etc after including config/inc_header). Didn't have your CSS for the styling, so I eliminated most of that and will finish making it match Snitz defaults today.

Added field to members table to control Wiki edit capability. Will have to create an admin page or use pop_profile. Used mLev for admin control.

All that said, though; the pop_preview doesn't generate anything. There must be a link to it which incorporates functional choices which you have neglected to provide.
AnonJr Posted - 11 December 2013 : 17:52:33
... Almost forgot about the preview page for editing/creating a page.

Here's pop_wiki_preview.asp:

<!-- #include virtual="/inc_func_wiki.asp"-->
<%
strThisTab = "Refs"
strSection = "BoL"
strPgTitle = "Preview Page - Reference Materials - Training and Development"

%><!-- #include virtual="/forum/inc_func_common.asp"-->
<!-- #include virtual="/nav/top.asp" --><%

If Not InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
Call FailMessage("<li>You do not have permissions to view this page.</li>",False)
Else
Response.Write "<script language=""JavaScript"" type=""text/javascript"">" & vbNewLine & _
" function submitPreview()" & vbNewLine & _
" {" & vbNewLine & _
" if (window.opener.document.PostTopic.Title) {" & vbNewLine & _
" document.previewTopic.title.value = window.opener.document.PostTopic.Title.value;" & vbNewLine & _
" }" & vbNewLine & _
" document.previewTopic.message.value = window.opener.document.PostTopic.Message.value;" & vbNewLine & _
" document.previewTopic.StatusID.value = window.opener.document.PostTopic.StatusID.value;" & vbNewLine & _
" document.previewTopic.PageID.value = window.opener.document.PostTopic.PageID.value;" & vbNewLine & _
" document.previewTopic.submit()" & vbNewLine & _
" }" & vbNewLine & _
"</script>" & vbNewLine

if request("mode") = "" then
Response.Write "<form action=""pop_wiki_preview.asp"" method=""post"" name=""previewTopic"">" & vbNewLine & _
"<input type=""hidden"" name=""title"" value="""">" & vbNewLine & _
"<input type=""hidden"" name=""message"" value="""">" & vbNewLine & _
"<input type=""hidden"" name=""StatusID"" value="""">" & vbNewLine & _
"<input type=""hidden"" name=""PageID"" value="""">" & vbNewLine & _
"<input type=""hidden"" name=""mode"" value=""display"">" & vbNewLine & _
"</form>" & vbNewLine & _
"<script language=""JavaScript"" type=""text/javascript"">submitPreview();</script>" & vbNewLine
else
intPageID = cInt(Request.Form("PageID"))
strPageTitle = chkString(Trim(Request.Form("title")),"ClassTitle")
If Trim(strPageTitle) = "" Then strPageTitle = "No Title"
If strPageTitle = UCase(strPageTitle) Then strPageTitle = TitleCap(strPageTitle,False)
strPageContent = ChkString(Trim(Request.Form("message")),"ClassInformation")
If IsNumeric(Request.Form("StatusID")) Then
intStatusID = cInt(Request.Form("StatusID"))
Else
intStatusID = 4
End If
strAction = "display"
strDateLastUpdate = DateToStr(Now())
strUpdatedBy = Session(strCookieURL & "strEmpID") & "|" & Session(strCookieURL & "strNTUserFullName")

Response.Write "<hr width=""95%"">" & vbNewLine & _
"<div class=""l ffs"" style=""width:95%;margin-left:2.5%;"">" & vbNewLine & _
"<a href=""default.asp"">T & D Home</a>  »"
If intPageID = cLng(intRootNode) Or LCase(strAction) = "save" Then
Response.Write "  Reference Materials" & vbNewLine
Else
Response.Write "  <a href=""?PageID=" & intRootNode & """>Reference Materials</a>  »" & vbNewLine & _
"  " & ChkString(strPageTitle,"display") & vbNewLine
End If
Response.Write "</div>" & vbNewLine & _
"<hr width=""95%"">" & vbNewLine

'Start of main table
Response.Write "<table class=""tc tbc iffc fcc"" cellspacing=""0"" cellpadding=""8"" width=""95%"">" & vbNewLine & _
"<tr class=""hcc hfc c"">" & vbNewLine & _
"<td> </td>" & vbNewLine & _
"</tr>" & vbNewLine & _
"<tr>" & vbNewLine & "<td>" & vbNewLine

'Nav was pushing main content down, not sure what changed between original dev and now to re-introduce that issue
'Call WriteNav()
Call DisplayPg()

'End of main table
Response.Write "</td>" & vbNewLine & "</tr>" & vbNewLine & _
"<tr class=""putc hfc ffs c""><td>The information contained in these pages are subject to change. " & _
"Revisions and updates will occur from time to time to document changes and/or additions.</td></tr>" & vbNewLine & _
"<tr class=""hcc hfc c""><td> </td></tr>" & vbNewLine & _
"</table>" & vbNewLine & _
"<p class=""c""><a href=""JavaScript:onClick=window.close()"">Close Window</a></p>" & vbNewLine
end if
End If
%>
</body>

</html>
AnonJr Posted - 11 December 2013 : 17:51:32
The other page is inc_func_wiki.asp (code to follow the explanation/commentary/notes)

Because of the ... odd ... way this system has grown, the standard forum config wasn't available for the wiki pages - so I re-defined them here. Obviously you can get rid of the ones that will be present in a regular install.

Sub DisplayPg() handles the bulk of the page processing, and does parse the BBCode used by Snitz. It uses the same functions and treats any page title between brackets (e.g. [Page Title]) as a wiki page and will link to the page of that title or offer an Admin a link to create that page. The way this is set up, only authors can see draft pages, though you may or may not want to include the "internal" folk in that as well.

I did use an altered version of PostingButtons() included at the bottom of this page. It really should be replaced with the stock one. If I'm remembering right, that will mean making some changes as there may be a conflict with one of the field names...

Sub DisplayPgHistory() is used to show a complete edit history, marking up the changes using a diff engine borrowed from the OpenWikiNG project. (the original site seems to have gone away...)

Sub ListRecentChanges() is used to have a sort of "recent changes" page that lists the last 80-ish pages created/edited. If I remember right, I did use the TopSQL() function, so it should be good for MSSQL/MySQL.

Sub WriteNav() is used to write a little nav bar for all the pinned pages.

The rest should be fairly self-explanatory. I'll try to get some screenshots posted tomorrow.

<!-- #include virtual="/forum/inc_iconfiles.asp"-->
<!-- #include virtual="/forum/inc_func_posting.asp"-->
<%
'used for configuring the forum-type functions
Dim strAllowForumCode : strAllowForumCode = "1"
Dim strAllowHTML : strAllowHTML = "0"
Dim strIMGInPosts : strIMGInPosts = "1"
Dim strIcons : strIcons = "1"
Dim strImageUrl : strImageUrl = Application.Contents("SiteURL") & "forum/images/"
Dim strDateType : strDateType = "dmmy"
Dim strDBType : strDBType = "sqlserver"
Dim strThisTab : strThisTab = "Refs"
Dim strSection : strSection = "BoL"
Dim strWikiDB : strWikiDB = Application.Contents("SQLConn")
Dim strMetaFilter : strMetaFilter = "edt,save,msg,srch,hstry,chng,rvrt"
Dim intRootNode : intRootNode = "1"

Sub DisplayPg()
'Format the text before display
strPageContent = FormatStr(strPageContent)
strPageContent = Smile(strPageContent)
strPageContent = ConvertWikiTags(strPageContent)

Response.Write "<div class=""wikicontent"">" & vbNewLine
Select Case intStatusID
Case 1 'Public
Response.Write "<h1>" & ChkString(strPageTitle,"display") & "</h1>" & vbNewLine & strPageContent & vbNewLine
Case 2 'Internal
Response.Write "<div class=""ok"">Internal Education Page</div>"
If InArray(strEducators,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "<h1>" & ChkString(strPageTitle,"display") & "</h1>" & vbNewLine & strPageContent & vbNewLine
End If
Case 4 'Draft
Response.Write "<div class=""warning"">Draft Page - Not Yet Public</div>"
If InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "<h1>" & ChkString(strPageTitle,"display") & "</h1>" & vbNewLine & strPageContent & vbNewLine
End If
Case 6 'Deleted
Response.Write "<div class=""oops"">Deleted Page</div>"
If InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "<h1>" & ChkString(strPageTitle,"display") & "</h1>" & vbNewLine & strPageContent & vbNewLine
End If
Case Else
'Not a valid status...
End Select
Response.Write "</div>" & vbNewLine
End Sub

Sub EditPg()
If strAction = "edt" Then
'Write edit form
If intPageID = 0 Then strPageTitle = Request.QueryString("Title")
Response.Write "<div class=""wikicontent"">" & vbNewLine & _
"<script type=""text/javascript"" src=""./forum/inc_code.js""></script>" & vbNewLine & _
"<script type=""text/javascript"" src=""./forum/selectbox.js""></script>" & vbNewLine

If Request.QueryString("Version") <> "" And IsNumeric(Request.QueryString("Version")) Then
Response.Write "<div class=""warning"">Confirm Rollback to Version " & Request.QueryString("Version") & "</div>"
End If

Response.Write "<form action=""wiki.asp"" name=""PostTopic"" method=""post"">" & vbNewLine
Call PostingButtons()
If InArray(strAllowedSiteAdminList,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "<p><b>Title:</b><br />" & _
"<input type=""text"" name=""Title"" value=""" & strPageTitle & """ maxlength=""200"" size=""90"" /></p>" & vbNewLine
Else
Response.Write "<div><b>Title:</b> “" & strPageTitle & "”</div>" & vbNewLine
Response.Write "<input type=""hidden"" name=""Title"" value=""" & strPageTitle & """ />" & vbNewLine
End If
If intPageID <> 0 Then
Response.Write "<p><b>Reason for Edit:</b><br />" & _
"<input type=""text"" name=""EditReason"" "
If Request.QueryString("Version") <> "" And IsNumeric(Request.QueryString("Version")) Then
Response.Write "value=""Rollback to Version " & Request.QueryString("Version") & """ "
End If
Response.Write "size=""90"" /></p>" & vbNewLine
End If
Response.Write "<p><b>Page Content:</b><br />" & _
"<textarea rows=""20"" cols=""90"" name=""Message"" " & _
"onselect=""storeCaret(this);"" onclick=""storeCaret(this);"" onkeyup=""storeCaret(this);"" " & _
"onchange=""storeCaret(this);"">" & _
CleanCode(strPageContent) & "</textarea></p>" & vbNewLine & _
"<p>" & _
"|<label><input type=""radio"" name=""StatusID"" value=""4""" & chkCheckbox(cInt(intStatusID), 4,True) & " />Draft</label>" & vbNewLine & _
"|<label><input type=""radio"" name=""StatusID"" value=""1""" & chkCheckbox(cInt(intStatusID), 1,True) & " />Public</label>" & vbNewLine
If InArray(strEducators,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "|<label><input type=""radio"" name=""StatusID"" value=""2""" & chkCheckbox(cInt(intStatusID), 2,True) & " />Internal</label>" & vbNewLine
End If
Response.Write "|<label><input type=""radio"" name=""StatusID"" value=""6""" & chkCheckbox(cInt(intStatusID), 6,True) & " />Deleted</label>" & vbNewLine
If InArray(strAllowedSiteAdminList,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "||<label><input type=""checkbox"" name=""NavBar"" value=""1"" " & chkCheckbox(cInt(intNavBar), 1,True) & " /> Add To Nav Bar</label>" & vbNewLine
Else
Response.Write "<input type=""hidden"" name=""NavBar"" value=""" & intNavBar & """ />" & vbNewLine
End If
Response.Write "|</p><input type=""hidden"" name=""PageID"" value=""" & intPageID & """ />" & vbNewLine & _
"<input type=""hidden"" name=""Action"" value=""save"" />" & vbNewLine & _
"<p><button type=""submit"">Save Page</button>  " & _
"<button type=""button"" name=""Preview"" onclick=""PreviewPage()"">Preview</button>  " & vbNewLine & _
"<button type=""button"" name=""Back"" onclick=""window.history.back()"">Discard Changes</button>" & vbNewLine & _
"</p>" & vbNewLine & _
"</form>" & vbNewLine & _
"</div>" & vbNewLine & _
"<script type=""text/javascript"">" & vbNewLine & _
"function PreviewPage()" & vbNewLine & _
"{" & vbNewLine & _
" if (document.PostTopic.Message) {" & vbNewLine & _
" if (trim(document.PostTopic.Message.value)=="""") {" & vbNewLine & _
" alert(""Nothing to Preview!"")" & vbNewLine & _
" return false" & vbNewLine & _
" }" & vbNewLine & _
" popupWin = window.open('pop_wiki_preview.asp', 'preview_wiki', 'scrollbars=yes,width=800,height=650')" & vbNewLine & _
" return true" & vbNewLine & _
" }" & vbNewLine & _
"}" & vbNewLine & _
"</script>" & vbNewLine
Else
'Process form
intPageID = Trim(Request.Form("PageID"))
If Not isNumeric(intPageID) Then
intPageID = 0
Else
intPageID = cLng(intPageID)
End If

strPgTitle = chkString(Trim(Request.Form("Title")),"ClassTitle")
If Trim(strPgTitle) = "" Then strPgTitle = "No Title"
If strPgTitle = UCase(strPgTitle) Then strPgTitle = TitleCap(strPgTitle,False)
strWikiTitle = Replace(TitleCap(strPgTitle,True)," ","")

strEditReason = chkString(Trim(Request.Form("EditReason")),"ClassInformation")
If Trim(strEditReason) = "" Then strEditReason = "-- No Comment --"

strPgContent = ChkString(Trim(Request.Form("Message")),"ClassInformation")
If Trim(strPgContent) = "" Then strPgContent = "-- Page Content --"

intStatusID = Trim(Request.Form("StatusID"))
If IsNumeric(intStatusID) Then
If InArray("1,2,4,6",cInt(intStatusID)) Then
intStatusID = cInt(intStatusID)
Else
intStatusID = 4
End If
Else
intStatusID = 4
End If

If InArray(strAllowedSiteAdminList,LCase(Session(strCookieURL & "userid"))) Then
intNavBar = Trim(Request.Form("NavBar"))
If cStr(intNavBar) = "1" Then
intNavBar = 1
Else
intNavBar = 0
End If
End If

strDateLastUpdate = DateToStr(Now())
strUpdatedBy = Session(strCookieURL & "strEmpID") & "|" & Session(strCookieURL & "strNTUserFullName")

Dim objWikiDB : Set objWikiDB = Server.CreateObject("ADODB.Recordset")

If intPageID <> 0 Then
strSQL = "SELECT * FROM Wiki_Content WHERE PageID = " & intPageID
objWikiDB.Open strSQL, strWikiDB, adOpenDynamic, adLockPessimistic, adCmdText
If Not objWikiDB.BOF Then objWikiDB.MoveFirst
If Not objWikiDB.EOF Then
'Check for changes
If strPgTitle <> objWikiDB("PgTitle") Or _
strWikiTitle <> objWikiDB("wikiTitle") Or _
strPgContent <> objWikiDB("PgContent") Or _
intStatusID <> cInt(objWikiDB("StatusID")) Or _
intNavBar <> cInt(objWikiDB("NavBar")) Then
'Archive old version
Dim objWikiArchive : Set objWikiArchive = Server.CreateObject("ADODB.Recordset")
objWikiArchive.Open "Wiki_Archive", strWikiDB, adOpenDynamic, adLockPessimistic, adCmdTable
objWikiArchive.AddNew
objWikiArchive("PageID") = objWikiDB("PageID")
objWikiArchive("Version") = objWikiDB("Version")
objWikiArchive("wikiTitle") = objWikiDB("wikiTitle")
objWikiArchive("PgTitle") = objWikiDB("PgTitle")
objWikiArchive("StatusID") = objWikiDB("StatusID")
objWikiArchive("DateLastUpdated") = objWikiDB("DateLastUpdated")
objWikiArchive("UpdatedBy") = objWikiDB("UpdatedBy")
objWikiArchive("NavBar") = objWikiDB("NavBar")
objWikiArchive("PgContent") = objWikiDB("PgContent")
objWikiArchive("EditReason") = strEditReason
objWikiArchive.Update
objWikiArchive.Close : Set objWikiArchive = Nothing
End If

objWikiDB("Version") = (cInt(objWikiDB("Version")) + 1)
If InArray(strAllowedSiteAdminList,LCase(Session(strCookieURL & "userid"))) Then
objWikiDB("NavBar") = intNavBar
End If
Else
Call FailMessage("<li>You are trying to edit a page that doesn't exist.</li>",True)
End If
Else
'New page
objWikiDB.Open "Wiki_Content", strWikiDB, adOpenKeyset, adLockPessimistic, adCmdTable
objWikiDB.AddNew
objWikiDB("Version") = 1
If InArray(strAllowedSiteAdminList,LCase(Session(strCookieURL & "userid"))) Then
objWikiDB("NavBar") = intNavBar
Else
objWikiDB("NavBar") = 0
End If
End If

'Write new/chaged page
objWikiDB("wikiTitle") = strWikiTitle
objWikiDB("PgTitle") = strPgTitle
objWikiDB("StatusID") = intStatusID
objWikiDB("DateLastUpdated") = strDateLastUpdate
objWikiDB("UpdatedBy") = strUpdatedBy
objWikiDB("PgContent") = strPgContent

objWikiDB.Update
If intPageID = 0 Then intPageID = cLng(objWikiDB("PageID"))
objWikiDB.Close : Set objWikiDB = Nothing

Response.Redirect("wiki.asp?PageID=" & intPageID)
End If
End Sub

Sub DisplayPgHistory()
Response.Write "<div class=""wikicontent"">" & vbNewLine

Dim arrPageHistory, intTotRecs
Dim lblVersion : lblVersion = 0
Dim lblPageTitle : lblPageTitle = 1
Dim lblStatusID : lblStatusID = 2
Dim lblDateLastUpdated : lblDateLastUpdated = 3
Dim lblUpdatedBy : lblUpdatedBy = 4
Dim lblNavBar : lblNavBar = 5
Dim lblPageContent : lblPageContent = 6
Dim lblEditReason : lblEditReason = 7

strSQL = "SELECT Version, PgTitle, StatusID, DateLastUpdated, UpdatedBy, NavBar, PgContent, '-- No Comment --' AS EditReason " & _
"FROM Wiki_Content WHERE PageID = " & intPageID & " " & _
"UNION " & _
"SELECT Version, PgTitle, StatusID, DateLastUpdated, UpdatedBy, NavBar, PgContent, EditReason " & _
"FROM Wiki_Archive WHERE PageID = " & intPageID & " " & _
"ORDER BY Version DESC;"

Dim objPageHistory : Set objPageHistory = Server.CreateObject("ADODB.Recordset")
objPageHistory.Open strSQL, strWikiDB, adOpenDynamic, adLockReadOnly, adCmdText

If Not objPageHistory.BOF Then objPageHistory.MoveFirst
If Not objPageHistory.EOF Then
arrPageHistory = objPageHistory.GetRows(adGetRowsRest)
intTotRecs = UBound(arrPageHistory,2)
objPageHistory.Close : Set objPageHistory = Nothing

Dim objMatcher : Set objMatcher = New Matcher

Response.Write "<table class=""tbc"" style=""float:right;vertical-align:top;width:100%;"" cellspacing=""0"" cellpadding=""8"">" & vbNewLine
Dim intRec : intRec = 0

For intRec = 0 To intTotRecs Step 1
'Write meta info
Response.Write "<tr class=""putc hfc"" id=""rev" & arrPageHistory(lblVersion,intRec) & """><td>" & vbNewLine & _
"<div class=""ffs"">" & vbNewLine & _
chkDate(arrPageHistory(lblDateLastUpdated,intRec)," ",True)
If cLng(arrPageHistory(lblVersion,intRec)) = 1 Then
Response.Write ": version " & arrPageHistory(lblVersion,intRec) & " added"
Else
Response.Write ": updated to version " & arrPageHistory(lblVersion,intRec)
End If
Response.Write " by " & Mid(arrPageHistory(lblUpdatedBy,intRec),(InStr(arrPageHistory(lblUpdatedBy,intRec),"|")+1)) & vbNewLine & _
"</div>" & vbNewLine & _
"</td></tr>" & vbNewLine

'Misc options
Response.Write "<tr class=""hfc ffs"" style=""background:black;""><td>" & vbNewLine & _
"| <a href=""#rev" & arrPageHistory(lblVersion,intRec) & """>Link to this revision</a>" & vbNewLine & _
" | <a href=""javascript:ReverseContentDisplay('dtls" & arrPageHistory(lblVersion,intRec) & "')"">Show/Hide Details</a>"
'rollback link
If InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) And intRec <> 0 Then
Response.Write " | <a href=""wiki.asp?PageID=" & intPageID & "&Version=" & arrPageHistory(lblVersion,intRec) & "&Action=rvrt"">" & _
"Rollback to version " & arrPageHistory(lblVersion,intRec) & "</a>"
End If
Response.Write " |</td></tr>" & vbNewLine

'Write page content
Response.Write "<tr id=""dtls" & arrPageHistory(lblVersion,intRec) & """>" & _
"<td class=""fcc iffc"" style=""background:white;"">" 'white-space:pre;overflow:scroll;

'Show if lblStatusID changed
intCurrentStatus = cInt(arrPageHistory(lblStatusID,intRec))
If cLng(arrPageHistory(lblVersion,intRec)) = 1 Then
intPreviousStatus = cInt(arrPageHistory(lblStatusID,intRec))
Else
intPreviousStatus = cInt(arrPageHistory(lblStatusID,(intRec + 1)))
End If
If intCurrentStatus <> intPreviousStatus Then
Response.Write "<div class=""ffs"" style=""background:WhiteSmoke;border:2px solid black;padding:5px;margin-bottom:10px;"">"
Response.Write "<b>Status changed from “"
Select Case intPreviousStatus
Case 1
Response.Write "Public"
Case 2
Response.Write "Internal"
Case 4
Response.Write "Draft"
Case 6
Response.Write "Deleted"
End Select
Response.Write "” to “"
Select Case intCurrentStatus
Case 1
Response.Write "Public"
Case 2
Response.Write "Internal"
Case 4
Response.Write "Draft"
Case 6
Response.Write "Deleted"
End Select
Response.Write "</b>"
Response.Write "”.</div>" & vbNewLine
End If

'Write out content w/ changes
If cLng(arrPageHistory(lblVersion,intRec)) = 1 Then
'Write out title
Response.Write "<h1>" & arrPageHistory(lblPageTitle,intRec) & "</h1>" & vbNewLine
Response.Write Replace(CleanCode(arrPageHistory(lblPageContent,intRec)),vbNewLine,"<br />")
Else
If arrPageHistory(lblEditReason,(intRec + 1)) <> "-- No Comment --" Then
Response.Write "<div class=""ffs"" style=""background:WhiteSmoke;border:2px solid black;padding:5px;margin-bottom:10px;"">" & vbNewLine & _
"Edit Reason: " & arrPageHistory(lblEditReason,(intRec + 1)) & vbNewLine & _
"</div>" & vbNewLine
End If
'Write out title
Response.Write "<h1>" & arrPageHistory(lblPageTitle,intRec) & "</h1>" & vbNewLine
strCurrentVer = CleanCode(arrPageHistory(lblPageContent,intRec))
strPreviousVer = CleanCode(arrPageHistory(lblPageContent,(intRec + 1)))
Response.Write Replace(objMatcher.Compare(strPreviousVer, strCurrentVer),vbNewLine,"<br />")
End If

Response.Write "</td></tr>" & vbNewLine
Next

Response.Write "</table>" & vbNewLine
Set objMatcher = Nothing
Else
objPageHistory.Close : Set objPageHistory = Nothing
Response.Write "<div class=""oops"">Not a valid page.</div>" & vbNewLine
End If

'End content tag
Response.Write "</div>" & vbNewLine
End Sub

Sub ListRecentChanges()
strSQL = "SELECT PageID, Version, PgTitle, StatusID, DateLastUpdated, UpdatedBy FROM Wiki_Content "
If InArray(strAllowedSiteAdminList,LCase(Session(strCookieURL & "userid"))) Then
strSQL = strSQL & "WHERE StatusID IN (1,2,4,6) "
ElseIf InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
strSQL = strSQL & "WHERE StatusID IN (1,2,4,6) "
ElseIf InArray(strEducators,LCase(Session(strCookieURL & "userid"))) Then
strSQL = strSQL & "WHERE StatusID IN (1,2) "
Else
strSQL = strSQL & "WHERE StatusID IN (1) "
End If
strSQL = strSQL & "ORDER BY DateLastUpdated DESC;"
strSQL = TopSQL(strSQL, 80)

Dim objRecentChanges : Set objRecentChanges = Server.CreateObject("ADODB.Recordset")
objRecentChanges.Open strSQL, strWikiDB, adOpenDynamic, adLockReadOnly, adCmdText

Response.Write "<div class=""wikicontent"">" & vbNewLine
Response.Write "<h1>Recently Changed Pages</h1>" & vbNewLine

If Not objRecentChanges.BOF Then objRecentChanges.MoveFirst
If Not objRecentChanges.EOF Then
Dim strListDate : strListDate = Left(objRecentChanges("DateLastUpdated"),8)
Response.Write "<p>" & chkDate(Left(objRecentChanges("DateLastUpdated"),8),"",False) & "<ul>" & vbNewLine
Do Until objRecentChanges.EOF
If strListDate <> Left(objRecentChanges("DateLastUpdated"),8) Then
Response.Write "</ul></p>" & vbNewLine
strListDate = Left(objRecentChanges("DateLastUpdated"),8)
Response.Write "<p>" & chkDate(Left(objRecentChanges("DateLastUpdated"),8),"",False) & "<ul>" & vbNewLine
End If
Response.Write "<li><a href=""wiki.asp?PageID=" & objRecentChanges("PageID") & """>" & _
ChkString(objRecentChanges("PgTitle"),"display") & "</a> "
'Was considering linking to the most recent change diff instead of the page.
'Response.Write "<li><a href=""?PageID=" & objRecentChanges("PageID") & "&Action=hstry#rev" & objRecentChanges("Version") & """>" & _
' ChkString(objRecentChanges("PgTitle"),"display") & "</a> "
If objRecentChanges("Version") = 1 Then
Response.Write "[Added]"
Else
Response.Write "[Updated]"
End If
Response.Write "</li>" & vbNewLine
objRecentChanges.MoveNext
Loop
Response.Write "</ul></p>" & vbNewLine
Else
Response.Write "<p>No recent changes.</p>" & vbNewLine
End If

Response.Write "</div>" & vbNewLine

objRecentChanges.Close : Set objRecentChanges = Nothing
End Sub

Sub SearchWiki()
strSQL = "SELECT PageID, PgTitle, StatusID FROM Wiki_Content "
If InArray(strAllowedSiteAdminList,LCase(Session(strCookieURL & "userid"))) Then
strSQL = strSQL & "WHERE StatusID IN (1,2,4,6) "
ElseIf InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
strSQL = strSQL & "WHERE StatusID IN (1,2,4,6) "
ElseIf InArray(strEducators,LCase(Session(strCookieURL & "userid"))) Then
strSQL = strSQL & "WHERE StatusID IN (1,2) "
Else
strSQL = strSQL & "WHERE StatusID IN (1) "
End If
strSQL = strSQL & "AND (PgContent LIKE '%" & ChkString(Request.QueryString("q"),"SQLString") & "%' "
strSQL = strSQL & "OR PgContent LIKE '%" & Replace(ChkString(Request.QueryString("q"),"SQLString")," ","%") & "%' "
strSQL = strSQL & "OR PgTitle LIKE '%" & ChkString(Request.QueryString("q"),"SQLString") & "%');"
'strSQL = TopSQL(strSQL, 80)

Dim objSearchResults : Set objSearchResults = Server.CreateObject("ADODB.Recordset")
objSearchResults.Open strSQL, strWikiDB, adOpenDynamic, adLockReadOnly, adCmdText

Response.Write "<div class=""wikicontent"">" & vbNewLine
Response.Write "<h1>Search Results</h1>" & vbNewLine

If Not objSearchResults.BOF Then objSearchResults.MoveFirst
If Not objSearchResults.EOF Then
Response.Write "<p><ul>" & vbNewLine
Do Until objSearchResults.EOF
Response.Write "<li><a href=""wiki.asp?PageID=" & objSearchResults("PageID") & """>" & _
ChkString(objSearchResults("PgTitle"),"display") & "</a></li>"
objSearchResults.MoveNext
Loop
Response.Write "</ul></p>" & vbNewLine
Else
Response.Write "<h3>No Search Results Found</h3>" & vbNewLine
End If

objSearchResults.Close : Set objSearchResults = Nothing

Response.Write "</div>" & vbNewLine
End Sub

Sub WriteNav()
'Begining of WikiNav
Response.Write "<div class=""wikinav hide"">" & vbNewLine

'Nav Bar
Response.Write "<a href=""wiki.asp?PageID=" & intRootNode & """>Reference Materials Home</a>" & vbNewLine & _
"<ul style=""margin-top:2px;"">" & vbNewLine

strSQL = "SELECT PageID, PgTitle, StatusID FROM Wiki_Content " & _
"WHERE NavBar = 1 AND PageID <> " & intRootNode & " " & _
"ORDER BY PgTitle;"

Dim objNavBar : Set objNavBar = Server.CreateObject("ADODB.Recordset")
objNavBar.Open strSQL, strWikiDB, adOpenDynamic, adLockReadOnly, adCmdText

If Not objNavBar.BOF Then objNavBar.MoveFirst
If Not objNavBar.EOF Then
Do Until objNavBar.EOF
Select Case cLng(objNavBar("StatusID"))
Case 1 'Public
Response.Write "<li><a href=""wiki.asp?PageID=" & objNavBar("PageID") & """>" & ChkString(objNavBar("PgTitle"),"display") & "</a></li>" & vbNewLine
Case 2 'Internal
If InArray(strEducators,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "<li><a href=""wiki.asp?PageID=" & objNavBar("PageID") & """>" & ChkString(objNavBar("PgTitle"),"display") & " (Internal)</a></li>" & vbNewLine
End If
Case 4 'Draft
If InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "<li><a href=""wiki.asp?PageID=" & objNavBar("PageID") & """>" & ChkString(objNavBar("PgTitle"),"display") & " (Draft)</a></li>" & vbNewLine
End If
Case 6 'Deleted
If InArray(strAllowedSiteAdminList,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "<li class=""hlfc""><a href=""wiki.asp?PageID=" & objNavBar("PageID") & """>" & ChkString(objNavBar("PgTitle"),"display") & " (Deleted)</a></li>" & vbNewLine
End If
Case Else
'don't write anything, not valid status code
End Select

objNavBar.MoveNext
Loop
End If

objNavBar.Close : Set objNavBar = Nothing

Response.Write "<li><a href=""?Action=chng"">Recently Changed Pages</a></li>" & vbNewLine & _
"</ul>" & vbNewLine & _
"</div>" & vbNewLine
End Sub

' Turn a node's content into displayable HTML
function ConvertWikiTags(byval text)
dim re
set re = new RegExp
re.Global = true

' Convert wiki words to HTML links
re.Pattern = "\[(\n<>]*)]"
text = re.Replace(text,GetRef("reMakeWikiLink"))

ConvertWikiTags = text
end function

function reMakeWikiLink(match,linked_page,pos,source)
strSQL = "SELECT PageID, StatusID FROM Wiki_Content " & _
"WHERE PgTitle = '" & linked_page & "' OR wikiTitle = '" & linked_page & "';"

Dim objLinkInfo : Set objLinkInfo = Server.CreateObject("ADODB.Recordset")
objLinkInfo.Open strSQL, strWikiDB, adOpenDynamic, adLockPessimistic, adCmdText

If Not objLinkInfo.BOF Then objLinkInfo.MoveFirst
If Not objLinkInfo.EOF Then
Select Case cLng(objLinkInfo("StatusID"))
Case 1 'Public
reMakeWikiLink = "<a href=""wiki.asp?PageID=" & objLinkInfo("PageID") & """>" & ChkString(linked_page,"display") & "</a>"
Case 2 'Internal
If InArray(strEducators,LCase(Session(strCookieURL & "userid"))) Then
reMakeWikiLink = "<a href=""wiki.asp?PageID=" & objLinkInfo("PageID") & """>" & ChkString(linked_page,"display") & " (Internal)</a>"
Else
reMakeWikiLink = ChkString(linked_page,"display")
End If
Case 4 'Draft
If InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
reMakeWikiLink = "<a href=""wiki.asp?PageID=" & objLinkInfo("PageID") & """>" & ChkString(linked_page,"display") & " (Draft)</a>"
Else
reMakeWikiLink = "<a href=""wiki.asp?PageID=" & objLinkInfo("PageID") & """>" & ChkString(linked_page,"display") & " (Being Updated)</a>"
End If
Case 6 'Deleted
If InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
reMakeWikiLink = "<a href=""wiki.asp?PageID=" & objLinkInfo("PageID") & """>" & ChkString(linked_page,"display") & " (Deleted)</a>"
Else
reMakeWikiLink = ChkString(linked_page,"display")
End If
Case Else
End Select
Else
If InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
reMakeWikiLink = ChkString(linked_page,"display") & "<a href=""wiki.asp?PageID=0&Action=edt&Title=" & Server.HTMLEncode(linked_page) & """ title=""Describe "" & ChkString(linked_page,"display") & """">?</a>"
Else
reMakeWikiLink = ChkString(linked_page,"display")
End If
End If

objLinkInfo.Close : Set objLinkInfo = Nothing
end function

Function ValidAction()
Select Case True
Case Request.Form("Action") <> ""
ValidAction = LCase(Request.Form("Action"))
Case Request.QueryString("Action") <> ""
ValidAction = LCase(Request.QueryString("Action"))
Case Else
ValidAction = "display"
End Select
End Function

Function ValidPageID()
Select Case True
Case Request.Form("PageID") <> "" And IsNumeric(Request.Form("PageID"))
ValidPageID = cLng(Request.Form("PageID"))
Case Request.QueryString("PageID") <> "" And IsNumeric(Request.QueryString("PageID"))
ValidPageID = cLng(Request.QueryString("PageID"))
Case Else
ValidPageID = cLng(intRootNode)
End Select
End Function

Function oldValidPageName()
Select Case True
Case Request.Form("page") <> ""
oldValidPageName = LCase(Request.Form("page"))
Case Request.QueryString("page") <> ""
oldValidPageName = LCase(Request.QueryString("page"))
Case Else
oldValidPageName = ""
End Select
End Function

Sub oldPageRedirect()
strSQL = "SELECT PageID FROM Wiki_Content " & _
"WHERE PgTitle = '" & ChkString(strPage,"SQLString") & "' " & _
" OR wikiTitle = '" & ChkString(strPage,"SQLString") & "';"

Dim objOldLink : Set objOldLink = Server.CreateObject("ADODB.Recordset")
objOldLink.Open strSQL, strWikiDB, adOpenDynamic, adLockPessimistic, adCmdText

If Not objOldLink.BOF Then objOldLink.MoveFirst
If Not objOldLink.EOF Then
intPageID = cLng(objOldLink("PageID"))
Else
intPageID = intRootNode
End If

objOldLink.Close : Set objOldLink = Nothing
Response.Redirect("wiki.asp?PageID=" & intPageID)
End Sub

Sub PostingButtons()
%><p style="margin-top:0.5em;margin-bottom:0.5em;">
<a href="Javascript:bold();" tabindex="-1"><img src="./forum/images/icon_editor_bold.gif" align="absmiddle" /></a><a href="Javascript:italicize();" tabindex="-1"><img src="./forum/images/icon_editor_italicize.gif" align="absmiddle" /></a><a href="Javascript:underline();" tabindex="-1"><img src="./forum/images/icon_editor_underline.gif" align="absmiddle" /></a><a href="Javascript:strike();" tabindex="-1"><img src="./forum/images/icon_editor_strike.gif" align="absmiddle" /></a> 
<!-- <a href="Javascript:left();" tabindex="-1"><img src="./forum/images/icon_editor_left.gif" align="absmiddle" /></a><a href="Javascript:center();" tabindex="-1"><img src="./forum/images/icon_editor_center.gif" align="absmiddle" /></a><a href="Javascript:right();" tabindex="-1"><img src="./forum/images/icon_editor_right.gif" align="absmiddle" /></a>  -->
<a href="Javascript:openWindow8('pop_imglibrary.asp?folder=.\\images\\BooksOnlineImages\\');"><img src="./forum/images/icon_editor_image.gif" align="absmiddle" /></a><a href="Javascript:hr();" tabindex="-1"><img src="./forum/images/icon_editor_hr.gif" align="absmiddle" /></a> 
<a href="Javascript:hyperlink();" tabindex="-1"><img src="./forum/images/icon_editor_url.gif" align="absmiddle" /></a><a href="Javascript:email();" tabindex="-1"><img src="./forum/images/icon_editor_email.gif" align="absmiddle" /></a> 
<a href="Javascript:showcode();" tabindex="-1"><img src="./forum/images/icon_editor_code.gif" align="absmiddle" /></a><a href="Javascript:quote();" tabindex="-1"><img src="./forum/images/icon_editor_quote.gif" align="absmiddle" /></a><a href="Javascript:list();" tabindex="-1"><img src="./forum/images/icon_editor_list.gif" align="absmiddle" /></a> 
<select name="Size" tabindex="-1" onChange="showsize(this.options[this.selectedIndex].value)">
<option value="" selected="selected">Size</option>
<option value="1">Smaller</option>
<option value="2">Small</option>
<option value="3">Medium</option>
<option value="4">Large</option>
<option value="5">Larger</option>
<option value="6">Largest</option>
</select> 
<select name="Color" tabindex="-1" onChange="showcolor(this.options[this.selectedIndex].value)">
<option value="" selected="selected">Color</option>
<option style="color:black;" value="black">Black</option>
<option style="color:red;" value="red">Red</option>
<option style="color:yellow;" value="yellow">Yellow</option>
<option style="color:pink;" value="pink">Pink</option>
<option style="color:green;" value="green">Green</option>
<option style="color:orange;" value="orange">Orange</option>
<option style="color:purple;" value="purple">Purple</option>
<option style="color:blue;" value="blue">Blue</option>
<option style="color:beige;" value="beige">Beige</option>
<option style="color:brown;" value="brown">Brown</option>
<option style="color:teal;" value="teal">Teal</option>
<option style="color:navy;" value="navy">Navy</option>
<option style="color:maroon;" value="maroon">Maroon</option>
<option style="color:limegreen;" value="limegreen">LimeGreen</option>
</select></p><%
End Sub

' ---------------------------------------------------------------------------
' Copyright(c) 2000-2002, Laurens Pit
' All rights reserved.
'
' Redistribution and use in source and binary forms, with or without
' modification, are permitted provided that the following conditions
' are met:
'
' * Redistributions of source code must retain the above copyright
' notice, this list of conditions and the following disclaimer.
' * Redistributions in binary form must reproduce the above
' copyright notice, this list of conditions and the following
' disclaimer in the documentation and/or other materials provided
' with the distribution.
' * Neither the name of OpenWiki nor the names of its contributors
' may be used to endorse or promote products derived from this
' software without specific prior written permission.
'
' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
' "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
' LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
' FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
' REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
' INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
' BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
' CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
' LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
' ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
' POSSIBILITY OF SUCH DAMAGE.
'
' ---------------------------------------------------------------------------
' $Source: /cvsroot/openwiki-ng/openwiking/owbase/ow/owdiff.asp,v $
' $Revision: 1.2 $
' $Author: gbamber $
' ---------------------------------------------------------------------------
'
' Computes the difference between two page revisions.
'
Class Matcher
Private vLineBreak
Private vLineOriented
Private vA
Private vB
Private vBhash
Private vOut
Private vOutlen
Private vDebug

Private Sub Class_Initialize()
vLineBreak = vbCRLF
vLineOriented = True
vOut = ""
vOutlen = 0
vDebug = False
End Sub

Private Sub Class_Terminate()
End Sub

Public Property Let Preformatted(pPreformatted)
If pPreformatted Then
vLineBreak = vbCRLF
Else
vLineBreak = "<br/>"
End If
End Property

Public Property Let LineOriented(pLineOriented)
vLineOriented = pLineOriented
End Property

Public Property Let Debug(pDebug)
vDebug = pDebug
End Property

Public Property Let Outlen(pOutlen)
vOutlen = pOutlen
End Property

Private Function Tokenize(pText)
Dim vRegEx, vMatches, vMatch, vRegEx2, vMatches2, vMatch2, vValue
Set Tokenize = New Vector
Set vRegEx = New RegExp
vRegEx.IgnoreCase = False
vRegEx.Global = True
vRegEx.Pattern = ".+"
pText = Replace(pText, Chr(9), Space(8))
If Not vLineOriented Then
Set vRegEx2 = New RegExp
vRegEx2.IgnoreCase = False
vRegEx2.Global = True
vRegEx2.Pattern = "\s*\S+"
End If
Set vMatches = vRegEx.Execute(pText)
For Each vMatch In vMatches
vValue = Replace(vMatch.Value, vbCR, "")
If vLineOriented Then
Tokenize.Push(vValue)
Else
If Trim(vValue) = "" Then
Tokenize.Push(vValue)
Else
Set vMatches2 = vRegEx2.Execute(vValue)
For Each vMatch2 In vMatches2
Tokenize.Push(vMatch2.Value)
Next
End If
Tokenize.Push(vbCRLF)
End If
Next
If vValue = "" Then
Tokenize.Push("")
Elseif Not vLineOriented Then
Tokenize.Pop()
End If
Set vRegEx = Nothing
If Not vLineOriented Then
Set vRegEx2 = Nothing
End If
End Function

Private Sub HashB
Dim i, vElem, vList
Set vBhash = CreateObject("Scripting.Dictionary")
For i = 0 To vB.Count - 1
vElem = vB.ElementAt(i)
If Trim(vElem) <> "" And vElem <> vbCRLF Then
If vBhash.Exists(vElem) Then
Set vList = vBhash.Item(vElem)
vList.Push(i)
Else
Set vList = New Vector
vList.Push(i)
vBhash.Add vElem, vList
End If
End If
Next
End Sub

Private bestStartA
Private bestStartB
Private bestSize
' find longest matching block in vA[pALow,pAHigh] and vB[pBLow,pBHigh]
Private Sub FindLongestMatch(pALow, pAHigh, pBLow, pBHigh)
Dim i, j, k, x, vList
bestStartA = pALow
bestStartB = pBLow
bestSize = 0

Dim vLen, vNewLen, vElem
Set vLen = New Vector
vLen.Dimension = vB.Count
For i = pALow To pAHigh
Set vNewLen = New Vector
vNewLen.Dimension = vB.Count
vElem = vA.ElementAt(i)
If vBhash.Exists(vElem) Then
Set vList = vBhash.Item(vElem)
For x = 0 To vList.Count - 1
j = vList.ElementAt(x)
If j > pBHigh Then
Exit For
End If
If j >= pBLow Then
If j > 0 Then
k = vLen.ElementAt(j - 1) + 1
Else
k = 1
End If
vNewLen.SetElementAt j, k
If k > bestSize Then
bestStartA = i - k + 1
bestStartB = j - k + 1
bestSize = k
End If
End If
Next
End If
Set vLen = vNewLen
Next

' add junk on both sides
Do While bestStartA > pALow And bestStartB > pBLow
If (Trim(vA.ElementAt(bestStartA - 1)) = "" Or vA.ElementAt(bestStartA - 1) = vbCRLF) And (Trim(vB.ElementAt(bestStartB - 1)) = "" Or vB.ElementAt(bestStartB - 1) = vbCRLF) Then
bestStartA = bestStartA - 1
bestStartB = bestStartB - 1
bestSize = bestSize + 1
Else
Exit Do
End If
Loop
Do While bestStartA + bestSize <= pAHigh And bestStartB + bestSize <= pBHigh
If (Trim(vA.ElementAt(bestStartA + bestSize)) = "" Or vA.ElementAt(bestStartA + bestSize) = vbCRLF) And (Trim(vB.ElementAt(bestStartB + bestSize)) = "" Or vB.ElementAt(bestStartB + bestSize) = vbCRLF) Then
bestSize = bestSize + 1
Else
Exit Do
End If
Loop
End Sub

Private Sub SplitLine(pLine)
Dim i
Do
i = InStrRev(pLine, " ", 80)
If i > 0 Then
vOut = vOut & Left(pLine, i) & vLineBreak
pLine = LTrim(Mid(pLine, i))
Else
vOut = vOut & pLine
End If
Loop While i > 0
End Sub

Private Sub Output(pTag, pVector, pFrom, pTo)
Dim i, vElem

If pTag = "delete" Then
vOut = vOut & "<strike style=""color:red;"">"
Elseif pTag = "insert" Then
vOut = vOut & "<span style=""background:lightgreen;"">"
End If

For i = pFrom To pTo
vElem = pVector.ElementAt(i)
If vElem = vbCRLF Then
vElem = vLineBreak
vOutlen = 0
Elseif vElem = "" Then
vElem = " "
End If

vOutlen = vOutlen + Len(vElem)
If vOutlen > 80 Then
If Len(vElem) > 80 Then
SplitLine(vElem)
vElem = ""
Else
vOut = vOut & vLineBreak
vElem = LTrim(vElem)
vOutlen = Len(vElem)
End If
End If

vOut = vOut & vElem

If vLineOriented Then
vOut = vOut & vLineBreak
vOutlen = 0
End If
Next

If pTag = "delete" Then
vOut = vOut & "</strike>"
Elseif pTag = "insert" Then
vOut = vOut & "</span>"
End If
End Sub

Private Sub InnerReplace(pAFrom, pATo, pBFrom, pBTo)
Dim i, vText1, vText2, vMatcher
vText1 = ""
vText2 = ""
For i = pAFrom To pATo
vText1 = vText1 & vA.ElementAt(i)
If i < pATo Then
vText1 = vText1 & vbCRLF
End If
Next
For i = pBFrom To pBTo
vText2 = vText2 & vB.ElementAt(i)
If i < pBTo Then
vText2 = vText2 & vbCRLF
End If
Next
Set vMatcher = New Matcher
vMatcher.Outlen = vOutlen
vMatcher.LineOriented = False
vMatcher.Debug = vDebug
vOut = vOut & vMatcher.Compare(vText1, vText2) & vLineBreak
End Sub

Private Sub Out(vAFound, vBFound, vSize)
If matchedI < vAFound And matchedJ < vBFound Then
If vLineOriented Then
Call InnerReplace(matchedI, vAFound - 1, matchedJ, vBFound - 1)
Else
Call Output("delete", vA, matchedI, vAFound - 1)
' TODO: maybe, add "<br/>" when the intraline deleted was part of the last line
Call Output("insert", vB, matchedJ, vBFound - 1)
End If
Elseif matchedI < vAFound Then
Call Output("delete", vA, matchedI, vAFound - 1)
Elseif matchedJ < vBFound Then
Call Output("insert", vB, matchedJ, vBFound - 1)
End If
If vSize > 0 Then
Call Output("equal", vA, vAFound, vAFound + vSize - 1)
End If
End Sub

Dim matchedI, matchedJ
' match between [pALow,pAHigh] and [pBLow,pBHigh]
Private Sub GetMatchingBlocks(pDepth, pALow, pAHigh, pBLow, pBHigh)
If pDepth = 1 Then
matchedI = 0
matchedJ = 0
End If

Call FindLongestMatch(pALow, pAHigh, pBLow, pBHigh)

If bestSize > 0 Then
Dim vAFound, vBFound, vSize
vAFound = bestStartA
vBFound = bestStartB
vSize = bestSize

If pALow < vAFound And pBLow < vBFound Then
Call GetMatchingBlocks(pDepth + 1, pALow, vAFound - 1, pBLow, vBFound - 1)
End If

Call Out(vAFound, vBFound, vSize)

matchedI = vAFound + vSize
matchedJ = vBFound + vSize

If matchedI <= pAHigh And matchedJ <= pBHigh Then
Call GetMatchingBlocks(pDepth + 1, matchedI, pAHigh, matchedJ, pBHigh)
End If
End If

If pDepth = 1 Then
Call Out(vA.Count, vB.Count, 0)
End If
End Sub

Public Function Compare(pText1, pText2)
vOut = ""
Set vA = Tokenize(pText1)
Set vB = Tokenize(pText2)
HashB()
Call GetMatchingBlocks(1, 0, vA.Count - 1, 0, vB.Count - 1)
Compare = vOut
End Function
End Class

' ---------------------------------------------------------------------------
' $Source: /cvsroot/openwiki-ng/openwiking/owbase/ow/owvector.asp,v $
' $Revision: 1.2 $
' $Author: gbamber $
' ---------------------------------------------------------------------------
'
' Implements a resizable array.
'

Class Vector
Private myStack
Private myCount

Private Sub Class_Initialize()
Redim myStack(8)
myCount = -1
End Sub

Private Sub Class_Terminate()
End Sub

Public Property Let Dimension(pDim)
Redim myStack(pDim)
End Property

Public Property Get Count()
Count = myCount + 1
End Property

Public Sub Push(pElem)
myCount = myCount + 1
If (UBound(myStack) < myCount) Then
Redim Preserve myStack(UBound(myStack) * 2)
End If
Call SetElementAt(myCount, pElem)
End Sub

Public Function Pop()
If IsObject(myStack(myCount)) Then
Set Pop = myStack(myCount)
Else
Pop = myStack(myCount)
End If
myCount = myCount - 1
End Function

Public Function Top()
If IsObject(myStack(myCount)) Then
Set Top = myStack(myCount)
Else
Top = myStack(myCount)
End If
End Function

Public Function ElementAt(pIndex)
If IsObject(myStack(pIndex)) Then
Set ElementAt = myStack(pIndex)
Else
ElementAt = myStack(pIndex)
End If
End Function

Public Sub SetElementAt(pIndex, pValue)
If IsObject(pValue) Then
Set myStack(pIndex) = pValue
Else
myStack(pIndex) = pValue
End If
End Sub

Public Sub RemoveElementAt(pIndex)
Do While pIndex < myCount
Call SetElementAt(pIndex, ElementAt(pIndex + 1))
pIndex = pIndex + 1
Loop
myCount = myCount - 1
End Sub

Public Function IsEmpty()
IsEmpty = (myCount < 0)
End Function
End Class

Sub NotUsedAnymore()
If intPageID = cLng(intRootNode) Then
strSQL = "SELECT PageID, PgTitle, StatusID FROM Wiki_Content " & _
"WHERE NavBar = 1 AND PageID <> " & intRootNode & " " & _
"ORDER BY PgTitle;"

Dim objNavBar : Set objNavBar = Server.CreateObject("ADODB.Recordset")
objNavBar.Open strSQL, strWikiDB, adOpenDynamic, adLockReadOnly, adCmdText

If Not objNavBar.BOF Then objNavBar.MoveFirst
If Not objNavBar.EOF Then
Do Until objNavBar.EOF
Select Case cLng(objNavBar("StatusID"))
Case 1 'Public
Response.Write "<h3><a href=""wiki.asp?PageID=" & objNavBar("PageID") & """>" & _
ChkString(objNavBar("PgTitle"),"display") & _
"</a></h3>" & vbNewLine
Case 2 'Internal
If InArray(strEducators,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "<h3 class=""ok""><a href=""wiki.asp?PageID=" & objNavBar("PageID") & """>" & _
ChkString(objNavBar("PgTitle"),"display") & _
"</a></h3>" & vbNewLine
End If
Case 4 'Draft
If InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "<h3 class=""warning""><a href=""wiki.asp?PageID=" & objNavBar("PageID") & """>" & _
ChkString(objNavBar("PgTitle"),"display") & _
"</a></h3>" & vbNewLine
End If
Case 6 'Deleted
If InArray(strAllowedSiteAdminList,LCase(Session(strCookieURL & "userid"))) Then
Response.Write "<h3 class=""oops""><a href=""wiki.asp?PageID=" & objNavBar("PageID") & """>" & _
ChkString(objNavBar("PgTitle"),"display") & _
"</a></h3>" & vbNewLine
End If
Case Else
End Select
objNavBar.MoveNext
Loop
End If

objNavBar.Close : Set objNavBar = Nothing
End If
End Sub
%>


AnonJr Posted - 11 December 2013 : 17:40:28
There are only two pages that need to be added - and both need some edits to properly fit into a stock Sniz install.

First is wiki.asp (code to follow the explanation/commentary/notes)

This is the page that handles all the main logic for throwing errors, figuring out if you have permission to see something, etc. I'd already changed the links to use the PageID instead of the wikiTitle, but given some of the links out on the intranet that I couldn't get changed, there's a function there to auto-convert. Probably not needed if it never existed in the Snitz version. (Keep or discard as you feel necessary)

There may be a custom function or two that I added to inc_func_common.asp that I'll need to post up. Let me know if you run across one.

Also, style is all run by CSS and doesn't have a direct/obvious tie to the Snitz color scheme - adjust as you feel necessary.

The bits referencing "strSection" are related to the tabbed navigation I'm using and can be disreguarded. I am using a different header than inc_header.asp, so there will need to be changes relating to that...

The permissions is jacked - mostly relating to using the permissions the rest of the site uses instead of the forum permissions. There's a comma-delimited list of IDs called "strAllowedManualWikiEdits" that defines who has edit privileges.

There's another for pages marked "internal". The idea was to have pages that only we could see, share, etc. My thought was to let Admins have full Edit privileges, Admins and Mods get "internal" access, and everyone is considered "Public" (logged in or otherwise).

There is a rather naive search for just the wiki, though it probably ought to be integrated into the regular site search.

... I'm sure I'm forgetting to mention something that will be of use - as before ask and I'll answer as best as I remember.

<!-- #include virtual="/inc_func_wiki.asp"-->
<%
Dim strAction : strAction = ValidAction()
Dim intPageID : intPageID = ValidPageID()
'Checking for old style page names being passed
Dim strPage : strPage = oldValidPageName()
If strPage <> "" Then Call oldPageRedirect()

'Gather page data
If LCase(strAction) <> "save" Then
If intPageID <> 0 Then
If LCase(strAction) = "rvrt" And IsNumeric(Request.QueryString("Version")) Then
strSQL = "SELECT Version, wikiTitle, PgTitle, StatusID, DateLastUpdated, UpdatedBy, NavBar, PgContent " & _
"FROM Wiki_Archive WHERE PageID = " & intPageID & " AND Version = " & cLng(Request.QueryString("Version")) & ";"
strAction = "edt"
Else
strSQL = "SELECT Version, wikiTitle, PgTitle, StatusID, DateLastUpdated, UpdatedBy, NavBar, PgContent " & _
"FROM Wiki_Content WHERE PageID = " & intPageID & ";"
End If

Dim objPageData : Set objPageData = Server.CreateObject("ADODB.Recordset")
objPageData.Open strSQL, strWikiDB, adOpenDynamic, adLockReadOnly, adCmdText
If Not objPageData.BOF Then objPageData.MoveFirst
If Not objPageData.EOF Then
intVersion = cLng(objPageData("Version"))
strWikiTitle = objPageData("wikiTitle")
strPageTitle = objPageData("PgTitle")
strPageContent = objPageData("PgContent")
intStatusID = cLng(objPageData("StatusID"))
strLastUpdate = objPageData("DateLastUpdated")
strUpdatedBy = objPageData("UpdatedBy")
intNavBar = cInt(objPageData("NavBar"))
Else
Response.Redirect("wiki.asp?PageID=" & intRootNode)
End If
objPageData.Close : Set objPageData = Nothing
Else
intVersion = 1
strWikiTitle = "NewPage"
strPageTitle = "New Page"
strPageContent = "New Page"
intStatusID = 4 'Draft
strLastUpdate = DateToStr(Now())
strUpdatedBy = Session(strCookieURL & "strEmpID") & "|" & Session(strCookieURL & "strNTUserFullName")
intNavBar = 0
strAction = "edt"
End If
End If

'Special nav pages
Select Case intPageID
Case 142
strSection = "LibSvcs"
Case 143
strSection = "Precept"
Case 153
strSection = "ECRef"
Case 154
strSection = "CERef"
Case 162
strSection = "Staff"
Case 164
strSection = "FAQ"
End Select

If intPageID = cLng(intRootNode) Or LCase(strAction) = "save" Then
strPgTitle = "Reference Materials - "
Else
strPgTitle = ChkString(strPageTitle,"display") & " - Reference Materials - "
End If

%><!-- #include virtual="/forum/inc_func_common.asp"-->
<!-- #include virtual="/nav/top.asp" --><%

Response.Write "<hr width=""95%"">" & vbNewLine & _
"<div class=""l ffs"" style=""width:95%;margin-left:2.5%;"">" & vbNewLine & _
"<a href=""default.asp"">T & D Home</a>  »"
If intPageID = cLng(intRootNode) Or LCase(strAction) = "save" Then
Response.Write "  Reference Materials" & vbNewLine
Else
Response.Write "  <a href=""wiki.asp?PageID=" & intRootNode & """>Reference Materials</a>  »" & vbNewLine & _
"  " & ChkString(strPageTitle,"display") & vbNewLine
End If
Response.Write "</div>" & vbNewLine & _
"<hr width=""95%"">" & vbNewLine

'Start of main table
Response.Write "<table class=""tc tbc iffc fcc"" cellspacing=""0"" cellpadding=""8"" width=""95%"">" & vbNewLine & _
"<tr class=""hcc hfc c hide"">" & vbNewLine & _
"<td> </td>" & vbNewLine & _
"</tr>" & vbNewLine & _
"<tr class=""putc hfc"">" & vbNewLine & _
"<td>"
'Page Info
If Not InArray(strMetaFilter,LCase(strAction)) Then
Response.Write "<div class=""l ffs"" style=""float:left;"">" & vbNewLine & _
"Updated on: <b>" & chkDate(strLastUpdate,"",True) & "</b>" & vbNewLine & _
" by <b>" & Mid(strUpdatedBy,(InStr(strUpdatedBy,"|")+1)) & "</b>" & vbNewLine & _
"<br /><a href=""wiki.asp?PageID=" & intPageID & "&Action=hstry"">Edit History</a>"
'Edit link
If InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
Response.Write " | <a href=""wiki.asp?PageID=" & intPageID & "&Action=edt"">Edit this page</a>" & vbNewLine
End If

Response.Write "</div>"
End If
'Search Box
Response.Write "<div class=""r hide"" style=""float:right;"">" & vbNewLine & _
"<form method=""get"">Search the Education Reference for: " & vbNewLine & _
"<input type=""hidden"" name=""Action"" value=""srch"" />" & vbNewLine & _
"<input type=""text"" name=""q"" size=""25"""
If Request.QueryString("q") <> "" Then Response.Write " value=""" & Request.QueryString("q") & """"
Response.Write " /><button type=""submit"">Go</button>" & vbNewLine & _
"</form>" & vbNewLine & _
"</div>" & vbNewLine & _
"</td>" & vbNewLine & _
"</tr>" & vbNewLine

'Main Wiki Content
Response.Write "<tr>" & vbNewLine & "<td>" & vbNewLine

Call WriteNav()

Select Case LCase(strAction)
Case "edt", "save"
'Edit Form
If InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
Call EditPg()
Else
Response.Write "<div class=""oops"">You do not have permission to edit this page.</div>"
End If
Case "msg"
'Show a success/fail/other message
'not used at this juncture
Case "srch"
'Show search results
Call SearchWiki()
Case "hstry"
Call DisplayPgHistory()
Case "chng"
'List recent changes
Call ListRecentChanges()
Case Else
'Show the page
If intStatusID = 4 And Not InArray(strAllowedManualWikiEdits,LCase(Session(strCookieURL & "userid"))) Then
'Show last public/internal version
strSQL = "SELECT Version, wikiTitle, PgTitle, StatusID, DateLastUpdated, UpdatedBy, NavBar, PgContent " & _
"FROM Wiki_Archive WHERE PageID = " & intPageID & " AND StatusID IN (1,2) " & _
"ORDER BY Version DESC;"
strSQL = TopSQL(strSQL, 1)
Dim objPageArchive : Set objPageArchive = Server.CreateObject("ADODB.Recordset")
objPageArchive.Open strSQL, strWikiDB, adOpenDynamic, adLockReadOnly, adCmdText
If Not objPageArchive.BOF Then objPageArchive.MoveFirst
If Not objPageArchive.EOF Then
intVersion = cLng(objPageArchive("Version"))
strWikiTitle = objPageArchive("wikiTitle")
strPageTitle = objPageArchive("PgTitle")
strPageContent = objPageArchive("PgContent")
intStatusID = cLng(objPageArchive("StatusID"))
strLastUpdate = objPageArchive("DateLastUpdated")
strUpdatedBy = objPageArchive("UpdatedBy")
intNavBar = cInt(objPageArchive("NavBar"))
End If
objPageArchive.Close : Set objPageArchive = Nothing
End If

Call DisplayPg()
End Select

'End of main table
Response.Write "</td>" & vbNewLine & "</tr>" & vbNewLine & _
"<tr class=""putc hfc ffs c""><td>The information contained in these pages are subject to change. " & _
"Revisions and updates will occur from time to time to document changes and/or additions.</td></tr>" & vbNewLine & _
"<tr class=""hcc hfc c hide""><td> </td></tr>" & vbNewLine & _
"</table>" & vbNewLine & _
"<br />" & vbNewLine

%><!--#include virtual="/nav/bottom.asp"--><%
Response.Write "</body>" & vbNewLine & "</html>"
%>
AnonJr Posted - 11 December 2013 : 17:02:14
I was hoping you'd say that. You do such good work.

Here come the pieces of the puzzle ...and some of my less-than-best practices.

I've got two tables - Wiki_Content and Wiki_Archive. The latter being an archive of old versions of the various pages so you can maintain a solid history of changes.

Wiki_Content contains the following fields:

  • PageID: bigint; Auto-numbered ID for each page in the wiki.

  • Version: int; An integer used to keep track of the page's version number. Used in some of the rollback code and I had plans to allow linking to a specific version of a page.

  • wikiTitle: nvarchar(200); Stores a modified version of the page title and was originally going to be used in a number of places... not even sure I'm still using it or if it's worth keeping.

  • PgTitle: nvarchar(200); ...stores the page's title. I'm big on field names that help me figure out what the hell I'm looking at when I've long forgotten the project.

  • StatusID: bigint; Probably the wrong datatype for the job, but it keeps a status code of the current page - Draft, Public, Internal, Deleted, etc. (Yes, nothing is ever really deleted - I'd like to keep it that way.)

  • DateLastUpdated: nvarchar(14); ... I better not need to explain this one. Stores the date as text like Snitz, using the same functions.

  • UpdatedBy: nvarchar(100); In the code I'm using, it stores the employee number and name of the person who last updated the page. It probably ought to be adjusted to just accommodate the member ID of the person who last updated the page and re-code the page to look up their name. I'd originally stored the name because the table I am pulling employee information from does not contain information on people who are not current employees... didn't want a big fat "Last Updated By: ?????" on a page. So maybe we do want to keep the username around too. I'll leave that up to you.

  • NavBar: tinyint; just a little boolean flag to indicate if the page will be pinned on a little side bar that shows on all the wiki pages.

  • PgContent: nvarchar(MAX); the big honkin' field that holds the actual page data.


Wiki_Archive mirrors the basic structure with the notable exception that PageID doesn't auto-number and allows for duplicates. There's also an additional nvarchar(MAX) field called EditReason that contains... the reason for the edit.

None of the fields allow for Null values, and I'm reasonably sure I've forgotten a restraint or two already...
Carefree Posted - 11 December 2013 : 15:05:08
Anon, I'll package it for you.
Maxime Posted - 11 December 2013 : 13:01:53
I use very often Google translation to the forum here and translate pages and forum mods into French. Without it, I would be lost
AnonJr Posted - 11 December 2013 : 12:27:07
That's ok.

I've had some ... fun ... over the years trying to work with others via Google Translate.
Maxime Posted - 11 December 2013 : 11:29:19
Excuse me can Google translation translates to me not well lol! I do not know English, I'm sorry.
AnonJr Posted - 11 December 2013 : 11:24:58
No it's not on SnitzBitz nor is it ready to go on a stock setup... that was what the original question was asking - if anyone had the time to do the cleanup and packaging as work/life has prevented me from finishing that last little step.
Maxime Posted - 11 December 2013 : 11:06:11
yes I am interested, I have the 3.47 version of the Snitz forum and that this mod is on snitbitz.com?

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.32 seconds. Powered By: Snitz Forums 2000 Version 3.4.07