本文整理汇总了PHP中format_base::page_set_cm方法的典型用法代码示例。如果您正苦于以下问题:PHP format_base::page_set_cm方法的具体用法?PHP format_base::page_set_cm怎么用?PHP format_base::page_set_cm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类format_base
的用法示例。
在下文中一共展示了format_base::page_set_cm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: page_set_cm
/**
* Allows course format to execute code on moodle_page::set_cm()
*
* If we are inside the main module for this course, remove extra node level
* from navigation: substitute course node with activity node, move all children
*
* @param moodle_page $page instance of page calling set_cm
*/
public function page_set_cm(moodle_page $page)
{
global $PAGE;
parent::page_set_cm($page);
if ($PAGE == $page && ($cm = $this->get_activity()) && $cm->uservisible && $cm->id === $page->cm->id && ($activitynode = $page->navigation->find($cm->id, navigation_node::TYPE_ACTIVITY)) && ($node = $page->navigation->find($page->course->id, navigation_node::TYPE_COURSE))) {
// Substitute course node with activity node, move all children.
$node->action = $activitynode->action;
$node->type = $activitynode->type;
$node->id = $activitynode->id;
$node->key = $activitynode->key;
$node->isactive = $node->isactive || $activitynode->isactive;
$node->icon = null;
if ($activitynode->children->count()) {
foreach ($activitynode->children as &$child) {
$child->remove();
$node->add_node($child);
}
} else {
$node->search_for_active_node();
}
$activitynode->remove();
}
}