Container::getRouter()->generate('administration'),
"name" => get_lang('PlatformAdmin'),
);
Display::display_header($tool_name);
if ($action == 'add' || $action == 'edit') {
echo '
';
echo Display::url(
Display::return_icon('folder_up.png', get_lang("Back"), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'admin/course_category.php?category='.Security::remove_XSS($category)
);
echo '
';
$form_title = ($action == 'add') ? get_lang('AddACategory') : get_lang('EditNode');
if (!empty($category)) {
$form_title .= ' ' . get_lang('Into') . ' ' . Security::remove_XSS($category);
}
$url = api_get_self().'?action='.Security::remove_XSS($action).'&category='.Security::remove_XSS($category).'&id='.Security::remove_XSS($categoryId);
$form = new FormValidator('course_category', 'post', $url);
$form->addElement('header', '', $form_title);
$form->addElement('hidden', 'formSent', 1);
$form->addElement('text', 'code', get_lang("CategoryCode"));
$form->addElement('text', 'name', get_lang("CategoryName"));
$form->addRule('name', get_lang('PleaseEnterCategoryInfo'), 'required');
$form->addRule('code', get_lang('PleaseEnterCategoryInfo'), 'required');
$group = array(
$form->createElement('radio', 'auth_course_child', get_lang("AllowCoursesInCategory"), get_lang('Yes'), 'TRUE'),
$form->createElement('radio', 'auth_course_child', null, get_lang('No'), 'FALSE')
);
$form->addGroup($group, null, get_lang("AllowCoursesInCategory"));
if (!empty($categoryInfo)) {
$class = "save";
$text = get_lang('Save');
$form->setDefaults($categoryInfo);
$form->addButtonSave($text);
} else {
$class = "add";
$text = get_lang('AddCategory');
$form->setDefaults(array('auth_course_child' => 'TRUE'));
$form->addButtonCreate($text);
}
$form->display();
} else {
// If multiple URLs and not main URL, prevent deletion and inform user
if ($action == 'delete' && api_get_multiple_access_url() && api_get_current_access_url_id() != 1) {
Display::display_warning_message(get_lang('CourseCategoriesAreGlobal'));
}
echo '';
$link = null;
if (!empty($parentInfo)) {
$parentCode = $parentInfo['parent_id'];
echo Display::url(
Display::return_icon('back.png', get_lang("Back"), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'admin/course_category.php?category='.$parentCode
);
}
if (empty($parentInfo) || $parentInfo['auth_cat_child'] == 'TRUE') {
echo Display::url(
Display::return_icon('new_folder.png', get_lang("AddACategory"), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'admin/course_category.php?action=add&category='.Security::remove_XSS($category)
);
}
echo '
';
if (!empty($parentInfo)) {
echo Display::page_subheader($parentInfo['name'].' ('.$parentInfo['code'].')');
}
echo CourseCategory::listCategories($category);
}
Display::display_footer();