moved code up one level to eliminate the docs subdirectory
[acontent.git] / themes / default / home / index_course.tmpl.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 // determine the from url is search.php or index.php
14 global $_base_path;
15 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
16 require_once(TR_INCLUDE_PATH.'classes/DAO/UserCoursesDAO.class.php');
17
18 // This template is called by home/index.php and home/search.php
19 // Find out the caller URL and direct the page back to the caller 
20 // after adding/removing the course from "My Courses"
21 list($caller_url, $url_param) = Utility::getRefererURLAndParams();
22
23 if (isset($this->search_text)) $keywords = explode(' ', $this->search_text);
24 ?>
25
26
27 <div class="input-form">
28 <fieldset class="group_form"><legend class="group_form"><?php echo $this->title; ?></legend>
29 <?php if (is_array($this->courses)) { ?>
30   <div class="results">
31     <ol class="remove-margin-left">
32 <?php 
33         if (isset($_SESSION['user_id'])) $userCoursesDAO = new UserCoursesDAO();
34         
35         $num_results = count($this->courses);
36         
37         // if the requested page number exceeds the max number of pages, set the current page to the last page
38         $num_pages = ceil($num_results / RESULTS_PER_PAGE);
39         if ($this->curr_page_num > $num_pages) $this->curr_page_num = $num_pages;
40         
41         
42         $start_num = ($this->curr_page_num - 1) * RESULTS_PER_PAGE;
43         $end_num = min($this->curr_page_num * RESULTS_PER_PAGE, $num_results);
44 ?>
45       <li class="course" style="font-weight:bold">
46         <div><?php echo ((strstr($caller_script, 'search.php') ? _AT('results'):_AT('lessons'))).' '.($start_num+1) .'-'.$end_num.' '._AT('of').' '.$num_results.' '. ($this->search_text<>'' ? _AT('for').' "<em>'.$this->search_text.'</em>"':'');?>
47         <?php  
48         if($_SESSION['user_id']){ ?>
49           <span style="float: right"><img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/my_own_course.gif" alt="<?php echo _AT('my_authoring_course'); ?>" title="<?php echo _AT('my_authoring_course'); ?>" />&nbsp;&nbsp;&nbsp;<?php echo _AT('authoring_img_info'); ?></span>
50           <?php } ?>
51         </div>
52                                 
53       </li>
54 <?php   for ($i = $start_num; $i < $end_num; $i++) {
55                 // only display the first 200 character of course description
56                 $row = $this->courses[$i];
57                 
58                 // find whether the current user is the author of this course
59                 if (isset($_SESSION['user_id'])) $user_role = $userCoursesDAO->get($_SESSION['user_id'], $row['course_id']);
60                 
61                 $len_description = 330;
62                 if (strlen($row['description']) > $len_description)
63                         $description = Utility::highlightKeywords(substr($row['description'], 0, $len_description), $keywords).' ...';
64                 else
65                         $description = Utility::highlightKeywords($row['description'], $keywords);
66 ?>
67       <li class="course">
68
69 <?php if ($user_role['role'] == TR_USERROLE_AUTHOR) {?>
70           <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/my_own_course.gif" alt="<?php echo _AT('my_authoring_course'); ?>" title="<?php echo _AT('my_authoring_course'); ?>" />
71 <?php } else  {?>
72           <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/others_course.png" alt="<?php echo _AT('others_course'); ?>" title="<?php echo _AT('others_course'); ?>" />
73 <?php } ?>
74           <a href="<?php echo TR_BASE_HREF; ?>home/course/index.php?_course_id=<?php echo $row['course_id']; ?>"><?php echo Utility::highlightKeywords($row['title'], $keywords); ?></a>
75 <?php if ($user_role['role'] == TR_USERROLE_VIEWER) {?>
76           <a href="<?php echo TR_BASE_HREF; ?>home/<?php echo $caller_url; ?>action=remove<?php echo SEP; ?>cid=<?php echo $row['course_id']; ?>">
77             <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/bookmark_remove.png" alt='<?php echo htmlspecialchars(_AT('remove_from_list')); ?>' title='<?php echo htmlspecialchars(_AT('remove_from_list')); ?>' border="0" />
78           </a>
79 <?php } if ($user_role['role'] == NULL && $_SESSION['user_id']>0) {?>
80           <a href="<?php echo TR_BASE_HREF; ?>home/<?php echo $caller_url; ?>action=add<?php echo SEP; ?>cid=<?php echo $row['course_id'];?>">
81             <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/bookmark_add.png" alt="<?php echo htmlspecialchars(_AT('add_into_list')); ?>" title="<?php echo htmlspecialchars(_AT('add_into_list')); ?>" border="0" />
82           </a>
83 <?php }?>
84           <a href="<?php echo TR_BASE_HREF; ?>home/ims/ims_export.php?course_id=<?php echo $row['course_id']; ?>">
85             <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/export.png" alt="<?php echo _AT('download_content_package'); ?>" title="<?php echo _AT('download_content_package'); ?>" border="0" />
86           </a>
87           <a href="<?php echo TR_BASE_HREF; ?>home/imscc/ims_export.php?course_id=<?php echo $row['course_id']; ?>">
88             <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/export_cc.png" alt="<?php echo _AT('download_common_cartridge'); ?>" title="<?php echo _AT('download_common_cartridge'); ?>" border="0" />
89           </a>
90
91         <div><?php echo $description; ?></div>
92       </li>                             
93 <?php } // end of foreach; ?>
94     </ol>
95 <?php   print_paginator($this->curr_page_num, $num_results, $url_param, RESULTS_PER_PAGE);?>
96   </div>
97 <?php } // end of if
98 else {
99 //      echo _AT("no_results_for_keywords", $this->search_text);
100         echo _AT("none_found");
101 } // end of else?>
102 </fieldset>
103 </div>