Autor Tópico: Novas Estatísticas Top 10  (Lida 145 vezes)

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

Online candidosa2

  • Suporte Tecnico
  • Fundador
  • *
  • Mensagens: 5086
  • Rank: 1658
  • Sexo: Masculino
  • Suporte
    • Hosting Moçambique
Novas Estatísticas Top 10
« em: 27 de Novembro de 2025, 23:59 »
Já há algum tempo que penso em fazer isto, porque nenhum dos mods de estatísticas existentes funciona. Alguns enchem o formulário com consultas, outros sobrecarregam-no com consultas à base de dados. Em suma, este mod está totalmente integrado na programação do SMF.

Pode desenvolver o mod, eu estou apenas a começar.

./Sources/Subs-Recent.php

Encontrar
Código: [Seleccione]
m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg,
COALESCE(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name,

Alterar
Código: [Seleccione]
, t.num_views, t.num_replies,
Encontrar
Código: [Seleccione]
'time' => timeformat($row['poster_time']),

Adicionar abaixo
Código: [Seleccione]
'views' => comma_format($row['num_views']),
        'replies' => comma_format($row['num_replies']),


./Themes/default/BoardIndex.template.php

Localizar (existem 2; se quiser que apareçam na parte superior, edite a parte superior; caso contrário, edite a parte inferior)

Código: [Seleccione]
// Show lots of posts.
      elseif (!empty($context['latest_posts']))
      {
        echo '
            <dl id="ic_recentposts" class="middletext">';

        /* Each post in latest_posts has:
              board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
              subject, short_subject (shortened with...), time, link, and href. */
        foreach ($context['latest_posts'] as $post)
            echo '
              <dt><strong>', $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</dt>
              <dd>', $post['time'], '</dd>';
        echo '
            </dl>';

alterar

Código: [Seleccione]
// Show lots of posts.
      elseif (!empty($context['latest_posts']))
      {
        echo '
                              <table cellpadding="0" cellspacing="1" width="100%" border="0">
              <tr>
              <td class="catbg2" style="text-align:left;" colspan="2">',$txt['recent_title'],'</td>
              <td class="catbg2" style="text-align:center;">',$txt['recent_replies'],'</td>
              <td class="catbg2" style="text-align:center;">',$txt['recent_views'],'</td>
              <td class="catbg2" style="text-align:center;">',$txt['recent_boardname'],'</td>
              <td class="catbg2" style="text-align:center;">',$txt['recent_by'],'</td>
              <td class="catbg2" style="text-align:right;">',$txt['recent_time'],'</td>
            </tr>';


        /* Each post in latest_posts has:
              board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
              subject, short_subject (shortened with...), time, link, and href. */
                  $cnt = 0;
        foreach ($context['latest_posts'] as $post){
        $cnt++;
        $class = ($cnt % 2) ? 'windowbg' : 'windowbg2';
       
        echo '
                    <tr>
                    <td></td>
                        <td class="', $class, '" title="', $post['preview'] ,'">', $post['link'], '</td>
                        <td class="', $class, '" style="text-align:center;">', $post['replies'], '</td>
                        <td class="', $class, '" style="text-align:center;">', $post['views'], '</td>                       
                        <td class="', $class, '" style="text-align:center;">',$post['board']['link'], '</td>
                        <td class="', $class, '" style="text-align:center;">',$post['poster']['link'], '</td>
                        <td class="', $class, '" style="text-align:right;" nowrap="nowrap">', $post['time'], '</td>

                    </tr>';
      }

        echo '
            </table>';

./Themes/default/languages/Modifications.english.php

encontrar
Código: [Seleccione]
?>
Adicionar Antes:

Código: [Seleccione]
$txt['recent_title'] = 'Subject';
$txt['recent_views'] = 'Views';
$txt['recent_replies'] = 'Replies';
$txt['recent_boardname'] = 'Board name';
$txt['recent_by'] = 'Author';
$txt['recent_time'] = 'Date';

ao ficheiro de idioma que está a usar nosso caso e portuguese_pt
Código: [Seleccione]
$txt['recent_title'] = 'Tópicos Recentes';
$txt['recent_views'] = 'Visualizações';
$txt['recent_replies'] = 'Respostas';
$txt['recent_boardname'] = 'Nome da Secção';
$txt['recent_by'] = 'Enviado por';
$txt['recent_time'] = 'Data';

quero que apareça no topo

Código: [Seleccione]
// This is the "Recent Posts" bar.
 if (!empty($settings['number_recent_posts']) && (!empty($context['latest_posts']) || !empty($context['latest_post'])))
 {
 echo '
 <div class="title_barIC">
 <h4 class="titlebg">
 <span class="ie6_header floatleft">
 <a href="', $scripturl, '?action=recent"><img class="icon" src="', $settings['images_url'], '/post/xx.gif" alt="', $txt['recent_posts'], '" /></a>
 ', $txt['recent_posts'], '
 </span>
 </h4>
 </div>
 <div class="hslice" id="recent_posts_content">
 <div class="entry-title" style="display: none;">', $context['forum_name_html_safe'], ' - ', $txt['recent_posts'], '</div>
 <div class="entry-content" style="display: none;">
 <a rel="feedurl" href="', $scripturl, '?action=.xml;type=webslice">', $txt['subscribe_webslice'], '</a>
 </div>';

 // Only show one post.
 if ($settings['number_recent_posts'] == 1)
 {
 // latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
 echo '
 <strong><a href="', $scripturl, '?action=recent">', $txt['recent_posts'], '</a></strong>
 <p id="infocenter_onepost" class="middletext">
 ', $txt['recent_view'], ' &quot;', $context['latest_post']['link'], '&quot; ', $txt['recent_updated'], ' (', $context['latest_post']['time'], ')<br />
 </p>';
 }
 // Show lots of posts.
 elseif (!empty($context['latest_posts']))
 {
 echo '
 <dl id="ic_recentposts" class="middletext">';

 /* Each post in latest_posts has:
 board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
 subject, short_subject (shortened with...), time, link, and href. */
 foreach ($context['latest_posts'] as $post)
 echo '
 <dt><strong>', $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</dt>
 <dd>', $post['time'], '</dd>';
 echo '
 </dl>';
 }
 echo '
 </div>';
 }

encontrar

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

Adicionar abaixo
Código: [Seleccione]
// This is the "Recent Posts" bar.
 if (!empty($settings['number_recent_posts']))
 {
 echo '
 <div class="cat_bar">
 <h3 class="catbg">
 <span class="ie6_header floatleft">
 <a href="', $scripturl, '?action=recent"><i class="icon-edit-sign icon-large"></i></a>
 ', $txt['recent_posts'], '
 </span>
 </h3>
 </div>
 <div class="hslice" id="recent_posts_content">
 <div class="entry-title" style="display: none;">', $context['forum_name_html_safe'], ' - ', $txt['RecentTopicsOnBoardIndex_recenttopics'], '</div>
 <div class="entry-content" style="display: none;">
 <a rel="feedurl" href="', $scripturl, '?action=.xml;type=webslice">', $txt['subscribe_webslice'], '</a>
 </div>';

 // Only show one post.
 if ($settings['number_recent_posts'] == 1)
 {
 // latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
 echo '
 <strong><a href="', $scripturl, '?action=recent">', $txt['recent_posts'], '</a></strong>
 <p id="infocenter_onepost" class="middletext">
 ', $txt['recent_view'], ' &quot;', $context['latest_post']['link'], '&quot; ', $txt['recent_updated'], ' (', $context['latest_post']['time'], ')<br />
 </p>';
 }
 // Show lots of posts.
 elseif (!empty($context['latest_posts']))
 {
 echo '
 <table width="100%" cellpadding="0" cellspacing="2" style="font-size:11px;border:1px solid #ccc;padding:1px;">
          <tr>
              <td class="catbg2" style="text-align:left;" colspan="2">',$txt['recent_title'],'</td>
              <td class="catbg2" style="text-align:center;">',$txt['recent_replies'],'</td>
              <td class="catbg2" style="text-align:center;">',$txt['recent_views'],'</td>
              <td class="catbg2" style="text-align:center;">',$txt['recent_boardname'],'</td>
              <td class="catbg2" style="text-align:center;">',$txt['recent_by'],'</td>
              <td class="catbg2" style="text-align:right;">',$txt['recent_time'],'</td>
            </tr>';


 /* Each post in latest_posts has:
 board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
 subject, short_subject (shortened with...), time, link, and href. */
 $cnt = 0;
 foreach ($context['latest_posts'] as $post){
        $cnt++;
        $class = ($cnt % 2) ? 'windowbg' : 'windowbg2';
       
        echo '
 <tr>
 <td></td>
 <td class="', $class, '" title="', $post['preview'] ,'">', $post['link'], '</td>
 <td class="', $class, '" style="text-align:center;">', $post['replies'], '</td>
 <td class="', $class, '" style="text-align:center;">', $post['views'], '</td>
 <td class="', $class, '" style="text-align:center;">',$post['board']['link'], '</td>
 <td class="', $class, '" style="text-align:center;">',$post['poster']['link'], '</td>
 <td class="', $class, '" style="text-align:right;" nowrap="nowrap">', $post['time'], '</td>

 </tr>';
      }

 echo '
 </table>
 <br/>';
 
 }
 echo '
 </div>';
 }