viewDiscussionUI.inc
7.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/**
* Presentation information for adding a unit
*
* @author Omar Rahbeeni
* @date 5 May 2003
* @package presentation.lookAndFeel.knowledgeTree.
*
*/
function getPageButtons($oThread){
global $default;
$sToRender .= "<table width=100%><tr>\n";
$sToRender .= "<td align=right width=100%><a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $oThread->getDocumentID() . "&fAddComment=1&fNewComment=1") . "\"><img src=\"$default->graphicsUrl/widgets/addcomment.gif\" border=\"0\" /></a></td>\n";
$sToRender .= "<td align=right width=10><a href=\"" . generateControllerLink("viewDocument", "fDocumentID=" . $oThread->getDocumentID() . "&fAddComment=1") . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\" /></a></td>\n";
$sToRender .= "</tr></table>\n";
return $sToRender ;
}
// If there are no threads to view for a document
function getViewFailPage($sMessage)
{
global $default;
if (strlen($sMessage)>0){
$sToRender = $sMessage;
}
else $sToRender = "Current document has no discussion. Press the ADD button to start a discussion.";
return $sToRender;
}
/**
* Page to create a new thread
*
* @param $fDocumentID -> a valid document ID
*/
function getNewThreadOption($fDocumentID) {
global $default;
$sToRender .= "Would you like to create a new Discussion thread for this document?";
$sToRender .= " ";
$sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $fDocumentID . "&fNewThread=1") . "\"><img src=\"$default->graphicsUrl/widgets/new.gif\" border=\"0\"></a>";
$sToRender .= "<a href=\"" . generateControllerLink("viewDocument", "fDocumentID=" . $fDocumentID) . "\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>";
return $sToRender;
}
/**
* Renders the path for the document
*
* @param $fDocumentID -> a valid document ID
*/
function renderDocumentPath($iDocumentID) {
global $default;
$oDocument = & Document::get($iDocumentID);
$sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
$sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
$sDocumentPath = displayFolderPathLink(Folder::getFolderPathAsArray($oDocument->getFolderID()), Folder::getFolderPathNamesAsArray($oDocument->getFolderID()), "$default->rootUrl/control.php?action=browse") . " > ";
$sDocumentPath .= "<a href=\"$default->rootUrl/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php?fDocumentID=" . $oDocument->getID() . "&fForInlineView=1\">" . $oDocument->getName() . "</a>";
return "<table border=0 cellpadding=\"5\" width = 100%><tr><td bgcolor=\"$sTDBGColour\">$sDocumentPath</td></tr></table>\n";
}
/**
* Views the list of comments for a document
* Prints out 1 comment
* User needs to call this function many times to list all comments
*
* @param $iNum -> its the iterative index of the current comment
* @param $iThread -> a valid Thread Object
* @param $oComment -> a valid Comment Object
* @param $oUser -> a valid User Object (Logged in user)
*/
function getViewComment($iNum,$oThread,$oComment,$oUser) {
global $default;
$iSubjectChars = 59;
// If iNum is odd then highlight it
if (($iNum%2) == 1) $BGcolor = "#F5F6EE";
if (($iNum%2) == 0) $UserBGcolor = "#F5F6EE";
// If the Subject string is too long
if (strlen($oComment->getSubject())>$iSubjectChars ) $dotdot = " ...";
if (strlen($oUser->getUserName())> 13 ) $Userdotdot = " ...";
// If this is the first Subject line then create a table
if ($iNum == 1) {
$sHeading = "Document Discussion Comments";
$sToRender .= renderHeading($sHeading );
$sToRender .= renderDocumentPath($oThread->getDocumentID());
$sToRender .= "<table border=0 width=100%><tr>";
$sToRender .= "<td width=100><b>Views: </b> " . $oThread->getNumberOfViews() . "</td>";
$sToRender .= "<td width=20></td>";
$sToRender .= "<td><b>Replies: </b> " . $oThread->getNumberOfReplies() . "</td>";
$sToRender .= "<td align=right><a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $oThread->getDocumentID() . "&fAddComment=1&fCommentID=" . $oComment->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/addcomment.gif\" border=\"0\" /></a>";
$sToRender .= "<img src=\"$default->graphicsUrl/widgets/back.gif\" onmouseover=\"this.style.cursor='hand'\" onclick=\"javascript: history.go(-1);\" ></td>";
$sToRender .= "</tr></table><br>\n";
$sToRender .= "<table border=\"0\" width=\"100%\">\n";
$sToRender .= "<tr><td></td>\n";
$sToRender .= "<td><b>Subject</b></td>\n";
$sToRender .= "<td><b>Author</b></td>\n";
$sToRender .= "<td><b>Date</b></td>\n";
$sToRender .= "</tr>\n";
}
$sToRender .= "<tr><td>$iNum </td><td style=\"background-color:$BGcolor\" width=450><a style=\"width:94%\" href=\"" . $_SERVER['PHP_SELF'] . "?fViewComment=1&iCommentID=" . $oComment->getID() . "&iDocumentID=" . $oThread->getDocumentID() . "\" title=\"" . $oComment->getSubject() . "\">" . substr($oComment->getSubject(),0,$iSubjectChars ) . $dotdot . "</a></td>\n";
$sToRender .= "<td style=\"background-color:$UserBGcolor\" width=\"100\" title=\"$oUser->getUserName()\">" . substr($oUser->getUserName(),0,10) . $Userdotdot . "</td>\n";
$sToRender .= "<td style=\"background-color:$BGcolor\" width=\"80\">" . $oComment->getDate() . "<td></tr>\n";
// If this is the last subject line then close the table
if ($iNum == ($oThread->getNumberOfReplies())) { $sToRender .= "\n</table>\n\n";}
return $sToRender;
}
/**
* Views a single thread comment with its text body
*
* @param $iDocumentID -> a valid Document ID
* @param $oComment -> a valid Comment Object
* @param $oUser -> a valid User Object (Logged in user)
*/
function getCommentBody($oComment, $iDocumentID, $oUser) {
global $default;
$sHeading = "Document Comment";
$sToRender .= renderHeading($sHeading);
$sToRender .= renderDocumentPath($iDocumentID);
$sBody = urldecode(str_replace("%0D%0A","<br>",str_replace("+", " ",$oComment->getBody())));
$aBody = explode("<br>",$sBody);
$sBody = "";
$numChars = 80; // number of chars in a line
// Used for wrapping text that may be too long on one any line
for ($i=0; $i <= sizeof($aBody) ;$i++) {
if (strlen($aBody[$i]) >$numChars){
$loop = (strlen($aBody[$i]) - (strlen($aBody[$i])) % $numChars)/$numChars +1;
$j=$numChars;
for($j=0; $j < $loop; $j++ ) {
$sBody .= "<br>" . substr($aBody[$i],($j*$numChars), $numChars) . "";
}
} else { $sBody .= "<br>" . $aBody[$i]; }
}
$sToRender .= "<br><table width=100% border=0><tr ><td colspan=2><b>Author: </b>" . $oUser->getUserName() . "</td>\n";
$sToRender .= "<td align=right>\n";
$sToRender .= "<a href=\"" . generateControllerLink("addComment", "fDocumentID=" . $iDocumentID . "&fReplyComment=1&fCommentID=" . $oComment->getID()) . "\"><img src=\"$default->graphicsUrl/widgets/reply.gif\" border=\"0\" /></a>";
$sToRender .= "</td><td width=30><a href=\"" . generateControllerLink("viewDiscussion", "fForDiscussion=1&fDocumentID=$iDocumentID") . "\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=0 ><a></td></tr>\n";
$sToRender .= "<tr><td width=\"1\" style=\"background-color:#F5F6EE;\" valign=\"top\"><b>Subject: </b></td><td width=405 style=\"background-color:#F5F6EE;\">";
$sToRender .= "<a>" . $oComment->getSubject() . "</a>";
$sToRender .= "</td><td colspan=2><b>Date: </b><font color=\"#056DCE\">" . $oComment->getDate() . "</font> </td></tr><tr><td colspan=4 valign=top>";
$sToRender .= "<table width=10 border=0><tr><td><a>";
$sToRender .= $sBody; // Div Views as HTML
$sToRender .= "</a></td></tr></table>";
$sToRender .= "</td>\n";
$sToRender .= "</tr></table> ";
return $sToRender;
}
?>