Changes for XHTML and accessibility compliance
[moodle.git] / blocks / social_activities / block_social_activities.php
CommitLineData
0f3fe4b6 1<?php //$Id$
2
3class CourseBlock_social_activities extends MoodleBlock {
4 function CourseBlock_social_activities ($course) {
5 $this->title = get_string('blockname','block_social_activities');
6 $this->content_type = BLOCK_TYPE_LIST;
7 $this->course = $course;
8 $this->version = 2004041800;
9 }
10
11 function applicable_formats() {
2b0d60ec 12 return array('social' => true);
0f3fe4b6 13 }
14
15 function get_content() {
16 global $USER, $CFG;
17
2eb68e6f 18 if ($this->content !== NULL) {
0f3fe4b6 19 return $this->content;
20 }
2eb68e6f 21 if (empty($this->course)) {
22 return '';
23 }
0f3fe4b6 24
25 $this->content = New object;
26 $this->content->items = array();
27 $this->content->icons = array();
28 $this->content->footer = '';
29
30 // To make our day, we start with an ugly hack
31 global $sections, $mods, $modnames;
32
33 $section = $sections[0];
34 // That wasn't so bad, was it?
35
36 $groupbuttons = $this->course->groupmode;
37 $groupbuttonslink = (!$this->course->groupmodeforce);
38 $isteacher = isteacher($this->course->id);
39 $isediting = isediting($this->course->id);
40 $ismoving = ismoving($this->course->id);
41 if ($ismoving) {
42 $strmovehere = get_string('movehere');
43 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
44 $strcancel= get_string('cancel');
45 $stractivityclipboard = $USER->activitycopyname;
46 }
47
48 $modinfo = unserialize($this->course->modinfo);
49 $editbuttons = '';
50
51 if ($ismoving) {
839f2456 52 $this->content->icons[] = '&nbsp;<img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11" alt=\"\" />';
facf75c1 53 $this->content->items[] = $USER->activitycopyname.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true">'.$strcancel.'</a>)';
0f3fe4b6 54 }
55
56 if (!empty($section->sequence)) {
57 $sectionmods = explode(',', $section->sequence);
58 foreach ($sectionmods as $modnumber) {
59 if (empty($mods[$modnumber])) {
60 continue;
61 }
62 $mod = $mods[$modnumber];
63 if ($isediting && !$ismoving) {
64 if ($groupbuttons) {
65 if (! $mod->groupmodelink = $groupbuttonslink) {
66 $mod->groupmode = $this->course->groupmode;
67 }
68
69 } else {
70 $mod->groupmode = false;
71 }
72 $editbuttons = '<br />'.make_editing_buttons($mod, true, true);
73 } else {
74 $editbuttons = '';
75 }
76 if ($mod->visible || $isteacher) {
77 if ($ismoving) {
78 if ($mod->id == $USER->activitycopy) {
79 continue;
80 }
81 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'">'.
98ea2a6e 82 '<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0" /></a>';
0f3fe4b6 83 $this->content->icons[] = '';
84 }
85 $instancename = urldecode($modinfo[$modnumber]->name);
86 if (!empty($CFG->filterall)) {
87 $instancename = filter_text('<nolink>'.$instancename.'</nolink>', $this->course->id);
88 }
89 $linkcss = $mod->visible ? '' : ' class="dimmed" ';
90 if (!empty($modinfo[$modnumber]->extra)) {
91 $extra = urldecode($modinfo[$modnumber]->extra);
92 } else {
93 $extra = '';
94 }
facf75c1 95 if (!empty($modinfo[$modnumber]->icon)) {
96 $icon = $CFG->pixpath.'/'.urldecode($modinfo[$modnumber]->icon);
97 } else {
98 $icon = $CFG->modpixpath.'/'.$mod->modname.'/icon.gif';
99 }
0f3fe4b6 100
101 if ($mod->modname == 'label') {
102 $this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
103 $this->content->icons[] = '';
104 } else {
105 $this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
106 ' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$instancename.'</a>'.$editbuttons;
98ea2a6e 107 $this->content->icons[] = '<img src="'.$icon.'" height="16" width="16" alt="'.$mod->modfullname.'" />';
0f3fe4b6 108 }
109 }
110 }
111 }
112
113 if ($ismoving) {
114 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'">'.
98ea2a6e 115 '<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0" /></a>';
0f3fe4b6 116 $this->content->icons[] = '';
117 }
118
119 if ($isediting && $modnames) {
120 $this->content->footer = '<div style="text-align: right;">'.
cb57e6f4 121 print_section_add_menus($this->course, 0, $modnames, true, true).'</div>';
0f3fe4b6 122 } else {
123 $this->content->footer = '';
124 }
125
126 return $this->content;
127 }
128}
129
130?>