Autor Tópico: Smf 2.0.x Jquery Top10  (Lida 8061 vezes)

0 Membros e 1 Visitante estão a ver este tópico.

Offline candidosa2

  • Suporte Tecnico
  • Fundador
  • *
  • Mensagens: 5073
  • Rank: 1658
  • Sexo: Masculino
  • Suporte
    • Hosting Moçambique
Smf 2.0.x Jquery Top10
« em: 20 de Dezembro de 2010, 04:33 »
Aqui estão as imagens demo porque ainda nao tem link com o demo







Boardindex.php

Código: [Seleccione]
loadTemplate('BoardIndex');
Código: [Seleccione]
loadTemplate('BoardIndex');
TopStats();

Código: [Seleccione]
?>
Código: [Seleccione]
// Full Top 10
function TopStats()
{
   global $context, $smcFunc, $txt, $db_prefix, $scripturl, $modSettings;
         // Newest members top 10
   $members_result =  $smcFunc['db_query']('', '
      SELECT id_member, real_name, posts
      FROM {db_prefix}members
      ORDER BY id_member DESC
      LIMIT 10',
      array(
      )
   );
   $context['new_members'] = array();
   while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
   {
      $context['new_members'][] = array(
         'name' => $row_members['real_name'],
         'id' => $row_members['id_member'],
         'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
         'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
      );
   }
   $smcFunc['db_free_result']($members_result);


// karma
   
    //  Top 10 karma
   $members_result = $smcFunc['db_query']('', '
      SELECT id_member, real_name, karma_good
      FROM {db_prefix}members
      ORDER BY karma_good DESC
      LIMIT 10');
   $context['repkarma'] = array();
   while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
   {
      $context['repkarma'][] = array(
         'name' => $row_members['real_name'],
         'id' => $row_members['id_member'],
         'karma' => $row_members['karma_good'],
         'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
         'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
      );
   }
   $smcFunc['db_free_result']($members_result);

   if (empty($context['repkarma']))
      return;

// karma finished

   //// Newest members top 10 Finish
     // Poster top 10.
    $members_result = $smcFunc['db_query']('', '
        SELECT id_member, real_name, posts
        FROM {db_prefix}members
        WHERE posts > {int:no_posts}
        ORDER BY posts DESC
        LIMIT 10',
        array(
            'no_posts' => 0,
        )
    );
    $context['top_posters'] = array();
    $max_num_posts = 1;
    $context['MemberColor_ID_MEMBER'] = array();
    while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
    {
        $context['top_posters'][] = array(
            'name' => $row_members['real_name'],
            'id' => $row_members['id_member'],
            'num_posts' => $row_members['posts'],
            'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
            'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
        );

        if ($max_num_posts < $row_members['posts'])
            $max_num_posts = $row_members['posts'];
        if (!empty($modSettings['MemberColorStats']) && !empty($row_members['id_member']))
            $context['MemberColor_ID_MEMBER'][$row_members['id_member']] = $row_members['id_member'];
    }
    $smcFunc['db_free_result']($members_result);

    foreach ($context['top_posters'] as $i => $poster)
    {
        $context['top_posters'][$i]['post_percent'] = round(($poster['num_posts'] * 100) / $max_num_posts);
        $context['top_posters'][$i]['num_posts'] = comma_format($context['top_posters'][$i]['num_posts']);
    }

    // Board top 10.
    $boards_result = $smcFunc['db_query']('', '
        SELECT id_board, name, num_posts
        FROM {db_prefix}boards AS b
        WHERE {query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
            AND b.id_board != {int:recycle_board}' : '') . '
            AND b.redirect = {string:blank_redirect}
        ORDER BY num_posts DESC
        LIMIT 10',
        array(
            'recycle_board' => $modSettings['recycle_board'],
            'blank_redirect' => '',
        )
    );
    $context['top_boards'] = array();
    $max_num_posts = 1;
    while ($row_board = $smcFunc['db_fetch_assoc']($boards_result))
    {
        $context['top_boards'][] = array(
            'id' => $row_board['id_board'],
            'name' => $row_board['name'],
            'num_posts' => $row_board['num_posts'],
            'href' => $scripturl . '?board=' . $row_board['id_board'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>'
        );

        if ($max_num_posts < $row_board['num_posts'])
            $max_num_posts = $row_board['num_posts'];
    }
    $smcFunc['db_free_result']($boards_result);

    foreach ($context['top_boards'] as $i => $board)
    {
        $context['top_boards'][$i]['post_percent'] = round(($board['num_posts'] * 100) / $max_num_posts);
        $context['top_boards'][$i]['num_posts'] = comma_format($context['top_boards'][$i]['num_posts']);
    }
        // Are you on a larger forum?  If so, let's try to limit the number of topics we search through.
    if ($modSettings['totalMessages'] > 100000)
    {
        $request = $smcFunc['db_query']('', '
            SELECT id_topic
            FROM {db_prefix}topics
            WHERE num_replies != {int:no_replies}' . ($modSettings['postmod_active'] ? '
                AND approved = {int:is_approved}' : '') . '
            ORDER BY num_replies DESC
            LIMIT 100',
            array(
                'no_replies' => 0,
                'is_approved' => 1,
            )
        );
        $topic_ids = array();
        while ($row = $smcFunc['db_fetch_assoc']($request))
            $topic_ids[] = $row['id_topic'];
        $smcFunc['db_free_result']($request);
    }
    else
        $topic_ids = array();
    // Topic views top 10.
    $topic_view_result = $smcFunc['db_query']('', '
        SELECT m.subject, t.num_views, t.id_board, t.id_topic, b.name
        FROM {db_prefix}topics AS t
            INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
            INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
            AND b.id_board != {int:recycle_board}' : '') . ')
        WHERE {query_see_board}' . (!empty($topic_ids) ? '
            AND t.id_topic IN ({array_int:topic_list})' : ($modSettings['postmod_active'] ? '
            AND t.approved = {int:is_approved}' : '')) . '
        ORDER BY t.num_views DESC
        LIMIT 10',
        array(
            'topic_list' => $topic_ids,
            'recycle_board' => $modSettings['recycle_board'],
            'is_approved' => 1,
        )
    );
    $context['top_topics_views'] = array();
    $max_num_views = 1;
    while ($row_topic_views = $smcFunc['db_fetch_assoc']($topic_view_result))
    {
        censorText($row_topic_views['subject']);
$row_topic_views['subject'] = shorten_subject($row_topic_views['subject'], 20);
        $context['top_topics_views'][] = array(
            'id' => $row_topic_views['id_topic'],
            'board' => array(
                'id' => $row_topic_views['id_board'],
                'name' => $row_topic_views['name'],
                'href' => $scripturl . '?board=' . $row_topic_views['id_board'] . '.0',
                'link' => '<a href="' . $scripturl . '?board=' . $row_topic_views['id_board'] . '.0">' . $row_topic_views['name'] . '</a>'
            ),
            'subject' => $row_topic_views['subject'],
            'num_views' => $row_topic_views['num_views'],
            'href' => $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0',
            'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>'
        );

        if ($max_num_views < $row_topic_views['num_views'])
            $max_num_views = $row_topic_views['num_views'];
    }
    $smcFunc['db_free_result']($topic_view_result);

    foreach ($context['top_topics_views'] as $i => $topic)
    {
        $context['top_topics_views'][$i]['post_percent'] = round(($topic['num_views'] * 100) / $max_num_views);
        $context['top_topics_views'][$i]['num_views'] = comma_format($context['top_topics_views'][$i]['num_views']);
    }

    // Try to cache this when possible, because it's a little unavoidably slow.
    if (($members = cache_get_data('stats_top_starters', 360)) == null)
    {
        $request = $smcFunc['db_query']('', '
            SELECT id_member_started, COUNT(*) AS hits
            FROM {db_prefix}topics' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
            WHERE id_board != {int:recycle_board}' : '') . '
            GROUP BY id_member_started
            ORDER BY hits DESC
            LIMIT 10',
            array(
                'recycle_board' => $modSettings['recycle_board'],
            )
        );
        $members = array();
        while ($row = $smcFunc['db_fetch_assoc']($request))
            $members[$row['id_member_started']] = $row['hits'];
        $smcFunc['db_free_result']($request);

        cache_put_data('stats_top_starters', $members, 360);
    }

    if (empty($members))
        $members = array(0 => 0);

    // Topic poster top 10.
    $members_result = $smcFunc['db_query']('', '
        SELECT id_member, real_name
        FROM {db_prefix}members
        WHERE id_member IN ({array_int:member_list})
        ORDER BY FIND_IN_SET(id_member, {string:top_topic_posters})
        LIMIT 10',
        array(
            'member_list' => array_keys($members),
            'top_topic_posters' => implode(',', array_keys($members)),
        )
    );
    $context['top_starters'] = array();
    $max_num_topics = 1;
    while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
    {
        $context['top_starters'][] = array(
            'name' => $row_members['real_name'],
            'id' => $row_members['id_member'],
            'num_topics' => $members[$row_members['id_member']],
            'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
            'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
        );

        if ($max_num_topics < $members[$row_members['id_member']])
            $max_num_topics = $members[$row_members['id_member']];
        if (!empty($modSettings['MemberColorStats']))
            $context['MemberColor_ID_MEMBER'][$row_members['id_member']] = $row_members['id_member'];
    }
    $smcFunc['db_free_result']($members_result);

    foreach ($context['top_starters'] as $i => $topic)
    {
        $context['top_starters'][$i]['post_percent'] = round(($topic['num_topics'] * 100) / $max_num_topics);
        $context['top_starters'][$i]['num_topics'] = comma_format($context['top_starters'][$i]['num_topics']);
    }
   
    //Yeah baby give me some colors =).
   if (!empty($modSettings['MemberColorLinkInstalled']) && !empty($context['MemberColor_ID_MEMBER'])) {
      $colorDatas = load_onlineColors($context['MemberColor_ID_MEMBER']);
      $cmemcolid = null;
      if (!empty($modSettings['MemberColorStats'])) {
         // First the Top Posters =)
         foreach($context['top_posters'] as $key => $value) {
            $cmemcolid = $context['top_posters'][$key]['id'];
            if(!empty($colorDatas[$cmemcolid]['colored_link']))
               $context['top_posters'][$key]['link'] = $colorDatas[$cmemcolid]['colored_link'];
         }
         // First the Top Starter =)   
         foreach($context['top_starters'] as $key => $value) {
            $cmemcolid = $context['top_starters'][$key]['id'];
            if(!empty($colorDatas[$cmemcolid]['colored_link']))
               $context['top_starters'][$key]['link'] = $colorDatas[$cmemcolid]['colored_link'];
         }
         // First the New Members =)   
         foreach($context['new_members'] as $key => $value) {
            $cmemcolid = $context['new_members'][$key]['id'];
            if(!empty($colorDatas[$cmemcolid]['colored_link']))
               $context['new_members'][$key]['link'] = $colorDatas[$cmemcolid]['colored_link'];
         }
         // First the Top Karma =)   
         foreach($context['repkarma'] as $key => $value) {
            $cmemcolid = $context['repkarma'][$key]['id'];
            if(!empty($colorDatas[$cmemcolid]['colored_link']))
               $context['repkarma'][$key]['link'] = $colorDatas[$cmemcolid]['colored_link'];
         }
      }
      if (!empty($modSettings['latestMember']) && !empty($modSettings['MemberColorLatestMember'])) {
         if(!empty($colorDatas[$modSettings['latestMember']]['colored_link']))
            $context['latest_member']['link'] = $colorDatas[$modSettings['latestMember']]['colored_link'];
      }
   }
}


index.template.php

Código: [Seleccione]
</head>
Código: [Seleccione]
<script src="', $settings['theme_url'], '/jquery-1.2.2.pack.js" type="text/javascript"></script>
<script type="text/javascript">

    $(document).ready(function(){
         
        $(".contentBox:not(:first)").hide();
        $("#tabs li a:first").addClass("active");
       
        $("#tabs li a").click(function(){
       
            var indexTabLink = $("#tabs li a").index(this);
           
            $(".contentBox").hide().eq(indexTabLink).show();
            $("#tabs li a").removeClass("active").eq(indexTabLink).addClass("active");
           
        });
       
       
    });
   
</script>


index.css

Código: [Seleccione]
#tabs li {display:inline;}

#tabs li a {
    color:#080808;
    text-decoration:none;
    background:#f1f1f1 url(../images/bgr_normal.png) repeat-x top left;
    border:1px solid #c4c4c4;
    display:block;
    float:left;
    padding:5px;
    margin-right:10px
}

#tabs li a.active {
    background-image:url(../images/bgr_active.png);
    border:1px solid #c4c4c4
}

.contentBox {
    width:100%;
    height:auto;
    border:1px solid #c4c4c4;
    margin-top:20px}

.contentBox h1 {margin:10px}


Boardindex.template.php

Código: [Seleccione]
echo '
    <div id="boardindex_table">
        <table class="table_list">';


Código: [Seleccione]
echo'
<div style="height:1px;"><>
<ul id="tabs" style="margin-left:0px;padding-left:0px;">
<li><a href="javascript:void(0)" title="Postes Recentes">Postes Recentes</a></li>
<li><a href="javascript:void(0)" title="Mensagem e Karma">Mensagem / Karma</a></li>
<li><a href="javascript:void(0)" title="10 Assunto Tópico Quente">Top10 & Topico mais Popular</a></li>
<li><a href="javascript:void(0)" title="Utilizadores Online">Utilizador OnLine</a></li>           
<li><a href="javascript:void(0)" title="Estatísticas do Fórum">Estatísticas</a></li>
</ul>
<div style="height:10px;"><>
<div class="windowbg2 contentBox">
';
//Son İletiler Burdan
echo'
<table width="100%">
<tr>
<td class="catbg" width="55%">
Tópico
</td>
<td class="catbg" width="20%">
Enviado
</td>
<td class="catbg" width="25%">
Horas
</td>
</tr>
</table>
';
echo'
<table class="windowbg2" width="100%">
<tr>
<td width="55%">
';
if (!empty($context['latest_posts']))
foreach ($context['latest_posts'] as $post)
echo'
<img src="', $settings['images_url'], '/konubasi.gif" style="margin-right:3px;" alt="" border="0" /><a href="',$post['href'],'">', $post['short_subject'], '</a><br />
';
echo'
</td>
<td width="20%">
';
if (!empty($context['latest_posts']))
foreach ($context['latest_posts'] as $post)
echo'
<img src="', $settings['images_url'], '/uyebasi.gif" style="margin-right:3px;" alt="" border="0" />', $post['poster']['link'],'<br />
';
echo'
</td>
<td width="25%">
';
if (!empty($context['latest_posts']))
foreach ($context['latest_posts'] as $post)
echo'
<img src="', $settings['images_url'], '/tarihbasi.gif" style="margin-right:3px;" alt="" border="0" />', $post['time'], '<br />
';
echo'
</td>
</tr>
</table>
';
// Buraya Kadar
echo'
<>
<div class="windowbg2 contentBox">
';
//Top10 Konu - Mesaj Burdan
echo'
<table width="100%">
<tr>
<td class="catbg" width="30%">
Top Postes por Membros
</td>
<td class="catbg" width="20%">
Mensagem
</td>
<td width="2px"></td>
<td class="catbg" width="30%">
Área dos membros com melhor Karma
</td>
<td class="catbg" width="20%">
Karma
</td>
</tr>
</table>
';
echo'
<table class="windowbg2" width="100%">
<tr>
';
echo'
<td width="30%">
';
foreach ($context['top_posters'] as $poster)
{
echo'
<img src="', $settings['images_url'], '/kategoribasi.gif" style="margin-right:3px;" alt="" border="0" />', $poster['link'], '<br />
';
}
echo'
</td>
<td width="20%">';
foreach ($context['top_posters'] as $poster)
{
echo'
<img src="', $settings['images_url'], '/uyebasi.gif" style="margin-right:3px;" alt="" border="0" />', $poster['num_posts'], '<br />
';
}
echo'
</td>
';
echo'
<td width="2px"></td>
';
echo'
<td width="30%">';
foreach ($context['repkarma'] as $member)
{
echo'
<img src="', $settings['images_url'], '/kategoribasi.gif" style="margin-right:3px;" alt="" border="0" />', $member['link'], '<br />
';
}
echo'
</td>
<td width="20%">
';
foreach ($context['repkarma'] as $member)
{
echo'
<img src="', $settings['images_url'], '/uyebasi.gif" style="margin-right:3px;" alt="" border="0" />', $member['karma'], '<br />
';
}
echo'
</td>
';
echo'
</tr>
</table>
';
//Buraya Kadar
echo'
<>
<div class="contentBox">
';
//Popüler Konular Burdan
echo'
<table width="100%">
<tr>
<td class="catbg" width="30%">
Quem iniciou o Tópico
</td>
<td class="catbg" width="20%">
Tópico
</td>
<td width="2px"></td>
<td class="catbg" width="30%">
Tópicos mais populares
</td>
<td class="catbg" width="20%">
Vistos
</td>
</tr>
</table>
';

echo'
<table class="windowbg2" width="100%">
<tr>
<td width="30%" valign="top">
';
foreach ($context['top_starters'] as $poster)
echo'
<img src="', $settings['images_url'], '/kategoribasi.gif" style="margin-right:3px;" alt="" border="0" />', $poster['link'], '<br />
';
echo'
</td>
<td width="20%" valign="top">
';
foreach ($context['top_starters'] as $poster)
echo'
<img src="', $settings['images_url'], '/uyebasi.gif" style="margin-right:3px;" alt="" border="0" />', $poster['num_topics'], '<br />
';
echo'
</td>
<td width="30%">
';
foreach ($context['top_topics_views'] as $topic)
echo'
<img src="', $settings['images_url'], '/kategoribasi.gif" style="margin-right:3px;" alt="" border="0" />', $topic['link'], '<br />
';
echo'
</td>
<td width="20%">
';
foreach ($context['top_topics_views'] as $topic)
echo'
<img src="', $settings['images_url'], '/uyebasi.gif" style="margin-right:3px;" alt="" border="0" />', $topic['num_views'], '<br />
';
echo'
</td>
</tr>
</table>
';

//Buraya Kadar
echo'
<>
<div class="contentBox">
';
//Online Üyeler Burdan
echo'
<table width="100%">
<tr>
<td class="catbg" width="100%">
Postes feitos Por: ' . $context['num_users_online'], ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'],' ', $context['show_who'] ? '' : '', $context['num_guests'], ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], '';
    // Handle hidden users and buddies.
    $bracketList = array();
    if ($context['show_buddies'])
        $bracketList[] = $context['num_buddies'] . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
    if (!empty($context['num_spiders']))
        $bracketList[] = $context['num_spiders'] . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
    if (!empty($context['num_users_hidden']))
        $bracketList[] = $context['num_users_hidden'] . ' ' . $txt['hidden'];
    if (!empty($bracketList))
        echo ' (' . implode(', ', $bracketList) . ')';
echo'
</td>
</tr>
</table>
';
echo'
<table class="windowbg2" width="100%">
<tr>
';
echo'<td width="100%">';
if (!empty($context['users_online']))
{
echo'', implode(', ', $context['list_users_online']);
}
echo'
</td>
</tr>
</table>
';
//Buraya Kadar
echo'
<>
<div class="contentBox">






';
//İstatistikler Burdan
echo'
<table width="100%">
<tr>
<td class="catbg" width="100%">
',$context['forum_name_html_safe'],' Estatísticas
</td>
</tr>
</table>
';
echo'
<table class="windowbg2" width="100%">
<tr>
<td width="50%">
Tópicos no Total: ', $context['common_stats']['total_topics'], '<br />
Postes no Total: ', $context['common_stats']['total_posts'], '<br />
Membros no Total: ', $context['common_stats']['total_members'], '
</td>
<td width="50%">
', (!empty($context['latest_post']) ? $txt['latest_post'] . ': <strong>&quot;' . $context['latest_post']['link'] . '&quot;</strong>  ( ' . $context['latest_post']['time'] . ' )<br />' : ''), '
<a href="', $scripturl, '?action=recent">', $txt['recent_view'], '</a>', $context['show_stats'] ? '<br />
<a href="' . $scripturl . '?action=stats">' . $txt['more_stats'] . '</a>' : '', '
</td>
</tr>
</table>
';
// Buraya Kadar
echo'
<>
<br class="clear" />
';

Dentro do tema que você tem que colocar  o que esta no anexo
« Última modificação: 21 de Agosto de 2013, 17:38 por candidosa2 »