| | 31 | |
|---|
| | 32 | } |
|---|
| | 33 | |
|---|
| | 34 | function generic_comments_displayobjectannotations($object, $object_type, $view) |
|---|
| | 35 | { |
|---|
| | 36 | $return = ""; |
|---|
| | 37 | |
|---|
| | 38 | if ($object_type == "file::file") |
|---|
| | 39 | { |
|---|
| | 40 | $txt = __gettext('Click to add or view comments on this file.'); |
|---|
| | 41 | $int = implode('',action('annotate',$object->ident,'file::file',NULL, |
|---|
| | 42 | array('comment_form_type'=>'inline', 'comment_sort'=>'DESC', 'comment_form_text'=>$txt))); |
|---|
| | 43 | |
|---|
| | 44 | $return .= <<< END |
|---|
| | 45 | <script type="text/javascript"> |
|---|
| | 46 | <!-- |
|---|
| | 47 | $int |
|---|
| | 48 | --> |
|---|
| | 49 | </script> |
|---|
| | 50 | <noscript> |
|---|
| | 51 | END; |
|---|
| | 52 | $return .= implode('',action('annotate',$object->ident,'file::file',NULL, |
|---|
| | 53 | array('comment_form_type'=>'summary', 'comment_sort'=>'DESC', 'comment_form_text'=>$txt))); |
|---|
| | 54 | |
|---|
| | 55 | $return .= <<< END |
|---|
| | 56 | </noscript> |
|---|
| | 57 | END; |
|---|
| | 58 | } |
|---|
| | 59 | |
|---|
| | 60 | return $return; |
|---|
| 228 | | $body = "<p>$comment_count <a href=\"{$CFG->wwwroot}mod/generic_comments/comment_page.php?object_id=$object_id&object_type=$object_type$comment_sort\">$comment_form_text</a>"; |
|---|
| | 261 | $body = "<p>$comment_count <a href=\"{$CFG->wwwroot}mod/generic_comments/comment_page.php?object_id=$object_id&object_type=$object_type$comment_sort\">$comment_form_text</a>"; |
|---|
| | 262 | |
|---|
| | 263 | |
|---|
| | 264 | |
|---|
| | 265 | } elseif ($comment_form_type == 'inline') { |
|---|
| | 266 | // Funky javascript inline editing |
|---|
| | 267 | |
|---|
| | 268 | $count = count_records('comments','object_id',$object_id,'object_type',$object_type); |
|---|
| | 269 | if (!isset($count) || $count == 0) { |
|---|
| | 270 | $comment_count = "0 ".__gettext("comments")."."; |
|---|
| | 271 | } elseif ($count == 1) { |
|---|
| | 272 | $comment_count = "1 ".__gettext("comment")."."; |
|---|
| | 273 | } else { |
|---|
| | 274 | $comment_count = $count." ".__gettext("comments")."."; |
|---|
| | 275 | } |
|---|
| | 276 | |
|---|
| | 277 | if ($parameters && strtoupper($parameters['comment_sort']) == 'DESC') { |
|---|
| | 278 | $comment_sort = '&comment_sort=DESC'; |
|---|
| | 279 | } |
|---|
| | 280 | |
|---|
| | 281 | $field = display_input_field(array("new_comment","","longtext")); |
|---|
| | 282 | if (logged_on) { |
|---|
| | 283 | $userid = $_SESSION['userid']; |
|---|
| | 284 | } else { |
|---|
| | 285 | $userid = -1; |
|---|
| | 286 | } |
|---|
| | 287 | |
|---|
| | 288 | /* There now follows a selection of nasty hacks. Yes yes, I know this is ugly, but it means that it falls back cleanly if no javascript is supported. TODO: There must be a better way, but i'm too tired just now to think of one.*/ |
|---|
| | 289 | if (logged_on) { |
|---|
| | 290 | $comment_name = $_SESSION['name']; |
|---|
| | 291 | } else { |
|---|
| | 292 | $comment_name = __gettext("Guest"); |
|---|
| | 293 | } |
|---|
| | 294 | |
|---|
| | 295 | $comment_name_enc = templates_draw(array( |
|---|
| | 296 | |
|---|
| | 297 | 'context' => 'databox1', |
|---|
| | 298 | 'name' => __gettext("Your name"), |
|---|
| | 299 | 'column1' => "<input type=\"text\" name=\"postedname\" value=\"".htmlspecialchars($comment_name, ENT_COMPAT, 'utf-8')."\" />" |
|---|
| | 300 | |
|---|
| | 301 | ) |
|---|
| | 302 | ); |
|---|
| | 303 | $postcomment = __gettext("Post comment..."); |
|---|
| | 304 | $bodyfrm = <<< END |
|---|
| | 305 | <span style="cursor:hand; cursor:pointer" onclick="showhide('oid_$object_id')">$comment_count $comment_form_text</span> |
|---|
| | 306 | <div id="oid_$object_id" style="display:none"> |
|---|
| | 307 | <form id="comment_$object_id"> |
|---|
| | 308 | $field |
|---|
| | 309 | <input type="hidden" name="action" value="comment:add" /> |
|---|
| | 310 | <input type="hidden" name="object_id" value="{$object_id}" /> |
|---|
| | 311 | <input type="hidden" name="object_type" value="{$object_type}" /> |
|---|
| | 312 | <input type="hidden" name="owner" value="{$userid}" /> |
|---|
| | 313 | <input type="hidden" name="comment_form_type" value="integrated" /> |
|---|
| | 314 | <input type="hidden" name="comment_sort" value="{$comment_sort}" /> |
|---|
| | 315 | $comment_name_enc |
|---|
| | 316 | </form> |
|---|
| | 317 | <div id="ajaxmessages"></div> |
|---|
| | 318 | <span style="cursor:hand; cursor:pointer" onclick="sendcomment('{$CFG->wwwroot}mod/generic_comments/action_redirection.php','comment_$object_id')">$postcomment</span> |
|---|
| | 319 | </div> |
|---|
| | 320 | END; |
|---|
| | 321 | $body = ""; |
|---|
| | 322 | foreach (explode("\n",addslashes($bodyfrm)) as $line) |
|---|
| | 323 | $body .= "document.write(\"" . trim($line) . "\");"; |
|---|
| | 324 | |
|---|