############################################################## ## Название дополнения: Вывод пользователей лайкнувших пост (ajax) ## Автор дополнения: Dredd < ICQ: 616733573 > ## Описание дополнения: Всё понятно из названия. ## ## Уровень инсталяции: простой ## Время установки: 5 минут ############################################################## # #-----[ OPEN ]------------------------------------------ # ajax.php # #-----[ FIND ]------------------------------------------ # 'like' => array('user'), # #-----[ AFTER ADD ]------------------------------------- # 'list_likes' => array('user'), 'likes_popup' => array('user'), # #-----[ FIND ]------------------------------------------ # function like() { require(AJAX_DIR .'like.php'); } # #-----[ AFTER ADD ]------------------------------------- # function list_likes() { $post_id = (int) $this->request['post_id']; if (!$likes = CACHE('bb_cache')->get('list_like_['.$post_id.']')) { $likes = DB()->fetch_rowset("SELECT l.*, u.* FROM bb_like l, ".BB_USERS." u WHERE l.post_id = $post_id AND l.user_id = u.user_id ORDER BY u.username ASC LIMIT 3"); CACHE('bb_cache')->set('list_like_['.$post_id.']', $likes); } $html = (!$likes) ? ' ' : ''; $html .= '
'; $html .= '
'; $html .= ''; foreach($likes as $row) { $html .= ''.profile_url($row).', '; } $html .= (!$likes) ? 'Это сообщение никому не нравится.
' : 'и другим нравится это. '; $this->response['post_id'] = $post_id; $this->response['html'] = $html; } function likes_popup() { global $bb_cfg; $post_id = (int) $this->request['post_id']; if (!$popup = CACHE('bb_cache')->get('likes_popup_['.$post_id.']')) { $popup = DB()->fetch_rowset("SELECT l.*, u.* FROM bb_like l, ".BB_USERS." u WHERE l.post_id = $post_id AND l.user_id = u.user_id ORDER BY u.username ASC"); CACHE('bb_cache')->set('likes_popup_['.$post_id.']', $popup); } $html = '

Пользователи, которым нравится сообщение #'.$post_id.'

    '; foreach($popup as $row) { // Gender switch($row['user_gender']) { case MALE: $gender = 'Мужской'; break; case FEMALE: $gender = 'Женский'; break; default: $gender = ''; break; } $html .= '
  1. '; $html .= ''. str_replace(''; $html .= '
    '; $html .= '

    '.profile_url($row).'

    '; $html .= '
    '; $html .= '
    '.($bb_cfg['gender'] && $gender) ? $gender : ''.'
    '; $html .= '
    Сообщения:
    '.$row['user_posts'].'
    Сид-бонусы:
    '.$row['user_points'].'
    '; $html .= '
  2. '; } $html .= '
'; $this->response['post_id'] = $post_id; $this->response['html'] = $html; } # #-----[ OPEN ]------------------------------------------ # templates/default/viewtopic.tpl # #-----[ FIND ]------------------------------------------ # ajax.callback.like = function (data) { $('#like_'+ data.post_id).html(data.html); } # #-----[ AFTER ADD ]------------------------------------- # ajax.list_likes = function (post_id) { ajax.exec({ action: 'list_likes', post_id: post_id }); }; ajax.callback.list_likes = function (data) { $('#likes-post-'+ data.post_id).html(data.html); } ajax.likes_popup = function (post_id) { ajax.exec({ action: 'likes_popup', post_id: post_id }); }; ajax.callback.likes_popup = function (data) { $('#likes-popup-'+ data.post_id).html(data.html); } # #-----[ FIND ]------------------------------------------ #
Мне нравится  {postrow.LIKE}
# #-----[ AFTER ADD ]------------------------------------- #   

Лайкнули

# #-----[ OPEN ]------------------------------------------ # templates/default/css/main.css # #-----[ END INSERT ]------------------------------------- # .likesSummary { padding: 5px; margin-top: 10px; border: 1px solid #D7EDFC; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; -khtml-border-radius: 5px; } .likesSummary { overflow: hidden; zoom: 1; font-size: 11px; } .LikeText { float: left; } .likesSummary { font-size: 11px; } .secondaryContent { background: #F0F7FC url('http://torrentpier.me/styles/default/xenforo/gradients/category-23px-light.png') repeat-x top; padding: 10px; border-bottom: 1px solid #D7EDFC; } .xenOverlay { display: none; width: 690px; z-index: 10000; } .section { margin: 10px auto; } .section div{ max-height: 350px; overflow: auto; } .xenOverlay > .section, .xenOverlay > .sectionMain { background: transparent; margin: 0px; } .xenOverlay .section, .xenOverlay .sectionMain { border: 20px solid rgba(3, 42, 70, 0.506); border-radius: 20px; box-shadow: 0px 25px 50px rgba(0, 0, 0, 0.506); padding: 0px; } .xenOverlay .section .heading, .xenOverlay .sectionMain .heading { border-radius: 0; margin-bottom: 0px; } .heading { color: #F0F7FC; margin: 0px; } .heading, .xenForm .formHeader { background-color: #65A5D1; border-bottom: 1px solid #176093; border-top-left-radius: 5px; border-top-right-radius: 5px; color: #F0F7FC; font-size: 11pt; font-weight: 700; margin-bottom: 3px; padding: 5px 10px; } .xenOverlay .section .subHeading, .xenOverlay .sectionMain .subHeading { margin-top: 0px; } .subHeading { background: url("http://torrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.su/styles/default/xenforo/gradients/category-23px-light.png") 50% 0% repeat-x #F9D9B0; border-bottom: 1px solid #F9BC6D; border-top: 1px solid #F9D9B0; color: #6D3F03; font-size: 11px; margin: 3px auto 0px; padding: 5px 10px; } .pairsInline dl, .pairsInline dt, .pairsInline dd { display: inline; } .pairs dt, .pairsInline dt, .pairsJustified dt { color: #969696; } .pairsInline dl, .pairsInline dt, .pairsInline dd { display: inline; } dl, dt, dd, ol, li { margin: 0px; padding: 0px;} .subHeading a { color: #6D3F03; font-size: 11px; line-height: 1.27; } .xenOverlay .overlayScroll { max-height: 400px; overflow: auto; } .memberListItem { overflow: hidden; } .primaryContent { background-color: #FCFCFF; border-bottom: 1px solid #D7EDFC; padding: 10px; } .memberListItem .avatars, .memberListItem .icon { float: left; } .avatars img, .avatars .img { background-color: #FCFCFF; border: 1px solid #A5CAE4; border-radius: 4px; padding: 2px; } .avatars .img { background-position: 2px 2px; background-repeat: no-repeat; display: block; overflow: hidden; text-indent: 1000px; white-space: nowrap; word-wrap: normal; } .avatars .img.s { height: 48px; width: 48px; } .memberListItem .extra { float: right; font-size: 11px; } .memberListItem .member { margin-left: 65px; } .memberListItem h3.username { font-size: 13pt; font-weight: 700; margin-bottom: 3px; } .memberListItem .userInfo { font-size: 11px; margin-bottom: 3px; } .dimmed, a.dimmed, .dimmed a {color: #646464; } .sectionFooter { overflow: hidden; } .sectionFooter { background: url("http://torrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.sutorrentpier.su/styles/default/xenforo/gradients/category-23px-light.png") 50% 0% repeat-x #D7EDFC; border-bottom: 1px solid #A5CAE4; color: #65A5D1; font-size: 11px; line-height: 16px; padding: 4px 10px; } .xenOverlay .overlayOnly { display: block !important; } .xenOverlay .sectionFooter .button, .xenOverlay .sectionFooter .buttonContainer { float: right; min-width: 75px; } .button.primary { background-color: #A5CAE4; } .button { background: url("http://torrentpier.su/styles/default/xenforo/gradients/form-button-white-25px.png") 50% 0% repeat-x #DCDCEB; border-bottom: 1px solid #B3B3BD; border-left: 1px solid #DDDDEB; border-radius: 7px; border-right: 1px solid #DDDDEB; border-top: 1px solid #FFFFFF; box-shadow: 0px 1px 4px 0px #C8C8D2; box-sizing: border-box; color: #000000; cursor: pointer; display: inline-block; font-family: "Calibri", "Trebuchet MS", "Verdana", "Geneva", "Arial", "Helvetica", sans-serif; font-size: 12px; font-style: normal; height: 23px; line-height: 23px; outline: medium none currentColor; padding: 0px 6px; text-align: center; text-shadow: 0px 0px 0px transparent, 0px -1px 2px white; }