644e0a534258cf0a1f1a42dfbc65ef19a17a375f
[acontent.git] / docs / include / sidemenus / category.inc.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 if (!defined('TR_INCLUDE_PATH')) { exit; }
14 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'classes/DAO/CourseCategoriesDAO.class.php');
16 require_once(TR_INCLUDE_PATH.'classes/DAO/CoursesDAO.class.php');
17
18 global $savant;
19
20 $courseCategoriesDAO = new CourseCategoriesDAO();
21 $coursesDAO = new CoursesDAO();
22 $output = '';
23
24 // get the number of courses in each category
25 $courses_in_category = $coursesDAO->getCategoriesAndNumOfCourses();
26
27 if (is_array($courses_in_category)) {
28         foreach ($courses_in_category as $row){
29                 $course_num_summary[$row['category_id']] = $row['num_of_courses'];
30         }
31 }
32
33 // get all categories
34 $categories = $courseCategoriesDAO->getAll();
35
36 if (is_array($categories)) {
37         foreach ($categories as $category) {
38                 $output .= '<a href="'.TR_BASE_HREF.'home/index.php?catid='.$category['category_id'].'">';
39                 
40                 if ($_GET['catid'] <> '' && $_GET['catid'] == $category['category_id']) {
41                         $output .= '<span class="selected-sidemenu">';
42                 }
43                 $output .= $category['category_name'].'&nbsp;';
44                 if (isset($course_num_summary[$category['category_id']])) {
45                         $output .= '('.$course_num_summary[$category['category_id']].')';
46                 }
47                 else {
48                         $output .= '(0)';
49                 }
50                 if ($_GET['catid'] <> '' && $_GET['catid'] == $category['category_id']) {
51                         $output .= '</span>';
52                 }
53                 $output .= '</a><br />';
54         }
55 }
56
57 // Uncategorized
58 if (isset($course_num_summary[0])) {
59         $output .= '<a href="'.TR_BASE_HREF.'home/index.php?catid=0">';
60         
61         if ($_GET['catid'] <> '' && $_GET['catid'] == 0) {
62                 $output .= '<span class="selected-sidemenu">';
63         }
64                 
65         $output .= _AT('cats_uncategorized').'&nbsp;('.$course_num_summary[0].')';
66         if ($_GET['catid'] <> '' && $_GET['catid'] == 0) {
67                 $output .= '</span>';
68         }
69         $output .= '</a><br />';
70 }
71
72 if ($output == '') {
73         $output = _AT('none_found');
74 }
75 $savant->assign('title', _AT('category'));
76 $savant->assign('dropdown_contents', $output);
77 //$savant->assign('default_status', "hide");
78
79 $savant->display('include/box.tmpl.php');
80 ?>