本文整理匯總了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();
}
}