本文整理汇总了PHP中coursecat::get_children_count方法的典型用法代码示例。如果您正苦于以下问题:PHP coursecat::get_children_count方法的具体用法?PHP coursecat::get_children_count怎么用?PHP coursecat::get_children_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coursecat
的用法示例。
在下文中一共展示了coursecat::get_children_count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: coursecat_category
/**
* Returns HTML to display a course category as a part of a tree
*
* This is an internal function, to display a particular category and all its contents
* use {@link core_course_renderer::course_category()}
*
* @param coursecat_helper $chelper various display options
* @param coursecat $coursecat
* @param int $depth depth of this category in the current tree
* @return string
*/
protected function coursecat_category(coursecat_helper $chelper, $coursecat, $depth)
{
// open category tag
$classes = array('category');
if (empty($coursecat->visible)) {
$classes[] = 'dimmed_category';
}
if ($chelper->get_subcat_depth() > 0 && $depth >= $chelper->get_subcat_depth()) {
// do not load content
$categorycontent = '';
$classes[] = 'notloaded';
if ($coursecat->get_children_count() || $chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_COLLAPSED && $coursecat->get_courses_count()) {
$classes[] = 'with_children';
$classes[] = 'collapsed';
}
} else {
// load category content
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, $depth);
$classes[] = 'loaded';
if (!empty($categorycontent)) {
$classes[] = 'with_children';
}
}
// Make sure JS file to expand category content is included.
$this->coursecat_include_js();
$content = html_writer::start_tag('div', array('class' => join(' ', $classes), 'data-categoryid' => $coursecat->id, 'data-depth' => $depth, 'data-showcourses' => $chelper->get_show_courses(), 'data-type' => self::COURSECAT_TYPE_CATEGORY));
// category name
$categoryname = $coursecat->get_formatted_name();
$categoryname = html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $coursecat->id)), $categoryname);
if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_COUNT && ($coursescount = $coursecat->get_courses_count())) {
$categoryname .= html_writer::tag('span', ' (' . $coursescount . ')', array('title' => get_string('numberofcourses'), 'class' => 'numberofcourse'));
}
$content .= html_writer::start_tag('div', array('class' => 'info'));
$content .= html_writer::tag($depth > 1 ? 'h4' : 'h3', $categoryname, array('class' => 'categoryname'));
$content .= html_writer::end_tag('div');
// .info
// add category content to the output
$content .= html_writer::tag('div', $categorycontent, array('class' => 'content'));
$content .= html_writer::end_tag('div');
// .category
// Return the course category tree HTML
return $content;
}
示例2: coursecat_category
/**
* Returns HTML to display a course category as a part of a tree
*
* This is an internal function, to display a particular category and all its contents
* use {@link core_course_renderer::course_category()}
*
* @param coursecat_helper $chelper various display options
* @param coursecat $coursecat
* @param int $depth depth of this category in the current tree
* @return string
*/
protected function coursecat_category(coursecat_helper $chelper, $coursecat, $depth)
{
global $CFG, $OUTPUT;
// open category tag
$classes = array('category');
if (empty($coursecat->visible)) {
$classes[] = 'dimmed_category';
}
if ($chelper->get_subcat_depth() > 0 && $depth >= $chelper->get_subcat_depth()) {
// do not load content
$categorycontent = '';
$classes[] = 'notloaded';
if ($coursecat->get_children_count() || $chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_COLLAPSED && $coursecat->get_courses_count()) {
$classes[] = 'with_children';
$classes[] = 'collapsed';
}
} else {
// load category content
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, $depth);
$classes[] = 'loaded';
if (!empty($categorycontent)) {
$classes[] = 'with_children';
}
}
$classes[] = 'essentialcats';
if (intval($CFG->version) >= 2013111800) {
// Make sure JS file to expand category content is included.
$this->coursecat_include_js();
}
$content = html_writer::start_tag('div', array('class' => join(' ', $classes), 'data-categoryid' => $coursecat->id, 'data-depth' => $depth, 'data-showcourses' => $chelper->get_show_courses(), 'data-type' => self::COURSECAT_TYPE_CATEGORY));
if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_COUNT) {
$coursescount = $coursecat->get_courses_count();
$content .= html_writer::tag('span', ' (' . $coursescount . ')', array('title' => get_string('numberofcourses'), 'class' => 'numberofcourse'));
}
// category name
$categoryname = html_writer::tag('span', $coursecat->get_formatted_name());
$categoryiconnum = 'categoryicon' . $coursecat->id;
// Do a settings check to output our icon for the category
if ($OUTPUT->get_setting('enablecategoryicon')) {
if ($OUTPUT->get_setting($categoryiconnum) && $OUTPUT->get_setting('enablecustomcategoryicon')) {
// User has set a value for the category
$val = $OUTPUT->get_setting($categoryiconnum);
} else {
// User hasn't set a value for the category, get the default
$val = $OUTPUT->get_setting('defaultcategoryicon');
}
}
if (!empty($val)) {
$icon = html_writer::tag('i', '', array('class' => 'fa fa-' . $val));
} else {
$icon = '';
}
$categoryname = html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $coursecat->id)), $icon . $categoryname);
$content .= html_writer::start_tag('div', array('class' => 'info'));
$content .= html_writer::tag($depth > 1 ? 'h4' : 'h3', $categoryname, array('class' => 'categoryname'));
$content .= html_writer::end_tag('div');
// .info
// add category content to the output
$content .= html_writer::tag('div', $categorycontent, array('class' => 'content'));
$content .= html_writer::end_tag('div');
// .category
return $content;
}