本文整理汇总了PHP中navigation_node::contains_active_node方法的典型用法代码示例。如果您正苦于以下问题:PHP navigation_node::contains_active_node方法的具体用法?PHP navigation_node::contains_active_node怎么用?PHP navigation_node::contains_active_node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类navigation_node
的用法示例。
在下文中一共展示了navigation_node::contains_active_node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_contains_active_node
public function test_contains_active_node() {
// demo5, and activity1 were set to active during setup
// Should be true as it contains all nodes
$this->assertTrue($this->node->contains_active_node());
// Should be true as demo5 is a child of demo3
$this->assertTrue($this->node->get('demo3')->contains_active_node());
// Obviously duff
$this->assertFalse($this->node->get('demo1')->contains_active_node());
// Should be true as demo5 contains activity1
$this->assertTrue($this->node->get('demo3')->get('demo5')->contains_active_node());
// Should be true activity1 is the active node
$this->assertTrue($this->node->get('demo3')->get('demo5')->get('activity1')->contains_active_node());
// Obviously duff
$this->assertFalse($this->node->get('demo3')->get('demo4')->contains_active_node());
}
示例2: navigation_node
protected function navigation_node(navigation_node $node, $attrs = array(), $depth = 1)
{
$items = $node->children;
// exit if empty, we don't want an empty ul element
if ($items->count() == 0) {
return '';
}
// array of nested li elements
$lis = array();
$number = 0;
foreach ($items as $item) {
$number++;
if (!$item->display) {
continue;
}
$isbranch = $item->children->count() > 0 || $item->nodetype == navigation_node::NODETYPE_BRANCH;
$hasicon = !$isbranch && $item->icon instanceof renderable;
if ($isbranch) {
$item->hideicon = true;
}
$content = $this->output->render($item);
// this applies to the li item which contains all child lists too
$liclasses = array($item->get_css_type());
$liexpandable = array();
if ($isbranch) {
$liclasses[] = 'contains_branch';
if (!$item->forceopen || !$item->forceopen && $item->collapse || $item->children->count() == 0 && $item->nodetype == navigation_node::NODETYPE_BRANCH) {
$liexpandable = array('aria-expanded' => 'false');
} else {
$liexpandable = array('aria-expanded' => 'true');
}
if ($item->requiresajaxloading) {
$liexpandable['data-requires-ajax'] = 'true';
$liexpandable['data-loaded'] = 'false';
}
} else {
if ($hasicon) {
$liclasses[] = 'item_with_icon';
}
}
if ($item->isactive === true) {
$liclasses[] = 'current_branch';
}
$nodetextid = 'label_' . $depth . '_' . $number;
$liattr = array('class' => join(' ', $liclasses), 'tabindex' => '-1', 'role' => 'treeitem') + $liexpandable;
// class attribute on the div item which only contains the item content
$divclasses = array('tree_item');
if ($isbranch) {
$divclasses[] = 'branch';
} else {
$divclasses[] = 'leaf';
}
if (!empty($item->classes) && count($item->classes) > 0) {
$divclasses[] = join(' ', $item->classes);
}
$divattr = array('class' => join(' ', $divclasses));
if (!empty($item->id)) {
$divattr['id'] = $item->id;
}
$content = html_writer::tag('p', $content, $divattr) . $this->navigation_node($item, array(), $depth + 1);
if (!empty($item->preceedwithhr) && $item->preceedwithhr === true) {
$content = html_writer::empty_tag('hr') . $content;
}
$liattr['aria-labelledby'] = $nodetextid;
$content = html_writer::tag('li', $content, $liattr);
if ($node->contains_active_node()) {
$lis[] = $content;
}
}
if (count($lis)) {
if (empty($attrs['role'])) {
$attrs['role'] = 'group';
}
return html_writer::tag('ul', implode("\n", $lis), $attrs);
} else {
return '';
}
}