Created
January 26, 2011 12:55
-
-
Save joacim-boive/796643 to your computer and use it in GitHub Desktop.
Create semantic discussion threads for a Lotus Notes threaded view.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%REM | |
Agent agentCreateThread | |
Created Jan 25, 2011 by Joacim Boive/Infoware | |
Description: | |
Create semantic discussion threads for a Lotus Notes threaded view. | |
%END REM | |
Option Public | |
Option Declare | |
Dim threadLevel As Integer | |
Sub Initialize | |
Dim s As New NotesSession | |
Dim doc As NotesDocument | |
Dim db As NotesDatabase | |
Dim response As NotesDocument | |
Dim coll As NotesDocumentCollection | |
Dim item As NotesItem | |
Dim closeHTML As String | |
closeHTML = "</dl>" | |
Print "content-type: text;" | |
Print "content-type: text/html;" | |
Print | | |
<!DOCTYPE html | |
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<title>Discussion Thread</title> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> | |
</head> | |
<body> | |
| | |
Set db = s.Currentdatabase | |
Set coll = db.Unprocesseddocuments | |
Set doc = coll.getFirstDocument | |
While Not doc Is Nothing 'loop thru the top thread documents. | |
threadLevel = 0 | |
Set item = doc.getFirstItem("Subject") | |
print |<dl class="errand"><dt>| & item.text & "</dt>" 'set's the HTML for the thread head. | |
If(hasResponse(doc)) Then Call loopResponses(doc)' add a definition description and an ordered list. | |
print closeHTML | |
Set doc = coll.getNextDocument(doc) | |
Wend | |
Print "</body></html>" | |
End Sub | |
%REM | |
Function hasResponse | |
Description: Joacim Boive 2011-01-25 | |
Checks if current function has any respones. | |
If so we need to build our HTML accordingly. | |
%END REM | |
Function hasResponse(doc As NotesDocument) As Boolean | |
hasResponse = (doc.Responses.Count > 0) | |
End Function | |
%REM | |
Sub loopResponses | |
Description: Joacim Boive 2011-01-25 | |
Recursive approach to get all children of a parent. | |
This might break at around 200 recursions (meaning 200 response documents), | |
I'm taking a wild stab in the dark here assuming that won't be an issue... | |
%END REM | |
Sub loopResponses(parent As NotesDocument) | |
Dim coll As NotesDocumentCollection | |
Dim doc As NotesDocument | |
Dim item As NotesItem | |
Dim x As Integer | |
Set coll = parent.Responses | |
Set doc = coll.GetFirstDocument | |
print "<dd><ol>" | |
Do Until doc Is Nothing | |
threadLevel = threadLevel + 1 | |
Set item = doc.getFirstItem("Subject") | |
print "<li><dl><dt>" & item.text & "</dt>" | |
If(hasResponse(doc)) Then Call loopResponses(doc) | |
threadLevel = threadLevel - 1 ' closed one level | |
print "</dl></li>" | |
Set doc = coll.GetNextDocument(doc) | |
Loop | |
print "</ol></dd>" | |
End sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment