2003-09-16 03:07:21 +00:00
< ? PHP // $Id$
/// This page lists all the instances of glossary in a particular course
/// Replace glossary with the name of your module
require_once ( " ../../config.php " );
require_once ( " lib.php " );
2004-08-08 18:44:45 +00:00
require_once ( " $CFG->dirroot /rss/rsslib.php " );
2003-09-16 03:07:21 +00:00
require_variable ( $id ); // course
if ( ! $course = get_record ( " course " , " id " , $id )) {
error ( " Course ID is incorrect " );
}
require_login ( $course -> id );
add_to_log ( $course -> id , " glossary " , " view all " , " index.php?id= $course->id " , " " );
/// Get all required strings
$strglossarys = get_string ( " modulenameplural " , " glossary " );
$strglossary = get_string ( " modulename " , " glossary " );
2004-08-08 18:44:45 +00:00
$strrss = get_string ( " rss " );
2003-09-16 03:07:21 +00:00
/// Print the header
if ( $course -> category ) {
$navigation = " <A HREF= \" ../../course/view.php?id= $course->id\ " > $course -> shortname </ A > -> " ;
}
2003-09-28 16:53:17 +00:00
print_header ( " $course->shortname : $strglossarys " , " $course->fullname " , " $navigation $strglossarys " , " " , " " , true , " " , navmenu ( $course ));
2003-09-16 03:07:21 +00:00
/// Get all the appropriate data
if ( ! $glossarys = get_all_instances_in_course ( " glossary " , $course )) {
notice ( " There are no glossaries " , " ../../course/view.php?id= $course->id " );
die ;
}
/// Print the list of instances (your module will probably extend this)
$timenow = time ();
$strname = get_string ( " name " );
$strweek = get_string ( " week " );
$strtopic = get_string ( " topic " );
2003-10-26 08:14:54 +00:00
$strentries = get_string ( " entries " , " glossary " );
2003-09-16 03:07:21 +00:00
if ( $course -> format == " weeks " ) {
2003-10-26 08:14:54 +00:00
$table -> head = array ( $strweek , $strname , $strentries );
$table -> align = array ( " CENTER " , " LEFT " , " CENTER " );
2003-09-16 03:07:21 +00:00
} else if ( $course -> format == " topics " ) {
2003-10-26 08:14:54 +00:00
$table -> head = array ( $strtopic , $strname , $strentries );
$table -> align = array ( " CENTER " , " LEFT " , " CENTER " );
2003-09-16 03:07:21 +00:00
} else {
2003-10-26 08:14:54 +00:00
$table -> head = array ( $strname , $strentries );
$table -> align = array ( " LEFT " , " CENTER " );
2003-09-16 03:07:21 +00:00
}
2004-08-08 18:44:45 +00:00
$can_subscribe = ( isstudent ( $course -> id ) or isteacher ( $course -> id ) or isadmin ());
if ( $show_rss = ( $can_subscribe && isset ( $CFG -> enablerssfeeds ) && isset ( $CFG -> glossary_enablerssfeeds ) &&
$CFG -> enablerssfeeds && $CFG -> glossary_enablerssfeeds )) {
$table -> head [] = $strrss ;
$table -> align [] = " CENTER " ;
}
2004-01-26 12:21:44 +00:00
$currentsection = " " ;
2003-09-16 03:07:21 +00:00
foreach ( $glossarys as $glossary ) {
2003-09-28 10:57:22 +00:00
if ( ! $glossary -> visible ) {
//Show dimmed if the mod is hidden
$link = " <A class= \" dimmed \" HREF= \" view.php?id= $glossary->coursemodule\ " > $glossary -> name </ A > " ;
} else {
//Show normal if the mod is visible
$link = " <A HREF= \" view.php?id= $glossary->coursemodule\ " > $glossary -> name </ A > " ;
}
2004-01-26 12:21:44 +00:00
$printsection = " " ;
if ( $glossary -> section !== $currentsection ) {
if ( $glossary -> section ) {
$printsection = $glossary -> section ;
}
if ( $currentsection !== " " ) {
$table -> data [] = 'hr' ;
}
$currentsection = $glossary -> section ;
}
2003-09-16 03:07:21 +00:00
2003-10-28 16:10:36 +00:00
$count = count_records_sql ( " SELECT COUNT(*) FROM { $CFG -> prefix } glossary_entries where (glossaryid = $glossary->id or sourceglossaryid = $glossary->id ) " );
2003-10-26 08:14:54 +00:00
2004-08-08 18:44:45 +00:00
//If this glossary has RSS activated, calculate it
if ( $show_rss ) {
$rsslink = '' ;
if ( $glossary -> rsstype and $glossary -> rssarticles ) {
//Calculate the tolltip text
$tooltiptext = get_string ( " rsssubscriberss " , " glossary " , $glossary -> name );
//Get html code for RSS link
$rsslink = rss_get_link ( $course -> id , $USER -> id , " glossary " , $glossary -> id , $tooltiptext );
}
}
2003-09-16 03:07:21 +00:00
if ( $course -> format == " weeks " or $course -> format == " topics " ) {
2004-08-08 18:44:45 +00:00
$linedata = array ( $printsection , $link , $count );
2003-09-16 03:07:21 +00:00
} else {
2004-08-08 18:44:45 +00:00
$linedata = array ( $link , $count );
}
if ( $show_rss ) {
$linedata [] = $rsslink ;
2003-09-16 03:07:21 +00:00
}
2004-08-08 18:44:45 +00:00
$table -> data [] = $linedata ;
2003-09-16 03:07:21 +00:00
}
2003-10-26 08:14:54 +00:00
echo " <br /> " ;
2003-09-16 03:07:21 +00:00
print_table ( $table );
/// Finish the page
print_footer ( $course );
?>