本文整理匯總了PHP中grade_category::_get_children_recursion方法的典型用法代碼示例。如果您正苦於以下問題:PHP grade_category::_get_children_recursion方法的具體用法?PHP grade_category::_get_children_recursion怎麽用?PHP grade_category::_get_children_recursion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類grade_category
的用法示例。
在下文中一共展示了grade_category::_get_children_recursion方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _get_children_recursion
/**
* Private method used to retrieve all children of this category recursively
*
* @param grade_category $category Source of current recursion
* @return array An array of child grade categories
*/
private static function _get_children_recursion($category)
{
$children_array = array();
foreach ($category->children as $sortorder => $child) {
if (array_key_exists('itemtype', $child)) {
$grade_item = new grade_item($child, false);
if (in_array($grade_item->itemtype, array('course', 'category'))) {
$type = $grade_item->itemtype . 'item';
$depth = $category->depth;
} else {
$type = 'item';
$depth = $category->depth;
// we use this to set the same colour
}
$children_array[$sortorder] = array('object' => $grade_item, 'type' => $type, 'depth' => $depth);
} else {
$children = grade_category::_get_children_recursion($child);
$grade_category = new grade_category($child, false);
if (empty($children)) {
$children = array();
}
$children_array[$sortorder] = array('object' => $grade_category, 'type' => 'category', 'depth' => $grade_category->depth, 'children' => $children);
}
}
// sort the array
ksort($children_array);
return $children_array;
}