mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 02:27:34 -07:00
r138
быстрое добавление постов (ajax) git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@138 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
parent
7124a63544
commit
af29494fb4
4 changed files with 90 additions and 22 deletions
|
@ -48,10 +48,16 @@ switch($this->request['type'])
|
||||||
|
|
||||||
case 'reply';
|
case 'reply';
|
||||||
if(!$post) $this->ajax_die('not post');
|
if(!$post) $this->ajax_die('not post');
|
||||||
|
|
||||||
|
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
|
||||||
if(bf($userdata['user_opt'], 'user_opt', 'allow_post'))
|
if(bf($userdata['user_opt'], 'user_opt', 'allow_post'))
|
||||||
{
|
{
|
||||||
$this->ajax_die($lang['RULES_REPLY_CANNOT']);
|
$this->ajax_die($lang['RULES_REPLY_CANNOT']);
|
||||||
}
|
}
|
||||||
|
else if(!$is_auth['auth_reply'])
|
||||||
|
{
|
||||||
|
$this->ajax_die(sprintf($lang['SORRY_AUTH_REPLY'], strip_tags($is_auth['auth_reply_type'])));
|
||||||
|
}
|
||||||
|
|
||||||
// Use trim to get rid of spaces placed there by MS-SQL 2000
|
// Use trim to get rid of spaces placed there by MS-SQL 2000
|
||||||
$quote_username = (trim($post['post_username']) != '') ? $post['post_username'] : get_username($post['poster_id']);
|
$quote_username = (trim($post['post_username']) != '') ? $post['post_username'] : get_username($post['poster_id']);
|
||||||
|
@ -77,7 +83,7 @@ switch($this->request['type'])
|
||||||
$message = (string) $this->request['message'];
|
$message = (string) $this->request['message'];
|
||||||
if(!trim($message)) $this->ajax_die($lang['EMPTY_MESSAGE']);
|
if(!trim($message)) $this->ajax_die($lang['EMPTY_MESSAGE']);
|
||||||
$message = bbcode2html($message);
|
$message = bbcode2html($message);
|
||||||
$this->response['message_html'] = $message;
|
$this->response['view_message'] = $message;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'edit':
|
case 'edit':
|
||||||
|
@ -103,8 +109,8 @@ switch($this->request['type'])
|
||||||
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']));
|
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DB()->query("UPDATE ". BB_POSTS_TEXT ." SET post_text = '". DB()->escape($text) ."' WHERE post_id = $post_id LIMIT 1");
|
DB()->query("UPDATE ". BB_POSTS_TEXT ." SET post_text = '". DB()->escape($text) ."' WHERE post_id = $post_id LIMIT 1");
|
||||||
add_search_words($post_id, stripslashes($text), stripslashes($post['topic_title']));
|
add_search_words($post_id, stripslashes($text), stripslashes($post['topic_title']));
|
||||||
update_post_html(array(
|
update_post_html(array(
|
||||||
'post_id' => $post_id,
|
'post_id' => $post_id,
|
||||||
'post_text' => $text,
|
'post_text' => $text,
|
||||||
|
@ -203,6 +209,51 @@ switch($this->request['type'])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'add':
|
case 'add':
|
||||||
|
if (!isset($this->request['topic_id']))
|
||||||
|
{
|
||||||
|
$this->ajax_die('empty topic_id');
|
||||||
|
}
|
||||||
|
$topic_id = (int) $this->request['topic_id'];
|
||||||
|
$t_data = DB()->fetch_row("SELECT t.*, f.*
|
||||||
|
FROM ". BB_TOPICS ." t, ". BB_FORUMS ." f
|
||||||
|
WHERE t.topic_id = $topic_id
|
||||||
|
AND f.forum_id = t.forum_id
|
||||||
|
LIMIT 1");
|
||||||
|
if(!$t_data) bb_die($lang['TOPIC_POST_NOT_EXIST']);
|
||||||
|
|
||||||
|
$is_auth = auth(AUTH_ALL, $post['forum_id'], $userdata, $post);
|
||||||
|
if(bf($userdata['user_opt'], 'user_opt', 'allow_post'))
|
||||||
|
{
|
||||||
|
$this->ajax_die($lang['RULES_REPLY_CANNOT']);
|
||||||
|
}
|
||||||
|
else if(!$is_auth['auth_reply'])
|
||||||
|
{
|
||||||
|
$this->ajax_die(sprintf($lang['SORRY_AUTH_REPLY'], strip_tags($is_auth['auth_reply_type'])));
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = (string) $this->request['message'];
|
||||||
|
$message = prepare_message($message);
|
||||||
|
|
||||||
|
if($bb_cfg['max_smilies'])
|
||||||
|
{
|
||||||
|
$count_smilies = substr_count(bbcode2html($text), '<img class="smile" src="'. $bb_cfg['smilies_path']);
|
||||||
|
if($count_smilies > $bb_cfg['max_smilies'])
|
||||||
|
{
|
||||||
|
$this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DB()->sql_query("INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_time, poster_ip) VALUES ($topic_id, ". $t_data['forum_id'] .", ". $userdata['user_id'] .", '". TIMENOW ."', '". USER_IP ."')");
|
||||||
|
$post_id = DB()->sql_nextid();
|
||||||
|
DB()->sql_query("INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_text) VALUES ($post_id, '". DB()->escape($message) ."')");
|
||||||
|
|
||||||
|
add_search_words($post_id, stripslashes($message), stripslashes($t_data['topic_title']));
|
||||||
|
update_post_html(array(
|
||||||
|
'post_id' => $post_id,
|
||||||
|
'post_text' => $message,
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->response['redirect'] = make_url(POST_URL . $post_id .'#'. $post_id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -57,7 +57,7 @@ $bb_cfg['css_ver'] = 1;
|
||||||
|
|
||||||
// Increase number of revision after update
|
// Increase number of revision after update
|
||||||
$bb_cfg['tp_version'] = '2.0.2';
|
$bb_cfg['tp_version'] = '2.0.2';
|
||||||
$bb_cfg['tp_release_state'] = 'TP II r133';
|
$bb_cfg['tp_release_state'] = 'TP II r138';
|
||||||
$bb_cfg['tp_release_date'] = '24-07-2011';
|
$bb_cfg['tp_release_date'] = '24-07-2011';
|
||||||
|
|
||||||
$bb_cfg['board_disabled_msg'] = 'форум временно отключен'; // 'forums temporarily disabled'; // show this msg if board has been disabled via ON/OFF trigger
|
$bb_cfg['board_disabled_msg'] = 'форум временно отключен'; // 'forums temporarily disabled'; // show this msg if board has been disabled via ON/OFF trigger
|
||||||
|
|
|
@ -295,19 +295,6 @@ BBCode.prototype = {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called before form submitting.
|
|
||||||
function checkForm(form) {
|
|
||||||
var formErrors = false;
|
|
||||||
if (form.message.value.length < 2) {
|
|
||||||
formErrors = "Please enter the message.";
|
|
||||||
}
|
|
||||||
if (formErrors) {
|
|
||||||
setTimeout(function() { alert(formErrors) }, 100);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emulation of innerText for Mozilla.
|
// Emulation of innerText for Mozilla.
|
||||||
if (window.HTMLElement && window.HTMLElement.prototype.__defineSetter__) {
|
if (window.HTMLElement && window.HTMLElement.prototype.__defineSetter__) {
|
||||||
HTMLElement.prototype.__defineSetter__("innerText", function (sText) {
|
HTMLElement.prototype.__defineSetter__("innerText", function (sText) {
|
||||||
|
|
|
@ -2,13 +2,11 @@
|
||||||
<!-- ELSE -->
|
<!-- ELSE -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
ajax.callback.posts = function(data){
|
ajax.callback.posts = function(data){
|
||||||
if(data.message_html){
|
$('#view_message').show();
|
||||||
$('#view_message').show();
|
|
||||||
$('.view-message').html(data.message_html);
|
$('.view-message').html(data.message_html);
|
||||||
initPostBBCode('.view-message');
|
initPostBBCode('.view-message');
|
||||||
var maxH = screen.height - 490;
|
var maxH = screen.height - 490;
|
||||||
$('.view-message').css({ maxHeight: maxH });
|
$('.view-message').css({ maxHeight: maxH });
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<div class="mrg_4" style="padding-left:2px;">
|
<div class="mrg_4" style="padding-left:2px;">
|
||||||
|
@ -148,10 +146,42 @@ ajax.callback.posts = function(data){
|
||||||
<div class="mrg_4 tCenter">
|
<div class="mrg_4 tCenter">
|
||||||
<div class="pad_4">{CAPTCHA_HTML}</div>
|
<div class="pad_4">{CAPTCHA_HTML}</div>
|
||||||
<input title="Alt+Enter" type="submit" name="preview" value="{L_PREVIEW}" />
|
<input title="Alt+Enter" type="submit" name="preview" value="{L_PREVIEW}" />
|
||||||
<input title="Ctrl+Enter" type="submit" name="post" class="bold" value="{L_SUBMIT}" />
|
<input onclick="submitted = true;" title="Ctrl+Enter" type="submit" name="post" class="bold" value="{L_SUBMIT}" />
|
||||||
<input type="button" value="Быстрый предпросмотр" onclick="ajax.exec({ action: 'posts', type: 'view_message', message: $('textarea.editor').val()});">
|
<input type="button" value="Быстрый предпросмотр" onclick="ajax.exec({ action: 'posts', type: 'view_message', message: $('textarea#message').val()});">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var submitted = false;
|
||||||
|
// Called before form submitting.
|
||||||
|
function checkForm(form) {
|
||||||
|
var formErrors = false;
|
||||||
|
if (form.message.value.length < 2) {
|
||||||
|
formErrors = "{L_EMPTY_MESSAGE}";
|
||||||
|
}
|
||||||
|
if (formErrors) {
|
||||||
|
setTimeout(function() { alert(formErrors) }, 100);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
<!-- IF QUICK_REPLY -->
|
||||||
|
<!-- IF $bb_cfg['use_ajax_posts'] && !IS_GUEST -->
|
||||||
|
if(form.message.value.length < 100 && submitted)
|
||||||
|
{
|
||||||
|
setTimeout(function() {
|
||||||
|
ajax.exec({
|
||||||
|
action: 'posts',
|
||||||
|
type: 'add',
|
||||||
|
message: $('textarea#message').val(),
|
||||||
|
topic_id: {TOPIC_ID}
|
||||||
|
});
|
||||||
|
}, 100);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
<!-- ENDIF -->
|
||||||
|
<!-- ENDIF -->
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var bbcode = new BBCode("message");
|
var bbcode = new BBCode("message");
|
||||||
var ctrl = "ctrl";
|
var ctrl = "ctrl";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue