本文整理匯總了PHP中coursecat::cr_make_categories_list方法的典型用法代碼示例。如果您正苦於以下問題:PHP coursecat::cr_make_categories_list方法的具體用法?PHP coursecat::cr_make_categories_list怎麽用?PHP coursecat::cr_make_categories_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類coursecat
的用法示例。
在下文中一共展示了coursecat::cr_make_categories_list方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: cr_make_categories_list
function cr_make_categories_list(&$list, &$parents, $requiredcapability = '', $excludeid = 0, $category = NULL, $path = "")
{
global $CFG, $DB;
require_once $CFG->libdir . '/coursecatlib.php';
// For categories list use just this one function:
if (empty($list)) {
$list = array();
}
$list += coursecat::cr_make_categories_list($requiredcapability, $excludeid);
// Building the list of all parents of all categories in the system is highly undesirable and hardly ever needed.
// Usually user needs only parents for one particular category, in which case should be used:
// coursecat::get($categoryid)->get_parents()
if (empty($parents)) {
$parents = array();
}
$all = $DB->get_records_sql('SELECT id, parent FROM {course_categories} ORDER BY sortorder');
foreach ($all as $record) {
if ($record->parent) {
$parents[$record->id] = array_merge($parents[$record->parent], array($record->parent));
} else {
$parents[$record->id] = array();
}
}
}