本文整理汇总了PHP中format_base::extend_course_navigation方法的典型用法代码示例。如果您正苦于以下问题:PHP format_base::extend_course_navigation方法的具体用法?PHP format_base::extend_course_navigation怎么用?PHP format_base::extend_course_navigation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类format_base
的用法示例。
在下文中一共展示了format_base::extend_course_navigation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extend_course_navigation
/**
* Loads all of the course sections into the navigation
*
* @param global_navigation $navigation
* @param navigation_node $node The course node within the navigation
*/
public function extend_course_navigation($navigation, navigation_node $node)
{
global $PAGE;
// if section is specified in course/view.php, make sure it is expanded in navigation
if ($navigation->includesectionnum === false) {
$selectedsection = optional_param('section', null, PARAM_INT);
if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
$navigation->includesectionnum = $selectedsection;
}
}
// check if there are callbacks to extend course navigation
parent::extend_course_navigation($navigation, $node);
// We want to remove the general section if it is empty.
$modinfo = get_fast_modinfo($this->get_course());
$sections = $modinfo->get_sections();
if (!isset($sections[0])) {
// The general section is empty to find the navigation node for it we need to get its ID.
$section = $modinfo->get_section_info(0);
$generalsection = $node->get($section->id, navigation_node::TYPE_SECTION);
if ($generalsection) {
// We found the node - now remove it.
$generalsection->remove();
}
}
}
示例2: extend_course_navigation
/**
* Loads all of the course sections into the navigation
*
* @param global_navigation $navigation
* @param navigation_node $node The course node within the navigation
*/
public function extend_course_navigation($navigation, navigation_node $node)
{
global $PAGE;
// If section is specified in course/view.php, make sure it is expanded in navigation.
if ($navigation->includesectionnum === false) {
$selectedsection = optional_param('section', null, PARAM_INT);
if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
$navigation->includesectionnum = $selectedsection;
}
}
parent::extend_course_navigation($navigation, $node);
$modinfo = get_fast_modinfo($this->get_course());
$context = context_course::instance($modinfo->courseid);
$sectioninfos = $this->get_sections();
foreach ($sectioninfos as $sectionnum => $section) {
if ($sectionnum == 0) {
if (empty($modinfo->sections[0]) && ($sectionnode = $node->get($section->id, navigation_node::TYPE_SECTION))) {
// The general section is empty, remove the node from navigation.
$sectionnode->remove();
}
} else {
if ($this->get_section_display_mode($section) > FORMAT_PERIODS_COLLAPSED && ($sectionnode = $node->get($section->id, navigation_node::TYPE_SECTION))) {
// Remove or hide navigation nodes for sections that are hidden/not available.
if (!has_capability('moodle/course:viewhiddenactivities', $context) && $navigation->includesectionnum != $sectionnum) {
$sectionnode->remove();
} else {
$sectionnode->hidden = true;
}
}
}
}
}
示例3: extend_course_navigation
/**
* Loads all of the course sections into the navigation
*
* @param global_navigation $navigation
* @param navigation_node $node The course node within the navigation
*/
public function extend_course_navigation($navigation, navigation_node $node)
{
global $PAGE;
// if section is specified in course/view.php, make sure it is expanded in navigation
if ($navigation->includesectionnum === false) {
$selectedsection = optional_param('section', null, PARAM_INT);
if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
$navigation->includesectionnum = $selectedsection;
}
}
parent::extend_course_navigation($navigation, $node);
}
示例4: extend_course_navigation
/**
* Loads all of the course sections into the navigation
*
* First this function calls callback_FORMATNAME_display_content() if it exists to check
* if the navigation should be extended at all
*
* Then it calls function callback_FORMATNAME_load_content() if it exists to actually extend
* navigation
*
* By default the parent method is called
*
* @param global_navigation $navigation
* @param navigation_node $node The course node within the navigation
*/
public function extend_course_navigation($navigation, navigation_node $node)
{
global $PAGE;
// if course format displays section on separate pages and we are on course/view.php page
// and the section parameter is specified, make sure this section is expanded in
// navigation
if ($navigation->includesectionnum === false) {
$selectedsection = optional_param('section', null, PARAM_INT);
if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
$navigation->includesectionnum = $selectedsection;
}
}
// check if there are callbacks to extend course navigation
$displayfunc = 'callback_' . $this->format . '_display_content';
if (function_exists($displayfunc) && !$displayfunc()) {
return;
}
$featurefunction = 'callback_' . $this->format . '_load_content';
if (function_exists($featurefunction) && ($course = $this->get_course())) {
$featurefunction($navigation, $course, $node);
} else {
parent::extend_course_navigation($navigation, $node);
}
}