From d208d07b7f5c256879897e514ec9d1c22105709a Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 7 May 2004 02:27:56 +0000 Subject: [PATCH] Renamed "weeks_topics" to "section_links" --- blocks/section_links/block_section_links.php | 73 ++++++++++++++++++++ blocks/section_links/db/mysql.php | 33 +++++++++ blocks/section_links/db/mysql.sql | 0 blocks/section_links/db/postgres7.php | 33 +++++++++ blocks/section_links/db/postgres7.sql | 0 5 files changed, 139 insertions(+) create mode 100644 blocks/section_links/block_section_links.php create mode 100644 blocks/section_links/db/mysql.php create mode 100644 blocks/section_links/db/mysql.sql create mode 100644 blocks/section_links/db/postgres7.php create mode 100644 blocks/section_links/db/postgres7.sql diff --git a/blocks/section_links/block_section_links.php b/blocks/section_links/block_section_links.php new file mode 100644 index 00000000000..525e2f5b874 --- /dev/null +++ b/blocks/section_links/block_section_links.php @@ -0,0 +1,73 @@ +format == 'topics') { + $this->title = get_string('topics', 'block_section_links'); + } + else if ($course->format == 'weeks') { + $this->title = get_string('weeks', 'block_section_links'); + } + else { + $this->title = get_string('blockname', 'block_section_links'); + } + $this->content_type = BLOCK_TYPE_TEXT; + $this->course = $course; + $this->version = 2004050500; + } + + function applicable_formats() { + return (COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS); + } + + function get_content() { + global $CFG, $USER; + + $highlight = 0; + + if($this->content !== NULL) { + return $this->content; + } + + if ($this->course->format == 'weeks') { + $highlight = ceil((time()-$this->course->startdate)/604800); + $linktext = get_string('jumptocurrentweek', 'block_section_links'); + } + else if ($this->course->format == 'topics') { + $highlight = $this->course->marker; + $linktext = get_string('jumptocurrenttopic', 'block_section_links'); + } + $inc = 1; + if ($this->course->numsections > 22) { + $inc = 2; + } + if ($this->course->numsections > 40) { + $inc = 5; + } + $courseid = $this->course->id; + if ($display = get_field('course_display', 'display', 'course', $courseid, 'userid', $USER->id)) { + $link = "$CFG->wwwroot/course/view.php?id=$courseid&topic=all"; + } else { + $link = ''; + } + $text = ''; + for ($i = $inc; $i <= $this->course->numsections; $i += $inc) { + if ($i == $highlight) { + $text .= "$i "; + } else { + $text .= "$i "; + } + } + if ($highlight) { + $text .= "
$linktext"; + } + + $this->content = New object; + $this->content->header = 'Hello'; + $this->content->footer = ''; + $this->content->text = $text; + return $this->content; + } +} +?> diff --git a/blocks/section_links/db/mysql.php b/blocks/section_links/db/mysql.php new file mode 100644 index 00000000000..897bb3032a7 --- /dev/null +++ b/blocks/section_links/db/mysql.php @@ -0,0 +1,33 @@ +