Posted By

Garciat on 01/05/09


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


topic title on index by hcs EDITED BY ME


 / Published in: PHP
 

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE extension SYSTEM "ext-1.0.dtd">
  3.  
  4. <!--
  5. /**
  6. * @copyright topic_title_on_index Copyright (C) 2008 hcs
  7. * @copyright Copyright (C) 2008 PunBB, partially based on code copyright (C) 2008 FluxBB.org
  8. * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
  9. * @package topic_title_on_index
  10. */
  11. -->
  12.  
  13. <extension engine="1.0">
  14. <id>topic_title_on_index</id>
  15. <title>Topic title on forum index </title>
  16. <version>1.0.0 Beta</version>
  17. <description>Replace the Last Post link on the index page for the name of the topic instead of the date format.</description>
  18. <author>hcs</author>
  19.  
  20. <minversion>1.3</minversion>
  21. <maxtestedon>1.3.2</maxtestedon>
  22.  
  23. <hooks>
  24. <hook id="in_qr_get_cats_and_forums"><![CDATA[
  25. $query['SELECT'] .=', t.subject, u.id as poster_id';
  26. $query['JOINS'][] = array(
  27. 'LEFT JOIN' => 'topics AS t',
  28. 'ON' => 'f.last_post_id=t.last_post_id'
  29. );
  30. $query['JOINS'][] = array(
  31. 'LEFT JOIN' => 'users AS u',
  32. 'ON' => 'f.last_poster=u.username'
  33. );
  34. ]]></hook>
  35.  
  36. <hook id="in_start"><![CDATA[
  37. function words($string, $words)
  38. {
  39. return implode(" ", array_slice(explode(' ', $string), 0, $words)) . '...';
  40. }
  41.  
  42. function relative_time($timestamp)
  43. {
  44. $d = time() - $timestamp;
  45. if ($d < 60)
  46. return $d." second".(($d==1)?'':'s')." ago";
  47. else
  48. {
  49. $d = floor($d / 60);
  50. if($d < 60)
  51. return $d." minute".(($d==1)?'':'s')." ago";
  52. else
  53. {
  54. $d = floor($d / 60);
  55. if($d < 24)
  56. return $d." hour".(($d==1)?'':'s')." ago";
  57. else
  58. {
  59. $d = floor($d / 24);
  60. if($d < 7)
  61. return $d." day".(($d==1)?'':'s')." ago";
  62. else
  63. {
  64. $d = floor($d / 7);
  65. if($d < 4)
  66. return $d." week".(($d==1)?'':'s')." ago";
  67. }//Week
  68. }//Day
  69. }//Hour
  70. }//Minute
  71. }
  72.  
  73. $words = 4;
  74. ]]></hook>
  75.  
  76. <hook id="in_normal_row_pre_display"><![CDATA[
  77. if(strpos($forum_page['item_body']['info']['lastpost'], $lang_index['No post info']) === false && strpos($forum_page['item_body']['info']['lastpost'], $lang_common['Never']) === false)
  78. $forum_page['item_body']['info']['lastpost'] = '<li class="info-lastpost"><span class="label">'.$lang_index['Last post'].'</span> <strong><a href="'.forum_link($forum_url['post'], $cur_forum['last_post_id']).'">'.forum_htmlencode(words($cur_forum['subject'], $words)).'</a></strong> <cite>'.relative_time($cur_forum['last_post']).' '.sprintf($lang_index['Last poster'], '<a href="'.forum_link($forum_url['user'], $cur_forum['poster_id']).'">'.forum_htmlencode($cur_forum['last_poster']).'</a>').'</cite></li>';
  79. ]]></hook>
  80.  
  81. </hooks>
  82.  
  83. </extension>

Report this snippet  

You need to login to post a comment.