File: index.php

package info (click to toggle)
moodle 1.4.4.dfsg.1-3sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 57,876 kB
  • ctags: 29,496
  • sloc: php: 271,617; sql: 5,084; xml: 702; perl: 638; sh: 403; java: 283; makefile: 42; pascal: 21
file content (127 lines) | stat: -rw-r--r-- 4,214 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?PHP // $Id: index.php,v 1.10.2.2 2004/10/05 22:51:47 stronk7 Exp $

/// 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");
    require_once("$CFG->dirroot/rss/rsslib.php");

    require_variable($id);   // course

    if (! $course = get_record("course", "id", $id)) {
        error("Course ID is incorrect");
    }

    require_course_login($course);

    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");
    $strrss = get_string("rss");


/// Print the header

    print_header_simple("$strglossarys", "", "$strglossarys", "", "", true, "", navmenu($course));

/// 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");
    $strentries  = get_string("entries", "glossary");

    if ($course->format == "weeks") {
        $table->head  = array ($strweek, $strname, $strentries);
        $table->align = array ("CENTER", "LEFT", "CENTER");
    } else if ($course->format == "topics") {
        $table->head  = array ($strtopic, $strname, $strentries);
        $table->align = array ("CENTER", "LEFT", "CENTER");
    } else {
        $table->head  = array ($strname, $strentries);
        $table->align = array ("LEFT", "CENTER");
    }

    $can_subscribe = (isstudent($course->id) or isteacher($course->id) or isadmin());

    if ($show_rss = (($can_subscribe || $course->id == SITEID) && 
                     isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) &&
                     $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds)) {
        $table->head[] = $strrss;
        $table->align[] = "CENTER";
    }

    $currentsection = "";

    foreach ($glossarys as $glossary) {
        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>";
        }
        $printsection = "";
        if ($glossary->section !== $currentsection) {
            if ($glossary->section) {
                $printsection = $glossary->section;
            }
            if ($currentsection !== "") {
                $table->data[] = 'hr';
            }
            $currentsection = $glossary->section;
        }

        $count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = $glossary->id or sourceglossaryid = $glossary->id)");

        //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);
                if (empty($USER->id)) {
                    $userid = 0;
                } else {
                    $userid = $USER->id;
                }
                //Get html code for RSS link
                $rsslink = rss_get_link($course->id, $userid, "glossary", $glossary->id, $tooltiptext);
            }
        }

        if ($course->format == "weeks" or $course->format == "topics") {
            $linedata = array ($printsection, $link, $count);
        } else {
            $linedata = array ($link, $count);
        }

        if ($show_rss) {
            $linedata[] = $rsslink;
        }

        $table->data[] = $linedata;
    }

    echo "<br />";

    print_table($table);

/// Finish the page

    print_footer($course);

?>