Merge branch 'wip-mdl-32770' of git://github.com/rajeshtaneja/moodle
authorAparup Banerjee <aparup@moodle.com>
Tue, 15 May 2012 08:41:54 +0000 (16:41 +0800)
committerAparup Banerjee <aparup@moodle.com>
Tue, 15 May 2012 08:41:54 +0000 (16:41 +0800)
1  2 
course/format/renderer.php
lang/en/moodle.php
theme/base/style/course.css

@@@ -146,9 -146,16 +146,9 @@@ abstract class format_section_renderer_
          }
  
          $o.= html_writer::start_tag('div', array('class' => 'summary'));
 +        $o.= $this->format_summary_text($section);
  
 -        $context = context_course::instance($section->course);
 -        $summarytext = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php',
 -            $context->id, 'course', 'section', $section->id);
 -        $summaryformatoptions = new stdClass();
 -        $summaryformatoptions->noclean = true;
 -        $summaryformatoptions->overflowdiv = true;
 -
 -        $o.= format_text($summarytext, $section->summaryformat, $summaryformatoptions);
 -
 +        $context = context_course::instance($course->id);
          if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $context)) {
              $url = new moodle_url('/course/editsection.php', array('id'=>$section->id));
  
      protected function section_summary($section, $course) {
  
          $o = '';
 -        $o.= html_writer::start_tag('li', array('id' => 'section-'.$section->section));
 +        $o.= html_writer::start_tag('li', array('id' => 'section-'.$section->section,
 +            'class' => 'section-summary clearfix'));
  
          $title = get_section_name($course, $section);
 -        $o.= html_writer::start_tag('div', array('class' => 'section-summary'));
          $o.= html_writer::start_tag('a', array('href' => course_get_url($course, $section->section)));
          $o.= $this->output->heading($title, 3, 'header section-title');
          $o.= html_writer::end_tag('a');
  
          $o.= html_writer::start_tag('div', array('class' => 'summarytext'));
 -        $o.= format_text($section->summary, $section->summaryformat);
 -        $o.= html_writer::end_tag('div');
 +        $o.= $this->format_summary_text($section);
          $o.= html_writer::end_tag('div');
          $o.= html_writer::end_tag('li');
  
       * @param stdClass $course The course entry from DB
       * @param array $sections The course_sections entries from the DB
       * @param int $sectionno The section number in the coruse which is being dsiplayed
-      * @return string HTML to output.
+      * @return array associative array with previous and next section link
       */
      protected function get_nav_links($course, $sections, $sectionno) {
          // FIXME: This is really evil and should by using the navigation API.
          $back = $sectionno - 1;
          while ($back > 0 and empty($links['previous'])) {
              if ($canviewhidden || $sections[$back]->visible) {
-                 $links['previous'] = html_writer::link(course_get_url($course, $back),
-                     $this->output->larrow().$this->output->spacer().get_section_name($course, $sections[$back]));
+                 $previouslink = html_writer::tag('span', $this->output->larrow(), array('class' => 'larrow'));
+                 $previouslink .= get_section_name($course, $sections[$back]);
+                 $links['previous'] = html_writer::link(course_get_url($course, $back), $previouslink);
              }
              $back--;
          }
          $forward = $sectionno + 1;
          while ($forward <= $course->numsections and empty($links['next'])) {
              if ($canviewhidden || $sections[$forward]->visible) {
-                 $links['next'] = html_writer::link(course_get_url($course, $forward),
-                     get_section_name($course, $sections[$forward]).$this->output->spacer().$this->output->rarrow());
+                 $nextlink = get_section_name($course, $sections[$forward]);
+                 $nextlink .= html_writer::tag('span', $this->output->rarrow(), array('class' => 'rarrow'));
+                 $links['next'] = html_writer::link(course_get_url($course, $forward), $nextlink);
              }
              $forward++;
          }
  
-         $o = '';
-         $o.= html_writer::start_tag('div', array('class' => 'section-navigation yui3-g'));
-         $o.= html_writer::tag('div', $links['previous'], array('class' => 'yui3-u'));
-         $o.= html_writer::tag('div', $links['next'], array('class' => 'right yui3-u'));
-         $o.= html_writer::end_tag('div');
-         return $o;
+         return $links;
      }
  
      /**
              echo $this->end_section_list();
          }
  
-         // Section next/previous links.
+         // Title with section navigation links.
          $sectionnavlinks = $this->get_nav_links($course, $sections, $displaysection);
-         echo $sectionnavlinks;
-         // Title with completion help icon.
+         $sectiontitle = '';
+         $sectiontitle .= html_writer::start_tag('div', array('class' => 'section-navigation headingblock header'));
+         $sectiontitle .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left'));
+         $sectiontitle .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right'));
+         $sectiontitle .= html_writer::tag('div', get_section_name($course, $sections[$displaysection]), array('class' => 'mdl-align'));
+         $sectiontitle .= html_writer::end_tag('div');
+         echo $sectiontitle;
+         // Show completion help icon.
          $completioninfo = new completion_info($course);
          echo $completioninfo->display_help_icon();
-         $title = get_section_name($course, $sections[$displaysection]);
-         echo $this->output->heading($title, 2, 'headingblock header outline');
  
          // Copy activity clipboard..
          echo $this->course_activity_clipboard($course, $displaysection);
              print_section_add_menus($course, $displaysection, $modnames);
          }
          echo $this->section_footer();
-         echo $sectionnavlinks;
          echo $this->end_section_list();
+         // Display section bottom navigation.
+         $courselink = html_writer::link(course_get_url($course), get_string('returntomaincoursepage'));
+         $sectionbottomnav = '';
+         $sectionbottomnav .= html_writer::start_tag('div', array('class' => 'section-navigation mdl-bottom'));
+         $sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left'));
+         $sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right'));
+         $sectionbottomnav .= html_writer::tag('div', $courselink, array('class' => 'mdl-align'));
+         $sectionbottomnav .= html_writer::end_tag('div');
+         echo $sectionbottomnav;
      }
  
      /**
  
              echo $this->end_section_list();
  
 -            // Print the add section link
 -            $straddsection = get_string('addanadditionalsection', 'moodle');
 -            echo html_writer::start_tag('div', array('class' => 'mdl-align'));
 -            echo $this->output->action_link(
 -                new moodle_url('/course/addsection.php',
 -                    array('courseid' => $course->id, 'sesskey' => sesskey())
 -                ), $this->output->pix_icon('t/add', $straddsection).$straddsection, null,
 -                    array('class' => 'addsectionlink')
 -            );
 +            echo html_writer::start_tag('div', array('class' => 'mdl-right'));
 +
 +            // Increase number of sections.
 +            $straddsection = get_string('increasesections', 'moodle');
 +            $url = new moodle_url('/course/changenumsections.php',
 +                array('courseid' => $course->id,
 +                      'increase' => true,
 +                      'sesskey' => sesskey()));
 +            $icon = $this->output->pix_icon('t/switch_plus', $straddsection);
 +            echo html_writer::link($url, $icon.get_accesshide($straddsection), array('class' => 'increase-sections'));
 +
 +            if ($course->numsections > 0) {
 +                // Reduce number of sections sections.
 +                $strremovesection = get_string('reducesections', 'moodle');
 +                $url = new moodle_url('/course/changenumsections.php',
 +                    array('courseid' => $course->id,
 +                          'increase' => false,
 +                          'sesskey' => sesskey()));
 +                $icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
 +                echo html_writer::link($url, $icon.get_accesshide($strremovesection), array('class' => 'reduce-sections'));
 +            }
 +
              echo html_writer::end_tag('div');
          } else {
              echo $this->end_section_list();
          }
  
      }
 +
 +    /**
 +     * Generate html for a section summary text
 +     *
 +     * @param stdClass $section The course_section entry from DB
 +     * @return string HTML to output.
 +     */
 +    protected function format_summary_text($section) {
 +        $context = context_course::instance($section->course);
 +        $summarytext = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php',
 +            $context->id, 'course', 'section', $section->id);
 +
 +        $options = new stdClass();
 +        $options->noclean = true;
 +        $options->overflowdiv = true;
 +        return format_text($summarytext, $section->summaryformat, $options);
 +    }
  }
diff --combined lang/en/moodle.php
@@@ -43,6 -43,7 +43,6 @@@ $string['activityweighted'] = 'Activit
  $string['add'] = 'Add';
  $string['addactivity'] = 'Add an activity...';
  $string['addadmin'] = 'Add admin';
 -$string['addanadditionalsection'] = 'Add an additional section';
  $string['addblock'] = 'Add a block';
  $string['addcomment'] = 'Add a comment...';
  $string['addcountertousername'] = 'Create user by adding number to username';
@@@ -878,7 -879,6 +878,7 @@@ $string['includenoneusers'] = 'Include 
  $string['includeroleassignments'] = 'Include role assignments';
  $string['includesitefiles'] = 'Include site files used in this course';
  $string['includeuserfiles'] = 'Include user files';
 +$string['increasesections'] = 'Increase the number of sections';
  $string['info'] = 'Information';
  $string['institution'] = 'Institution';
  $string['instudentview'] = 'in student view';
@@@ -1314,7 -1314,6 +1314,7 @@@ $string['recentactivityreport'] = 'Ful
  $string['recipientslist'] = 'Recipients list';
  $string['recreatedcategory'] = 'Recreated category {$a}';
  $string['redirect'] = 'Redirect';
 +$string['reducesections'] = 'Reduce the number of sections';
  $string['refresh'] = 'Refresh';
  $string['refreshingevents'] = 'Refreshing events';
  $string['registration'] = 'Moodle registration';
@@@ -1393,6 -1392,7 +1393,7 @@@ $string['restoreusersprecheck'] = 'Chec
  $string['restoreusersprecheckerror'] = 'Some problems were detected when checking user data';
  $string['restricted'] = 'Restricted';
  $string['returningtosite'] = 'Returning to this web site?';
+ $string['returntomaincoursepage'] = 'Return to main course page';
  $string['returntooriginaluser'] = 'Return to {$a}';
  $string['revert'] = 'Revert';
  $string['role'] = 'Role';
@@@ -8,17 -8,20 +8,21 @@@
  
  .course-content .section .activity img.activityicon {vertical-align:middle;height:16px;width:16px;}
  .course-content .section .activity .commands img.iconsmall {vertical-align: baseline;}
 -.course-content .section-summary { border: 1px solid #DDD; margin-top: 5px; }
 +.course-content .section-summary { border: 1px solid #DDD; margin-top: 5px; list-style: none; }
  .course-content .section-summary .section-title  { margin: 2px 5px 2px 5px; }
  .course-content .section-summary .summarytext { margin: 2px 5px 2px 5px; }
- .course-content .section-navigation { display: block; padding: 10px; }
- .course-content .section-navigation .right { float: right; }
+ .course-content .section-navigation { display: block; padding: 0.5em; margin-top: 1em; margin-bottom: -0.5em !important; }
+ .course-content .section-navigation .mdl-left { float: left; font-weight: normal; margin-right: 1em; }
+ .course-content .section-navigation .mdl-left .larrow { margin-right: 0.1em; }
+ .course-content .section-navigation .mdl-right { float: right; font-weight: normal; margin-left: 1em; }
+ .course-content .section-navigation .mdl-right .rarrow { margin-left: 0.1em; }
+ .course-content .section-navigation .mdl-bottom { font-weight: normal; margin-top: 0; }
  
  #page-site-index .subscribelink {text-align:right;}
  #page-site-index .headingblock {margin-bottom: 9px;}
  #page-site-index .clearfloat {float: none;clear: both; height:0px;}
  
 +.path-course-view a.reduce-sections {padding-left: 0.2em;}
  .path-course-view .headingblock {margin-bottom: 9px;}
  .path-course-view .subscribelink {text-align:right;}
  .path-course-view .unread {margin-left: 3em;}