Похожие темы 1.1.0

Добавляет вывод похожих тем при просмотре темы.

  1. Exile
    Совместимость:
    проверялся на совместимость
    Изменения в БД:
    не требуются
    Автор:
    _Xz_
    Общественное достояние:
    да
    Описание: добавляет вывод похожих тем при просмотре темы.
    Инструкция по установке:
    PHP:
    config.php
    +
    $bb_cfg['similar_topics']     = 5//Кол-во выводимых топиков если 0 мод отключен
    $bb_cfg['similar_title']      = 3//Кол-во слов для поиска
    $bb_cfg['similar_title_len']  = 3//Минимальная длина слов для поиска


    displaying_torrent.php
    ?
        if (!
    $dl_allowed)
    +
    перед
        
    if($bb_cfg['similar_topics'])
        {
            global 
    $title_match$datastore;

            if (!
    $forums $datastore->get('cat_forums'))
            {
                
    $datastore->update('cat_forums');
                
    $forums $datastore->get('cat_forums');
            }

            
    $title_match true;
            
    $search_match_topics_csv '';

            
    $row_title explode(" "$t_data['topic_title']);
            foreach(
    $row_title as $title)
            {
                if(isset(
    $i) && !($i $bb_cfg['similar_title'])) continue;

                if(
    mb_strlen($title'UTF-8') > $bb_cfg['similar_title_len'])
                {
                    
    $titles[] = $title;
                    
    $i++;
                }
            }
            if(empty(
    $titles)) $titles $row_title[1];

            
    $title_match_sql clean_text_match(join(' '$titles), truefalsefalse);
            
    $title_match_topics get_title_match_topics($title_match_sql, array());
            
    $search_match_topics_csv join(','$title_match_topics);

            if(
    $search_match_topics_csv)
            {
                
    $trash_forums $bb_cfg['trash_forum_id'] ? $bb_cfg['trash_forum_id'] : '0';

                
    $similar DB()->fetch_rowset("SELECT t.*, u.*, u2.username as last_username, u2.user_id as last_user_id,
                    u2.user_rank as last_user_rank, tor.*, ts.seeders, ts.leechers
                        FROM "
    BB_TOPICS ." t
                        LEFT JOIN "
    BB_USERS ." u ON(t.topic_poster          = u.user_id)
                        LEFT JOIN "
    BB_POSTS ." p ON(p.post_id               = t.topic_last_post_id)
                        LEFT JOIN "
    BB_USERS ." u2 ON(p.poster_id            = u2.user_id)
                        LEFT JOIN "
    BB_BT_TORRENTS ." tor ON(t.topic_id      = tor.topic_id)
                        LEFT JOIN "
    BB_BT_TRACKER_SNAP ." ts ON(tor.topic_id = ts.topic_id)
                    WHERE t.topic_id   IN(
    $search_match_topics_csv)
                        AND t.topic_id != 
    {$t_data['topic_id']}
                        AND t.topic_id = tor.topic_id
                    GROUP BY tor.topic_id
                    ORDER BY t.topic_last_post_time DESC
                    LIMIT 
    {$bb_cfg['similar_topics']}
                "
    );

                if(
    $similar)
                {
                    
    $page_cfg['use_tablesorter'] = true;

                    
    $template->assign_vars(array(
                        
    'SIMILAR_TOPICS' => true,
                    ));

                    foreach (
    $similar as $row)
                    {
                        
    $is_unread is_unread($row['topic_last_post_time'], $row['topic_id'], $row['forum_id']);

                        
    $template->assign_block_vars('postrow.attach.similar', array(
                            
    'POST_ID'           => $row['topic_first_post_id'],

                            
    'TOPIC_ID'          => $row['topic_id'],
                            
    'TOPIC_TITLE'       => wbr(str_short($row['topic_title'], 70)),
                            
    'FULL_TOPIC_TITLE'  => $row['topic_title'],

                            
    'FORUM_NAME'        => $forums['forum'][$row['forum_id']]['forum_name'],
                            
    'U_FORUM'           => FORUM_URL $row['forum_id'],

                            
    'REPLIES'           => $row['topic_replies'],
                            
    'VIEWS'             => $row['topic_views'],

                            
    'POSTER'            => profile_url($row),
                            
    'AUTHOR'            => profile_url(array('user_id' => $row['last_user_id'], 'username' => $row['last_username'], 'user_rank' => $row['last_user_rank'])),
                            
    'LAST_POST_TIME'    => bb_date($row['topic_last_post_time']),
                            
    'LAST_POST_ID'      => $row['topic_last_post_id'],

                            
    'IS_UNREAD'         => $is_unread,
                            
    'TOPIC_ICON'        => get_topic_icon($row$is_unread),
                            
    'PAGINATION'        => ($row['topic_status'] == TOPIC_MOVED) ? '' build_topic_pagination(TOPIC_URL $row['topic_id'], $row['topic_replies'], $bb_cfg['posts_per_page']),

                            
    'SEEDERS'           => ($row['seeders']) ? $row['seeders'] : 0,
                            
    'LEECHERS'          => ($row['leechers']) ? $row['leechers'] : 0,
                            
    'TOR_SIZE'          => humn_size($row['size']),
                            
    'COMPL_CNT'         => $row['complete_count'],
                            
    'ATTACH_ID'         => $row['attach_id'],
                            
    'TOR_FROZEN'        => (!IS_AM) ? isset($bb_cfg['tor_frozen'][$row['tor_status']]) : '',
                            
    'TOR_STATUS_ICON'   => $bb_cfg['tor_icons'][$row['tor_status']],
                            
    'TOR_STATUS_TEXT'   => $lang['TOR_STATUS_NAME'][$row['tor_status']],
                        ));
                    }
                }
            }
        }

    viewtopic_attach.tpl
    ?
    <!-- 
    END attach -->
    +
    перед
    <!-- IF SIMILAR_TOPICS -->
    <
    script type="text/javascript">
    ajax.openedPosts = {};

    ajax.view_post = function(post_idsrc) {
        if (!
    ajax.openedPosts[post_id]) {
            
    ajax.exec({
                
    action  'view_post',
                
    post_id post_id
            
    });
        }
        else {
            var 
    $post = $('#post_'+post_id);
            if (
    $post.is(':visible')) {
                
    $post.hide();
            }    else {
                
    $post.css({ display'' });
            }
        }
        $(
    src).toggleClass('unfolded2');
    };

    ajax.callback.view_post = function(data) {
        var 
    post_id data.post_id;
        var 
    $tor = $('#tor_'+post_id);
        
    window.location.href='#tor_'+post_id;
        $(
    '#post-row tr')
            .clone()
            .
    attr({ id'post_'+post_id })
            .
    find('div.post_body').html(data.post_html).end()
            .
    find('a.tLink').attr({ href: $('a.tLink'$tor).attr('href') }).end()
            .
    find('a.dLink').attr({ href: $('a.si-dl'$tor).attr('href') }).end()
            .
    insertAfter($tor)
        ;
        
    initPostBBCode('#post_'+post_id);
        var 
    maxH   screen.height 290;
        var 
    maxW   screen.width 60;
        var 
    $post  = $('div.post_similar_wrap', $('#post_'+post_id));
        var 
    $links = $('div.post_links', $('#post_'+post_id));
        
    $post.css({ maxWidthmaxWmaxHeightmaxH });
        
    $links.css({ maxWidthmaxW });
        if ($.
    browser.msie) {
            if (
    $post.height() > maxH) { $post.height(maxH); }
            if (
    $post.width() > maxW)  { $post.width(maxW); $links.width(maxW); }
        }
        
    ajax.openedPosts[post_id] = true;
    };
    </
    script>

    <
    style type="text/css">
    .
    post_similar_wrap border1px #A5AFB4 solid; margin: 8px 8px 6px; overflow: auto; }
    .post_links margin6px; }
    .
    unfolded2, .folded2 displayblock; }
    </
    style>

    <
    table id="post-row" style="display: none;">
    <
    tr>
        <
    td class="row2" colspan="8">
            <
    div class="post_similar_wrap row1">
                <
    div class="post_body pad_6"></div>
                <
    div class="clear"></div>
            </
    div>
            <
    div class="post_links med bold tCenter"><class="tLink">{L_OPEN_TOPIC}</a> &nbsp;&#0183;&nbsp; <a class="dLink">{L_DL_TORRENT}</a></div>
        
    </td>
    </
    tr>
    </
    table>
    <
    div class="spacer_10"></div>
    <
    table class="bordered w100">
    <
    th class="thHead gen clickable bold" style="font-size: 12px;" onclick="toggle_block('relesing'); return false;">Похожие темы</th>
    <
    tr id="relesing" style="display: none;">
    <
    td class="td2 row2 tCenter">
    <
    table width="100%" class="forumline tablesorter">
    <
    thead>
    <
    tr>
        <
    th class="{sorter: 'text'}"></th>
        <
    th class="{sorter: 'text'}"></th>
        <
    th width="25%" class="{sorter: 'text'}"><class="tbs-text">{L_FORUM}</b></th>
        <
    th width="75%" class="{sorter: 'text'}"><class="tbs-text">{L_TOPIC}</b></th>
        <
    th width="100" class="{sorter: 'text'}"><class="tbs-text">{L_AUTHOR}</b></th>
        <
    th class="{sorter: false}">{L_TORRENT}</th>
        <
    th class="{sorter: false}">{L_REPLIES_SHORT}</th>
        <
    th width="120" class="{sorter: 'text'} nowrap"><class="tbs-text">{L_LASTPOST}</b></th>
    </
    tr>
    </
    thead>
    <!-- 
    BEGIN similar -->
    <
    tr class="tCenter row1 med" id="tor_{postrow.attach.similar.POST_ID}">
        <
    td>
            <
    span style="display: none;">{postrow.attach.similar.TOPIC_ICON}</span>
            <
    img src="{postrow.attach.similar.TOPIC_ICON}">
        </
    td>
        <
    td class="row1 tCenter" title="{postrow.attach.similar.TOR_STATUS_TEXT}">{postrow.attach.similar.TOR_STATUS_ICON}</td>
        <
    td><class="med" href="{postrow.attach.similar.U_FORUM}" class="genmed">{postrow.attach.similar.FORUM_NAME}</a></td>
        <
    td class="tLeft">
            <
    a title="{postrow.attach.similar.FULL_TOPIC_TITLE}" class="folded2 tLink" onclick="ajax.view_post({postrow.attach.similar.POST_ID}, this); return false;" href="{TOPIC_URL}{postrow.attach.similar.TOPIC_ID}"><!-- IF postrow.attach.similar.TOR_FROZEN -->{postrow.attach.similar.TOPIC_TITLE}<!-- ELSE --><b>{postrow.attach.similar.TOPIC_TITLE}</b><!-- ENDIF --></a>
            <!-- IF 
    postrow.attach.similar.PAGINATION --><span class="topicPG">&nbsp;[{ICON_GOTOPOST}{L_GOTO_SHORT} {postrow.attach.similar.PAGINATION} ]</span><!-- ENDIF -->
        </
    td>
        <
    td><class="med" href="{postrow.attach.similar.POSTER_URL}">{postrow.attach.similar.POSTER}</a></td>
        <
    td class="tCenter nowrap" style="padding: 2px 4px;">
            <
    span class="seedmed" title="{L_SEEDERS}"><b>{postrow.attach.similar.SEEDERS}</b></span><span class="med"> | </span><span class="leechmed" title="{L_LEECHERS}"><b>{postrow.attach.similar.LEECHERS}</b></span>
            <
    div class="spacer_2"></div>
            <!-- IF 
    postrow.attach.similar.TOR_FROZEN -->{postrow.attach.similar.TOR_SIZE}<!-- ELSE --><a title="{L_DL_TORRENT}" href="{DOWNLOAD_URL}{postrow.attach.similar.ATTACH_ID}" class="small si-dl">{postrow.attach.similar.TOR_SIZE}</a><!-- ENDIF -->
        </
    td>
        <
    td class="tCenter small nowrap" style="padding: 3px 4px 2px;">
        <
    p>
            <
    span title="{L_REPLIES}">{postrow.attach.similar.REPLIES}</span>
            <
    span class="small"> | </span>
            <
    span title="{L_VIEWS}">{postrow.attach.similar.VIEWS}</span>
        </
    p>
        <
    p style="padding-top: 2px" class="med" title="{L_COMPLETED}">
            <
    b>{postrow.attach.similar.COMPL_CNT}</b>
        </
    p>
        </
    td>
        <
    td class="gensmall nowrap">
            <
    div>{postrow.attach.similar.LAST_POST_TIME}</div>
            <
    class="med" href="{postrow.attach.similar.AUTHOR_URL}">{postrow.attach.similar.AUTHOR}</a> <!-- IF postrow.attach.similar.IS_UNREAD --><a href="{TOPIC_URL}{postrow.attach.similar.TOPIC_ID}{NEWEST_URL}">{ICON_NEWEST_REPLY}</a><!-- ELSE -->
            <
    a href="{POST_URL}{postrow.attach.similar.LAST_POST_ID}#{postrow.attach.similar.LAST_POST_ID}">{ICON_LATEST_REPLY}</a><!-- ENDIF -->
        </
    td>
    </
    tr>
    <!-- 
    END similar -->
    </
    table>
        </
    td>
        </
    tr>
        </
    table>
    <
    div class="spacer_10"></div>
    <!-- ENDIF -->

    Изображения

    1. 12343.png
    2. 234343.png

Последние обнoвления

  1. Обновление 1.1.0