本文整理匯總了PHP中grade_tree::category_collapse方法的典型用法代碼示例。如果您正苦於以下問題:PHP grade_tree::category_collapse方法的具體用法?PHP grade_tree::category_collapse怎麽用?PHP grade_tree::category_collapse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類grade_tree
的用法示例。
在下文中一共展示了grade_tree::category_collapse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: category_collapse
/**
* Static recursive helper - removes items from collapsed categories
*
* @param array &$element The seed of the recursion
* @param array $collapsed array of collapsed categories
*
* @return void
*/
public function category_collapse(&$element, $collapsed)
{
if ($element['type'] != 'category') {
return;
}
if (empty($element['children']) or count($element['children']) < 2) {
return;
}
if (in_array($element['object']->id, $collapsed['aggregatesonly'])) {
$category_item = reset($element['children']);
//keep only category item
$element['children'] = array(key($element['children']) => $category_item);
} else {
if (in_array($element['object']->id, $collapsed['gradesonly'])) {
// Remove category item
reset($element['children']);
$first_key = key($element['children']);
unset($element['children'][$first_key]);
}
foreach ($element['children'] as $sortorder => $child) {
// Recurse through the element's children
grade_tree::category_collapse($element['children'][$sortorder], $collapsed);
}
}
}