<?php if ( ! defined('OC_ADMIN')) exit('Direct access is not allowed.');
/*
* Copyright 2014 Osclass
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
osc_enqueue_script('jquery-validate');
//customize Head
function customHead() { ?>
<script type="text/javascript">
$(document).ready(function(){
// Code for form validation
$("form[name=comments_form]").validate({
rules: {
num_moderate_comments: {
required: true,
digits: true
},
comments_per_page: {
required: true,
digits: true
}
},
messages: {
num_moderate_comments: {
required: '<?php echo osc_esc_js(__("Moderated comments: this field is required")); ?>.',
digits: '<?php echo osc_esc_js(__("Moderated comments: this field must only contain numeric characters")); ?>.'
},
comments_per_page: {
required: '<?php echo osc_esc_js(__("Comments per page: this field is required")); ?>.',
digits: '<?php echo osc_esc_js(__("Comments per page: this field must only contain numeric characters")); ?>.'
}
},
wrapper: "li",
errorLabelContainer: "#error_list",
invalidHandler: function(form, validator) {
$('html,body').animate({ scrollTop: $('h1').offset().top }, { duration: 250, easing: 'swing'});
},
submitHandler: function(form){
$('button[type=submit], input[type=submit]').attr('disabled', 'disabled');
form.submit();
}
});
if( !$('input[name="moderate_comments"]').is(':checked') ) {
$('.comments_approved').css('display', 'none');
}
$('input[name="moderate_comments"]').bind('change', function() {
if( $(this).is(':checked') ) {
$('.comments_approved').css('display', '');
} else {
$('.comments_approved').css('display', 'none');
}
});
});
</script>
<?php
}
osc_add_hook('admin_header','customHead', 10);
function render_offset(){
return 'row-offset';
}
function addHelp() {
echo '<p>' . __("Modify the options that allow your users to publish comments on your site's listings.") . '</p>';
}
osc_add_hook('help_box','addHelp');
osc_add_hook('admin_page_header','customPageHeader');
function customPageHeader(){ ?>
<h1><?php _e('Settings'); ?>
<a href="#" class="btn ico ico-32 ico-help float-right"></a>
</h1>
<?php
}
function customPageTitle($string) {
return sprintf(__('Comment Settings » %s'), $string);
}
osc_add_filter('admin_title', 'customPageTitle');
osc_current_admin_theme_path( 'parts/header.php' ); ?>
<div id="general-settings">
<ul id="error_list"></ul>
<form name="comments_form" action="<?php echo osc_admin_base_url(true); ?>" method="post">
<input type="hidden" name="page" value="settings" />
<input type="hidden" name="action" value="comments_post" />
<fieldset>
<div class="form-horizontal">
<h2 class="render-title"><?php _e('Comment Settings'); ?></h2>
<div class="form-row">
<div class="form-label"><?php _e('Default comment settings'); ?></div>
<div class="form-controls">
<div class="form-label-checkbox">
<label>
<input type="checkbox" <?php echo ( osc_comments_enabled() ? 'checked="checked"' : '' ); ?> name="enabled_comments" value="1" /> <?php _e('Allow people to post comments on listings'); ?>
</label>
</div>
<div class="form-label-checkbox">
<label>
<input type="checkbox" <?php echo ( osc_comments_edit_enabled() ? 'checked="checked"' : '' ); ?> name="enabled_edit_comments" value="1" /> <?php _e('Allow people to edit their own comments'); ?>
</label>
</div>
<?php if(osc_comments_edit_enabled()): ?>
<div class="form-row">
<div class="help-block">
<p><strong class="text-red"><?php _e('Important!'); ?></strong> <?php _e('This feature was added since the Osclass Evolution v. 4.4.0 so if you don\'t see the "Edit comment" button when this option is enabled, you need to add it to your template manually!'); ?></p>
<p><?php printf(__('To do this, open the file: <strong class="text-red">%s</strong> and find a link in it where the "href" attribute has the <strong class="text-red">%s</strong> function.'), '/oc-content/themes/YOUR_TEMPLATE/item.php', 'osc_delete_comment_url()'); ?></p>
<p><?php _e('Before this link, add the following code:'); ?></p>
<div class="code-block">
<span class="php-tag"><?php if</span><span class="php-function">(osc_comments_edit_enabled())</span><span class="php-tag">: ?></span>
<br>
<a rel="nofollow" data-comment-action="edit-comment" data-comment-id="<span class="php-tag"><?php</span> <span class="php-function">echo osc_comment_id();</span> <span class="php-tag">?></span>" href="javascript:;" title="<span class="php-tag"><?php</span> <span class="php-function">_e('Edit your comment');</span> <span class="php-tag">?></span>"><span class="php-tag"><?php</span> <span class="php-function">_e('Edit');</span> <span class="php-tag">?></span></a>
<br>
<span> | </span>
<br>
<span class="php-tag"><?php endif; ?></span>
</div>
<p><?php _e('All rules for posting comments (moderation and number of comments for auto-approval of comments) apply to editing comments.'); ?></p>
</div>
</div>
<?php endif; ?>
<div class="form-label-checkbox">
<label>
<input type="checkbox" <?php echo ( osc_reg_user_post_comments() ? 'checked="checked"' : '' ); ?> name="reg_user_post_comments" value="1" /> <?php _e('Users must be registered and logged in to comment'); ?>
</label>
</div>
<div class="form-label-checkbox">
<label>
<input type="checkbox" <?php echo ( ( osc_moderate_comments() == -1 ) ? '' : 'checked="checked"' ); ?> name="moderate_comments" value="1" /> <?php _e('A comment is being held for moderation'); ?>
</label>
</div>
<div class="form-label-checkbox-offset">
<?php printf( __('Before a comment appears, comment author must have at least %s previously approved comments'), '<input type="text" class="input-small" name="num_moderate_comments" value="' . ( (osc_moderate_comments() == -1 ) ? '0' : osc_esc_html( osc_moderate_comments() ) ) . '" />' ); ?>
<div class="help-box"><?php _e('If the value is zero, an administrator must always approve comments'); ?></div>
</div>
</div>
</div>
<div class="form-row">
<div class="form-label"><?php _e('Other comment settings'); ?></div>
<div class="form-controls">
<?php printf( __('Break comments into pages with %s comments per page'), '<input type="text" class="input-small" name="comments_per_page" value="' . osc_esc_html( osc_comments_per_page() ) . '" />' ); ?>
<div class="help-box"><?php _e('If the value is zero all comments are shown'); ?></div>
</div>
</div>
<h2 class="render-title"><?php _e('Notifications'); ?></h2>
<div class="form-row">
<div class="form-label"><?php _e('E-mail admin whenever') ?></div>
<div class="form-controls">
<div class="form-label-checkbox">
<label>
<input type="checkbox" <?php echo ( osc_notify_new_comment() ? 'checked="checked"' : '' ); ?> name="notify_new_comment" value="1" /> <?php _e("A new comment is posted"); ?>
</label>
</div>
</div>
</div>
<div class="form-row">
<div class="form-label"><?php _e('E-mail admin whenever') ?></div>
<div class="form-controls">
<div class="form-label-checkbox">
<label>
<input type="checkbox" <?php echo ( osc_notify_edit_comment() ? 'checked="checked"' : '' ); ?> name="notify_edit_comment" value="1" /> <?php _e("A comment is edited"); ?>
</label>
</div>
</div>
</div>
<div class="form-row">
<div class="form-label"><?php _e('E-mail user whenever') ?></div>
<div class="form-controls">
<div class="form-label-checkbox">
<label>
<input type="checkbox" <?php echo ( osc_notify_new_comment_user() ? 'checked="checked"' : '' ); ?> name="notify_new_comment_user" value="1" /> <?php _e("There's a new comment on his listing"); ?>
</label>
</div>
</div>
</div>
<div class="form-actions">
<input type="submit" id="save_changes" value="<?php echo osc_esc_html( __('Save changes') ); ?>" class="btn btn-submit" />
</div>
</div>
</fieldset>
</form>
</div>
<?php osc_current_admin_theme_path( 'parts/footer.php' ); ?>