original_string: private function get_course_categories() {
          global $CFG;
          require_once($CFG->dirroot.'/course/lib.php');
  
          $categories = array();
          $cap = 'moodle/category:viewhiddencategories';
          $showcategories = !core_course_category::is_simple_site();
  
          if ($showcategories) {
              foreach ($this->page->categories as $category) {
                  $context = context_coursecat::instance($category->id);
                  if (!core_course_category::can_view_category($category)) {
                      continue;
                  }
                  $url = new moodle_url('/course/index.php', array('categoryid' => $category->id));
                  $name = format_string($category->name, true, array('context' => $context));
                  $categorynode = breadcrumb_navigation_node::create($name, $url, self::TYPE_CATEGORY, null, $category->id);
                  if (!$category->visible) {
                      $categorynode->hidden = true;
                  }
                  $categories[] = $categorynode;
              }
          }
  
          // Don't show the 'course' node if enrolled in this course.
          if (!is_enrolled(context_course::instance($this->page->course->id, null, '', true))) {
              $courses = $this->page->navigation->get('courses');
              if (!$courses) {
                  // Courses node may not be present.
                  $courses = breadcrumb_navigation_node::create(
                      get_string('courses'),
                      new moodle_url('/course/index.php'),
                      self::TYPE_CONTAINER
                  );
              }
              $categories[] = $courses;
          }
  
          return $categories;
      }
code: private function get_course_categories() {
          global $CFG;
          require_once($CFG->dirroot.'/course/lib.php');
  
          $categories = array();
          $cap = 'moodle/category:viewhiddencategories';
          $showcategories = !core_course_category::is_simple_site();
  
          if ($showcategories) {
              foreach ($this->page->categories as $category) {
                  $context = context_coursecat::instance($category->id);
                  if (!core_course_category::can_view_category($category)) {
                      continue;
                  }
                  $url = new moodle_url('/course/index.php', array('categoryid' => $category->id));
                  $name = format_string($category->name, true, array('context' => $context));
                  $categorynode = breadcrumb_navigation_node::create($name, $url, self::TYPE_CATEGORY, null, $category->id);
                  if (!$category->visible) {
                      $categorynode->hidden = true;
                  }
                  $categories[] = $categorynode;
              }
          }
  
          // Don't show the 'course' node if enrolled in this course.
          if (!is_enrolled(context_course::instance($this->page->course->id, null, '', true))) {
              $courses = $this->page->navigation->get('courses');
              if (!$courses) {
                  // Courses node may not be present.
                  $courses = breadcrumb_navigation_node::create(
                      get_string('courses'),
                      new moodle_url('/course/index.php'),
                      self::TYPE_CONTAINER
                  );
              }
              $categories[] = $courses;
          }
  
          return $categories;
      }
code_tokens: private function get_course_categories ( ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/course/lib.php' ) ; $ categories = array ( ) ; $ cap = 'moodle/category:viewhiddencategories' ; $ showcategories = ! core_course_category :: is_simple_site ( ) ; if ( $ showcategories ) { foreach ( $ this -> page -> categories as $ category ) { $ context = context_coursecat :: instance ( $ category -> id ) ; if ( ! core_course_category :: can_view_category ( $ category ) ) { continue ; } $ url = new moodle_url ( '/course/index.php' , array ( 'categoryid' => $ category -> id ) ) ; $ name = format_string ( $ category -> name , true , array ( 'context' => $ context ) ) ; $ categorynode = breadcrumb_navigation_node :: create ( $ name , $ url , self :: TYPE_CATEGORY , null , $ category -> id ) ; if ( ! $ category -> visible ) { $ categorynode -> hidden = true ; } $ categories [ ] = $ categorynode ; } } // Don't show the 'course' node if enrolled in this course. if ( ! is_enrolled ( context_course :: instance ( $ this -> page -> course -> id , null , '' , true ) ) ) { $ courses = $ this -> page -> navigation -> get ( 'courses' ) ; if ( ! $ courses ) { // Courses node may not be present. $ courses = breadcrumb_navigation_node :: create ( get_string ( 'courses' ) , new moodle_url ( '/course/index.php' ) , self :: TYPE_CONTAINER ) ; } $ categories [ ] = $ courses ; } return $ categories ; }
docstring: Get the list of categories leading to this course.
  
  This function is used by {@link navbar::get_items()} to add back the "courses"
  node and category chain leading to the current course.  Note that this is only ever
  called for the current course, so we don't need to bother taking in any parameters.
  
  @return array
docstring_tokens: Get the list of categories leading to this course .