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: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473:
<?php
$plugin_is_filter = 5 | CLASS_PLUGIN;
$plugin_description = gettext("Provides a unified comment handling facility.");
$plugin_author = "Stephen Billard (sbillard)";
$plugin_category = gettext('Misc');
$option_interface = 'comment_form';
zp_register_filter('admin_toolbox_global', 'comment_form::toolbox');
require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/comment_form/class-comment.php');
require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/comment_form/functions.php');
if (OFFSET_PATH) {
zp_register_filter('admin_overview', 'comment_form_print10Most');
zp_register_filter('admin_tabs', 'comment_form::admin_tabs');
} else {
zp_register_filter('handle_comment', 'comment_form_postcomment');
zp_register_filter('object_addComment', 'comment_form_addComment');
if (getOption('comment_form_pagination')) {
zp_register_filter('theme_head', 'comment_form_PaginationJS');
}
if (getOption('tinymce4_comments')) {
require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/tinymce4.php');
zp_register_filter('theme_head', 'comment_form_visualEditor');
}
}
class comment_form {
function __construct() {
setOptionDefault('email_new_comments', 1);
setOptionDefault('comment_name_required', 'required');
setOptionDefault('comment_email_required', 'required');
setOptionDefault('comment_web_required', 1);
setOptionDefault('Use_Captcha', false);
setOptionDefault('comment_form_addresses', 0);
setOptionDefault('comment_form_require_addresses', 0);
setOptionDefault('comment_form_members_only', 0);
setOptionDefault('comment_form_albums', 1);
setOptionDefault('comment_form_images', 1);
setOptionDefault('comment_form_articles', 1);
setOptionDefault('comment_form_pages', 1);
setOptionDefault('comment_form_rss', 1);
setOptionDefault('comment_form_private', 1);
setOptionDefault('comment_form_anon', 1);
setOptionDefault('comment_form_showURL', 1);
setOptionDefault('comment_form_comments_per_page', 10);
setOptionDefault('comment_form_pagination', true);
setOptionDefault('comment_form_toggle', 1);
setOptionDefault('tinymce4_comments', null);
setOptionDefault('comment_form_dataconfirmation', 0);
}
function getOptionsSupported() {
global $_zp_captcha;
require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/tinymce4.php');
$checkboxes = array(
gettext('Albums') => 'comment_form_albums',
gettext('Images') => 'comment_form_images');
if (extensionEnabled('zenpage')) {
$checkboxes = array_merge($checkboxes, array(
gettext('Pages') => 'comment_form_pages',
gettext('News') => 'comment_form_articles'));
}
$configarray = getTinyMCE4ConfigFiles('comment');
$options = array(
gettext('Enable comment notification') => array(
'key' => 'email_new_comments',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 0,
'desc' => gettext('Email the Admin when new comments are posted')),
gettext('Name field') => array(
'key' => 'comment_name_required',
'type' => OPTION_TYPE_RADIO,
'order' => 0.1,
'buttons' => array(
gettext('Omit') => 0,
gettext('Show') => 1,
gettext('Require') => 'required'),
'desc' => gettext('If the <em>Name</em> field is required, the poster must provide a name.')),
gettext('Email field') => array(
'key' => 'comment_email_required',
'type' => OPTION_TYPE_RADIO,
'order' => 0.2,
'buttons' => array(
gettext('Omit') => 0,
gettext('Show') => 1,
gettext('Require') => 'required'),
'desc' => gettext('If the <em>Email</em> field is required, the poster must provide an email address.')),
gettext('Website field') => array(
'key' => 'comment_web_required',
'type' => OPTION_TYPE_RADIO,
'order' => 0.3,
'buttons' => array(
gettext('Omit') => 0,
gettext('Show') => 1,
gettext('Require') => 'required'),
'desc' => gettext('If the <em>Website</em> field is required, the poster must provide a website.')),
gettext('Captcha field') => array(
'key' => 'Use_Captcha',
'type' => OPTION_TYPE_RADIO,
'order' => 0.4,
'buttons' => array(
gettext('Omit') => 0,
gettext('For guests') => 2,
gettext('Require') => 1),
'desc' => ($_zp_captcha->name) ? gettext('If <em>Captcha</em> is required, the form will include a Captcha verification.') : '<span class="notebox">' . gettext('No captcha handler is enabled.') . '</span>'),
gettext('Address fields') => array(
'key' => 'comment_form_addresses',
'type' => OPTION_TYPE_RADIO,
'order' => 7,
'buttons' => array(
gettext('Omit') => 0,
gettext('Show') => 1,
gettext('Require') => 'required'),
'desc' => gettext('If <em>Address fields</em> are shown or required, the form will include positions for address information. If required, the poster must supply data in each address field.')),
gettext('Allow comments on') => array(
'key' => 'comment_form_allowed',
'type' => OPTION_TYPE_CHECKBOX_ARRAY,
'order' => 0.9,
'checkboxes' => $checkboxes,
'desc' => gettext('Comment forms will be presented on the checked pages.')),
gettext('Toggled comment block') => array(
'key' => 'comment_form_toggle',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 2,
'desc' => gettext('If checked, existing comments will be initially hidden. Clicking on the provided button will show them.')),
gettext('Show author URL') => array(
'key' => 'comment_form_showURL',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 7,
'desc' => gettext('To discourage SPAM, uncheck this box and the author URL will not be revealed.')),
gettext('Only members can comment') => array(
'key' => 'comment_form_members_only',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 4,
'desc' => gettext('If checked, only logged in users will be allowed to post comments.')),
gettext('Allow private postings') => array(
'key' => 'comment_form_private',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 6,
'desc' => gettext('If checked, posters may mark their comments as private (not for publishing).')),
gettext('Allow anonymous posting') => array(
'key' => 'comment_form_anon',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 5,
'desc' => gettext('If checked, posters may exclude their personal information from the published post.')),
gettext('Include RSS link') => array(
'key' => 'comment_form_rss',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 8,
'desc' => gettext('If checked, an RSS link will be included at the bottom of the comment section.')),
gettext('Comments per page') => array(
'key' => 'comment_form_comments_per_page',
'type' => OPTION_TYPE_TEXTBOX,
'order' => 9,
'desc' => gettext('The comments that should show per page on the admin tab and when using the jQuery pagination')),
gettext('Comment editor configuration') => array(
'key' => 'tinymce4_comments',
'type' => OPTION_TYPE_SELECTOR,
'order' => 1,
'selections' => $configarray,
'null_selection' => gettext('Disabled'),
'desc' => gettext('Configuration file for TinyMCE when used for comments. Set to <code>Disabled</code> to disable visual editing.')),
gettext('Pagination') => array(
'key' => 'comment_form_pagination',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 3,
'desc' => gettext('Uncheck to disable the jQuery pagination of comments. Enabled by default.')),
gettext('Data usage confirmation') => array(
'key' => 'comment_form_dataconfirmation',
'type' => OPTION_TYPE_CHECKBOX,
'order' => 11,
'desc' => gettext('If checked a mandatory checkbox is added for users to confirm about data storage and handling by your site. This is recommend to comply with the European GDPR.'))
);
return $options;
}
function handleOption($option, $currentValue) {
}
static function admin_tabs($tabs) {
if (zp_loggedin(COMMENT_RIGHTS)) {
$add = true;
$newtabs = array();
foreach ($tabs as $key => $tab) {
if ($add && !in_array($key, array('overview', 'edit', 'upload', 'pages', 'news', 'tags', 'menu'))) {
$newtabs['comments'] = array(
'text' => gettext("comments"),
'link' => FULLWEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/' . 'comment_form/admin-comments.php?page=comments&tab=' . gettext('comments'),
'subtabs' => NULL);
$add = false;
}
$newtabs[$key] = $tab;
}
return $newtabs;
}
return $tabs;
}
static function toolbox() {
if (zp_loggedin(COMMENT_RIGHTS)) {
?>
<li>
<?php printLinkHTML(WEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/' . 'comment_form/admin-comments.php?page=comments&tab=' . gettext('comments'), gettext("Comments"), NULL, NULL, NULL); ?>
</li>
<?php
}
}
}
function printCommentForm($showcomments = true, $addcommenttext = NULL, $addheader = true, $comment_commententry_mod = '', $desc_order = false) {
global $_zp_gallery_page, $_zp_current_admin_obj, $_zp_current_comment, $_zp_captcha, $_zp_authority, $_zp_HTML_cache, $_zp_current_image, $_zp_current_album, $_zp_current_zenpage_page, $_zp_current_zenpage_news;
if (getOption('email_new_comments')) {
$email_list = $_zp_authority->getAdminEmail();
if (empty($email_list)) {
setOption('email_new_comments', 0);
}
}
if (is_null($addcommenttext))
$addcommenttext = '<h3>' . gettext('Add a comment:') . '</h3>';
switch ($_zp_gallery_page) {
case 'album.php':
if (!getOption('comment_form_albums'))
return;
$obj = $_zp_current_album;
break;
case 'image.php':
if (!getOption('comment_form_images'))
return;
$obj = $_zp_current_image;
break;
case 'pages.php':
if (!getOption('comment_form_pages'))
return;
$obj = $_zp_current_zenpage_page;
break;
case 'news.php':
if (!getOption('comment_form_articles') || !is_NewsArticle())
return;
$obj = $_zp_current_zenpage_news;
break;
default:
return;
break;
}
$comments_open = $obj->getCommentsAllowed();
?>
<!-- printCommentForm -->
<div id="commentcontent">
<?php
$num = getCommentCount();
if ($showcomments) {
if ($num == 0) {
if ($addheader)
echo '<h3 class="empty">' . gettext('No Comments') . '</h3>';
$display = '';
} else {
if ($addheader)
echo '<h3>' . sprintf(ngettext('%u Comment', '%u Comments', $num), $num) . '</h3>';
if (getOption('comment_form_toggle')) {
?>
<div id="comment_toggle"><!-- place holder for toggle button --></div>
<script type="text/javascript">
function toggleComments(hide) {
if (hide) {
$('div.comment').hide();
$('.Pagination').hide();
$('#comment_toggle').html('<button class="button buttons" onclick="javascript:toggleComments(false);"><?php echo gettext('show comments'); ?></button>');
} else {
$('div.comment').show();
$('.Pagination').show();
$('#comment_toggle').html('<button class="button buttons" onclick="javascript:toggleComments(true);"><?php echo gettext('hide comments'); ?></button>');
}
}
$(document).ready(function() {
toggleComments(window.location.hash.search(/
});
</script>
<?php
$display = ' style="display:none"';
} else {
$display = '';
}
}
$hideoriginalcomments = '';
if (getOption('comment_form_pagination') && COMMENTS_PER_PAGE < $num) {
$hideoriginalcomments = ' style="display:none"';
}
if (getOption('comment_form_pagination') && COMMENTS_PER_PAGE < $num) {
?>
<div class="Pagination"></div><!-- this is the jquery pagination nav placeholder -->
<div id="Commentresult"></div>
<?php
}
?>
<div id="comments"<?php echo $hideoriginalcomments; ?>>
<?php
while (next_comment($desc_order)) {
if (!getOption('comment_form_showURL')) {
$_zp_current_comment['website'] = '';
}
?>
<div class="comment" <?php echo $display; ?>>
<div class="commentinfo">
<h4 id="zp_comment_id_<?php echo $_zp_current_comment['id']; ?>"><?php printCommentAuthorLink(); ?>: <?php echo gettext('on'); ?> <?php
echo getCommentDateTime();
printEditCommentLink(gettext('Edit'), ', ', '');
?></h4>
</div><!-- class "commentinfo" -->
<div class="commenttext"><?php echo html_encodeTagged(getCommentBody(), false); ?></div><!-- class "commenttext" -->
</div><!-- class "comment" -->
<?php
}
?>
</div><!-- id "comments" -->
<?php
}
if (getOption('comment_form_pagination') && COMMENTS_PER_PAGE < $num) {
?>
<div class="Pagination"></div><!-- this is the jquery pagination nav placeholder -->
<?php
}
?>
<!-- Comment Box -->
<?php
if ($comments_open) {
if (MEMBERS_ONLY_COMMENTS && !zp_loggedin(POST_COMMENT_RIGHTS)) {
echo gettext('Only registered users may post comments.');
} else {
$disabled = array('name' => '', 'website' => '', 'anon' => '', 'private' => '', 'comment' => '',
'street' => '', 'city' => '', 'state' => '', 'country' => '', 'postal' => '', 'comment_dataconfirmation' => '');
$stored = array_merge(array('email' => '', 'custom' => ''), $disabled, getCommentStored());
$custom = getSerializedArray($stored['custom']);
foreach ($custom as $key => $value) {
if (!empty($value))
$stored[$key] = $value;
}
foreach ($stored as $key => $value) {
$disabled[$key] = false;
}
if (zp_loggedin()) {
if (extensionEnabled('userAddressFields')) {
$address = userAddressFields::getCustomData($_zp_current_admin_obj);
foreach ($address as $key => $value) {
if (!empty($value)) {
$disabled[$key] = true;
$stored[$key] = $value;
}
}
}
$name = $_zp_current_admin_obj->getName();
if (!empty($name)) {
$stored['name'] = $name;
$disabled['name'] = ' disabled="disabled"';
} else {
$user = $_zp_current_admin_obj->getUser();
if (!empty($user)) {
$stored['name'] = $user;
$disabled['name'] = ' disabled="disabled"';
}
}
$email = $_zp_current_admin_obj->getEmail();
if (!empty($email)) {
$stored['email'] = $email;
$disabled['email'] = ' disabled="disabled"';
}
if (!empty($address['website'])) {
$stored['website'] = $address['website'];
$disabled['website'] = ' disabled="disabled"';
}
}
$data = zp_apply_filter('comment_form_data', array('data' => $stored, 'disabled' => $disabled));
$disabled = $data['disabled'];
$stored = $data['data'];
foreach ($data as $check) {
foreach ($check as $v) {
if ($v) {
$_zp_HTML_cache->disable();
break 2;
}
}
}
if (!empty($addcommenttext)) {
echo $addcommenttext;
}
?>
<div id="commententry" <?php echo $comment_commententry_mod; ?>>
<?php
$theme = getCurrentTheme();
$form = getPlugin('comment_form/comment_form.php', $theme);
require($form);
?>
</div><!-- id="commententry" -->
<?php
if (getOption('comment_form_rss') && getOption('RSS_comments')) {
?>
<br class="clearall" />
<?php
if (class_exists('RSS')) {
switch ($_zp_gallery_page) {
case "image.php":
printRSSLink("Comments-image", "", gettext("Subscribe to comments"), "");
break;
case "album.php":
printRSSLink("Comments-album", "", gettext("Subscribe to comments"), "");
break;
case "news.php":
printRSSLink("Comments-news", "", gettext("Subscribe to comments"), "");
break;
case "pages.php":
printRSSLink("Comments-page", "", gettext("Subscribe to comments"), "");
break;
}
}
}
}
} else {
?>
<div id="commententry">
<h3><?php echo gettext('Closed for comments.'); ?></h3>
</div><!-- id="commententry" -->
<?php
}
?>
</div><!-- id="commentcontent" -->
<?php
}
?>