if (!$pos) return array($str, '');\r
else return array(substr($str, 0, $pos), substr($str, $pos));\r
}\r
+ \r
+ /**\r
+ * This funciton returns a pair of (URL, URL parameters) of the PHP_SELF url. \r
+ * For example, if http referer is "http://localhost/achecker/home/index.php?a=1&b=2", \r
+ * the function returns array ("http://localhost/achecker/home/index.php?a=1&b=2&", 'a=1&b=2"');\r
+ * @access public\r
+ * @param none\r
+ * @return array of (URL, URL parameters)\r
+ * @author Cindy Qi Li\r
+ */\r
+ public static function getRefererURLAndParams() {\r
+ $caller_url_parts = explode('/', $_SERVER['PHP_SELF']); \r
+ $caller_script = $caller_url_parts[count($caller_url_parts)-1];\r
+ \r
+ if (count($_GET) > 0)\r
+ {\r
+ foreach ($_GET as $param => $value)\r
+ {\r
+ if ($param == 'action' || $param == 'cid') \r
+ continue;\r
+ else\r
+ $url_param .= $param.'='.urlencode($value).'&';\r
+ }\r
+ }\r
+ \r
+ $caller_url = $caller_script. '?'.(isset($url_param) ? $url_param : '');\r
+ $url_param = substr($url_param, 0, -1);\r
+ \r
+ return array($caller_url, $url_param);\r
+ }\r
}\r
?>
\ No newline at end of file
$userCoursesDAO = new UserCoursesDAO();
$output = '';
+// The main page can be home/index.php or home/search.php
+// Find out the caller URL and direct the page back to the caller
+// after adding/removing the course from "My Courses"
+list($caller_url, $url_param) = Utility::getRefererURLAndParams();
+
// retrieve data to display
if ($_SESSION['user_id'] > 0) {
$my_courses = $userCoursesDAO->getByUserID($_SESSION['user_id']);
$output .= ' <a href="'. TR_BASE_HREF.'home/course/index.php?_course_id='. $row['course_id'].'"'.(($_course_id == $row['course_id']) ? ' class="selected-sidemenu"' : '').'>'.$row['title'].'</a>'."\n";
if ($row['role'] == TR_USERROLE_VIEWER) {
$output .= ' <a href="'. TR_BASE_HREF.'home/'. $caller_url.'action=remove&cid='. $row['course_id'].'">'."\n";
- $output .= ' <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/delete.gif" alt="'. htmlspecialchars(_AT('remove_from_list')).'" title="'. htmlspecialchars(_AT('remove_from_list')).'" border="0" />'."\n";
+ $output .= ' <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/bookmark_remove.png" alt="'. htmlspecialchars(_AT('remove_from_list')).'" title="'. htmlspecialchars(_AT('remove_from_list')).'" border="0" />'."\n";
$output .= ' </a>'."\n";
}
if ($row['role'] == NULL && $_SESSION['user_id']>0) {
$output .= ' <a href="'. TR_BASE_HREF.'home/'. $caller_url.'action=add&cid='. $row['course_id'].'">'."\n";
- $output .= ' <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/add.gif" alt="'. htmlspecialchars(_AT('add_into_list')).'" title="'. htmlspecialchars(_AT('add_into_list')).'" border="0" />'."\n";
+ $output .= ' <img src="'. TR_BASE_HREF.'themes/'. $_SESSION['prefs']['PREF_THEME'].'/images/bookmark_add.png" alt="'. htmlspecialchars(_AT('add_into_list')).'" title="'. htmlspecialchars(_AT('add_into_list')).'" border="0" />'."\n";
$output .= ' </a>'."\n";
}
//$output .= ' <a href="'. TR_BASE_HREF.'home/ims/ims_export.php?course_id='. $row['course_id'].'">'."\n";
// This template is called by home/index.php and home/search.php
// Find out the caller URL and direct the page back to the caller
// after adding/removing the course from "My Courses"
-$caller_url_parts = explode('/', $_SERVER['PHP_SELF']);
-$caller_script = $caller_url_parts[count($caller_url_parts)-1];
-
-if (count($_GET) > 0)
-{
- foreach ($_GET as $param => $value)
- {
- if ($param == 'action' || $param == 'cid')
- continue;
- else
- $url_param .= $param.'='.urlencode($value).'&';
- }
-}
-
-$caller_url = $caller_script. '?'.(isset($url_param) ? $url_param : '');
-$url_param = substr($url_param, 0, -1);
+list($caller_url, $url_param) = Utility::getRefererURLAndParams();
if (isset($this->search_text)) $keywords = explode(' ', $this->search_text);
?>
<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>
<?php if ($user_role['role'] == TR_USERROLE_VIEWER) {?>
<a href="<?php echo TR_BASE_HREF; ?>home/<?php echo $caller_url; ?>action=remove&cid=<?php echo $row['course_id']; ?>">
- <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/delete.gif" alt='<?php echo htmlspecialchars(_AT('remove_from_list')); ?>' title='<?php echo htmlspecialchars(_AT('remove_from_list')); ?>' border="0" />
+ <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" />
</a>
<?php } if ($user_role['role'] == NULL && $_SESSION['user_id']>0) {?>
<a href="<?php echo TR_BASE_HREF; ?>home/<?php echo $caller_url; ?>action=add&cid=<?php echo $row['course_id'];?>">
- <img src="<?php echo TR_BASE_HREF; ?>themes/<?php echo $_SESSION['prefs']['PREF_THEME']; ?>/images/add.gif" alt="<?php echo htmlspecialchars(_AT('add_into_list')); ?>" title="<?php echo htmlspecialchars(_AT('add_into_list')); ?>" border="0" />
+ <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" />
</a>
<?php }?>
<a href="<?php echo TR_BASE_HREF; ?>home/ims/ims_export.php?course_id=<?php echo $row['course_id']; ?>">
</a>
</li>
<li><a href="<?php echo $this->base_path; ?>home/course/del_course.php?_course_id=<?php echo $this->course_id; ?>">
- <img src="<?php echo $this->base_path. "themes/".$this->theme."/images/delete.gif"; ?>" title="<?php echo _AT('del_course'); ?>" alt="<?php echo _AT('del_course'); ?>" border="0" class="shortcut_icon"/>
+ <img src="<?php echo $this->base_path. "themes/".$this->theme."/images/bookmark_remove.png"; ?>" title="<?php echo _AT('del_course'); ?>" alt="<?php echo _AT('del_course'); ?>" border="0" class="shortcut_icon"/>
</a>
</li>
<?php }?>