/** * This function prints the drop down list box for course categories * @access public * @param categoryID * @author Cindy Qi Li */ public static function printCourseCatsInDropDown($categoryID = 0) { require_once TR_INCLUDE_PATH . "classes/DAO/CourseCategoriesDAO.class.php"; echo '<option value="' . TR_COURSECATEGORY_UNCATEGORIZED . '"'; if ($categoryID == TR_COURSECATEGORY_UNCATEGORIZED) { echo ' selected="selected"'; } echo '>' . _AT('cats_uncategorized') . '</option>' . "\n"; $courseCategoriesDAO = new CourseCategoriesDAO(); $rows = $courseCategoriesDAO->getAll(); if (is_array($rows)) { foreach ($rows as $row) { echo '<option value="' . $row['category_id'] . '"'; if ($row['category_id'] == $categoryID) { echo ' selected="selected"'; } echo '>' . $row['category_name'] . '</option>' . "\n"; } } }
} } // Setup array of content tools for shortcuts tool bar. $savant->assign('tool_shortcuts', $_tool_shortcuts); // array of content tools for shortcuts tool bar. $savant->assign('content_base_href', $_tmp_base_href); $savant->assign('lang_code', $_SESSION['lang']); $savant->assign('lang_charset', $myLang->getCharacterSet()); $savant->assign('base_path', $_base_path); $savant->assign('theme', $_SESSION['prefs']['PREF_THEME']); $theme_img = $_base_path . 'themes/' . $_SESSION['prefs']['PREF_THEME'] . '/images/'; $savant->assign('img', $theme_img); // course categories for search tool require_once TR_INCLUDE_PATH . 'classes/DAO/CourseCategoriesDAO.class.php'; $courseCategoriesDAO = new CourseCategoriesDAO(); $savant->assign('categories', $courseCategoriesDAO->getAll()); // get custom css $custom_css = ''; if (isset($_custom_css)) { $custom_css = '<link rel="stylesheet" href="' . $_custom_css . '" type="text/css" />'; } if (isset($_custom_head)) { $custom_css .= ' ' . $_custom_head; } if (isset($_pages[$current_page]['guide'])) { $script_name = substr($_SERVER['PHP_SELF'], strlen($_base_path)); $savant->assign('guide', TR_GUIDES_PATH . 'index.php?p=' . htmlentities_utf8($script_name)); } $savant->assign('custom_css', $custom_css); if ($onload) {
require_once TR_INCLUDE_PATH . 'vitals.inc.php'; require_once TR_INCLUDE_PATH . 'classes/DAO/CourseCategoriesDAO.class.php'; require_once TR_INCLUDE_PATH . 'classes/DAO/CoursesDAO.class.php'; global $savant; $courseCategoriesDAO = new CourseCategoriesDAO(); $coursesDAO = new CoursesDAO(); $output = ''; // get the number of courses in each category $courses_in_category = $coursesDAO->getCategoriesAndNumOfCourses(); if (is_array($courses_in_category)) { foreach ($courses_in_category as $row) { $course_num_summary[$row['category_id']] = $row['num_of_courses']; } } // get all categories $categories = $courseCategoriesDAO->getAll(); if (is_array($categories)) { foreach ($categories as $category) { $output .= '<a href="' . TR_BASE_HREF . 'home/index.php?catid=' . $category['category_id'] . '">'; if ($_GET['catid'] != '' && $_GET['catid'] == $category['category_id']) { $output .= '<span class="selected-sidemenu">'; } $output .= $category['category_name'] . ' '; if (isset($course_num_summary[$category['category_id']])) { $output .= '(' . $course_num_summary[$category['category_id']] . ')'; } else { $output .= '(0)'; } if ($_GET['catid'] != '' && $_GET['catid'] == $category['category_id']) { $output .= '</span>'; }