Want more features on Pastebin? Sign Up, it's FREE!
Guest

active_topics (Grez)

By: KeyDog on Dec 30th, 2011  |  syntax: XML  |  size: 10.32 KB  |  views: 64  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE extension SYSTEM "ext-1.0.dtd">
  3.  
  4. <!--
  5. /*
  6.         Copyright (C) 2010 Tom "Grez" Bartoň
  7.         Released under GPL license version 3 or any later version <http://www.gnu.org/licenses/gpl.html>
  8.        
  9.         This extension is free software: you can redistribute it and/or modify
  10.         it under the terms of the GNU General Public License as published by
  11.         the Free Software Foundation, either version 3 of the License, or
  12.         (at your option) any later version.
  13.  
  14.         This extension is distributed in the hope that it will be useful,
  15.         but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.         GNU General Public License for more details.
  18.  
  19.         You should have received a copy of the GNU General Public License
  20.         along with this extension.  If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. -->
  23.  
  24. <extension engine="1.0">
  25.         <id>active_topics</id>
  26.         <title>Active Topics</title>
  27.         <version>1.1</version>
  28.         <description>Shows last active topics on the forum index.</description>
  29.         <author>Grez</author>
  30.         <minversion>1.3.4</minversion>
  31.         <maxtestedon>1.4.1</maxtestedon>
  32.        
  33.         <install>
  34.                 <![CDATA[
  35.  
  36. $query = array(
  37.         'SELECT'        =>      'conf_value',
  38.         'FROM'          =>      'config',
  39.         'WHERE'         =>      'conf_name = \'p_active_topics\''
  40. );
  41. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  42.  
  43. if($forum_db->num_rows($result) == 0) {
  44.         $at_config = array(
  45.                 'INSERT'        => 'conf_name, conf_value',
  46.                 'INTO'          => 'config',
  47.                 'VALUES'        => '\'p_active_topics\', 5'
  48.         );     
  49.  
  50.         $forum_db->query_build($at_config) or error(__FILE__, __LINE__);
  51. }
  52.                 ]]>
  53.         </install>
  54.        
  55.         <uninstall>
  56.                 <![CDATA[
  57.                
  58. $at_config = array(
  59.         'DELETE'        => 'config',
  60.         'WHERE'         => 'conf_name=\'p_active_topics\''
  61. );
  62.        
  63. $forum_db->query_build($at_config) or error(__FILE__, __LINE__);               
  64.                
  65.                 ]]>
  66.         </uninstall>
  67.        
  68.         <hooks>
  69.                 <hook id="in_stats_pre_info_output">
  70. <![CDATA[
  71. if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php')) {
  72.         include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
  73. } else {
  74.         include $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
  75. }
  76. ?>
  77. <div class="main-head">
  78.         <h2 class="hn"><span><?php echo $lang_active_topics['Active topics']; ?></span></h2>
  79. </div>
  80. <?php
  81. $query = array(
  82.         'SELECT'        => 't.id, t.poster, t.subject, t.posted, t.first_post_id, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to',
  83.         'FROM'          => 'topics AS t',
  84.         'JOINS'         => array(
  85.                 array(
  86.                         'LEFT JOIN'             => 'forum_perms AS fp',
  87.                         'ON'                    => '(fp.forum_id=t.forum_id AND fp.group_id='.$forum_user['g_id'].')'
  88.                 )
  89.         ),
  90.         'WHERE'         => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL',
  91.         'ORDER BY'      => 't.last_post DESC',
  92.         'LIMIT'         => $forum_config['p_active_topics']
  93. );
  94.  
  95. // With "has posted" indication
  96. if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] == '1')
  97. {
  98.         $subquery = array(
  99.                 'SELECT'        => 'COUNT(p.id)',
  100.                 'FROM'          => 'posts AS p',
  101.                 'WHERE'         => 'p.poster_id='.$forum_user['id'].' AND p.topic_id=t.id'
  102.         );
  103.  
  104.         ($hook = get_hook('vf_qr_get_has_posted')) ? eval($hook) : null;
  105.         $query['SELECT'] .= ', ('.$forum_db->query_build($subquery, true).') AS has_posted';
  106. }
  107.  
  108. require FORUM_ROOT.'lang/'.$forum_user['language'].'/forum.php';
  109.  
  110. $forum_page['item_header'] = array();
  111. $forum_page['item_header']['subject']['title'] = '<strong class="subject-title">'.$lang_forum['Topics'].'</strong>';
  112. $forum_page['item_header']['info']['replies'] = '<strong class="info-replies">'.$lang_forum['replies'].'</strong>';
  113.  
  114. if ($forum_config['o_topic_views'] == '1')
  115.         $forum_page['item_header']['info']['views'] = '<strong class="info-views">'.$lang_forum['views'].'</strong>';
  116.  
  117. $forum_page['item_header']['info']['lastpost'] = '<strong class="info-lastpost">'.$lang_forum['last post'].'</strong>';
  118. ?>
  119.         <div class="main-subhead">
  120.                 <p class="item-summary<?php echo ($forum_config['o_topic_views'] == '1') ? ' forum-views' : ' forum-noview' ?>"><span><?php printf($lang_forum['Forum subtitle'], implode(' ', $forum_page['item_header']['subject']), implode(', ', $forum_page['item_header']['info'])) ?></span></p>
  121.         </div>
  122.        
  123. <div class="main-content main-forum<?php echo ($forum_config['o_topic_views'] == '1') ? ' forum-views' : ' forum-noview' ?>">
  124. <?php
  125.  
  126. $forum_page['item_header']['subject']['title'] = '<strong class="subject-title">'.$lang_forum['Topics'].'</strong>';
  127.  
  128. $forum_page['item_count'] = 0;
  129.  
  130. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  131. while($cur_topic = $forum_db->fetch_assoc($result)) {
  132.                 ++$forum_page['item_count'];
  133.  
  134.                 // Start from scratch
  135.                 $forum_page['item_subject'] = $forum_page['item_body'] = $forum_page['item_status'] = $forum_page['item_nav'] = $forum_page['item_title'] = $forum_page['item_title_status'] = array();
  136.  
  137.                 if ($forum_config['o_censoring'] == '1')
  138.                         $cur_topic['subject'] = censor_words($cur_topic['subject']);
  139.  
  140.                 $forum_page['item_subject']['starter'] = '<span class="item-starter">'.sprintf($lang_forum['Topic starter'], forum_htmlencode($cur_topic['poster'])).'</span>';
  141.  
  142.                 // Assemble the Topic heading
  143.  
  144.                 // Should we display the dot or not? :)
  145.                 if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] == '1' && $cur_topic['has_posted'] > 0)
  146.                 {
  147.                         $forum_page['item_title']['posted'] = '<span class="posted-mark">'.$lang_forum['You posted indicator'].'</span>';
  148.                         $forum_page['item_status']['posted'] = 'posted';
  149.                 }
  150.  
  151.                 if ($cur_topic['sticky'] == '1')
  152.                 {
  153.                         $forum_page['item_title_status']['sticky'] = '<em class="sticky">'.$lang_forum['Sticky'].'</em>';
  154.                         $forum_page['item_status']['sticky'] = 'sticky';
  155.                 }
  156.  
  157.                 if ($cur_topic['closed'] == '1')
  158.                 {
  159.                         $forum_page['item_title_status']['closed'] = '<em class="closed">'.$lang_forum['Closed'].'</em>';
  160.                         $forum_page['item_status']['closed'] = 'closed';
  161.                 }
  162.  
  163.                 if (!empty($forum_page['item_title_status']))
  164.                         $forum_page['item_title']['status'] = '<span class="item-status">'.sprintf($lang_forum['Item status'], implode(', ', $forum_page['item_title_status'])).'</span>';
  165.                
  166.                 $forum_page['item_title']['link'] = '<a href="'.forum_link($forum_url['topic'], array($cur_topic['id'], sef_friendly($cur_topic['subject']))).'">'.forum_htmlencode($cur_topic['subject']).'</a>';
  167.                        
  168.                 $forum_page['item_body']['subject']['title'] = '<h3 class="hn"><span class="item-num">'.forum_number_format($forum_page['item_count']).'</span> '.implode(' ', $forum_page['item_title']).'</h3>';
  169.  
  170.                 if (empty($forum_page['item_status']))
  171.                         $forum_page['item_status']['normal'] = 'normal';
  172.  
  173.                 $forum_page['item_pages'] = ceil(($cur_topic['num_replies'] + 1) / $forum_user['disp_posts']);
  174.  
  175.                 if ($forum_page['item_pages'] > 1)
  176.                         $forum_page['item_nav']['pages'] = '<span>'.$lang_forum['Pages'].'&#160;</span>'.paginate($forum_page['item_pages'], -1, $forum_url['topic'], $lang_common['Page separator'], array($cur_topic['id'], sef_friendly($cur_topic['subject'])));
  177.  
  178.                 // Does this topic contain posts we haven't read? If so, tag it accordingly.
  179.                 if (!$forum_user['is_guest'] && $cur_topic['last_post'] > $forum_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_topic['id']]) || $tracked_topics['topics'][$cur_topic['id']] < $cur_topic['last_post']))
  180.                 {
  181.                         $forum_page['item_nav']['new'] = '<em class="item-newposts"><a href="'.forum_link($forum_url['topic_new_posts'], array($cur_topic['id'], sef_friendly($cur_topic['subject']))).'">'.$lang_forum['New posts'].'</a></em>';
  182.                         $forum_page['item_status']['new'] = 'new';
  183.                 }
  184.  
  185.                 if (!empty($forum_page['item_nav']))
  186.                         $forum_page['item_subject']['nav'] = '<span class="item-nav">'.sprintf($lang_forum['Topic navigation'], implode('&#160;&#160;', $forum_page['item_nav'])).'</span>';
  187.  
  188.                 // Assemble the Topic subject
  189.  
  190.                 $forum_page['item_body']['info']['replies'] = '<li class="info-replies"><strong>'.forum_number_format($cur_topic['num_replies']).'</strong> <span class="label">'.(($cur_topic['num_replies'] == 1) ? $lang_forum['reply'] : $lang_forum['replies']).'</span></li>';
  191.  
  192.                 if ($forum_config['o_topic_views'] == '1')
  193.                         $forum_page['item_body']['info']['views'] = '<li class="info-views"><strong>'.forum_number_format($cur_topic['num_views']).'</strong> <span class="label">'.(($cur_topic['num_views'] == 1) ? $lang_forum['view'] : $lang_forum['views']).'</span></li>';
  194.  
  195.                 $forum_page['item_body']['info']['lastpost'] = '<li class="info-lastpost"><span class="label">'.$lang_forum['Last post'].'</span> <strong><a href="'.forum_link($forum_url['post'], $cur_topic['last_post_id']).'">'.format_time($cur_topic['last_post']).'</a></strong> <cite>'.sprintf($lang_forum['by poster'], forum_htmlencode($cur_topic['last_poster'])).'</cite></li>';
  196.  
  197.                 $forum_page['item_body']['subject']['desc'] = '<p>'.implode(' ', $forum_page['item_subject']).'</p>';
  198.                 $forum_page['item_style'] = (($forum_page['item_count'] % 2 != 0) ? ' odd' : ' even').(($forum_page['item_count'] == 1) ? ' main-first-item' : '').((!empty($forum_page['item_status'])) ? ' '.implode(' ', $forum_page['item_status']) : '');
  199. ?>
  200.                 <div id="topic<?php echo $cur_topic['id'] ?>" class="main-item<?php echo $forum_page['item_style'] ?>">
  201.                         <span class="icon <?php echo implode(' ', $forum_page['item_status']) ?>"><!-- --></span>
  202.                         <div class="item-subject">
  203.                                 <?php echo implode("\n\t\t\t\t", $forum_page['item_body']['subject'])."\n" ?>
  204.                         </div>
  205.                         <ul class="item-info">
  206.                                 <?php echo implode("\n\t\t\t\t", $forum_page['item_body']['info'])."\n" ?>
  207.                         </ul>
  208.                 </div>
  209. <?php
  210.         }
  211. ?>
  212. </div>
  213. <?php
  214. ]]>
  215.                 </hook>
  216.                 <hook id="aop_setup_pre_topics_per_page">
  217. <![CDATA[
  218. if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php')) {
  219.         include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
  220. } else {
  221.         include $ext_info['path'].'/lang/English/online_today.php';
  222. }
  223. ?>
  224.                                         <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
  225.                                                 <div class="sf-box text">
  226.                                                         <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_active_topics['Active topics setting']; ?></span></label><br />
  227.                                                         <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="form[active_topics]" size="3" maxlength="3" value="<?php echo $forum_config['p_active_topics'] ?>" /></span>
  228.                                                 </div>
  229.                                         </div>
  230. <?php
  231. ]]>
  232.                 </hook>
  233.         </hooks>
  234. </extension>
clone this paste RAW Paste Data