fix the bug that the click on buttons of "add/remove lesson from my lesson list"...
authorCindy Li <cli@ocad.ca>
Thu, 12 Aug 2010 14:05:39 +0000 (14:05 -0000)
committerCindy Li <cli@ocad.ca>
Thu, 12 Aug 2010 14:05:39 +0000 (14:05 -0000)
docs/include/classes/Utility.class.php
docs/include/sidemenus/my_courses.inc.php
docs/themes/default/home/index_course.tmpl.php
docs/themes/default/include/header.tmpl.php

index 54deea9..cd918f0 100644 (file)
@@ -290,5 +290,35 @@ class Utility {
                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
index 84308b7..1a0da5a 100644 (file)
@@ -22,6 +22,11 @@ global $savant, $_course_id;
 $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']); 
@@ -46,12 +51,12 @@ if (!is_array($my_courses)) {
                $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";
index 6970157..ae2679e 100644 (file)
@@ -18,22 +18,7 @@ require_once(TR_INCLUDE_PATH.'classes/DAO/UserCoursesDAO.class.php');
 // 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);
 ?>
@@ -110,11 +95,11 @@ 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']; ?>">
index 2a32b8c..eaace23 100644 (file)
@@ -259,7 +259,7 @@ foreach ($this->top_level_pages as $page) {
         </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 }?>