Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/glossary/index.php
Go to the documentation of this file.
00001 <?php
00002 
00005 
00006 require_once("../../config.php");
00007 require_once("lib.php");
00008 require_once("$CFG->libdir/rsslib.php");
00009 require_once("$CFG->dirroot/course/lib.php");
00010 
00011 $id = required_param('id', PARAM_INT);   // course
00012 
00013 $PAGE->set_url('/mod/glossary/index.php', array('id'=>$id));
00014 
00015 if (!$course = $DB->get_record('course', array('id'=>$id))) {
00016     print_error('invalidcourseid');
00017 }
00018 
00019 require_course_login($course);
00020 $PAGE->set_pagelayout('incourse');
00021 $context = get_context_instance(CONTEXT_COURSE, $course->id);
00022 
00023 add_to_log($course->id, "glossary", "view all", "index.php?id=$course->id", "");
00024 
00025 
00027 
00028 $strglossarys = get_string("modulenameplural", "glossary");
00029 $strglossary  = get_string("modulename", "glossary");
00030 $strrss = get_string("rss");
00031 
00032 
00034 $PAGE->navbar->add($strglossarys, "index.php?id=$course->id");
00035 $PAGE->set_title($strglossarys);
00036 $PAGE->set_heading($course->fullname);
00037 echo $OUTPUT->header();
00038 
00040 
00041 if (! $glossarys = get_all_instances_in_course("glossary", $course)) {
00042     notice(get_string('thereareno', 'moodle', $strglossarys), "../../course/view.php?id=$course->id");
00043     die;
00044 }
00045 
00046 $usesections = course_format_uses_sections($course->format);
00047 if ($usesections) {
00048     $sections = get_all_sections($course->id);
00049 }
00050 
00052 
00053 $timenow = time();
00054 $strsectionname  = get_string('sectionname', 'format_'.$course->format);
00055 $strname  = get_string("name");
00056 $strentries  = get_string("entries", "glossary");
00057 
00058 $table = new html_table();
00059 
00060 if ($usesections) {
00061     $table->head  = array ($strsectionname, $strname, $strentries);
00062     $table->align = array ("CENTER", "LEFT", "CENTER");
00063 } else {
00064     $table->head  = array ($strname, $strentries);
00065     $table->align = array ("LEFT", "CENTER");
00066 }
00067 
00068 if ($show_rss = (isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) &&
00069                  $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds)) {
00070     $table->head[] = $strrss;
00071     $table->align[] = "CENTER";
00072 }
00073 
00074 $currentsection = "";
00075 
00076 foreach ($glossarys as $glossary) {
00077     if (!$glossary->visible && has_capability('moodle/course:viewhiddenactivities', $context)) {
00078         // Show dimmed if the mod is hidden.
00079         $link = "<a class=\"dimmed\" href=\"view.php?id=$glossary->coursemodule\">".format_string($glossary->name,true)."</a>";
00080     } else if ($glossary->visible) {
00081         // Show normal if the mod is visible.
00082         $link = "<a href=\"view.php?id=$glossary->coursemodule\">".format_string($glossary->name,true)."</a>";
00083     } else {
00084         // Don't show the glossary.
00085         continue;
00086     }
00087     $printsection = "";
00088     if ($usesections) {
00089         if ($glossary->section !== $currentsection) {
00090             if ($glossary->section) {
00091                 $printsection = get_section_name($course, $sections[$glossary->section]);
00092             }
00093             if ($currentsection !== "") {
00094                 $table->data[] = 'hr';
00095             }
00096             $currentsection = $glossary->section;
00097         }
00098     }
00099 
00100     // TODO: count only approved if not allowed to see them
00101 
00102     $count = $DB->count_records_sql("SELECT COUNT(*) FROM {glossary_entries} WHERE (glossaryid = ? OR sourceglossaryid = ?)", array($glossary->id, $glossary->id));
00103 
00104     //If this glossary has RSS activated, calculate it
00105     if ($show_rss) {
00106         $rsslink = '';
00107         if ($glossary->rsstype and $glossary->rssarticles) {
00108             //Calculate the tolltip text
00109             $tooltiptext = get_string("rsssubscriberss","glossary",format_string($glossary->name));
00110             if (!isloggedin()) {
00111                 $userid = 0;
00112             } else {
00113                 $userid = $USER->id;
00114             }
00115             //Get html code for RSS link
00116             $rsslink = rss_get_link($context->id, $userid, 'mod_glossary', $glossary->id, $tooltiptext);
00117         }
00118     }
00119 
00120     if ($usesections) {
00121         $linedata = array ($printsection, $link, $count);
00122     } else {
00123         $linedata = array ($link, $count);
00124     }
00125 
00126     if ($show_rss) {
00127         $linedata[] = $rsslink;
00128     }
00129 
00130     $table->data[] = $linedata;
00131 }
00132 
00133 echo "<br />";
00134 
00135 echo html_writer::table($table);
00136 
00138 
00139 echo $OUTPUT->footer();
00140 
 All Data Structures Namespaces Files Functions Variables Enumerations