PHP:
//################### Показ всех комментариев ###################//
case "allcomment":
NoAjaxQuery();
$note_id = intval($_POST['note_id']);
$comm_num = intval($_POST['comm_num']);
if($comm_num > 10 && $note_id){
$limit = $comm_num-10;
$sql_ = $db->super_query("SELECT SQL_CALC_FOUND_ROWS tb1.note_id, from_user_id, textcom, add_date, tb2.user_search_pref, user_photo, user_last_visit, tb3.owner_user_id FROM `".PREFIX."_notes_comments` tb1, `".PREFIX."_users` tb2, `".PREFIX."_notes` tb3 WHERE tb1.note_id = '{$note_id}' AND tb1.from_user_id = tb2.user_id AND tb1.note_id = tb3.id ORDER by `add_date` ASC LIMIT 0, {$limit}", 1);
$tpl->load_template('notes/comment.tpl');
foreach($sql_ as $row_comm){
if($row_comm['user_photo'])
$tpl->set('{ava}', $config['home_url'].'uploads/users/'.$row_comm['from_user_id'].'/50_'.$row_comm['user_photo']);
else
$tpl->set('{ava}', '{theme}/images/no_ava_50.png');
if($row_comm['user_last_visit'] >= $online_time)
$tpl->set('{online}', $lang['online']);
else
$tpl->set('{online}', '');
megaDate(strtotime($row_comm['date']));
if($row_comm['from_user_id'] == $user_id || $row_comm['owner_user_id'] == $user_id){
$tpl->set('[owner]', '');
$tpl->set('[/owner]', '');
} else
$tpl->set_block("'\\[owner\\](.*?)\\[/owner\\]'si","");
$tpl->set('{author}', $row_comm['user_search_pref']);
$tpl->set('{uid}', $row_comm['from_user_id']);
$tpl->set('{id}', $row_comm['id']);
$tpl->set('{comment}', stripslashes($row_comm['text']));
$tpl->compile('content');
}
AjaxTpl();
}
die();
break;
//################### Просмотр полной заметки ###################//
case "view":
$note_id = intval($_GET['note_id']);
//SQL Запрос
$row = $db->super_query("SELECT tb1.title, owner_user_id, full_text, comm_num, date, tb2.user_search_pref FROM `".PREFIX."_notes` tb1, `".PREFIX."_users` tb2 WHERE id = '{$note_id}' AND tb1.owner_user_id = tb2.user_id");
//ЧС
$CheckBlackList = CheckBlackList($row['owner_user_id']);
if(!$CheckBlackList){
if($row){
//Формирование мета титле и спидбара
$author_info = explode(' ', $row['user_search_pref']);
$user_speedbar = $lang['notes_view'];
$metatags['title'] = $lang['notes_view'];
//Загруажем head заметок
$tpl->load_template('notes/head.tpl');
$tpl->set('[view]', '');
$tpl->set('[/view]', '');
$tpl->set('{user-id}', $row['owner_user_id']);
$tpl->set('{note-id}', $note_id);
if($row['owner_user_id'] == $user_id){
$tpl->set('[owner]', '');
$tpl->set('[/owner]', '');
$tpl->set_block("'\\[not-owner\\](.*?)\\[/not-owner\\]'si","");
} else {
$tpl->set('[not-owner]', '');
$tpl->set('[/not-owner]', '');
$tpl->set_block("'\\[owner\\](.*?)\\[/owner\\]'si","");
}
$tpl->set('{name}', gramatikName($author_info[0]));
$tpl->set_block("'\\[add\\](.*?)\\[/add\\]'si","");
$tpl->set_block("'\\[edit\\](.*?)\\[/edit\\]'si","");
$tpl->set_block("'\\[all\\](.*?)\\[/all\\]'si","");
$tpl->compile('info');
//Загружаем шаблон вывода полного просомтра заметки
$tpl->load_template('notes/full.tpl');
$tpl->set('{note-id}', $note_id);
$tpl->set('{title}', stripslashes($row['title']));
$tpl->set('{full-text}', stripslashes($row['full_text']));
$tpl->set('{name}', $row['user_search_pref']);
$tpl->set('{user-id}', $row['owner_user_id']);
$date_comm = strtotime($row['date']);
if(date('Y-m-d', $date_comm) == date('Y-m-d', $yesterday_date))
$tpl->set('{date}', langdate('сегодня в H:i', $date_comm));
elseif(date('Y-m-d', $date_comm) == date('Y-m-d', ($yesterday_date-84600)))
$tpl->set('{date}', langdate('вчера в H:i', $date_comm));
else
$tpl->set('{date}', langdate('j F Y в H:i', $date_comm));
if($row['owner_user_id'] == $user_id){
$tpl->set('[owner]', '');
$tpl->set('[/owner]', '');
} else
$tpl->set_block("'\\[owner\\](.*?)\\[/owner\\]'si","");
if($row['comm_num'])
$tpl->set('{comm-num}', $row['comm_num'].' '.gram_record($row['comm_num'], 'comments'));
else
$tpl->set('{comm-num}', $lang['note_no_comments']);
if($row['comm_num'] > 10){
$tpl->set('[all-comm]', '');
$tpl->set('[/all-comm]', '');
} else
$tpl->set_block("'\\[all-comm\\](.*?)\\[/all-comm\\]'si","");
$tpl->set('{prev-text-comm}', gram_record(($row['comm_num']-10), 'prev').' '.($row['comm_num']-10).' '.gram_record(($row['comm_num']-10), 'comments'));
$tpl->set('{num}', $row['comm_num']);
$tpl->compile('content');
$tpl->result['content'] = str_replace('{note-id}', $note_id, $tpl->result['content']);
//Выводи комменты, если они есть
if($row['comm_num']){
if($row['comm_num'] >= 10)
$start_limit = $row['comm_num']-10;
else
$start_limit = 0;
$sql_ = $db->super_query("SELECT SQL_CALC_FOUND_ROWS tb1.note_id, from_user_id, textcom, add_date, tb2.user_search_pref, user_photo, user_last_visit FROM `".PREFIX."_notes_comments` tb1, `".PREFIX."_users` tb2 WHERE tb1.note_id = '{$note_id}' AND tb1.from_user_id = tb2.user_id ORDER by `add_date` ASC LIMIT {$start_limit}, {$row['comm_num']}", 1);
$tpl->load_template('notes/comment.tpl');
foreach($sql_ as $row_comm){
if($row_comm['user_photo'])
$tpl->set('{ava}', $config['home_url'].'uploads/users/'.$row_comm['from_user_id'].'/50_'.$row_comm['user_photo']);
else
$tpl->set('{ava}', '{theme}/images/no_ava_50.png');
if($row_comm['user_last_visit'] >= $online_time)
$tpl->set('{online}', $lang['online']);
else
$tpl->set('{online}', '');
megaDate(strtotime($row_comm['add_date']));
if($row_comm['from_user_id'] == $user_id || $row['owner_user_id'] == $user_id){
$tpl->set('[owner]', '');
$tpl->set('[/owner]', '');
} else
$tpl->set_block("'\\[owner\\](.*?)\\[/owner\\]'si","");
$tpl->set('{author}', $row_comm['user_search_pref']);
$tpl->set('{uid}', $row_comm['from_user_id']);
$tpl->set('{id}', $row_comm['id']);
$tpl->set('{comment}', stripslashes($row_comm['text']));
$tpl->compile('content');
}
}
//Загружаем форму добавления комментов
во общем полный ужас)