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