| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @author Mambo Foundation Inc see README.php 5 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 6 * See COPYRIGHT.php for copyright notices and details. 7 * @license GNU/GPL Version 2, see LICENSE.php 8 * 9 * Redistributions of files must retain the above copyright notice. 10 * 11 * Mambo is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; version 2 of the License. 14 */ 15 16 /** ensure this file is being included by a parent file */ 17 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 18 19 $_MAMBOTS->registerFunction( 'onPrepareContent', 'botMosComment' ); 20 21 function botMosComment( $published, &$row, &$params, $page=0 ) { 22 23 global $database, $mainframe, $option, $task; 24 global $mosConfig_lang, $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_usecaptcha, $my, $Itemid; 25 26 # Load configuration file 27 require ($mosConfig_absolute_path."/administrator/components/com_comment/config.comment.php"); 28 29 $seclistarray = explode (",", $allow_comments_in_sections); 30 if (in_array ($row->sectionid, $seclistarray)) { 31 32 # count number of comments 33 $database->setQuery( "SELECT count(*) FROM #__comment WHERE articleid='$row->id' AND published='1'" ); 34 $total = $database->loadResult(); 35 36 if ($option=='com_content' AND $task=='view' AND !$params->get( 'intro_only' )) { 37 38 # Check if valid user 39 $is_user = (strtolower($my->usertype) <> ''); 40 41 if ( $total >= 0 ) { 42 $comments = "<hr />"; 43 $comments .= "<table width='100%' border='0' cellspacing='1' cellpadding='4'>"; 44 $comments .= "<tr><td class='sectiontableheader'>".T_('User Comments')."</td></tr>"; 45 $database->setQuery( "SELECT id as mcid, name as mcname, startdate as mcdate, comments as mccomment FROM #__comment WHERE articleid='$row->id' AND published='1'" ); 46 $mcrows = $database->loadObjectList(); 47 for ($i=0, $n=count( $mcrows ); $i < $n; $i++) { 48 $mcrow = &$mcrows[$i]; 49 $mcrow->mcname = stripslashes($mcrow->mcname); 50 $message = stripslashes(preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $mcrow->mccomment)); 51 $comments .= "<tr class='sectiontableentry'><td valign='top'>"; 52 $comments .= "<hr />"; 53 $comments .= "<span class='small'>".T_('Comment by')." ".((empty($mcrow->mcname)) ? T_('Anonymous') : $mcrow->mcname)." ".T_('on')." ".$mcrow->mcdate ."</span><br />"; 54 $comments .= $message; 55 if(($i+1)%$comments_per_page == 0 && ($i+1) < $n) { 56 $comments .= "</td></tr></table>"; 57 $comments .= "{mospagebreak}"; 58 $comments .= "<table border='0' cellspacing='1' cellpadding='4'>"; 59 $comments .= "<tr><td class='sectiontableheader'>".T_('Comments')."</td></tr>"; 60 }else { 61 $comments .= "</td></tr>"; 62 } 63 } 64 $comments .= "</table>"; 65 } 66 67 # show comments form depending on config permissions 68 if (!$allow_anonymous_entries AND !$is_user) { 69 $comment_form = '<p>' . T_('Please login or register to add comments').'</p>'; 70 } else { 71 // replace previously written comment if it exists in case user 72 // has simply mistyped or misread captcha code 73 if (isset($_GET['comments'])) $curr_com = $_GET['comments']; 74 else $curr_com = ''; 75 $comment_form = "<form id=\"commentform\" action=\"".sefRelToAbs('index.php')."\" method=\"post\">\n<div>"; 76 $comment_form .= "<input type='hidden' name='option' value='com_comment' />\n"; 77 $comment_form .= "<input type='hidden' name='mcitemid' value='$Itemid' />\n"; 78 $comment_form .= "<input type='hidden' name='articleid' value='$row->id' />\n"; 79 $comment_form .= "<input type='hidden' name='func' value='entry' />\n"; 80 $comment_form .= "<input type='hidden' name='limit' value='".mosGetParam( $_GET, 'limit', '' )."' />\n"; 81 $comment_form .= "<input type='hidden' name='limitstart' value='".mosGetParam( $_GET, 'limitstart', '' )."' />\n"; 82 83 if ($my->username) { 84 $comment_form .= "<input type='hidden' name='mcname' value='$my->username'>"; 85 } else { 86 $comment_form .= T_("Your Name / Email Address"). " <input type='text' name='mcname' value='' />\n"; 87 } 88 $comment_form .= "<textarea style='width:75%;' rows='8' name='comments' class='inputbox'>" .$curr_com. "</textarea>"; 89 90 if ($mosConfig_usecaptcha == '1') { 91 $cflink = 'index.php?option=com_comment&task=captcha-audio&id='.$row->id.'&Itemid='.$Itemid; 92 $comment_form .= "<br />".T_('Security Check. Please enter this code')."<input type='text' name='spamstop' maxlength='5' size='5' class='inputbox' title=''> "; 93 $comment_form .= "<img src='{$mosConfig_live_site}/includes/captcha.php' border='0' title='' alt='' />"; 94 $comment_form .= "<a href='".sefRelToAbs($cflink)."' target='_blank'>".T_("Listen to code")."</a>"; 95 } 96 97 $comment_form .= "<br /><input name='go' type='submit' value='".T_('add comment')."' /><br />\n</div>\n</form>\n"; 98 } 99 100 # show comments then comments form 101 if (in_array ($row->sectionid, $seclistarray)) { 102 $row->text = $row->text.$comments.$comment_form; 103 } 104 105 # If we are not on the content page itself 106 } elseif (in_array ($row->sectionid, $seclistarray)) { 107 108 # count number of pages 109 $regex = '/{(mospagebreak)\s*(.*?)}/i'; 110 $matches = array(); 111 preg_match_all( $regex, $row->text, $matches, PREG_SET_ORDER ); 112 $botLimitStart = count($matches); 113 114 $contentItemId = $mainframe->getItemid($row->id); 115 $link = "index.php?option=com_content&task=view&id=$row->id"; 116 $link .= "&Itemid=".$contentItemId; 117 $link .= $botLimitStart > 0 ? ('&limit=1&limitstart='.$botLimitStart) : ''; 118 119 $replacementlink = "<a class=\"readon\" href='".sefRelToAbs($link)."'>"; 120 $row->text = $row->text.$replacementlink.T_('Write Comment')." (".$total.T_(' comments').")</a>"; 121 122 } 123 124 } 125 126 return true; 127 } 128 129 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 8 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |