Changeset 306
- Timestamp:
- 05/11/08 20:00:08 (7 months ago)
- Files:
-
- hot_topics/trunk/INSTALL.txt (added)
- hot_topics/trunk/lib.php (modified) (6 diffs)
- hot_topics/trunk/templates (added)
- hot_topics/trunk/templates/hottopics_link.html (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
hot_topics/trunk/lib.php
r201 r306 15 15 */ 16 16 17 /* 18 * @changelog 2008-05-11 Install text, code cleanup and tweak 19 * Rolando Espinoza La fuente 20 */ 21 17 22 function hottopics_pagesetup() { 18 23 // register template 24 templates_add_context('hottopics:link', 'mod/hottopics/templates/hottopics_link.html'); 19 25 } 20 26 … … 38 44 $days=7; 39 45 } else { 40 $days= $vars[1];46 $days=(int)$vars[1]; 41 47 } 42 48 … … 48 54 $limit=5; 49 55 } else { 50 $limit= $vars[2];56 $limit=(int)$vars[2]; 51 57 } 52 58 … … 56 62 $count=2; 57 63 } else { 58 $count= $vars[3];64 $count=(int)$vars[3]; 59 65 } 60 66 … … 64 70 65 71 66 67 $query_weblogs = "SELECT {$CFG->prefix}weblog_comments.post_id, {$CFG->prefix}weblog_posts.ident, {$CFG->prefix}weblog_posts.title, {$CFG->prefix}weblog_posts.posted, count(*) FROM `{$CFG->prefix}weblog_comments`, `{$CFG->prefix}weblog_posts` WHERE {$CFG->prefix}weblog_posts.ident = {$CFG->prefix}weblog_comments.post_id AND ({$CFG->prefix}weblog_posts.access= 'PUBLIC' OR {$CFG->prefix}weblog_posts.access='LOGGED_IN') AND DATE_SUB( CURDATE( ) , INTERVAL ".$days." DAY ) <= FROM_UNIXTIME({$CFG->prefix}weblog_comments.posted) GROUP BY {$CFG->prefix}weblog_comments.post_id HAVING count(*)>".$count." ORDER BY count(*) DESC, {$CFG->prefix}weblog_posts.title LIMIT ".$limit; 72 $query_weblogs = " 73 SELECT wc.post_id, wp.owner, wp.title, wp.posted, 74 count(*) as rank 75 FROM {$CFG->prefix}weblog_comments wc, {$CFG->prefix}weblog_posts wp 76 WHERE wp.ident = wc.post_id 77 AND wp.access in ('PUBLIC', 'LOGGED_IN') 78 AND DATE_SUB( CURDATE() , INTERVAL {$days} DAY ) <= FROM_UNIXTIME(wc.posted) 79 GROUP BY wc.post_id HAVING rank > {$count} 80 ORDER BY rank DESC, wp.title 81 LIMIT {$limit}"; 68 82 69 83 70 84 //GET THE RESULTS FROM DB 71 85 72 $posts = get_records_sql($query_weblogs); 86 $posts = get_records_sql($query_weblogs); 87 $html = ''; 73 88 74 if ($posts) { 89 if ($posts) { 90 $params = array('context' => 'hottopics:link'); 75 91 76 $html .="<span>"; 92 foreach($posts as $key => $info) { 93 94 $username = user_info('username', $info->owner); 95 $postid=$info->post_id; 96 $posttitle = htmlspecialchars($info->title, ENT_COMPAT, 'utf-8'); 77 97 78 foreach($posts as $key => $info) { 79 80 81 $usrid = $info->ident; 82 $postid=$info->post_id; 83 $posttitle = $info->title; 84 85 86 // GET THE POST OWNERS USERNAME (CAN THIS BE DONE ANOTHER WAY?) 87 88 $query_blogger = "SELECT * FROM {$CFG->prefix}users WHERE ident = ".$usrid; 89 90 $blogger = get_records_sql($query_blogger); 98 // Maybe there is some post without title... ¿? 99 if (empty($posttitle)) { 100 $posttitle = __gettext("Weblog post"); 101 } 102 103 $params['title'] = $posttitle; 104 $params['permalink'] = $CFG->wwwroot . $username . '/weblog/' . $postid . '.html'; 105 $params['comments'] = $info->rank; 106 $params['date'] = strftime('%Y-%m-%d', $info->posted); 91 107 92 foreach ($blogger as $key1 => $value) { 108 $html .= templates_draw($params); 93 109 94 95 $username=$value->username; 96 97 // OUTPUT LINK FOR EACH MATCHING POST - NOTE HTML CAN BE CHANGED TO SUITE NEEDS - E.G. REPLACE <P> WITH <LI> ETC 98 99 $html .= "<P><A HREF='".$username."/weblog/".$postid.".html'>".$posttitle."</A></P>"; 100 } 101 102 103 104 } 105 $html .="</span>"; 106 107 } 110 } 111 } 108 112 109 113 // RETURN RESULTANT HTML TO THE PAGE … … 113 117 } 114 118 115 ?>
