2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
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 /************************************************************************/
13 // determine the from url is search.php or index.php
15 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
16 require_once(TR_INCLUDE_PATH.'classes/DAO/UserCoursesDAO.class.php');
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();
23 if (isset($this->search_text)) $keywords = explode(' ', $this->search_text);
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)) { ?>
31 <ol class="remove-margin-left">
33 if (isset($_SESSION['user_id'])) $userCoursesDAO = new UserCoursesDAO();
35 $num_results = count($this->courses);
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;
42 $start_num = ($this->curr_page_num - 1) * RESULTS_PER_PAGE;
43 $end_num = min($this->curr_page_num * RESULTS_PER_PAGE, $num_results);
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>"':'');?>
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'); ?>" /> <?php echo _AT('authoring_img_info'); ?></span>
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];
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']);
61 $len_description = 330;
62 if (strlen($row['description']) > $len_description)
63 $description = Utility::highlightKeywords(substr($row['description'], 0, $len_description), $keywords).' ...';
65 $description = Utility::highlightKeywords($row['description'], $keywords);
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'); ?>" />
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'); ?>" />
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" />
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" />
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" />
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" />
91 <div><?php echo $description; ?></div>
93 <?php } // end of foreach; ?>
95 <?php print_paginator($this->curr_page_num, $num_results, $url_param, RESULTS_PER_PAGE);?>
99 // echo _AT("no_results_for_keywords", $this->search_text);
100 echo _AT("none_found");