| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: format.php,v 1.83.2.2 2007/11/23 16:41:19 skodak Exp $ 2 // Display the whole course as "topics" made of of modules 3 // In fact, this is very similar to the "weeks" format, in that 4 // each "topic" is actually a week. The main difference is that 5 // the dates aren't printed - it's just an aesthetic thing for 6 // courses that aren't so rigidly defined by time. 7 // Included from "view.php" 8 9 10 require_once($CFG->libdir.'/ajax/ajaxlib.php'); 11 12 $topic = optional_param('topic', -1, PARAM_INT); 13 14 // Bounds for block widths 15 // more flexible for theme designers taken from theme config.php 16 $lmin = (empty($THEME->block_l_min_width)) ? 100 : $THEME->block_l_min_width; 17 $lmax = (empty($THEME->block_l_max_width)) ? 210 : $THEME->block_l_max_width; 18 $rmin = (empty($THEME->block_r_min_width)) ? 100 : $THEME->block_r_min_width; 19 $rmax = (empty($THEME->block_r_max_width)) ? 210 : $THEME->block_r_max_width; 20 21 define('BLOCK_L_MIN_WIDTH', $lmin); 22 define('BLOCK_L_MAX_WIDTH', $lmax); 23 define('BLOCK_R_MIN_WIDTH', $rmin); 24 define('BLOCK_R_MAX_WIDTH', $rmax); 25 26 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 27 BLOCK_L_MAX_WIDTH); 28 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 29 BLOCK_R_MAX_WIDTH); 30 31 if ($topic != -1) { 32 $displaysection = course_set_display($course->id, $topic); 33 } else { 34 if (isset($USER->display[$course->id])) { // for admins, mostly 35 $displaysection = $USER->display[$course->id]; 36 } else { 37 $displaysection = course_set_display($course->id, 0); 38 } 39 } 40 41 $context = get_context_instance(CONTEXT_COURSE, $course->id); 42 43 if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) { 44 $course->marker = $marker; 45 if (! set_field("course", "marker", $marker, "id", $course->id)) { 46 error("Could not mark that topic for this course"); 47 } 48 } 49 50 $streditsummary = get_string('editsummary'); 51 $stradd = get_string('add'); 52 $stractivities = get_string('activities'); 53 $strshowalltopics = get_string('showalltopics'); 54 $strtopic = get_string('topic'); 55 $strgroups = get_string('groups'); 56 $strgroupmy = get_string('groupmy'); 57 $editing = $PAGE->user_is_editing(); 58 59 if ($editing) { 60 $strstudents = moodle_strtolower($course->students); 61 $strtopichide = get_string('topichide', '', $strstudents); 62 $strtopicshow = get_string('topicshow', '', $strstudents); 63 $strmarkthistopic = get_string('markthistopic'); 64 $strmarkedthistopic = get_string('markedthistopic'); 65 $strmoveup = get_string('moveup'); 66 $strmovedown = get_string('movedown'); 67 } 68 69 70 /// Layout the whole page as three big columns. 71 echo '<table id="layout-table" cellspacing="0" summary="'.get_string('layouttable').'"><tr>'; 72 73 /// The left column ... 74 $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable; 75 foreach ($lt as $column) { 76 switch ($column) { 77 case 'left': 78 79 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) { 80 echo '<td style="width:'.$preferred_width_left.'px" id="left-column">'; 81 print_container_start(); 82 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); 83 print_container_end(); 84 echo '</td>'; 85 } 86 87 break; 88 case 'middle': 89 /// Start main column 90 echo '<td id="middle-column">'; 91 print_container_start(); 92 echo skip_main_destination(); 93 94 print_heading_block(get_string('topicoutline'), 'outline'); 95 96 echo '<table class="topics" width="100%" summary="'.get_string('layouttable').'">'; 97 98 /// If currently moving a file then show the current clipboard 99 if (ismoving($course->id)) { 100 $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname))); 101 $strcancel= get_string('cancel'); 102 echo '<tr class="clipboard">'; 103 echo '<td colspan="3">'; 104 echo $stractivityclipboard.' (<a href="mod.php?cancelcopy=true&sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)'; 105 echo '</td>'; 106 echo '</tr>'; 107 } 108 109 /// Print Section 0 110 111 $section = 0; 112 $thissection = $sections[$section]; 113 114 if ($thissection->summary or $thissection->sequence or isediting($course->id)) { 115 echo '<tr id="section-0" class="section main">'; 116 echo '<td class="left side"> </td>'; 117 echo '<td class="content">'; 118 119 echo '<div class="summary">'; 120 $summaryformatoptions->noclean = true; 121 echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions); 122 123 if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) { 124 echo '<a title="'.$streditsummary.'" '. 125 ' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '. 126 ' alt="'.$streditsummary.'" /></a><br /><br />'; 127 } 128 echo '</div>'; 129 130 print_section($course, $thissection, $mods, $modnamesused); 131 132 if (isediting($course->id)) { 133 print_section_add_menus($course, $section, $modnames); 134 } 135 136 echo '</td>'; 137 echo '<td class="right side"> </td>'; 138 echo '</tr>'; 139 echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>'; 140 } 141 142 143 /// Now all the normal modules by topic 144 /// Everything below uses "section" terminology - each "section" is a topic. 145 146 $timenow = time(); 147 $section = 1; 148 $sectionmenu = array(); 149 150 while ($section <= $course->numsections) { 151 152 if (!empty($sections[$section])) { 153 $thissection = $sections[$section]; 154 155 } else { 156 unset($thissection); 157 $thissection->course = $course->id; // Create a new section structure 158 $thissection->section = $section; 159 $thissection->summary = ''; 160 $thissection->visible = 1; 161 if (!$thissection->id = insert_record('course_sections', $thissection)) { 162 notify('Error inserting new topic!'); 163 } 164 } 165 166 $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections); 167 168 if (!empty($displaysection) and $displaysection != $section) { 169 if ($showsection) { 170 $strsummary = strip_tags(format_string($thissection->summary,true)); 171 if (strlen($strsummary) < 57) { 172 $strsummary = ' - '.$strsummary; 173 } else { 174 $strsummary = ' - '.substr($strsummary, 0, 60).'...'; 175 } 176 $sectionmenu['topic='.$section] = s($section.$strsummary); 177 } 178 $section++; 179 continue; 180 } 181 182 if ($showsection) { 183 184 $currenttopic = ($course->marker == $section); 185 186 $currenttext = ''; 187 if (!$thissection->visible) { 188 $sectionstyle = ' hidden'; 189 } else if ($currenttopic) { 190 $sectionstyle = ' current'; 191 $currenttext = get_accesshide(get_string('currenttopic','access')); 192 } else { 193 $sectionstyle = ''; 194 } 195 196 echo '<tr id="section-'.$section.'" class="section main'.$sectionstyle.'">'; 197 echo '<td class="left side">'.$currenttext.$section.'</td>'; 198 199 echo '<td class="content">'; 200 if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students 201 echo get_string('notavailable'); 202 } else { 203 echo '<div class="summary">'; 204 $summaryformatoptions->noclean = true; 205 echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions); 206 207 if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) { 208 echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'. 209 '<img src="'.$CFG->pixpath.'/t/edit.gif" alt="'.$streditsummary.'" /></a><br /><br />'; 210 } 211 echo '</div>'; 212 213 print_section($course, $thissection, $mods, $modnamesused); 214 215 if (isediting($course->id)) { 216 print_section_add_menus($course, $section, $modnames); 217 } 218 } 219 echo '</td>'; 220 221 echo '<td class="right side">'; 222 if ($displaysection == $section) { // Show the zoom boxes 223 echo '<a href="view.php?id='.$course->id.'&topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'. 224 '<img src="'.$CFG->pixpath.'/i/all.gif" alt="'.$strshowalltopics.'" /></a><br />'; 225 } else { 226 $strshowonlytopic = get_string('showonlytopic', '', $section); 227 echo '<a href="view.php?id='.$course->id.'&topic='.$section.'" title="'.$strshowonlytopic.'">'. 228 '<img src="'.$CFG->pixpath.'/i/one.gif" alt="'.$strshowonlytopic.'" /></a><br />'; 229 } 230 231 if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) { 232 if ($course->marker == $section) { // Show the "light globe" on/off 233 echo '<a href="view.php?id='.$course->id.'&marker=0&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkedthistopic.'">'. 234 '<img src="'.$CFG->pixpath.'/i/marked.gif" alt="'.$strmarkedthistopic.'" /></a><br />'; 235 } else { 236 echo '<a href="view.php?id='.$course->id.'&marker='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkthistopic.'">'. 237 '<img src="'.$CFG->pixpath.'/i/marker.gif" alt="'.$strmarkthistopic.'" /></a><br />'; 238 } 239 240 if ($thissection->visible) { // Show the hide/show eye 241 echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopichide.'">'. 242 '<img src="'.$CFG->pixpath.'/i/hide.gif" alt="'.$strtopichide.'" /></a><br />'; 243 } else { 244 echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopicshow.'">'. 245 '<img src="'.$CFG->pixpath.'/i/show.gif" alt="'.$strtopicshow.'" /></a><br />'; 246 } 247 248 if ($section > 1) { // Add a arrow to move section up 249 echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=-1&sesskey='.$USER->sesskey.'#section-'.($section-1).'" title="'.$strmoveup.'">'. 250 '<img src="'.$CFG->pixpath.'/t/up.gif" alt="'.$strmoveup.'" /></a><br />'; 251 } 252 253 if ($section < $course->numsections) { // Add a arrow to move section down 254 echo '<a href="view.php?id='.$course->id.'&random='.rand(1,10000).'&section='.$section.'&move=1&sesskey='.$USER->sesskey.'#section-'.($section+1).'" title="'.$strmovedown.'">'. 255 '<img src="'.$CFG->pixpath.'/t/down.gif" alt="'.$strmovedown.'" /></a><br />'; 256 } 257 258 } 259 260 echo '</td></tr>'; 261 echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>'; 262 } 263 264 $section++; 265 } 266 echo '</table>'; 267 268 if (!empty($sectionmenu)) { 269 echo '<div align="center" class="jumpmenu">'; 270 echo popup_form($CFG->wwwroot.'/course/view.php?id='.$course->id.'&', $sectionmenu, 271 'sectionmenu', '', get_string('jumpto'), '', '', true); 272 echo '</div>'; 273 } 274 275 print_container_end(); 276 echo '</td>'; 277 278 break; 279 case 'right': 280 // The right column 281 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) { 282 echo '<td style="width:'.$preferred_width_right.'px" id="right-column">'; 283 print_container_start(); 284 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); 285 print_container_end(); 286 echo '</td>'; 287 } 288 289 break; 290 } 291 } 292 echo '</tr></table>'; 293 294 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |