当前位置: 首页>>代码示例>>PHP>>正文


PHP coursecat::get_children方法代码示例

本文整理汇总了PHP中coursecat::get_children方法的典型用法代码示例。如果您正苦于以下问题:PHP coursecat::get_children方法的具体用法?PHP coursecat::get_children怎么用?PHP coursecat::get_children使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coursecat的用法示例。


在下文中一共展示了coursecat::get_children方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: coursecat_subcategories

 /**
  * Renders the list of subcategories in a category
  *
  * @param coursecat_helper $chelper various display options
  * @param coursecat $coursecat
  * @param int $depth depth of the category in the current tree
  * @return string
  */
 protected function coursecat_subcategories(coursecat_helper $chelper, $coursecat, $depth)
 {
     global $CFG;
     $subcategories = array();
     if (!$chelper->get_categories_display_option('nodisplay')) {
         $subcategories = $coursecat->get_children($chelper->get_categories_display_options());
     }
     $totalcount = $coursecat->get_children_count();
     if (!$totalcount) {
         // Note that we call coursecat::get_children_count() AFTER coursecat::get_children() to avoid extra DB requests.
         // Categories count is cached during children categories retrieval.
         return '';
     }
     // prepare content of paging bar or more link if it is needed
     $paginationurl = $chelper->get_categories_display_option('paginationurl');
     $paginationallowall = $chelper->get_categories_display_option('paginationallowall');
     if ($totalcount > count($subcategories)) {
         if ($paginationurl) {
             // the option 'paginationurl was specified, display pagingbar
             $perpage = $chelper->get_categories_display_option('limit', $CFG->coursesperpage);
             $page = $chelper->get_categories_display_option('offset') / $perpage;
             $pagingbar = $this->paging_bar($totalcount, $page, $perpage, $paginationurl->out(false, array('perpage' => $perpage)));
             if ($paginationallowall) {
                 $pagingbar .= html_writer::tag('div', html_writer::link($paginationurl->out(false, array('perpage' => 'all')), get_string('showall', '', $totalcount)), array('class' => 'paging paging-showall'));
             }
         } else {
             if ($viewmoreurl = $chelper->get_categories_display_option('viewmoreurl')) {
                 // the option 'viewmoreurl' was specified, display more link (if it is link to category view page, add category id)
                 if ($viewmoreurl->compare(new moodle_url('/course/index.php'), URL_MATCH_BASE)) {
                     $viewmoreurl->param('categoryid', $coursecat->id);
                 }
                 $viewmoretext = $chelper->get_categories_display_option('viewmoretext', new lang_string('viewmore'));
                 $morelink = html_writer::tag('div', html_writer::link($viewmoreurl, $viewmoretext), array('class' => 'paging paging-morelink'));
             }
         }
     } else {
         if ($totalcount > $CFG->coursesperpage && $paginationurl && $paginationallowall) {
             // there are more than one page of results and we are in 'view all' mode, suggest to go back to paginated view mode
             $pagingbar = html_writer::tag('div', html_writer::link($paginationurl->out(false, array('perpage' => $CFG->coursesperpage)), get_string('showperpage', '', $CFG->coursesperpage)), array('class' => 'paging paging-showperpage'));
         }
     }
     // display list of subcategories
     $content = html_writer::start_tag('div', array('class' => 'subcategories'));
     if (!empty($pagingbar)) {
         $content .= $pagingbar;
     }
     foreach ($subcategories as $subcategory) {
         $content .= $this->coursecat_category($chelper, $subcategory, $depth + 1);
     }
     if (!empty($pagingbar)) {
         $content .= $pagingbar;
     }
     if (!empty($morelink)) {
         $content .= $morelink;
     }
     $content .= html_writer::end_tag('div');
     return $content;
 }
开发者ID:rushi963,项目名称:moodle,代码行数:66,代码来源:renderer.php

示例2: get_children_courses_count

 /**
  * Returns the number of courses in the category and sub-categories.
  *
  * @param coursecat $coursecat
  * @return int Count of courses
  */
 protected function get_children_courses_count($coursecat)
 {
     $childcoursescount = 0;
     $coursecatchildren = $coursecat->get_children();
     foreach ($coursecatchildren as $coursecatchild) {
         $childcoursescount += $coursecatchild->get_courses_count();
         if ($coursecatchild->get_children_count()) {
             $childcoursescount += $this->get_children_courses_count($coursecatchild);
         }
     }
     return $childcoursescount;
 }
开发者ID:julenpardo,项目名称:moodle-theme_essential,代码行数:18,代码来源:core_course_renderer.php

示例3: print_category_edit


//.........这里部分代码省略.........
        $categorypadding = str_repeat('      ', $depth);
        $categoryname = $categorypadding . html_writer::link($categoryurl, $categoryname, $attributes);

        $icons = array();
        if (has_capability('moodle/category:manage', $categorycontext)) {
            // Edit category.
            $icons[] = $OUTPUT->action_icon(
                new moodle_url('/course/editcategory.php', array('id' => $category->id)),
                new pix_icon('t/edit', $str->edit, 'moodle', array('class' => 'iconsmall')),
                null, array('title' => $str->edit)
            );
            // Delete category.
            $icons[] = $OUTPUT->action_icon(
                new moodle_url('/course/manage.php', array('deletecat' => $category->id, 'sesskey' => sesskey())),
                new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall')),
                null, array('title' => $str->delete)
            );
            // Change visibility.
            if (!empty($category->visible)) {
                $icons[] = $OUTPUT->action_icon(
                    new moodle_url('/course/manage.php', array('hidecat' => $category->id, 'sesskey' => sesskey())),
                    new pix_icon('t/hide', $str->hide, 'moodle', array('class' => 'iconsmall')),
                    null, array('title' => $str->hide)
                );
            } else {
                $icons[] = $OUTPUT->action_icon(
                    new moodle_url('/course/manage.php', array('showcat' => $category->id, 'sesskey' => sesskey())),
                    new pix_icon('t/show', $str->show, 'moodle', array('class' => 'iconsmall')),
                    null, array('title' => $str->show)
                );
            }
            // Cohorts.
            if (has_any_capability(array('moodle/cohort:manage', 'moodle/cohort:view'), $categorycontext)) {
                $icons[] = $OUTPUT->action_icon(
                    new moodle_url('/cohort/index.php', array('contextid' => $categorycontext->id)),
                    new pix_icon('t/cohort', $str->cohorts, 'moodle', array('class' => 'iconsmall')),
                    null, array('title' => $str->cohorts)
                );
            }
            // Move up/down.
            if ($up) {
                $icons[] = $OUTPUT->action_icon(
                    new moodle_url('/course/manage.php', array('moveupcat' => $category->id, 'sesskey' => sesskey())),
                    new pix_icon('t/up', $str->moveup, 'moodle', array('class' => 'iconsmall')),
                    null, array('title' => $str->moveup)
                );
            } else {
                $icons[] = $str->spacer;
            }
            if ($down) {
                $icons[] = $OUTPUT->action_icon(
                    new moodle_url('/course/manage.php', array('movedowncat' => $category->id, 'sesskey' => sesskey())),
                    new pix_icon('t/down', $str->movedown, 'moodle', array('class' => 'iconsmall')),
                    null, array('title' => $str->movedown)
                );
            } else {
                $icons[] = $str->spacer;
            }
        }

        $actions = '';
        if (has_capability('moodle/category:manage', $categorycontext)) {
            $popupurl = new moodle_url('/course/manage.php', array('movecat' => $category->id, 'sesskey' => sesskey()));
            $tempdisplaylist = array(0 => get_string('top')) + coursecat::make_categories_list('moodle/category:manage', $category->id);
            $select = new single_select($popupurl, 'movetocat', $tempdisplaylist, $category->parent, null, "moveform$category->id");
            $select->set_label(get_string('frontpagecategorynames'), array('class' => 'accesshide'));
            $actions = $OUTPUT->render($select);
        }

        $table->data[] = new html_table_row(array(
            // Category name.
            new html_table_cell($categoryname),
            // Course count.
            new html_table_cell($category->coursecount),
            // Icons.
            new html_table_cell(join(' ', $icons)),
            // Actions.
            new html_table_cell($actions)
        ));
    }

    if ($categories = $category->get_children()) {
        // Print all the children recursively.
        $countcats = count($categories);
        $count = 0;
        $first = true;
        $last = false;
        foreach ($categories as $cat) {
            $count++;
            if ($count == $countcats) {
                $last = true;
            }
            $up = $first ? false : true;
            $down = $last ? false : true;
            $first = false;

            print_category_edit($table, $cat, $depth+1, $up, $down);
        }
    }
}
开发者ID:number33,项目名称:moodle,代码行数:101,代码来源:manage.php

示例4: get_categories

 protected function get_categories(\coursecat $category)
 {
     static $categories = array();
     $categories[$category->id] = $category->name;
     foreach ($category->get_children() as $child) {
         $this->get_categories($child);
     }
     return $categories;
 }
开发者ID:dariogs,项目名称:moosh,代码行数:9,代码来源:CourseList.php


注:本文中的coursecat::get_children方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。