upgrade
This commit is contained in:
43
main/inc/ajax/course_category.ajax.php
Normal file
43
main/inc/ajax/course_category.ajax.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Responses to AJAX calls.
|
||||
*/
|
||||
require_once __DIR__.'/../global.inc.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$action = $_REQUEST['a'];
|
||||
|
||||
switch ($action) {
|
||||
case 'show_courses':
|
||||
$categoryId = (int) $_REQUEST['id'];
|
||||
$categoryInfo = CourseCategory::getCategoryById($categoryId);
|
||||
if (!empty($categoryInfo)) {
|
||||
$courses = CourseCategory::getCoursesInCategory($categoryInfo['code'], '', false, false);
|
||||
|
||||
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
|
||||
$headers = [
|
||||
get_lang('Name'),
|
||||
];
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
foreach ($headers as $header) {
|
||||
$table->setHeaderContents($row, $column, $header);
|
||||
$column++;
|
||||
}
|
||||
$result = '';
|
||||
foreach ($courses as $course) {
|
||||
$row++;
|
||||
$courseLink = '<a href="'.api_get_path(WEB_PATH).'courses/'.$course['directory'].'/index.php">'.$course['title'].'</a>';
|
||||
$table->setCellContents($row, 0, $courseLink);
|
||||
}
|
||||
|
||||
echo $table->toHtml();
|
||||
exit;
|
||||
}
|
||||
break;
|
||||
}
|
||||
exit;
|
||||
Reference in New Issue
Block a user