Пример #1
0
 protected function add_category_to_custommenu(custom_menu_item $parent, stdClass $category)
 {
     $branch = $parent->add($category->name, new moodle_url('/course/category.php', array('id' => $category->id)));
     if (!empty($category->categories)) {
         foreach ($category->categories as $subcategory) {
             $this->add_category_to_custommenu($branch, $subcategory);
         }
     }
     if (!empty($category->courses)) {
         foreach ($category->courses as $course) {
             $branch->add($course->shortname, new moodle_url('/course/view.php', array('id' => $course->id)), $course->fullname);
         }
     }
 }