original_string: public function get_content() {
  
          // The config should be loaded by now.
          // If its empty then we will use the global config for the section links block.
          if (isset($this->config)){
              $config = $this->config;
          } else{
              $config = get_config('block_section_links');
          }
  
          if ($this->content !== null) {
              return $this->content;
          }
  
          $this->content = new stdClass;
          $this->content->footer = '';
          $this->content->text   = '';
  
          if (empty($this->instance)) {
              return $this->content;
          }
  
          $course = $this->page->course;
          $courseformat = course_get_format($course);
          $numsections = $courseformat->get_last_section_number();
          $context = context_course::instance($course->id);
  
          // Course format options 'numsections' is required to display the block.
          if (empty($numsections)) {
              return $this->content;
          }
  
          // Prepare the increment value.
          if (!empty($config->numsections1) and ($numsections > $config->numsections1)) {
              $inc = $config->incby1;
          } else if ($numsections > 22) {
              $inc = 2;
          } else {
              $inc = 1;
          }
          if (!empty($config->numsections2) and ($numsections > $config->numsections2)) {
              $inc = $config->incby2;
          } else {
              if ($numsections > 40) {
                  $inc = 5;
              }
          }
  
          // Prepare an array of sections to create links for.
          $sections = array();
          $canviewhidden = has_capability('moodle/course:update', $context);
          $coursesections = $courseformat->get_sections();
          $coursesectionscount = count($coursesections);
          $sectiontojumpto = false;
          for ($i = $inc; $i <= $coursesectionscount; $i += $inc) {
              if ($i > $numsections || !isset($coursesections[$i])) {
                  continue;
              }
              $section = $coursesections[$i];
              if ($section->section && ($section->visible || $canviewhidden)) {
                  $sections[$i] = (object)array(
                      'section' => $section->section,
                      'visible' => $section->visible,
                      'highlight' => false
                  );
                  if ($courseformat->is_section_current($section)) {
                      $sections[$i]->highlight = true;
                      $sectiontojumpto = $section->section;
                  }
              }
          }
  
          if (!empty($sections)) {
              // Render the sections.
              $renderer = $this->page->get_renderer('block_section_links');
              $this->content->text = $renderer->render_section_links($this->page->course, $sections, $sectiontojumpto);
          }
  
          return $this->content;
      }
code: public function get_content() {
  
          // The config should be loaded by now.
          // If its empty then we will use the global config for the section links block.
          if (isset($this->config)){
              $config = $this->config;
          } else{
              $config = get_config('block_section_links');
          }
  
          if ($this->content !== null) {
              return $this->content;
          }
  
          $this->content = new stdClass;
          $this->content->footer = '';
          $this->content->text   = '';
  
          if (empty($this->instance)) {
              return $this->content;
          }
  
          $course = $this->page->course;
          $courseformat = course_get_format($course);
          $numsections = $courseformat->get_last_section_number();
          $context = context_course::instance($course->id);
  
          // Course format options 'numsections' is required to display the block.
          if (empty($numsections)) {
              return $this->content;
          }
  
          // Prepare the increment value.
          if (!empty($config->numsections1) and ($numsections > $config->numsections1)) {
              $inc = $config->incby1;
          } else if ($numsections > 22) {
              $inc = 2;
          } else {
              $inc = 1;
          }
          if (!empty($config->numsections2) and ($numsections > $config->numsections2)) {
              $inc = $config->incby2;
          } else {
              if ($numsections > 40) {
                  $inc = 5;
              }
          }
  
          // Prepare an array of sections to create links for.
          $sections = array();
          $canviewhidden = has_capability('moodle/course:update', $context);
          $coursesections = $courseformat->get_sections();
          $coursesectionscount = count($coursesections);
          $sectiontojumpto = false;
          for ($i = $inc; $i <= $coursesectionscount; $i += $inc) {
              if ($i > $numsections || !isset($coursesections[$i])) {
                  continue;
              }
              $section = $coursesections[$i];
              if ($section->section && ($section->visible || $canviewhidden)) {
                  $sections[$i] = (object)array(
                      'section' => $section->section,
                      'visible' => $section->visible,
                      'highlight' => false
                  );
                  if ($courseformat->is_section_current($section)) {
                      $sections[$i]->highlight = true;
                      $sectiontojumpto = $section->section;
                  }
              }
          }
  
          if (!empty($sections)) {
              // Render the sections.
              $renderer = $this->page->get_renderer('block_section_links');
              $this->content->text = $renderer->render_section_links($this->page->course, $sections, $sectiontojumpto);
          }
  
          return $this->content;
      }
code_tokens: public function get_content ( ) { // The config should be loaded by now. // If its empty then we will use the global config for the section links block. if ( isset ( $ this -> config ) ) { $ config = $ this -> config ; } else { $ config = get_config ( 'block_section_links' ) ; } if ( $ this -> content !== null ) { return $ this -> content ; } $ this -> content = new stdClass ; $ this -> content -> footer = '' ; $ this -> content -> text = '' ; if ( empty ( $ this -> instance ) ) { return $ this -> content ; } $ course = $ this -> page -> course ; $ courseformat = course_get_format ( $ course ) ; $ numsections = $ courseformat -> get_last_section_number ( ) ; $ context = context_course :: instance ( $ course -> id ) ; // Course format options 'numsections' is required to display the block. if ( empty ( $ numsections ) ) { return $ this -> content ; } // Prepare the increment value. if ( ! empty ( $ config -> numsections1 ) and ( $ numsections > $ config -> numsections1 ) ) { $ inc = $ config -> incby1 ; } else if ( $ numsections > 22 ) { $ inc = 2 ; } else { $ inc = 1 ; } if ( ! empty ( $ config -> numsections2 ) and ( $ numsections > $ config -> numsections2 ) ) { $ inc = $ config -> incby2 ; } else { if ( $ numsections > 40 ) { $ inc = 5 ; } } // Prepare an array of sections to create links for. $ sections = array ( ) ; $ canviewhidden = has_capability ( 'moodle/course:update' , $ context ) ; $ coursesections = $ courseformat -> get_sections ( ) ; $ coursesectionscount = count ( $ coursesections ) ; $ sectiontojumpto = false ; for ( $ i = $ inc ; $ i <= $ coursesectionscount ; $ i += $ inc ) { if ( $ i > $ numsections || ! isset ( $ coursesections [ $ i ] ) ) { continue ; } $ section = $ coursesections [ $ i ] ; if ( $ section -> section && ( $ section -> visible || $ canviewhidden ) ) { $ sections [ $ i ] = ( object ) array ( 'section' => $ section -> section , 'visible' => $ section -> visible , 'highlight' => false ) ; if ( $ courseformat -> is_section_current ( $ section ) ) { $ sections [ $ i ] -> highlight = true ; $ sectiontojumpto = $ section -> section ; } } } if ( ! empty ( $ sections ) ) { // Render the sections. $ renderer = $ this -> page -> get_renderer ( 'block_section_links' ) ; $ this -> content -> text = $ renderer -> render_section_links ( $ this -> page -> course , $ sections , $ sectiontojumpto ) ; } return $ this -> content ; }
docstring: Generates the content of the block and returns it.
  
  If the content has already been generated then the previously generated content is returned.
  
  @return stdClass
docstring_tokens: Generates the content of the block and returns it .