Automatic installer.php lang files by installer_builder (20070313)
[moodle.git] / mod / glossary / index.php
blob03fdd3df2d68e85ab177b9b43c95ece478b72f8b
1 <?php // $Id$
3 /// This page lists all the instances of glossary in a particular course
4 /// Replace glossary with the name of your module
6 require_once("../../config.php");
7 require_once("lib.php");
8 require_once("$CFG->libdir/rsslib.php");
10 $id = required_param('id', PARAM_INT); // course
12 if (! $course = get_record("course", "id", $id)) {
13 error("Course ID is incorrect");
16 require_course_login($course);
18 add_to_log($course->id, "glossary", "view all", "index.php?id=$course->id", "");
21 /// Get all required strings
23 $strglossarys = get_string("modulenameplural", "glossary");
24 $strglossary = get_string("modulename", "glossary");
25 $strrss = get_string("rss");
28 /// Print the header
30 print_header_simple("$strglossarys", "", "$strglossarys", "", "", true, "", navmenu($course));
32 /// Get all the appropriate data
34 if (! $glossarys = get_all_instances_in_course("glossary", $course)) {
35 notice("There are no glossaries", "../../course/view.php?id=$course->id");
36 die;
39 /// Print the list of instances (your module will probably extend this)
41 $timenow = time();
42 $strname = get_string("name");
43 $strweek = get_string("week");
44 $strtopic = get_string("topic");
45 $strentries = get_string("entries", "glossary");
47 if ($course->format == "weeks") {
48 $table->head = array ($strweek, $strname, $strentries);
49 $table->align = array ("CENTER", "LEFT", "CENTER");
50 } else if ($course->format == "topics") {
51 $table->head = array ($strtopic, $strname, $strentries);
52 $table->align = array ("CENTER", "LEFT", "CENTER");
53 } else {
54 $table->head = array ($strname, $strentries);
55 $table->align = array ("LEFT", "CENTER");
58 $can_subscribe = (isstudent($course->id) or isteacher($course->id) or isadmin());
60 if ($show_rss = (($can_subscribe || $course->id == SITEID) &&
61 isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) &&
62 $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds)) {
63 $table->head[] = $strrss;
64 $table->align[] = "CENTER";
67 $currentsection = "";
69 foreach ($glossarys as $glossary) {
70 if (!$glossary->visible) {
71 //Show dimmed if the mod is hidden
72 $link = "<a class=\"dimmed\" href=\"view.php?id=$glossary->coursemodule\">".format_string($glossary->name,true)."</a>";
73 } else {
74 //Show normal if the mod is visible
75 $link = "<a href=\"view.php?id=$glossary->coursemodule\">".format_string($glossary->name,true)."</a>";
77 $printsection = "";
78 if ($glossary->section !== $currentsection) {
79 if ($glossary->section) {
80 $printsection = $glossary->section;
82 if ($currentsection !== "") {
83 $table->data[] = 'hr';
85 $currentsection = $glossary->section;
88 $count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = $glossary->id or sourceglossaryid = $glossary->id)");
90 //If this glossary has RSS activated, calculate it
91 if ($show_rss) {
92 $rsslink = '';
93 if ($glossary->rsstype and $glossary->rssarticles) {
94 //Calculate the tolltip text
95 $tooltiptext = get_string("rsssubscriberss","glossary",format_string($glossary->name));
96 if (empty($USER->id)) {
97 $userid = 0;
98 } else {
99 $userid = $USER->id;
101 //Get html code for RSS link
102 $rsslink = rss_get_link($course->id, $userid, "glossary", $glossary->id, $tooltiptext);
106 if ($course->format == "weeks" or $course->format == "topics") {
107 $linedata = array ($printsection, $link, $count);
108 } else {
109 $linedata = array ($link, $count);
112 if ($show_rss) {
113 $linedata[] = $rsslink;
116 $table->data[] = $linedata;
119 echo "<br />";
121 print_table($table);
123 /// Finish the page
125 print_footer($course);