本文整理汇总了PHP中grade_tree::fill_levels方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_tree::fill_levels方法的具体用法?PHP grade_tree::fill_levels怎么用?PHP grade_tree::fill_levels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_tree
的用法示例。
在下文中一共展示了grade_tree::fill_levels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fill_levels
/**
* Static recursive helper - fills the levels array, useful when accessing tree elements of one level
*
* @param array &$levels The levels of the grade tree through which to recurse
* @param array &$element The seed of the recursion
* @param int $depth How deep are we?
* @return void
*/
public function fill_levels(&$levels, &$element, $depth)
{
if (!array_key_exists($depth, $levels)) {
$levels[$depth] = array();
}
// prepare unique identifier
if ($element['type'] == 'category') {
$element['eid'] = 'c' . $element['object']->id;
} else {
if (in_array($element['type'], array('item', 'courseitem', 'categoryitem'))) {
$element['eid'] = 'i' . $element['object']->id;
$this->items[$element['object']->id] =& $element['object'];
}
}
$levels[$depth][] =& $element;
$depth++;
if (empty($element['children'])) {
return;
}
$prev = 0;
foreach ($element['children'] as $sortorder => $child) {
grade_tree::fill_levels($levels, $element['children'][$sortorder], $depth);
$element['children'][$sortorder]['prev'] = $prev;
$element['children'][$sortorder]['next'] = 0;
if ($prev) {
$element['children'][$prev]['next'] = $sortorder;
}
$prev = $sortorder;
}
}