Changeset 1133
- Timestamp:
- 05/31/07 12:35:15 (2 years ago)
- Files:
-
- devel/mod/generic_comments/comments_actions.php (modified) (3 diffs)
- devel/mod/generic_comments/generic_comments.js (modified) (4 diffs)
- devel/mod/generic_comments/lib.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/mod/generic_comments/comments_actions.php
r1132 r1133 8 8 // Create a comment 9 9 case "comment:add": 10 $ok = false; 10 11 $comment = new StdClass; 11 12 $comment->object_id = optional_param('object_id',0,PARAM_INT); … … 33 34 $comment = plugin_hook("comment","publish",$comment); 34 35 $messages[] = __gettext("Your comment has been added."); // gettext variable 36 $ok = true; 35 37 36 38 // If we're logged on and not the owner of this post, add post to our watchlist … … 63 65 { 64 66 // If we are returning xml for the ajax response then output message and die. 67 68 if ($ok!=true) { 69 $ok = "<error>1</error>\n"; 70 } else { 71 $messages[] = __gettext(" Click <a href=\"\">here</a> to refresh"); 72 $ok = "<error>0</error>\n"; 73 } 74 65 75 $msg = implode("\n", $messages); 66 76 header("Content-type: text/xml"); 67 echo "<ajax>\n<message>$msg</message>\n</ajax>\n"; 77 78 echo "<ajax>\n<message>$msg</message>\n$ok</ajax>\n"; 68 79 exit; 69 80 } devel/mod/generic_comments/generic_comments.js
r1132 r1133 1 1 var http_Request = false; 2 var success = false; 3 var objectid = ""; 2 4 3 5 function showhide(oid) … … 51 53 message = result.getElementsByTagName('message')[0]; 52 54 53 document.getElementById('ajaxmessages').innerHTML = message.textContent; 54 // todo find system-message 55 error = result.getElementsByTagName('error')[0]; 56 if (error.textContent == '0') { 57 success = true; 58 } 59 60 if (success == true) 61 { 62 document.getElementById('ajaxmessages_' + objectid).innerHTML = '<a href="">' + message.textContent + '</a>'; 63 } 64 else 65 { 66 document.getElementById('ajaxmessages_' + objectid).innerHTML = message.textContent; 67 } 55 68 } else { 56 69 alert('There was a problem with the request.'); … … 59 72 } 60 73 61 function sendcomment(url, formid )74 function sendcomment(url, formid, oid) 62 75 { 63 76 var parameters; 77 objectid = oid; 64 78 65 79 http_Request = getAjaxObj(); … … 94 108 95 109 frm.new_comment.disabled=false; 110 111 if (success==true) { 112 frm.new_comment.value=""; 113 } 96 114 } devel/mod/generic_comments/lib.php
r1132 r1133 293 293 } 294 294 295 296 297 $thispageurl = generic_comments_add_parameter_to_url(get_url($object_id, $object_type),'comment_sort',$sort_sequence); 295 298 $comment_name_enc = templates_draw(array( 296 299 … … 302 305 ); 303 306 $postcomment = __gettext("Post comment..."); 307 308 if ($comments = get_records_sql("SELECT * FROM {$CFG->prefix}comments WHERE object_id = $object_id AND object_type = '$object_type' ORDER BY posted $sort_sequence")) { 309 $numcomments = count($comments); 310 $pagelinks = ''; 311 if (!empty($perpage) && $numcomments > $perpage) { 312 $comments = array_slice($comments, $offset, $perpage); 313 $numpages = ceil($numcomments / $perpage); 314 $pagelinks = __gettext("Page: "); 315 for ($i = 1; $i <= $numpages; $i++) { 316 $pagenum = $i - 1; 317 if ($pagenum != $page) { 318 if ($pagenum) { 319 $pageurl = generic_comments_add_parameter_to_url($thispageurl,'commentpage',$pagenum); 320 } 321 //$pageurl = $thispageurl . (($pagenum) ? '.' . $pagenum : ''); 322 $pagelinks .= ' <a href="' . $pageurl . '">' . $i . '</a>' ; 323 } else { 324 $pagelinks .= ' ' . $i . ' '; 325 } 326 327 } 328 //$thispageurl .= '.' . $page; 329 $thispageurl = generic_comments_add_parameter_to_url($thispageurl,'commentpage',$page); 330 331 } 332 333 foreach($comments as $comment) { 334 $commentmenu = ""; 335 if (isloggedin() && ($comment->owner == $_SESSION['userid'] || run("permissions:check",array("comment:delete",$_SESSION['userid'],$comment->object_id,$comment->object_type)))) { 336 $returnConfirm = __gettext("Are you sure you want to permanently delete this comment?"); 337 $Delete = __gettext("Delete"); 338 $commentmenu = <<< END 339 <a href="{$CFG->wwwroot}mod/generic_comments/action_redirection.php?action=comment:delete&comment_form_type=$comment_form_type&comment_delete={$comment->ident}" onclick="return confirm('$returnConfirm')">$Delete</a> 340 END; 341 } 342 $comment->postedname = htmlspecialchars($comment->postedname, ENT_COMPAT, 'utf-8'); 343 344 // turn commentor name into a link if they're a registered user 345 // add rel="nofollow" to comment links if they're not 346 if ($comment->owner > 0) { 347 $commentownerusername = user_info('username', $comment->owner); 348 $comment->postedname = '<a href="' . url . $commentownerusername . '/">' . $comment->postedname . '</a>'; 349 $comment->icon = '<a href="' . url . $commentownerusername . '/">' . user_icon_html($comment->owner,50) . "</a>"; 350 $comment->body = run("weblogs:text:process", array($comment->body, false)); 351 } else { 352 $comment->icon = "<img src=\"" . $CFG->wwwroot . "_icons/data/default.png\" width=\"50\" height=\"50\" align=\"left\" alt=\"\" />"; 353 $comment->body = run("weblogs:text:process", array($comment->body, true)); 354 } 355 356 $commentsbody .= templates_draw(array( 357 'context' => 'weblogcomment', 358 'postedname' => $comment->postedname, 359 'body' => '<a name="cmt' . $comment->ident . '" id="cmt' . $comment->ident . '"></a>' . $comment->body, 360 'posted' => strftime("%A, %d %B %Y, %H:%M %Z",$comment->posted), 361 'usericon' => $comment->icon, 362 'permalink' => $thispageurl . "#cmt" . $comment->ident, 363 'links' => $commentmenu 364 ) 365 ); 366 367 } 368 $commentsbody = templates_draw(array( 369 'context' => 'weblogcomments', 370 'paging' => $pagelinks, 371 'comments' => $commentsbody 372 ) 373 ); 374 } 375 304 376 $bodyfrm = <<< END 305 377 <span style="cursor:hand; cursor:pointer" onclick="showhide('oid_$object_id')">$comment_count $comment_form_text</span> … … 315 387 $comment_name_enc 316 388 </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> 389 <div id="ajaxmessages_$object_id"></div> 390 <span style="cursor:hand; cursor:pointer" onclick="sendcomment('{$CFG->wwwroot}mod/generic_comments/action_redirection.php','comment_$object_id', $object_id)">$postcomment</span> 391 392 $commentsbody 319 393 </div> 320 394 END;
