92f9eea06e91493d4e926308b896aa61620c1d21
[atutor.git] / mods / mediawiki / module_news.php
1 <?php
2 /*
3 * Rename the function to match the name of the module. Names of all news functions must be unique
4 * across all modules installed on a system. Return a variable called $news
5 */
6 require('mw_connect.php');
7                 // Number of links to be displayed on "detail view" box
8 function mediawiki_news() {
9         global $db_mw, $_config;
10                 $link_limit = "3";
11         if($_GET['p'] == "all"){
12                 $link_limit = "100";
13         }
14         $news = array();
15         $sql = "SELECT  P.page_id, P.page_title, R.rev_timestamp FROM ".MW_DB_PREFIX."page P, ".MW_DB_PREFIX."revision R WHERE R.rev_page = P.page_id ORDER BY R.rev_timestamp DESC";
16         $result = mysql_query($sql, $db_mw);
17         if($result){
18                 $news_count = 0;
19                 $page_ids = array();
20                 while($row = mysql_fetch_assoc($result)){
21
22                         if($news_count < $link_limit && !in_array( $row['page_id'],$page_ids)){
23                                 $this_time = AT_date("%Y-%m-%d %G:%i:%s", $row['rev_timestamp'],AT_DATE_MYSQL_TIMESTAMP_14);
24                                 $page_ids[] = $row['page_id'];
25                                 $news[] = array('time'=> $this_time, 
26                                         'alt'=>_AT('mediawiki_update'),
27                                         'thumb'=>'mods/mediawiki/mw_icon_sm.png', 
28                                         'link'=>'<a href="'.AT_BASE_HREF.url_rewrite('mods/mediawiki/index_mystart.php?p='.$row['page_title']).'"'.
29                                         (strlen($row['page_title']) > SUBLINK_TEXT_LEN ? ' title="'.$row['page_title'].'"' : '') .'>'. 
30                                         validate_length($row['page_title'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) .'</a>');
31                                 $news_count++;
32                         }
33                 }
34         }
35         return $news;
36
37 }
38 ?>