[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/course/format/weekscss/ -> format.php (source)

   1  <?php // $Id: format.php,v 1.24.2.4 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   * Evaluation weekly format for course display - NO layout tables, for accessibility, etc.
   6   * 
   7   * A duplicate course format to enable the Moodle development team to evaluate 
   8   * CSS for the multi-column layout in place of layout tables. 
   9   * Less risk for the Moodle 1.6 beta release.
  10   *   1. Straight copy of weeks/format.php
  11   *   2. Replace <table> and <td> with DIVs; inline styles.
  12   *   3. Reorder columns so that in linear view content is first then blocks;
  13   * styles to maintain original graphical (side by side) view.
  14   *
  15   * Target: 3-column graphical view using relative widths for pixel screen sizes 
  16   * 800x600, 1024x768... on IE6, Firefox. Below 800 columns will shift downwards.
  17   * 
  18   * http://www.maxdesign.com.au/presentation/em/ Ideal length for content.
  19   * http://www.svendtofte.com/code/max_width_in_ie/ Max width in IE.
  20   *
  21   * @copyright &copy; 2006 The Open University
  22   * @author N.D.Freear@open.ac.uk, and others.
  23   * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
  24   * @package  
  25   */
  26  //TODO (nfreear): Accessibility: evaluation, lang/en_utf8/moodle.php: $string['formatweekscss']
  27  
  28      $week = optional_param('week', -1, PARAM_INT);
  29  
  30      if ($week != -1) {
  31          $displaysection = course_set_display($course->id, $week);
  32      } else {
  33          if (isset($USER->display[$course->id])) {
  34              $displaysection = $USER->display[$course->id];
  35          } else {
  36              $displaysection = course_set_display($course->id, 0);
  37          }
  38      }
  39  
  40      $streditsummary  = get_string('editsummary');
  41      $stradd          = get_string('add');
  42      $stractivities   = get_string('activities');
  43      $strshowallweeks = get_string('showallweeks');
  44      $strweek         = get_string('week');
  45      $strgroups       = get_string('groups');
  46      $strgroupmy      = get_string('groupmy');
  47      $editing         = $PAGE->user_is_editing();
  48  
  49      if ($editing) {
  50          $strstudents = moodle_strtolower($course->students);
  51          $strweekhide = get_string('weekhide', '', $strstudents);
  52          $strweekshow = get_string('weekshow', '', $strstudents);
  53          $strmoveup   = get_string('moveup');
  54          $strmovedown = get_string('movedown');
  55      }
  56  
  57      $context = get_context_instance(CONTEXT_COURSE, $course->id);
  58  /* Internet Explorer min-width fix. (See theme/standard/styles_layout.css: min-width for Firefox.)
  59     Window width: 800px, Firefox 763px, IE 752px. (Window width: 640px, Firefox 602px, IE 588px.)    
  60  */
  61  ?>
  62  
  63  <!--[if IE]>
  64    <style type="text/css">
  65    .weekscss-format { width: expression(document.body.clientWidth < 800 ? "752px" : "auto"); }
  66    </style>
  67  <![endif]-->
  68  <?php
  69  /// Layout the whole page as three big columns (was, id="layout-table")
  70      echo '<div class="weekscss-format">';
  71  
  72  /// The left column ...
  73  
  74      if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
  75          echo '<div id="left-column">';
  76          blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
  77          echo '</div>';
  78      }
  79      
  80  /// The right column, BEFORE the middle-column.
  81      if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
  82          echo '<div id="right-column">';
  83          blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
  84          echo '</div>';
  85      }
  86  
  87  /// Start main column
  88      echo '<div id="middle-column">'. skip_main_destination();
  89  
  90      print_heading_block(get_string('weeklyoutline'), 'outline');
  91  
  92      // Note, an ordered list would confuse - "1" could be the clipboard or summary.
  93      echo "<ul class='weekscss'>\n";
  94  
  95  /// If currently moving a file then show the current clipboard
  96      if (ismoving($course->id)) {
  97          $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
  98          $strcancel= get_string('cancel');
  99          echo '<li class="clipboard">';
 100          echo $stractivityclipboard.'&nbsp;&nbsp;(<a href="mod.php?cancelcopy=true&amp;sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)';
 101          echo "</li>\n";
 102      }
 103  
 104  /// Print Section 0 with general activities
 105  
 106      $section = 0;
 107      $thissection = $sections[$section];
 108  
 109      if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
 110  
 111          // Note, no need for a 'left side' cell or DIV.
 112          // Note, 'right side' is BEFORE content.
 113          echo '<li id="section-0" class="section main" >';
 114          echo '<div class="right side" >&nbsp;</div>';        
 115          echo '<div class="content">';
 116          
 117          echo '<div class="summary">';
 118          $summaryformatoptions->noclean = true;
 119          echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
 120  
 121          if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
 122              echo '<p><a title="'.$streditsummary.'" '.
 123                   ' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
 124                   ' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
 125          }
 126          echo '</div>';
 127          
 128          print_section($course, $thissection, $mods, $modnamesused);
 129  
 130          if (isediting($course->id)) {
 131              print_section_add_menus($course, $section, $modnames);
 132          }
 133  
 134          echo '</div>';
 135          echo "</li>\n";
 136      }
 137  
 138  
 139  /// Now all the normal modules by week
 140  /// Everything below uses "section" terminology - each "section" is a week.
 141  
 142      $timenow = time();
 143      $weekdate = $course->startdate;    // this should be 0:00 Monday of that week
 144      $weekdate += 7200;                 // Add two hours to avoid possible DST problems
 145      $section = 1;
 146      $sectionmenu = array();
 147      $weekofseconds = 604800;
 148      $course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
 149  
 150      $strftimedateshort = ' '.get_string('strftimedateshort');
 151  
 152      while ($weekdate < $course->enddate) {
 153  
 154          $nextweekdate = $weekdate + ($weekofseconds);
 155          $weekday = userdate($weekdate, $strftimedateshort);
 156          $endweekday = userdate($weekdate+518400, $strftimedateshort);
 157  
 158          if (!empty($sections[$section])) {
 159              $thissection = $sections[$section];
 160  
 161          } else {
 162              unset($thissection);
 163              $thissection->course = $course->id;   // Create a new week structure
 164              $thissection->section = $section;
 165              $thissection->summary = '';
 166              $thissection->visible = 1;
 167              if (!$thissection->id = insert_record('course_sections', $thissection)) {
 168                  notify('Error inserting new week!');
 169              }
 170          }
 171  
 172          $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
 173  
 174          if (!empty($displaysection) and $displaysection != $section) {  // Check this week is visible
 175              if ($showsection) {
 176                  $sectionmenu['week='.$section] = s("$strweek $section |     $weekday - $endweekday");
 177              }
 178              $section++;
 179              $weekdate = $nextweekdate;
 180              continue;
 181          }
 182  
 183          if ($showsection) {
 184  
 185              $currentweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
 186  
 187              $currenttext = '';
 188              if (!$thissection->visible) {
 189                  $sectionstyle = ' hidden';
 190              } else if ($currentweek) {
 191                  $sectionstyle = ' current';
 192                  $currenttext = get_accesshide(get_string('currentweek','access'));
 193              } else {
 194                  $sectionstyle = '';
 195              }
 196  
 197              echo '<li id="section-'.$section.'" class="section main'.$sectionstyle.'" >'; //'<div class="left side">&nbsp;</div>';
 198  
 199              // Note, 'right side' is BEFORE content.
 200              echo '<div class="right side">';
 201              
 202              if ($displaysection == $section) {
 203                  echo '<a href="view.php?id='.$course->id.'&amp;week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
 204                       '<img src="'.$CFG->pixpath.'/i/all.gif" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
 205              } else {
 206                  $strshowonlyweek = get_string("showonlyweek", "", $section);
 207                  echo '<a href="view.php?id='.$course->id.'&amp;week='.$section.'" title="'.$strshowonlyweek.'">'.
 208                       '<img src="'.$CFG->pixpath.'/i/one.gif" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
 209              }
 210  
 211              if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
 212                  if ($thissection->visible) {        // Show the hide/show eye
 213                      echo '<a href="view.php?id='.$course->id.'&amp;hide='.$section.'&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekhide.'">'.
 214                           '<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
 215                  } else {
 216                      echo '<a href="view.php?id='.$course->id.'&amp;show='.$section.'&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekshow.'">'.
 217                           '<img src="'.$CFG->pixpath.'/i/show.gif" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
 218                  }
 219                  if ($section > 1) {                       // Add a arrow to move section up
 220                      echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=-1&amp;sesskey='.$USER->sesskey.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
 221                           '<img src="'.$CFG->pixpath.'/t/up.gif" class="icon up" alt="'.$strmoveup.'" /></a><br />';
 222                  }
 223  
 224                  if ($section < $course->numsections) {    // Add a arrow to move section down
 225                      echo '<a href="view.php?id='.$course->id.'&amp;random='.rand(1,10000).'&amp;section='.$section.'&amp;move=1&amp;sesskey='.$USER->sesskey.'#section-'.($section+1).'" title="'.$strmovedown.'">'.
 226                           '<img src="'.$CFG->pixpath.'/t/down.gif" class="icon down" alt="'.$strmovedown.'" /></a><br />';
 227                  }
 228              }
 229              echo '</div>';
 230  
 231              $weekperiod = $weekday.' - '.$endweekday;
 232  
 233              echo '<div class="content">';
 234              if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) {   // Hidden for students
 235                  print_heading($currenttext.$weekperiod.' ('.get_string('notavailable').')', null, 3, 'weekdates');
 236  
 237              } else {
 238                  print_heading($currenttext.$weekperiod, null, 3, 'weekdates');
 239  
 240                  echo '<div class="summary">';
 241                  $summaryformatoptions->noclean = true;
 242                  echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
 243  
 244                  if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
 245                      echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
 246                           '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
 247                  }
 248                  echo '</div>';
 249  
 250                  print_section($course, $thissection, $mods, $modnamesused);
 251  
 252                  if (isediting($course->id)) {
 253                      print_section_add_menus($course, $section, $modnames);
 254                  }
 255              }
 256  
 257              echo '</div>';
 258              echo "</li>\n";
 259          }
 260  
 261          $section++;
 262          $weekdate = $nextweekdate;
 263      }
 264      echo "</ul>\n";
 265  
 266      if (!empty($sectionmenu)) {
 267          echo '<div align="center" class="jumpmenu">';
 268          echo popup_form($CFG->wwwroot.'/course/view.php?id='.$course->id.'&amp;', $sectionmenu,
 269                     'sectionmenu', '', get_string('jumpto'), '', '', true);
 270          echo '</div>';
 271      }
 272  
 273      echo '</div>';
 274  
 275      echo '</div>';
 276      echo '<div class="clearer"></div>';
 277  
 278  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7