当前位置: 首页>>代码示例>>PHP>>正文


PHP convert_tree_to_html函数代码示例

本文整理汇总了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">&nbsp;</div>' . "\n";
            }
        }
        $str .= ' </li>' . "\n";
    }
    $str .= '</ul>' . "\n";
    return $str;
}
开发者ID:hatone,项目名称:moodle,代码行数:61,代码来源:weblib.php

示例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">&nbsp;</div>'."\n";
        }

        $str .= ' </li>'."\n";
    }
    $str .= '</ul>'."\n";

    return $str;
}
开发者ID:rwijaya,项目名称:moodle,代码行数:65,代码来源:deprecatedlib.php


注:本文中的convert_tree_to_html函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。