1010a6ea1bb83c2738ec2e7270df9421449f33fc
[atutor.git] / mods / mediawiki / sublinks.php
1 <?php
2
3 if (!defined('AT_INCLUDE_PATH')) { exit; }
4
5 /*****
6 * Free form PHP can appear here to retreive current information
7 * from the module, or a text description of the module where there is
8 * not current information
9 *****/
10 require('mw_connect.php');
11 global $db_mw;
12
13 $link_limit = 3;                // Number of links to be displayed on "detail view" box
14
15 $sql = "SELECT P.page_title, R.rev_timestamp FROM ".MW_DB_PREFIX."page P, ".MW_DB_PREFIX."revision R ORDER BY R.rev_timestamp DESC LIMIT  $link_limit";
16
17 // $sql = "SELECT hello_world_id, value FROM ".TABLE_PREFIX."hello_world WHERE course_id=".$_SESSION[course_id].
18 //        " ORDER BY value LIMIT $link_limit";
19 $result = mysql_query($sql, $db_mw);
20
21 if (mysql_num_rows($result) > 0) {
22         while ($row = mysql_fetch_assoc($result)) {
23                 /****
24                 * SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY are defined in include/lib/constance.lib.inc
25                 * SUBLINK_TEXT_LEN determins the maxium length of the string to be displayed on "detail view" box.
26                 *****/
27                 $list[] = '<a href="'.AT_BASE_HREF.url_rewrite('mods/mediawiki/index.php?p='.$row['page_title']).'"'.
28                           (strlen($row['page_title']) > SUBLINK_TEXT_LEN ? ' title="'.$row['page_title'].'"' : '') .'>'. 
29                           validate_length($row['page_title'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) .'</a>';
30         }
31         return $list;   
32 } else {
33         return 0;
34 }
35
36 ?>