[ Index ]

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

title

Body

[close]

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

   1  <?php // $Id: format.php,v 1.25.2.1 2007/10/22 06:54:40 nfreear Exp $
   2  // In fact, this is very similar to the "topics" format. 
   3  // The main difference is that news forum is replaced by LAMS learner
   4  // interface.
   5  
   6  require_once($CFG->dirroot.'/mod/lams/constants.php');
   7  require_once($CFG->dirroot.'/lib/weblib.php');
   8  
   9  $topic = optional_param('topic', -1, PARAM_INT);
  10  // Bounds for block widths
  11  // more flexible for theme designers taken from theme config.php
  12  $lmin = (empty($THEME->block_l_min_width)) ? 100 : $THEME->block_l_min_width;
  13  $lmax = (empty($THEME->block_l_max_width)) ? 210 : $THEME->block_l_max_width;
  14  $rmin = (empty($THEME->block_r_min_width)) ? 100 : $THEME->block_r_min_width;
  15  $rmax = (empty($THEME->block_r_max_width)) ? 210 : $THEME->block_r_max_width;
  16  
  17  define('BLOCK_L_MIN_WIDTH', $lmin);
  18  define('BLOCK_L_MAX_WIDTH', $lmax);
  19  define('BLOCK_R_MIN_WIDTH', $rmin);
  20  define('BLOCK_R_MAX_WIDTH', $rmax);
  21    
  22  $preferred_width_left  = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),  
  23                                          BLOCK_L_MAX_WIDTH);
  24  $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 
  25                                          BLOCK_R_MAX_WIDTH);
  26  
  27  if ($topic != -1) {
  28      $displaysection = course_set_display($course->id, $topic);
  29  } else {
  30      if (isset($USER->display[$course->id])) {       // for admins, mostly
  31          $displaysection = $USER->display[$course->id];
  32      } else {
  33          $displaysection = course_set_display($course->id, 0);
  34      }
  35  }
  36  
  37  $context = get_context_instance(CONTEXT_COURSE, $course->id);
  38  
  39  if (($marker >=0) and has_capability('moodle/course:setcurrentsection', $context) and confirm_sesskey()) {
  40      $course->marker = $marker;
  41      if (! set_field("course", "marker", $marker, "id", $course->id)) {
  42          error("Could not mark that topic for this course");
  43      }
  44  }
  45  
  46  $streditsummary   = get_string('editsummary');
  47  $stradd           = get_string('add');
  48  $stractivities    = get_string('activities');
  49  $strshowalltopics = get_string('showalltopics');
  50  $strtopic         = get_string('topic');
  51  $strgroups        = get_string('groups');
  52  $strgroupmy       = get_string('groupmy');
  53  $editing          = $PAGE->user_is_editing();
  54  
  55  if ($editing) {
  56      $strstudents = moodle_strtolower($course->students);
  57      $strtopichide = get_string('topichide', '', $strstudents);
  58      $strtopicshow = get_string('topicshow', '', $strstudents);
  59      $strmarkthistopic = get_string('markthistopic');
  60      $strmarkedthistopic = get_string('markedthistopic');
  61      $strmoveup = get_string('moveup');
  62      $strmovedown = get_string('movedown');
  63  }
  64  
  65  
  66  /// Layout the whole page as three big columns.
  67  echo '<table id="layout-table" cellspacing="0" summary="'.get_string('layouttable').'"><tr>';
  68  
  69  /// The left column ...
  70  
  71  if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
  72      echo '<td style="width:'.$preferred_width_left.'px" id="left-column">';
  73      blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
  74      echo '</td>';
  75  }
  76  
  77  /// Start main column
  78  echo '<td id="middle-column">'. skip_main_destination();
  79  
  80  print_heading_block(get_string('lamsoutline','lams'), 'outline');
  81  
  82  echo '<table class="topics" width="100%" height="100%" summary="'.get_string('layouttable').'">';
  83  
  84  /// If currently moving a file then show the current clipboard
  85  if (ismoving($course->id)) {
  86      $stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
  87      $strcancel= get_string('cancel');
  88      echo '<tr class="clipboard">';
  89      echo '<td colspan="3">';
  90      echo $stractivityclipboard.'&nbsp;&nbsp;(<a href="mod.php?cancelcopy=true&amp;sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)';
  91      echo '</td>';
  92      echo '</tr>';
  93  }
  94  
  95  /// Print Section 0
  96  
  97  $section = 0;
  98  $thissection = $sections[$section];
  99  
 100  if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
 101  
 102      echo '<tr id="section-0" class="section main">';
 103      echo '<td class="left side">&nbsp;</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', $course->id)) {
 111          echo '<a title="'.$streditsummary.'" '.
 112              ' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
 113              ' class="iconsmall" alt="'.$streditsummary.'" /></a><br /><br />';
 114      }
 115      echo '</div>';
 116      if(!isset($CFG->lams_serverurl)||!isset($CFG->lams_serverid)||!isset($CFG->lams_serverkey)){
 117          echo '<table width="100%" class="section">'.
 118              '<tr>'.
 119              '<td class="activity forum">'.
 120              '<table align="center" width="100%"  class="noticebox" border="0" cellpadding="15" cellspacing="0">'.
 121              '<tr><td bgcolor="#FFAAAA" class="noticeboxcontent">'.
 122              '<h3   class="main">All the LAMS module settings have not been set up!<br/> Please contact your administrator.</h3>'.
 123              '</td></tr></table>'.                                        
 124              '</td>'.
 125              '</tr>'.
 126              '</table>';
 127      }else{
 128          if(isediting($course->id)){//editing turned on. In this case
 129              echo '<table width="100%" class="section"><tr>';
 130              echo '<td align="left"><img src="../mod/lams/icon.gif" class="iconsmall" boarder="1" alt="LAMS"/>&nbsp;LAMS course</td>';
 131  
 132              $datetime =    date("F d,Y g:i a");
 133              $plaintext = trim($datetime).trim($USER->username).trim($LAMSCONSTANTS->author_method).trim($CFG->lams_serverid).trim($CFG->lams_serverkey);
 134              $hash = sha1(strtolower($plaintext));
 135              $author_url = $CFG->lams_serverurl.$LAMSCONSTANTS->login_request.
 136                  '?'.$LAMSCONSTANTS->param_uid.'='.$USER->username.
 137                  '&'.$LAMSCONSTANTS->param_method.'='.$LAMSCONSTANTS->author_method.
 138                  '&'.$LAMSCONSTANTS->param_timestamp.'='.urlencode($datetime).
 139                  '&'.$LAMSCONSTANTS->param_serverid.'='.$CFG->lams_serverid.
 140                  '&'.$LAMSCONSTANTS->param_hash.'='.$hash.
 141                  '&'.$LAMSCONSTANTS->param_courseid.'='.$course->id;
 142              echo '<div style="text-align: right"><td align="right">';
 143              //echo '<a target="popup" title="Open Author" href="../help.php?module=moodle&amp;file=resource/types.html"><span class="helplink"><img class="iconhelp" alt="Open Author" src="../pix/help.gif" /></span></a>';
 144              print_simple_box_start('right');
 145              echo '<a target="LAMS Author" title="LAMS Author" href="'.$author_url.'">'.get_string("openauthor", "lams").'</a>';
 146              print_simple_box_end();
 147  
 148              $datetime =    date("F d,Y g:i a");
 149              $plaintext = trim($datetime).trim($USER->username).trim($LAMSCONSTANTS->monitor_method).trim($CFG->lams_serverid).trim($CFG->lams_serverkey);
 150              $hash = sha1(strtolower($plaintext));
 151              $monitor_url = $CFG->lams_serverurl.$LAMSCONSTANTS->login_request.
 152                  '?'.$LAMSCONSTANTS->param_uid.'='.$USER->username.
 153                  '&'.$LAMSCONSTANTS->param_method.'='.$LAMSCONSTANTS->monitor_method.
 154                  '&'.$LAMSCONSTANTS->param_timestamp.'='.urlencode($datetime).
 155                  '&'.$LAMSCONSTANTS->param_serverid.'='.$CFG->lams_serverid.
 156                  '&'.$LAMSCONSTANTS->param_hash.'='.$hash.
 157                  '&'.$LAMSCONSTANTS->param_courseid.'='.$course->id;
 158  
 159              //echo '<a target="popup" title="Open Monitor" href="../help.php?module=moodle&amp;file=resource/types.html"><span class="helplink"><img class="iconhelp" alt="Open Monitor" src="../pix/help.gif" /></span></a>';                                                 
 160              print_simple_box_start('right');
 161              echo '<a target="LAMS Monitor" title="LAMS Monitor" href="'.$monitor_url.'">'.get_string("openmonitor", "lams").'</a>';
 162              print_simple_box_end();
 163              echo '</td></div>';
 164  
 165              echo '</tr></table>';                                                 
 166  
 167          }else{//editing turned off
 168              $datetime =    date("F d,Y g:i a");
 169              $plaintext = trim($datetime).trim($USER->username).trim($LAMSCONSTANTS->learner_method).trim($CFG->lams_serverid).trim($CFG->lams_serverkey);
 170              $hash = sha1(strtolower($plaintext));
 171              $url = $CFG->lams_serverurl.$LAMSCONSTANTS->login_request.
 172                  '?'.$LAMSCONSTANTS->param_uid.'='.$USER->username.
 173                  '&'.$LAMSCONSTANTS->param_method.'='.$LAMSCONSTANTS->learner_method.
 174                  '&'.$LAMSCONSTANTS->param_timestamp.'='.urlencode($datetime).
 175                  '&'.$LAMSCONSTANTS->param_serverid.'='.$CFG->lams_serverid.
 176                  '&'.$LAMSCONSTANTS->param_hash.'='.$hash.
 177                  '&'.$LAMSCONSTANTS->param_courseid.'='.$course->id;
 178  
 179              echo '<table width="100%" height="600" class="section">'.
 180                  '<tr>'.
 181                  '<td class="activity forum">'.
 182                  '<iframe name="iframe" id="iframe" src="'.$url.'"  width="100%" height="100%" frameborder="1">'.
 183                  '</iframe>'.
 184                  '</td>'.
 185                  '</tr>'.
 186                  '</table>';
 187          }
 188      }                            
 189      //print_section($course, $thissection, $mods, $modnamesused);
 190  
 191      /*if (isediting($course->id)) {
 192        print_section_add_menus($course, $section, $modnames);
 193        }*/
 194  
 195      echo '</td>';
 196      echo '<td class="right side">&nbsp;</td>';
 197      echo '</tr>';
 198      echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
 199  }
 200  
 201  
 202  /// Now all the normal modules by topic
 203  /// Everything below uses "section" terminology - each "section" is a topic.
 204  
 205  $timenow = time();
 206  $section = 1;
 207  $sectionmenu = array();
 208  
 209  while ($section <= $course->numsections) {
 210  
 211      if (!empty($sections[$section])) {
 212          $thissection = $sections[$section];
 213  
 214      } else {
 215          unset($thissection);
 216          $thissection->course = $course->id;   // Create a new section structure
 217          $thissection->section = $section;
 218          $thissection->summary = '';
 219          $thissection->visible = 1;
 220          if (!$thissection->id = insert_record('course_sections', $thissection)) {
 221              notify('Error inserting new topic!');
 222          }
 223      }
 224  
 225      $showsection = (has_capability('moodle/course:viewhiddensections', $context) or $thissection->visible or !$course->hiddensections);
 226  
 227      if (!empty($displaysection) and $displaysection != $section) {
 228          if ($showsection) {
 229              $strsummary = ' - '.strip_tags($thissection->summary);
 230              if (strlen($strsummary) < 57) {
 231                  $strsummary = ' - '.$strsummary;
 232              } else {
 233                  $strsummary = ' - '.substr($strsummary, 0, 60).'...';
 234              }
 235              $sectionmenu['topic='.$section] = s($section.$strsummary);
 236          }
 237          $section++;
 238          continue;
 239      }
 240  
 241      if ($showsection) {
 242  
 243          $currenttopic = ($course->marker == $section);
 244  
 245          $currenttext = '';
 246          if (!$thissection->visible) {
 247              $sectionstyle = ' hidden';
 248          } else if ($currenttopic) {
 249              $sectionstyle = ' current';
 250              $currenttext = get_accesshide(get_string('currenttopic','access'));
 251          } else {
 252              $sectionstyle = '';
 253          }
 254  
 255          echo '<tr id="section-'.$section.'" class="section main'.$sectionstyle.'">';
 256  
 257          echo '<td class="left side">&nbsp;'.$currenttext.'</td>';
 258  
 259          echo '<td class="content">';
 260          if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) {   // Hidden for students
 261              echo get_string('notavailable');
 262          } else {
 263              echo '<div class="summary">';
 264              $summaryformatoptions->noclean = true;
 265              echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
 266  
 267              if (isediting($course->id) && has_capability('moodle/course:update', $course->id)) {
 268                  echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
 269                      '<img src="'.$CFG->pixpath.'/t/edit.gif" class="iconsmall" alt="'.$streditsummary.'" /></a><br /><br />';
 270              }
 271              echo '</div>';
 272  
 273              print_section($course, $thissection, $mods, $modnamesused);
 274  
 275              if (isediting($course->id)) {
 276                  print_section_add_menus($course, $section, $modnames);
 277              }
 278          }
 279          echo '</td>';
 280  
 281          echo '<td class="right side">';
 282          if ($displaysection == $section) {      // Show the zoom boxes
 283              echo '<a href="view.php?id='.$course->id.'&amp;topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'.
 284                  '<img src="'.$CFG->pixpath.'/i/all.gif" height="25" width="16" border="0" alt="'.$strshowalltopics.'" /></a><br />';
 285          } else {
 286              $strshowonlytopic = get_string('showonlytopic', '', $section);
 287              echo '<a href="view.php?id='.$course->id.'&amp;topic='.$section.'" title="'.$strshowonlytopic.'">'.
 288                  '<img src="'.$CFG->pixpath.'/i/one.gif" height="16" width="16" border="0" alt="'.$strshowonlytopic.'" /></a><br />';
 289          }
 290  
 291              if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
 292              if ($course->marker == $section) {  // Show the "light globe" on/off
 293                  echo '<a href="view.php?id='.$course->id.'&amp;marker=0&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.
 294                      '<img src="'.$CFG->pixpath.'/i/marked.gif" height="16" width="16" border="0" alt="'.$strmarkedthistopic.'" /></a><br />';
 295              } else {
 296                  echo '<a href="view.php?id='.$course->id.'&amp;marker='.$section.'&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkthistopic.'">'.
 297                      '<img src="'.$CFG->pixpath.'/i/marker.gif" height="16" width="16" border="0" alt="'.$strmarkthistopic.'" /></a><br />';
 298              }
 299  
 300              if ($thissection->visible) {        // Show the hide/show eye
 301                  echo '<a href="view.php?id='.$course->id.'&amp;hide='.$section.'&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopichide.'">'.
 302                      '<img src="'.$CFG->pixpath.'/i/hide.gif" height="16" width="16" border="0" alt="'.$strtopichide.'" /></a><br />';
 303              } else {
 304                  echo '<a href="view.php?id='.$course->id.'&amp;show='.$section.'&amp;sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopicshow.'">'.
 305                      '<img src="'.$CFG->pixpath.'/i/show.gif" height="16" width="16" border="0" alt="'.$strtopicshow.'" /></a><br />';
 306              }
 307  
 308              if ($section > 1) {                       // Add a arrow to move section up
 309                  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.'">'.
 310                      '<img src="'.$CFG->pixpath.'/t/up.gif" class="iconsmall" alt="'.$strmoveup.'" /></a><br />';
 311              }
 312  
 313              if ($section < $course->numsections) {    // Add a arrow to move section down
 314                  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.'">'.
 315                      '<img src="'.$CFG->pixpath.'/t/down.gif" class="iconsmall" alt="'.$strmovedown.'" /></a><br />';
 316              }
 317  
 318          }
 319  
 320          echo '</td></tr>';
 321          echo '<tr class="section separator"><td colspan="3" class="spacer"></td></tr>';
 322      }
 323  
 324      $section++;
 325  }
 326  echo '</table>';
 327  
 328  if (!empty($sectionmenu)) {
 329      echo '<div align="center" class="jumpmenu">';
 330      echo popup_form($CFG->wwwroot.'/course/view.php?id='.$course->id.'&', $sectionmenu,
 331              'sectionmenu', '', get_string('jumpto'), '', '', true);
 332      echo '</div>';
 333  }
 334  
 335  
 336  echo '</td>';
 337  
 338  // The right column
 339  if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
 340      echo '<td style="width:'.$preferred_width_right.'px" id="right-column">';
 341      blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
 342      echo '</td>';
 343  }
 344  
 345  echo '</tr></table>';
 346  
 347  ?>


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