[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Social activities block. 19 * 20 * @package block_social_activities 21 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 class block_social_activities extends block_list { 26 function init(){ 27 $this->title = get_string('pluginname', 'block_social_activities'); 28 } 29 30 function applicable_formats() { 31 return array('course-view-social' => true); 32 } 33 34 function get_content() { 35 global $USER, $CFG, $DB, $OUTPUT; 36 37 if ($this->content !== NULL) { 38 return $this->content; 39 } 40 41 $this->content = new stdClass(); 42 $this->content->items = array(); 43 $this->content->icons = array(); 44 $this->content->footer = ''; 45 46 if (empty($this->instance)) { 47 return $this->content; 48 } 49 50 $course = $this->page->course; 51 52 require_once($CFG->dirroot.'/course/lib.php'); 53 54 $context = context_course::instance($course->id); 55 $isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context); 56 $modinfo = get_fast_modinfo($course); 57 58 /// extra fast view mode 59 if (!$isediting) { 60 if (!empty($modinfo->sections[0])) { 61 $options = array('overflowdiv'=>true); 62 foreach($modinfo->sections[0] as $cmid) { 63 $cm = $modinfo->cms[$cmid]; 64 if (!$cm->uservisible) { 65 continue; 66 } 67 68 $content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true)); 69 $instancename = $cm->get_formatted_name(); 70 71 if (!($url = $cm->url)) { 72 $this->content->items[] = $content; 73 $this->content->icons[] = ''; 74 } else { 75 $linkcss = $cm->visible ? '' : ' class="dimmed" '; 76 //Accessibility: incidental image - should be empty Alt text 77 $icon = '<img src="' . $cm->get_icon_url() . '" class="icon" alt="" /> '; 78 $this->content->items[] = '<a title="'.$cm->modplural.'" '.$linkcss.' '.$cm->extra. 79 ' href="' . $url . '">' . $icon . $instancename . '</a>'; 80 } 81 } 82 } 83 return $this->content; 84 } 85 86 87 // Slow & hacky editing mode. 88 /** @var core_course_renderer $courserenderer */ 89 $courserenderer = $this->page->get_renderer('core', 'course'); 90 $ismoving = ismoving($course->id); 91 $modinfo = get_fast_modinfo($course); 92 $section = $modinfo->get_section_info(0); 93 94 if ($ismoving) { 95 $strmovehere = get_string('movehere'); 96 $strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'")); 97 $strcancel= get_string('cancel'); 98 $stractivityclipboard = $USER->activitycopyname; 99 } else { 100 $strmove = get_string('move'); 101 } 102 $editbuttons = ''; 103 104 if ($ismoving) { 105 $this->content->icons[] = ' <img align="bottom" src="'.$OUTPUT->pix_url('t/move') . '" class="iconsmall" alt="" />'; 106 $this->content->items[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&sesskey='.sesskey().'">'.$strcancel.'</a>)'; 107 } 108 109 if (!empty($modinfo->sections[0])) { 110 $options = array('overflowdiv'=>true); 111 foreach ($modinfo->sections[0] as $modnumber) { 112 $mod = $modinfo->cms[$modnumber]; 113 if (!$mod->uservisible) { 114 continue; 115 } 116 if (!$ismoving) { 117 $actions = course_get_cm_edit_actions($mod, -1); 118 119 // Prepend list of actions with the 'move' action. 120 $actions = array('move' => new action_menu_link_primary( 121 new moodle_url('/course/mod.php', array('sesskey' => sesskey(), 'copy' => $mod->id)), 122 new pix_icon('t/move', $strmove, 'moodle', array('class' => 'iconsmall', 'title' => '')), 123 $strmove 124 )) + $actions; 125 126 $editbuttons = html_writer::tag('div', 127 $courserenderer->course_section_cm_edit_actions($actions, $mod, array('donotenhance' => true)), 128 array('class' => 'buttons') 129 ); 130 } else { 131 $editbuttons = ''; 132 } 133 if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $mod->context)) { 134 if ($ismoving) { 135 if ($mod->id == $USER->activitycopy) { 136 continue; 137 } 138 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&sesskey='.sesskey().'">'. 139 '<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>'; 140 $this->content->icons[] = ''; 141 } 142 $content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true)); 143 $instancename = $mod->get_formatted_name(); 144 145 $linkcss = $mod->visible ? '' : ' class="dimmed" '; 146 147 if (!($url = $mod->url)) { 148 $this->content->items[] = $content . $editbuttons; 149 $this->content->icons[] = ''; 150 } else { 151 //Accessibility: incidental image - should be empty Alt text 152 $icon = '<img src="' . $mod->get_icon_url() . '" class="icon" alt="" /> '; 153 $this->content->items[] = '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $mod->extra . 154 ' href="' . $url . '">' . $icon . $instancename . '</a>' . $editbuttons; 155 } 156 } 157 } 158 } 159 160 if ($ismoving) { 161 $this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&sesskey='.sesskey().'">'. 162 '<img style="height:16px; width:80px; border:0px" src="'.$OUTPUT->pix_url('movehere') . '" alt="'.$strmovehere.'" /></a>'; 163 $this->content->icons[] = ''; 164 } 165 166 $this->content->footer = $courserenderer->course_section_add_cm_control($course, 167 0, null, array('inblock' => true)); 168 169 return $this->content; 170 } 171 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |