本文整理汇总了PHP中convert_tree_to_html函数的典型用法代码示例。如果您正苦于以下问题:PHP convert_tree_to_html函数的具体用法?PHP convert_tree_to_html怎么用?PHP convert_tree_to_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convert_tree_to_html函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert_tree_to_html
/**
* Converts a nested array tree into HTML ul:li [recursive]
*
* @param array $tree A tree array to convert
* @param int $row Used in identifying the iteration level and in ul classes
* @return string HTML structure
*/
function convert_tree_to_html($tree, $row = 0)
{
$str = "\n" . '<ul class="tabrow' . $row . '">' . "\n";
$first = true;
$count = count($tree);
foreach ($tree as $tab) {
$count--;
// countdown to zero
$liclass = '';
if ($first && $count == 0) {
// Just one in the row
$liclass = 'first last';
$first = false;
} else {
if ($first) {
$liclass = 'first';
$first = false;
} else {
if ($count == 0) {
$liclass = 'last';
}
}
}
if (empty($tab->subtree) && !empty($tab->selected)) {
$liclass .= empty($liclass) ? 'onerow' : ' onerow';
}
if ($tab->inactive || $tab->active || $tab->selected) {
if ($tab->selected) {
$liclass .= empty($liclass) ? 'here selected' : ' here selected';
} else {
if ($tab->active) {
$liclass .= empty($liclass) ? 'here active' : ' here active';
}
}
}
$str .= !empty($liclass) ? '<li class="' . $liclass . '">' : '<li>';
if ($tab->inactive || $tab->active || $tab->selected && !$tab->linkedwhenselected) {
// The a tag is used for styling
$str .= '<a class="nolink"><span>' . $tab->text . '</span></a>';
} else {
$str .= '<a href="' . $tab->link . '" title="' . $tab->title . '"><span>' . $tab->text . '</span></a>';
}
if (!empty($tab->subtree)) {
$str .= convert_tree_to_html($tab->subtree, $row + 1);
} else {
if ($tab->selected) {
$str .= '<div class="tabrow' . ($row + 1) . ' empty"> </div>' . "\n";
}
}
$str .= ' </li>' . "\n";
}
$str .= '</ul>' . "\n";
return $str;
}
示例2: convert_tree_to_html
/**
* Converts a nested array tree into HTML ul:li [recursive]
*
* @deprecated since 2.5
*
* @param array $tree A tree array to convert
* @param int $row Used in identifying the iteration level and in ul classes
* @return string HTML structure
*/
function convert_tree_to_html($tree, $row=0) {
debugging('Function convert_tree_to_html() is deprecated since Moodle 2.5. Consider using class tabtree and core_renderer::render_tabtree()', DEBUG_DEVELOPER);
$str = "\n".'<ul class="tabrow'.$row.'">'."\n";
$first = true;
$count = count($tree);
foreach ($tree as $tab) {
$count--; // countdown to zero
$liclass = '';
if ($first && ($count == 0)) { // Just one in the row
$liclass = 'first last';
$first = false;
} else if ($first) {
$liclass = 'first';
$first = false;
} else if ($count == 0) {
$liclass = 'last';
}
if ((empty($tab->subtree)) && (!empty($tab->selected))) {
$liclass .= (empty($liclass)) ? 'onerow' : ' onerow';
}
if ($tab->inactive || $tab->active || $tab->selected) {
if ($tab->selected) {
$liclass .= (empty($liclass)) ? 'here selected' : ' here selected';
} else if ($tab->active) {
$liclass .= (empty($liclass)) ? 'here active' : ' here active';
}
}
$str .= (!empty($liclass)) ? '<li class="'.$liclass.'">' : '<li>';
if ($tab->inactive || $tab->active || ($tab->selected && !$tab->linkedwhenselected)) {
// The a tag is used for styling
$str .= '<a class="nolink"><span>'.$tab->text.'</span></a>';
} else {
$str .= '<a href="'.$tab->link.'" title="'.$tab->title.'"><span>'.$tab->text.'</span></a>';
}
if (!empty($tab->subtree)) {
$str .= convert_tree_to_html($tab->subtree, $row+1);
} else if ($tab->selected) {
$str .= '<div class="tabrow'.($row+1).' empty"> </div>'."\n";
}
$str .= ' </li>'."\n";
}
$str .= '</ul>'."\n";
return $str;
}