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);
26 <div class="input-form">
27 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('search'); ?></legend>
28 <form target="_top" action="<?php echo TR_BASE_HREF; ?>home/search.php" method="get" name="frm_search">
29 <input type="text" name="search_text" id="search_text" value="<?php if (isset($_REQUEST['search_text'])) echo $_REQUEST['search_text']; ?>" size="50" />
31 <?php if (is_array($this->categories)) { // print category dropdown list box?>
33 <option value="" <?php if (!isset($_GET['catid']) || $_GET['catid'] == '') echo 'selected="selected"'; ?>><?php echo _AT('all_categories'); ?></option>
34 <option value="">---------------------------------</option>
35 <?php foreach ($this->categories as $category) {?>
36 <option value="<?php echo $category['category_id']; ?>" <?php if ($_GET['catid'] == $category['category_id']) echo 'selected'; ?>><?php echo $category['category_name']; ?></option>
38 <option value="0" <?php if ($_GET['catid'] == 0 && $_GET['catid'] <> '') echo 'selected'; ?>><?php echo _AT('cats_uncategorized'); ?></option>
42 <input type="submit" name="search" size="100" value="<?php echo _AT("search"); ?>" />
48 <div class="input-form">
49 <fieldset class="group_form"><legend class="group_form"><?php echo $this->title; ?></legend>
50 <?php if (is_array($this->courses)) { ?>
52 <ol class="remove-margin-left">
54 if (isset($_SESSION['user_id'])) $userCoursesDAO = new UserCoursesDAO();
56 $num_results = count($this->courses);
58 // if the requested page number exceeds the max number of pages, set the current page to the last page
59 $num_pages = ceil($num_results / RESULTS_PER_PAGE);
60 if ($this->curr_page_num > $num_pages) $this->curr_page_num = $num_pages;
63 $start_num = ($this->curr_page_num - 1) * RESULTS_PER_PAGE;
64 $end_num = min($this->curr_page_num * RESULTS_PER_PAGE, $num_results);
66 <li class="course" style="font-weight:bold">
67 <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>"':'');?>
69 if($_SESSION['user_id']){ ?>
70 <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>
75 <?php for ($i = $start_num; $i < $end_num; $i++) {
76 // only display the first 200 character of course description
77 $row = $this->courses[$i];
79 // find whether the current user is the author of this course
80 if (isset($_SESSION['user_id'])) $user_role = $userCoursesDAO->get($_SESSION['user_id'], $row['course_id']);
82 $len_description = 330;
83 if (strlen($row['description']) > $len_description)
84 $description = Utility::highlightKeywords(substr($row['description'], 0, $len_description), $keywords).' ...';
86 $description = Utility::highlightKeywords($row['description'], $keywords);
90 <?php if ($user_role['role'] == TR_USERROLE_AUTHOR) {?>
91 <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'); ?>" />
93 <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'); ?>" />
95 <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>
96 <?php if ($user_role['role'] == TR_USERROLE_VIEWER) {?>
97 <a href="<?php echo TR_BASE_HREF; ?>home/<?php echo $caller_url; ?>action=remove&cid=<?php echo $row['course_id']; ?>">
98 <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" />
100 <?php } if ($user_role['role'] == NULL && $_SESSION['user_id']>0) {?>
101 <a href="<?php echo TR_BASE_HREF; ?>home/<?php echo $caller_url; ?>action=add&cid=<?php echo $row['course_id'];?>">
102 <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" />
105 <a href="<?php echo TR_BASE_HREF; ?>home/ims/ims_export.php?course_id=<?php echo $row['course_id']; ?>">
106 <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" />
108 <a href="<?php echo TR_BASE_HREF; ?>home/imscc/ims_export.php?course_id=<?php echo $row['course_id']; ?>">
109 <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" />
112 <div><?php echo $description; ?></div>
114 <?php } // end of foreach; ?>
116 <?php print_paginator($this->curr_page_num, $num_results, $url_param, RESULTS_PER_PAGE);?>
120 // echo _AT("no_results_for_keywords", $this->search_text);
121 echo _AT("none_found");