Browse Source

[svn r20440] FS#306 and FS#4143 - Course (Learning path) tool: Some fixes for better character encoding management.

Ivan Tcholakov 16 years ago
parent
commit
c7631d1d5f

+ 139 - 123
main/newscorm/learnpath.class.php

@@ -40,7 +40,7 @@ class learnpath {
 	var $current_time_start; //the time the user loaded this resource (this does not mean he can see it yet)
 	var $current_time_stop; //the time the user closed this resource
 	var $default_status = 'not attempted';
-	var $encoding = 'ISO-8859-1';
+	var $encoding = 'UTF-8';
 	var $error = '';
 	var $extra_information = ''; //this string can be used by proprietary SCORM contents to store data about the current learnpath
 	var $force_commit = false; //for SCORM only - if set to true, will send a scorm LMSCommit() request on each LMSSetValue()
@@ -369,9 +369,9 @@ class learnpath {
     	$max_time_allowed = $this->escape_string(htmlentities($max_time_allowed));
         if (empty($max_time_allowed)) { $max_time_allowed = 0; }
     	
-    	$title=htmlspecialchars($title,ENT_QUOTES);
-    	$title = $this->escape_string(mb_convert_encoding($title,$this->encoding,$charset));
-    	$description = $this->escape_string(mb_convert_encoding($description,$this->encoding,$charset)); 
+		$title = htmlspecialchars($title, ENT_QUOTES, $charset);  // TODO: To be checked for encoding problems.
+    	$title = $this->escape_string(api_convert_encoding($title, $this->encoding, $charset));
+    	$description = $this->escape_string(api_convert_encoding($description, $this->encoding, $charset));
     	$sql_count = "
     		SELECT COUNT(id) AS num
     		FROM " . $tbl_lp_item . "
@@ -595,13 +595,15 @@ class learnpath {
      */
     function add_lp($course,$name,$description='',$learnpath='guess',$origin='zip',$zipname='')
     {
+		global $charset;
+
 		//if($this->debug>0){error_log('New LP - In learnpath::add_lp()',0);}
     	//TODO
     	$tbl_lp = Database::get_course_table('lp');
     	//check course code exists
     	//check lp_name doesn't exist, otherwise append something
     	$i = 0;
-    	$name = learnpath::escape_string(htmlentities($name)); //Kevin Van Den Haute: added htmlentities()
+    	$name = learnpath::escape_string(api_htmlentities($name, ENT_QUOTES, $charset)); //Kevin Van Den Haute: added htmlentities()
     	$check_name = "SELECT * FROM $tbl_lp WHERE name = '$name'";
     	//if($this->debug>2){error_log('New LP - Checking the name for new LP: '.$check_name,0);}
     	$res_name = api_sql_query($check_name, __FILE__, __LINE__);
@@ -615,7 +617,7 @@ class learnpath {
     	}
     	//new name does not exist yet; keep it
     	//escape description
-    	$description = learnpath::escape_string(htmlentities($description)); //Kevin: added htmlentities()
+    	$description = learnpath::escape_string(api_htmlentities($description, ENT_QUOTES, $charset)); //Kevin: added htmlentities()
     	$type = 1;
     	switch($learnpath){
     		case 'guess':
@@ -954,6 +956,9 @@ class learnpath {
      * @return	boolean	True on success, false on error
      */
     function edit_item($id, $parent, $previous, $title, $description, $prerequisites=0, $audio=NULL, $max_time_allowed=0) {
+
+		global $charset;
+
     	if($this->debug > 0){error_log('New LP - In learnpath::edit_item()', 0);}
         if(empty($max_time_allowed)) { $max_time_allowed = 0;}
     	if(empty($id) or ($id != strval(intval($id))) or empty($title)){ return false; }
@@ -989,17 +994,18 @@ class learnpath {
 
     	$same_parent	= ($row_select['parent_item_id'] == $parent) ? true : false;
     	$same_previous	= ($row_select['previous_item_id'] == $previous) ? true : false;
-    	
+
+    	//TODO: htmlspecialchars to be checked for encoding related problems.
     	if($same_parent && $same_previous) {
     		//only update title and description
     		$sql_update = "
     			UPDATE " . $tbl_lp_item . " 
     			SET 
-    				title = '" . $this->escape_string(htmlspecialchars($title,ENT_QUOTES)) . "',
+    				title = '" . $this->escape_string(htmlspecialchars($title, ENT_QUOTES, $charset)) . "',
 					prerequisite = '".$prerequisites."',
-    				description = '" . $this->escape_string(htmlentities($description)) . "'
+    				description = '" . $this->escape_string(api_htmlentities($description, ENT_QUOTES, $charset)) . "'
                     ". $audio_update_sql . ",
-                    max_time_allowed = '" . $this->escape_string(htmlentities($max_time_allowed)) . "'
+                    max_time_allowed = '" . $this->escape_string(api_htmlentities($max_time_allowed, ENT_QUOTES, $charset)) . "'
     			WHERE id = " . $id;
     		$res_update = api_sql_query($sql_update, __FILE__, __LINE__);
     	}
@@ -1106,13 +1112,14 @@ class learnpath {
 		    	$new_next	= $row_select_old['next_item_id'];
 		    	$new_order	= $row_select_old['display_order'] + 1;
     		}
-	    	
+
+	    	//TODO: htmlspecialchars to be checked for encoding related problems.
     		//update the current item with the new data
     		$sql_update = "
 	    		UPDATE " . $tbl_lp_item . "
 	    		SET
-	    			title = '" . $this->escape_string(htmlspecialchars($title,ENT_QUOTES)) . "',
-	    			description = '" . $this->escape_string(htmlentities($description)) . "',
+	    			title = '" . $this->escape_string(htmlspecialchars($title, ENT_QUOTES, $charset)) . "',
+	    			description = '" . $this->escape_string(api_htmlentities($description, ENT_QUOTES, $charset)) . "',
 	    			parent_item_id = " . $parent . ",
 	    			previous_item_id = " . $previous . ",
 	    			next_item_id = " . $new_next . ",
@@ -2410,6 +2417,9 @@ class learnpath {
 	 * @todo 	Translate labels 
 	 */
 	function get_iv_interactions_array($lp_iv_id=0){
+
+		global $charset;
+
 		$list = array();
 		$table = Database::get_course_table('lp_iv_interaction');
 		$sql = "SELECT * FROM $table WHERE lp_iv_id = $lp_iv_id ORDER BY order_id ASC";
@@ -2417,14 +2427,14 @@ class learnpath {
 		$num = Database::num_rows($res);
 		if($num>0){
 			$list[] = array(
-				"order_id"=>htmlentities(get_lang('Order')),
-				"id"=>htmlentities(get_lang('InteractionID')),
-				"type"=>htmlentities(get_lang('Type')),
-				"time"=>htmlentities(get_lang('TimeFinished')),
-				"correct_responses"=>htmlentities(get_lang('CorrectAnswers')),
-				"student_response"=>htmlentities(get_lang('StudentResponse')),
-				"result"=>htmlentities(get_lang('Result')),
-				"latency"=>htmlentities(get_lang('LatencyTimeSpent')));
+				"order_id"=>api_htmlentities(get_lang('Order'), ENT_QUOTES, $charset),
+				"id"=>api_htmlentities(get_lang('InteractionID'), ENT_QUOTES, $charset),
+				"type"=>api_htmlentities(get_lang('Type'), ENT_QUOTES, $charset),
+				"time"=>api_htmlentities(get_lang('TimeFinished'), ENT_QUOTES, $charset),
+				"correct_responses"=>api_htmlentities(get_lang('CorrectAnswers'), ENT_QUOTES, $charset),
+				"student_response"=>api_htmlentities(get_lang('StudentResponse'), ENT_QUOTES, $charset),
+				"result"=>api_htmlentities(get_lang('Result'), ENT_QUOTES, $charset),
+				"latency"=>api_htmlentities(get_lang('LatencyTimeSpent'), ENT_QUOTES, $charset));
 			while ($row = Database::fetch_array($res)){
 				$list[] = array(
 					"order_id"=>($row['order_id']+1),
@@ -2464,6 +2474,9 @@ class learnpath {
 	 * @todo 	Translate labels 
 	 */
 	function get_iv_objectives_array($lp_iv_id=0){
+
+		global $chatset;
+
 		$list = array();
 		$table = Database::get_course_table('lp_iv_objective');
 		$sql = "SELECT * FROM $table WHERE lp_iv_id = $lp_iv_id ORDER BY order_id ASC";
@@ -2471,12 +2484,12 @@ class learnpath {
 		$num = Database::num_rows($res);
 		if($num>0){
 			$list[] = array(
-				"order_id"=>htmlentities(get_lang('Order')),
-				"objective_id"=>htmlentities(get_lang('ObjectiveID')),
-				"score_raw"=>htmlentities(get_lang('ObjectiveRawScore')),
-				"score_max"=>htmlentities(get_lang('ObjectiveMaxScore')),
-				"score_min"=>htmlentities(get_lang('ObjectiveMinScore')),
-				"status"=>htmlentities(get_lang('ObjectiveStatus')));
+				"order_id"=>api_htmlentities(get_lang('Order'), ENT_QUOTES, $charset),
+				"objective_id"=>api_htmlentities(get_lang('ObjectiveID'), ENT_QUOTES, $charset),
+				"score_raw"=>api_htmlentities(get_lang('ObjectiveRawScore'), ENT_QUOTES, $charset),
+				"score_max"=>api_htmlentities(get_lang('ObjectiveMaxScore'), ENT_QUOTES, $charset),
+				"score_min"=>api_htmlentities(get_lang('ObjectiveMinScore'), ENT_QUOTES, $charset),
+				"status"=>api_htmlentities(get_lang('ObjectiveStatus'), ENT_QUOTES, $charset));
 			while ($row = Database::fetch_array($res)){
 				$list[] = array(
 					"order_id"=>($row['order_id']+1),
@@ -2650,13 +2663,14 @@ class learnpath {
      */
     function get_html_toc()
     {
+		$charset = api_get_setting('platform_charset');
+
 		if($this->debug>0){error_log('New LP - In learnpath::get_html_toc()',0);}
     	$list = $this->get_toc();
-        $mych = api_get_setting('platform_charset'); 
     	//echo $this->current;
     	//$parent = $this->items[$this->current]->get_parent();
     	//if(empty($parent)){$parent = $this->ordered_items[$this->items[$this->current]->get_previous_index()];}
-    	$html= '<div class="scorm_title"><div class="scorm_title_text">'.utf8_decode(html_entity_decode($this->get_name(), ENT_QUOTES, $this->encoding)).'</div></div>';
+    	$html = '<div class="scorm_title"><div class="scorm_title_text">'.api_convert_encoding($this->get_name(), $charset, $this->encoding).'</div></div>';
     	
     	// build, display
     	if(api_is_allowed_to_edit())
@@ -2664,20 +2678,19 @@ class learnpath {
     		$gradebook=Security::remove_XSS($_GET['gradebook']);
     		$html	.='<div class="actions_lp">';
     		//the icon it was removed in display (build)
-    		//$html 	.= "<a href='lp_controller.php?".api_get_cidreq()."&amp;action=build&amp;lp_id=".$this->lp_id."' target='_parent'>".Display::return_icon('learnpath_build.gif', get_lang('Build')).' '.mb_convert_encoding(get_lang('Build'),$this->encoding,$mych)."</a>";
-    		$html 	.= "<a href='lp_controller.php?".api_get_cidreq()."&amp;gradebook=$gradebook&amp;action=build&amp;lp_id=".$this->lp_id."' target='_parent'>".mb_convert_encoding(get_lang('Build'),$this->encoding,$mych)."</a>";
+    		//$html 	.= "<a href='lp_controller.php?".api_get_cidreq()."&amp;action=build&amp;lp_id=".$this->lp_id."' target='_parent'>".Display::return_icon('learnpath_build.gif', get_lang('Build')).' '.get_lang('Build')."</a>";
+    		$html 	.= "<a href='lp_controller.php?".api_get_cidreq()."&amp;gradebook=$gradebook&amp;action=build&amp;lp_id=".$this->lp_id."' target='_parent'>".get_lang('Build')."</a>";
     		//the icon it was removed in display (organize)
-    		//$html 	.= "<a href='lp_controller.php?".api_get_cidreq()."&amp;action=admin_view&amp;lp_id=".$this->lp_id."' target='_parent'>".Display::return_icon('learnpath_organize.gif', get_lang('BasicOverview')).' '.mb_convert_encoding(get_lang('BasicOverview'),$this->encoding,$mych)."</a>";
-    		$html 	.= "<a href='lp_controller.php?".api_get_cidreq()."&amp;action=admin_view&amp;lp_id=".$this->lp_id."' target='_parent'>".mb_convert_encoding(get_lang('BasicOverview'),$this->encoding,$mych)."</a>";
+    		//$html 	.= "<a href='lp_controller.php?".api_get_cidreq()."&amp;action=admin_view&amp;lp_id=".$this->lp_id."' target='_parent'>".Display::return_icon('learnpath_organize.gif', get_lang('BasicOverview')).' '.get_lang('BasicOverview')."</a>";
+    		$html 	.= "<a href='lp_controller.php?".api_get_cidreq()."&amp;action=admin_view&amp;lp_id=".$this->lp_id."' target='_parent'>".get_lang('BasicOverview')."</a>";
     		//the icon it was removed in display (display)
-    		//$html 	.= '<span>'.Display::return_icon('learnpath_view.gif', get_lang("Display")).' '.mb_convert_encoding(get_lang("Display"),$this->encoding,$mych).'</span>';
-    		$html 	.= '<span>'.mb_convert_encoding(get_lang("Display"),$this->encoding,$mych).'</span>';
+    		//$html 	.= '<span>'.Display::return_icon('learnpath_view.gif', get_lang("Display")).' '.get_lang("Display").'</span>';
+    		$html 	.= '<span>'.get_lang("Display").'</span>';
     		$html 	.= '</div>';
-			unset($mych);
     	}
-    	
+
     	$html.= '<div id="inner_lp_toc" class="inner_lp_toc">'."\n" ;
-    	//$html.= '<div class="scorm_title"><div class="scorm_title_text">'.mb_convert_encoding($this->get_name(),$this->encoding,$mych).'</div></div>';
+    	//$html.= '<div class="scorm_title"><div class="scorm_title_text">'.api_convert_encoding($this->get_name(), $charset, $this->encoding).'</div></div>';
     	
     
     	//		" onchange=\"javascript:document.getElementById('toc_$parent').focus();\">\n";
@@ -2743,7 +2756,7 @@ class learnpath {
     			$title = rl_get_resource_name(api_get_course_id(),$this->get_id(),$item['id']);    			
     		}
     		
-    		$title = utf8_decode(html_entity_decode($title,ENT_QUOTES,$this->encoding));	
+    		$title = api_html_entity_decode(api_convert_encoding($title, $charset, $this->encoding), ENT_QUOTES, $charset);
     	
     		if($item['type']!='dokeos_chapter' and $item['type']!='dir' AND $item['type']!='dokeos_module')
     		{
@@ -3007,11 +3020,18 @@ class learnpath {
 	    					if($this->debug>2){error_log('New LP - In learnpath::get_link() '.__LINE__.' - Found match for protocol in '.$lp_item_path,0);}
 	    					//distant url, return as is
 	    					$file = $lp_item_path;
+							// Enabled and modified by Ivan Tcholakov, 16-OCT-2008.
 	    					/*
 	    					if(stristr($file,'<servername>')!==false){
 	    						$file = str_replace('<servername>',$course_path.'/scorm/'.$lp_path.'/',$lp_item_path);
 	    					}
 	    					*/
+	    					if(stripos($file,'<servername>')!==false){
+	    						//$file = str_replace('<servername>',$course_path.'/scorm/'.$lp_path.'/',$lp_item_path);
+	    						$web_course_path = str_replace('https://', '', str_replace('http://', '', $course_path));
+	    						$file = str_replace('<servername>', $web_course_path.'/scorm/'.$lp_path, $lp_item_path);
+	    					}
+							//
 	    					$file .= $aicc_append;
 	    				}else{
 	    					if($this->debug>2){error_log('New LP - In learnpath::get_link() '.__LINE__.' - No starting protocol in '.$lp_item_path,0);}
@@ -3665,7 +3685,7 @@ class learnpath {
      * Sets the encoding
      * @param	string	New encoding
      */
-    function set_encoding($enc='ISO-8859-1'){
+    function set_encoding($enc='ISO-8859-15'){
 		if($this->debug>0){error_log('New LP - In learnpath::set_encoding()',0);}
     	$enc = strtoupper($enc);
 	 	$encodings = array('UTF-8','ISO-8859-1','ISO-8859-15','cp1251','cp1252','KOI8-R','BIG5','GB2312','Shift_JIS','EUC-JP','');
@@ -4386,7 +4406,7 @@ class learnpath {
 		while($row = Database::fetch_array($result))
 		{
 				
-			$row['title'] = mb_convert_encoding($row['title'], $mycharset,$this->encoding);
+			$row['title'] = api_convert_encoding($row['title'], $mycharset, $this->encoding);
 			
 			$arrLP[] = array(
 			'id' => $row['id'],
@@ -4448,7 +4468,7 @@ class learnpath {
 			
 			for($i = 0; $i < count($arrLP); $i++)
 			{
-				$title = utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding));
+				$title=$arrLP[$i]['title'];
 				
 				if($arrLP[$i]['description'] == '')
 					$arrLP[$i]['description'] = '&nbsp;';
@@ -4546,7 +4566,7 @@ class learnpath {
 							$return .= '</a>' . "\n";
 						}
 						
-						$return .= "\t\t\t" . '<a href="' .api_get_self(). '?cidReq=' . $_GET['cidReq'] . '&amp;action=delete_item&amp;id=' . $arrLP[$i]['id'] . '&amp;lp_id=' . $this->lp_id . '" onclick="return confirmation(\'' . utf8_decode(html_entity_decode(addslashes($title), ENT_QUOTES, $this->encoding)) . '\');">';
+						$return .= "\t\t\t" . '<a href="' .api_get_self(). '?cidReq=' . $_GET['cidReq'] . '&amp;action=delete_item&amp;id=' . $arrLP[$i]['id'] . '&amp;lp_id=' . $this->lp_id . '" onclick="return confirmation(\'' . addslashes($title). '\');">';
 						$return .= '<img style="margin:1px;" alt="" src="../img/delete.gif" title="' . get_lang('_delete_learnpath_module') . '" />';
 						$return .= '</a>' . "\n";
 						
@@ -4567,7 +4587,7 @@ class learnpath {
 		
 		if ($_GET['updateaudio'] == 'true')
 		{
-			$return .= '<div style="margin:40px 0; float:right;"><button class="save" type="submit" name="save_audio" id="save_audio">'.get_lang('Save audio and organization').'</button></div>';
+			$return .= '<div style="margin:40px 0; float:right;"><button class="save" type="submit" name="save_audio" id="save_audio">'.get_lang('Save audio and organization').'</button></div>';  // TODO: What kind of language variable is this?
 		}				
 				
 		
@@ -4605,6 +4625,8 @@ class learnpath {
 	 */
 	function build_tree()
 	{
+		global $charset;
+
 		$return = "<script type=\"text/javascript\">\n";		
 		$return .= "\tm = new dTree('m');\n\n";		
 		$return .= "\tm.config.folderLinks		= true;\n";
@@ -4617,7 +4639,7 @@ class learnpath {
 		$menu	= 0;
 		$parent	= '';
 		
-		$return .= "\tm.add(" . $menu . ", -1, '" . utf8_decode(html_entity_decode(addslashes($this->name), ENT_QUOTES, $this->encoding)) . "');\n";
+		$return .= "\tm.add(" . $menu . ", -1, '" . addslashes($this->name) . "');\n";
 		
 		$tbl_lp_item = Database::get_course_table('lp_item');
 		
@@ -4634,10 +4656,7 @@ class learnpath {
 		while($row = Database::fetch_array($result))
 		{
 			
-			if($this->encoding!=$mycharset)
-			{
-				$row['title'] = mb_convert_encoding($row['title'], $mycharset, $this->encoding);
-			}		
+			$row['title'] = api_convert_encoding($row['title'], $mycharset, $this->encoding);
 			
 			$arrLP[] = array(
 				'id' => $row['id'],
@@ -4662,7 +4681,7 @@ class learnpath {
 		$title='';
 		for($i = 0; $i < count($arrLP); $i++)
 		{
-			$title = utf8_decode(html_entity_decode(addslashes($arrLP[$i]['title']), ENT_QUOTES, $this->encoding));
+			$title = api_html_entity_decode(addslashes($arrLP[$i]['title']), ENT_QUOTES, $charset);
 			$menu_page = api_get_self() . '?cidReq=' . $_GET['cidReq'] . '&amp;action=view_item&amp;id=' . $arrLP[$i]['id'] . '&amp;lp_id=' . $_SESSION['oLP']->lp_id;
 			$icon_name = str_replace(' ', '', $arrLP[$i]['item_type']);
 			if (file_exists("../img/lp_" . $icon_name . ".png"))
@@ -4696,6 +4715,8 @@ class learnpath {
 	 */
 	function create_document($_course)
 	{
+		global $charset;
+
 		$dir = isset($_GET['dir']) ? $_GET['dir'] : $_POST['dir']; // please do not modify this dirname formatting
 		
 		if(strstr($dir, '..'))
@@ -4781,7 +4802,7 @@ class learnpath {
 							$ct .= ", comment='" . $new_comment . "'";
 						
 						if($new_title)
-							$ct .= ", title='" . Database::escape_string(htmlspecialchars($new_title,ENT_QUOTES)) . ".html	'";
+							$ct .= ", title='" . Database::escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset)) . ".html	'";
 						
 						$sql_update = "
 							UPDATE " . $tbl_doc . "
@@ -4895,12 +4916,9 @@ class learnpath {
 				if($msg != '')
 					$return .= $msg;
 				
-				if($this->encoding=='UTF-8')
-				{
-					$row['title'] = utf8_decode($row['title']);
-				}		
+				$row['title'] = stripslashes(api_to_system_encoding(api_html_entity_decode($row['title'], ENT_QUOTES, $this->encoding), $this->encoding));
 				
-				$return .= '<p class="lp_title">' . $title = utf8_decode(html_entity_decode(stripslashes($row['title']),ENT_QUOTES,$this->encoding)) . '</p>';
+				$return .= '<p class="lp_title">' . $row['title'] . '</p>';
 				//$return .= '<p class="lp_text">' . ((trim($row['description']) == '') ? 'no description' : stripslashes($row['description'])) . '</p>';
 				
 				//$return .= '<hr />';
@@ -5069,7 +5087,7 @@ class learnpath {
 		
 			$return .= '<div class="sectiontitle">'.get_lang('CreateNewStep').'</div>';
 		
-			$return .= '<div class="sectioncomment"><a href="' .api_get_self(). '?cidReq=' . $_GET['cidReq'] . '&amp;action=add_item&amp;type=' . TOOL_DOCUMENT . '&amp;lp_id=' . $_SESSION['oLP']->lp_id . '">'.'<img title="Nuevo documento" src="../img/new_doc.gif" alt="Nuevo documento"/> '.get_lang("NewDocument").'</a></div>';
+			$return .= '<div class="sectioncomment"><a href="' .api_get_self(). '?cidReq=' . $_GET['cidReq'] . '&amp;action=add_item&amp;type=' . TOOL_DOCUMENT . '&amp;lp_id=' . $_SESSION['oLP']->lp_id . '">'.'<img title="Nuevo documento" src="../img/new_doc.gif" alt="Nuevo documento"/> '.get_lang("NewDocument").'</a></div>'; //TODO: A hardcoded Spanish text is here.
 		
 			$return .= '<div class="sectiontitle">'.get_lang('UseAnExistingResource').'</div>';
 			
@@ -5177,8 +5195,6 @@ class learnpath {
 			$item_title			= '';
 			$item_description	= '';
 		}
-		
-		//$item_title = mb_convert_encoding($item_title,$charset,$this->encoding);
 				
 		$return = '<div class="sectiontitle">';			
 			if($id != 0 && is_array($extra_info))
@@ -5249,20 +5265,20 @@ class learnpath {
 						
 							$return .= "\t\t\t\t" . '<select id="idParent" style="width:100%;" name="parent" onchange="load_cbo(this.value);" class="learnpath_item_form" size="1">';
 							
-								$return .= "\t\t\t\t\t" . '<option class="top" value="0">' . utf8_decode(html_entity_decode($this->name, ENT_QUOTES, $this->encoding)) . '</option>';
+								$return .= "\t\t\t\t\t" . '<option class="top" value="0">' . $this->name . '</option>';
 								
 								$arrHide = array($id);
 								$parent_item_id = $_SESSION['parent_item_id'];
 								for($i = 0; $i < count($arrLP); $i++) {
 									if($action != 'add') {
 										if(($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
-											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '</option>';
+											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . api_convert_encoding($arrLP[$i]['title'], $charset, $this->encoding) . '</option>';
 										} else {
 											$arrHide[] = $arrLP[$i]['id'];
 										}
 									} else {
 										if($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir')
-											$return .= "\t\t\t\t\t" . '<option ' . (($parent_item_id == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '</option>';
+											$return .= "\t\t\t\t\t" . '<option ' . (($parent_item_id == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . api_convert_encoding($arrLP[$i]['title'], $charset, $this->encoding) . '</option>';
 									}
 								}
 								if (is_array($arrLP)) {
@@ -5291,7 +5307,7 @@ class learnpath {
 										else
 											$selected = '';
 										
-										$return .= "\t\t\t\t\t" . '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">'.get_lang("After").' "' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '"</option>';
+										$return .= "\t\t\t\t\t" . '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">'.get_lang("After").' "' . api_convert_encoding($arrLP[$i]['title'], $charset, $this->encoding) . '"</option>';
 									}
 								}
 								
@@ -5416,8 +5432,8 @@ class learnpath {
 			$item_description	= '';
 		}
 				
-		$item_title=mb_convert_encoding($item_title,$charset,$this->encoding);
-		$item_description=mb_convert_encoding($item_description,$charset,$this->encoding);
+		$item_title = api_convert_encoding($item_title,$charset,$this->encoding);
+		$item_description = api_convert_encoding($item_description,$charset,$this->encoding);
 		
 		$return = '<div style="margin:3px 12px;">';
 
@@ -5741,7 +5757,7 @@ class learnpath {
 						$return .= "\t\t" . '<tr>' . "\n";
 							
 							$return .= "\t\t\t" . '<td class="label"><label for="idTitle">'.get_lang('Title').'</label></td>' . "\n";
-							$return .= "\t\t\t" . '<td class="input"><input id="idTitle" size="44" name="title" type="text" value="' . utf8_decode(html_entity_decode($item_title, ENT_QUOTES, $this->encoding)) . '" class="learnpath_item_form" /></td>' . "\n";
+							$return .= "\t\t\t" . '<td class="input"><input id="idTitle" size="44" name="title" type="text" value="' . $item_title . '" class="learnpath_item_form" /></td>' . "\n";
 						
 						$return .= "\t\t" . '</tr>' . "\n";
 					}				
@@ -5753,7 +5769,7 @@ class learnpath {
 						
 							$return .= "\t\t\t\t" . '<select id="idParent" style="width:100%;" name="parent" onchange="load_cbo(this.value);" class="learnpath_item_form" size="1">';
 							
-								$return .= "\t\t\t\t\t" . '<option class="top" value="0">' . utf8_decode(html_entity_decode($this->name, ENT_QUOTES, $this->encoding)) . '</option>';
+								$return .= "\t\t\t\t\t" . '<option class="top" value="0">' . $this->name . '</option>';
 								
 								$arrHide = array($id);
 								
@@ -5765,7 +5781,7 @@ class learnpath {
 									{
 										if(($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide))
 										{
-											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '</option>';
+											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . api_convert_encoding($arrLP[$i]['title'], $charset, $this->encoding) . '</option>';
 										}
 										else
 										{
@@ -5775,7 +5791,7 @@ class learnpath {
 									else
 									{
 										if($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir')
-											$return .= "\t\t\t\t\t" . '<option ' . (($parent_item_id == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '</option>';
+											$return .= "\t\t\t\t\t" . '<option ' . (($parent_item_id == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . api_convert_encoding($arrLP[$i]['title'], $charset, $this->encoding) . '</option>';
 									}
 								}
 								if (is_array($arrLP)) {								
@@ -5806,7 +5822,7 @@ class learnpath {
 										else
 											$selected = '';
 										
-										$return .= "\t\t\t\t\t" . '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">'.get_lang("After").' "' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '"</option>';
+										$return .= "\t\t\t\t\t" . '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">'.get_lang("After").' "' . api_convert_encoding($arrLP[$i]['title'], $charset, $this->encoding) . '"</option>';
 									}
 								}
 								
@@ -5843,7 +5859,7 @@ class learnpath {
 									$s_selected_position=$arrLP[$i]['id'];
 								elseif($action == 'add')
 									$s_selected_position=0;
-								$arrHide[$arrLP[$i]['id']]['value']=mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);								
+								$arrHide[$arrLP[$i]['id']]['value']=api_convert_encoding($arrLP[$i]['title'], $charset, $this->encoding);
 							}
 						}
 
@@ -5941,8 +5957,8 @@ class learnpath {
 			$item_title			= '';
 			$item_description	= '';
 		}
-		$item_title=mb_convert_encoding($item_title,$charset,$this->encoding);
-		$item_description=mb_convert_encoding($item_description,$charset,$this->encoding);
+		$item_title=api_convert_encoding($item_title,$charset,$this->encoding);
+		$item_description=api_convert_encoding($item_description,$charset,$this->encoding);
 		
 		$return = '<div style="margin:3px 12px;">';
 			
@@ -6013,7 +6029,7 @@ class learnpath {
 									{
 										if(($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide))
 										{
-											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding) . '</option>';
+											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding) . '</option>';
 										}
 										else
 										{
@@ -6023,7 +6039,7 @@ class learnpath {
 									else
 									{
 										if($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir')
-											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding) . '</option>';
+											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding) . '</option>';
 									}
 								}
 								if ($arrLP!=null) {
@@ -6103,7 +6119,7 @@ class learnpath {
 									$s_selected_position=$arrLP[$i]['id'];
 								elseif($action == 'add')
 									$s_selected_position=0;
-								$arrHide[$arrLP[$i]['id']]['value']=mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
+								$arrHide[$arrLP[$i]['id']]['value']=api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
 								
 							}
 						}
@@ -6182,7 +6198,7 @@ class learnpath {
 	
 		if($id != 0 && is_array($extra_info))
 		{
-			$item_title			= html_entity_decode(utf8_decode(html_entity_decode($extra_info['title'], ENT_QUOTES, $this->encoding)));
+			$item_title			= $extra_info['title'];
 			$item_description	= $extra_info['description'];
 			$item_path = api_get_path(WEB_COURSE_PATH) . $_course['path'].'/scorm/'.$this->path.'/'.stripslashes($extra_info['path']);
 		}
@@ -6238,8 +6254,8 @@ class learnpath {
 		
 		require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');		
 		$form = new FormValidator('form','POST',api_get_self()."?".$_SERVER["QUERY_STRING"]);
-		$defaults["title"] = $item_title;
-		$defaults["description"] = mb_convert_encoding($item_description,$charset,$this->encoding); 
+		$defaults["title"] = api_convert_encoding($item_title, $charset, $this->encoding);
+		$defaults["description"] = api_convert_encoding($item_description, $charset, $this->encoding);
 
 		$form->addElement('html',$return);
 					
@@ -6256,7 +6272,7 @@ class learnpath {
 				{
 					if(($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide))
 					{
-						$arrHide[$arrLP[$i]['id']]['value']=mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
+						$arrHide[$arrLP[$i]['id']]['value'] = api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
 						$arrHide[$arrLP[$i]['id']]['padding']=3+ $arrLP[$i]['depth'] * 10;
 						if($parent == $arrLP[$i]['id'])
 						{
@@ -6268,7 +6284,7 @@ class learnpath {
 				{
 					if($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir')
 					{
-						$arrHide[$arrLP[$i]['id']]['value']=mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
+						$arrHide[$arrLP[$i]['id']]['value']=api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
 						$arrHide[$arrLP[$i]['id']]['padding']=3+ $arrLP[$i]['depth'] * 10;
 						if($parent == $arrLP[$i]['id'])
 						{
@@ -6293,7 +6309,7 @@ class learnpath {
 
 			foreach($arrHide as $key => $value)
 			{
-				$parent_select->addOption(utf8_decode(html_entity_decode($value['value'], ENT_QUOTES, $this->encoding)),$key,'style="padding-left:'.$value['padding'].'px;"');
+				$parent_select->addOption($value['value'],$key,'style="padding-left:'.$value['padding'].'px;"');
 			}
 			$parent_select -> setSelected($s_selected_parent);			
 		}
@@ -6311,8 +6327,7 @@ class learnpath {
 				elseif($action == 'add')
 					$s_selected_position=$arrLP[$i]['id'];				
 
-				$arrHide[$arrLP[$i]['id']]['value']=get_lang("After").' "' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding));
-				
+				$arrHide[$arrLP[$i]['id']]['value']=get_lang("After").' "' . api_convert_encoding($arrLP[$i]['title'], $charset, $this->encoding);
 			}
 		}
 		
@@ -6523,12 +6538,12 @@ class learnpath {
 			require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
 			
 			$form = new FormValidator('form','POST',api_get_self()."?".$_SERVER["QUERY_STRING"],'','enctype="multipart/form-data"');
-            $defaults["title"] = html_entity_decode(utf8_decode(html_entity_decode($defaults["title"], ENT_QUOTES, $this->encoding)));
+            $defaults["title"]= api_convert_encoding($defaults["title"], $charset, $this->encoding);
             if(empty($defaults["title"]))
             {
-                    $defaults["title"] = html_entity_decode(utf8_decode(html_entity_decode($item_title, ENT_QUOTES, $this->encoding)));
+            	$defaults["title"] = api_html_entity_decode(api_convert_encoding($item_title, $charset, $this->encoding), ENT_QUOTES, $charset);
             }
-			$defaults["description"] = mb_convert_encoding($item_description,$charset,$this->encoding);
+			$defaults["description"] = api_convert_encoding($item_description, $charset, $this->encoding);
 		
 			$form->addElement('html',$return);
 						
@@ -6547,7 +6562,7 @@ class learnpath {
 			{
 				if($action != 'add'){
 					if(($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)){
-						$arrHide[$arrLP[$i]['id']]['value']=mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
+						$arrHide[$arrLP[$i]['id']]['value']=api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
 						$arrHide[$arrLP[$i]['id']]['padding']=3+ $arrLP[$i]['depth'] * 10;
 						if($parent == $arrLP[$i]['id']){
 							$s_selected_parent=$arrHide[$arrLP[$i]['id']];
@@ -6556,7 +6571,7 @@ class learnpath {
 				}
 				else{
 					if($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir'){
-						$arrHide[$arrLP[$i]['id']]['value']=mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
+						$arrHide[$arrLP[$i]['id']]['value']=api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
 						$arrHide[$arrLP[$i]['id']]['padding']=3+ $arrLP[$i]['depth'] * 10;
 						if($parent == $arrLP[$i]['id']){
 							$s_selected_parent=$arrHide[$arrLP[$i]['id']];
@@ -6567,7 +6582,7 @@ class learnpath {
 			$parent_select = &$form->addElement('select', 'parent', get_lang('Parent'), '', 'class="learnpath_item_form" style="width:40%;" onchange="load_cbo(this.value);"');
 						
 			foreach($arrHide as $key => $value) {		
-					$parent_select->addOption(utf8_decode(html_entity_decode($value['value'], ENT_QUOTES, $this->encoding)),$key,'style="padding-left:'.$value['padding'].'px;"');
+				$parent_select->addOption($value['value'],$key,'style="padding-left:'.$value['padding'].'px;"');
 			}
 					
 			if (!empty($id)) {
@@ -6591,7 +6606,7 @@ class learnpath {
 					elseif($action == 'add')
 						$s_selected_position=$arrLP[$i]['id'];
 					
-					$arrHide[$arrLP[$i]['id']]['value']=get_lang("After").' "' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) .'"';
+					$arrHide[$arrLP[$i]['id']]['value']=get_lang("After").' "' . api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding).'"';
 					
 				}
 			}
@@ -6645,7 +6660,7 @@ class learnpath {
 						elseif($action == 'add')
 							$s_selected_position=$arrLP[$i]['id'];
 						
-						$arrHide[$arrLP[$i]['id']]['value']=mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
+						$arrHide[$arrLP[$i]['id']]['value']=api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
 						
 					}
 				}
@@ -6812,8 +6827,8 @@ class learnpath {
 			$item_description	= '';
 			$item_url			= '';
 		}
-		$item_title=mb_convert_encoding($item_title,$charset,$this->encoding);
-		$item_description=mb_convert_encoding($item_description,$charset,$this->encoding);				
+		$item_title=api_convert_encoding($item_title,$charset,$this->encoding);
+		$item_description=api_convert_encoding($item_description,$charset,$this->encoding);
 		$return = '<div class="sectiontitle">';
 			
 			if($id != 0 && is_array($extra_info))
@@ -6868,7 +6883,7 @@ class learnpath {
 						$return .= "\t\t" . '<tr>' . "\n";
 							
 							$return .= "\t\t\t" . '<td class="label"><label for="idTitle">'.get_lang('Title').'</label></td>' . "\n";
-							$return .= "\t\t\t" . '<td class="input"><input id="idTitle" name="title" size="44" type="text" value="' . utf8_decode(html_entity_decode($item_title, ENT_QUOTES, $this->encoding)) . '" class="learnpath_item_form"/></td>' . "\n";
+							$return .= "\t\t\t" . '<td class="input"><input id="idTitle" name="title" size="44" type="text" value="' . $item_title . '" class="learnpath_item_form"/></td>' . "\n";
 						
 						$return .= "\t\t" . '</tr>' . "\n";
 					}				
@@ -6880,7 +6895,7 @@ class learnpath {
 						
 							$return .= "\t\t\t\t" . '<select id="idParent" style="width:100%;" name="parent" onchange="load_cbo(this.value);" class="learnpath_item_form" size="1">';
 							
-								$return .= "\t\t\t\t\t" . '<option class="top" value="0">' . utf8_decode(html_entity_decode($this->name, ENT_QUOTES, $this->encoding)) . '</option>';
+								$return .= "\t\t\t\t\t" . '<option class="top" value="0">' . $this->name . '</option>';
 								
 								$arrHide = array($id);
 								
@@ -6890,13 +6905,13 @@ class learnpath {
 									if($action != 'add') {
 										if(($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide))
 										{
-											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '</option>';
+											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding) . '</option>';
 										} else {
 											$arrHide[] = $arrLP[$i]['id'];
 										}
 									} else {
 										if($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir')
-											$return .= "\t\t\t\t\t" . '<option ' . (($parent_item_id == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '</option>';
+											$return .= "\t\t\t\t\t" . '<option ' . (($parent_item_id == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding) . '</option>';
 									}
 								}
 								
@@ -6930,7 +6945,7 @@ class learnpath {
 										else
 											$selected = '';
 										
-										$return .= "\t\t\t\t\t" . '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">'.get_lang("After").' "' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '"</option>';
+										$return .= "\t\t\t\t\t" . '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">'.get_lang("After").' "' . api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding) . '"</option>';
 									}
 								}
 								
@@ -6974,7 +6989,7 @@ class learnpath {
 									$s_selected_position=$arrLP[$i]['id'];
 								elseif($action == 'add')
 									$s_selected_position=0;
-								$arrHide[$arrLP[$i]['id']]['value']=mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
+								$arrHide[$arrLP[$i]['id']]['value']=api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
 								
 							}
 						}
@@ -7071,7 +7086,7 @@ class learnpath {
 			$item_title			= '';
 		}
 		
-		$item_title=mb_convert_encoding($item_title,$charset,$this->encoding);			
+		$item_title=api_convert_encoding($item_title,$charset,$this->encoding);
 		$return = '<div class="sectiontitle">';
 			
 			if($id != 0 && is_array($extra_info))
@@ -7154,7 +7169,7 @@ class learnpath {
 									{
 										if(($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide))
 										{
-											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '</option>';
+											$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding) . '</option>';
 										}
 										else
 										{
@@ -7164,7 +7179,7 @@ class learnpath {
 									else
 									{
 										if($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir')
-											$return .= "\t\t\t\t\t" . '<option ' . (($parent_item_id == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '</option>';
+											$return .= "\t\t\t\t\t" . '<option ' . (($parent_item_id == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding). '</option>';
 									}
 								}
 								
@@ -7199,7 +7214,7 @@ class learnpath {
 										else
 											$selected = '';
 										
-										$return .= "\t\t\t\t\t" . '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">'.get_lang("After").' "' . utf8_decode(html_entity_decode($arrLP[$i]['title'], ENT_QUOTES, $this->encoding)) . '"</option>';
+										$return .= "\t\t\t\t\t" . '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">'.get_lang("After").' "' . api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding) . '"</option>';
 									}
 								}
 								
@@ -7231,7 +7246,7 @@ class learnpath {
 									$s_selected_position=$arrLP[$i]['id'];
 								elseif($action == 'add')
 									$s_selected_position=0;
-								$arrHide[$arrLP[$i]['id']]['value']=mb_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
+								$arrHide[$arrLP[$i]['id']]['value']=api_convert_encoding($arrLP[$i]['title'],$charset,$this->encoding);
 								
 							}
 						}
@@ -7354,7 +7369,7 @@ class learnpath {
 		
 		$row= mysql_fetch_assoc($result);
 		$s_title = $row['title'];
-		$s_title=mb_convert_encoding($s_title,$charset,$this->encoding);
+		$s_title=api_convert_encoding($s_title,$charset,$this->encoding);
 		
 		
 				// we display an audio player if needed
@@ -7379,7 +7394,7 @@ class learnpath {
 		{
 			$return .= '<a href="' .api_get_self(). '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;action=edit_item_prereq&amp;view=build&amp;id=' . $item_id . '&amp;lp_id=' . $this->lp_id . '" title="'.get_lang('Prerequisites').'"><img align="absbottom" alt="'.get_lang('Prerequisites').'" src="../img/right.gif" title="'.get_lang('Prerequisites').'" /> '.get_lang('Prerequisites').'</a>';
 		}
-		$return .= '<a href="' .api_get_self(). '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;action=delete_item&amp;view=build&amp;id=' . $item_id . '&amp;lp_id=' . $this->lp_id . '" onclick="return confirmation(\'' .utf8_decode(html_entity_decode(addslashes($s_title), ENT_QUOTES, $this->encoding)). '\');" title="Delete the current item"><img alt="Delete the current item" align="absbottom" src="../img/delete.gif" title="'.get_lang("Delete").'" /> '.get_lang("Delete").'</a>';
+		$return .= '<a href="' .api_get_self(). '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;action=delete_item&amp;view=build&amp;id=' . $item_id . '&amp;lp_id=' . $this->lp_id . '" onclick="return confirmation(\'' .addslashes($s_title). '\');" title="Delete the current item"><img alt="Delete the current item" align="absbottom" src="../img/delete.gif" title="'.get_lang("Delete").'" /> '.get_lang("Delete").'</a>';
 		
 		//$return .= '<br><br><p class="lp_text">' . ((trim($s_description) == '') ? ''.get_lang("NoDescription").'' : stripslashes(nl2br($s_description))) . '</p>';
 		
@@ -7448,7 +7463,7 @@ class learnpath {
 
 		while($row_zero = Database::fetch_array($res_zero))
 		{
-			$return .= 'child_name[0][' . $i . '] = "'.get_lang("After").' \"' . mb_convert_encoding($row_zero['title'],$charset,$this->encoding) . '\"";' . "\n";
+			$return .= 'child_name[0][' . $i . '] = "'.get_lang("After").' \"' . api_convert_encoding($row_zero['title'],$charset,$this->encoding) . '\"";' . "\n";
 			$return .= 'child_value[0][' . $i++ . '] = "' . $row_zero['id'] . '";' . "\n";
 		}
 		
@@ -7477,7 +7492,7 @@ class learnpath {
 			
 			while($row_parent = Database::fetch_array($res_parent))
 			{
-				$return .= 'child_name[' . $row['id'] . '][' . $i . '] = "'.get_lang("After").' \"' . mb_convert_encoding($row_parent['title'],$charset,$this->encoding) . '\"";' . "\n";
+				$return .= 'child_name[' . $row['id'] . '][' . $i . '] = "'.get_lang("After").' \"' . api_convert_encoding($row_parent['title'],$charset,$this->encoding) . '\"";' . "\n";
 				$return .= 'child_value[' . $row['id'] . '][' . $i++ . '] = "' . $row_parent['id'] . '";' . "\n";
 			}
 			
@@ -7679,7 +7694,7 @@ class learnpath {
 			$arrLP[] = array(
 				'id' => $row['id'],
 				'item_type' => $row['item_type'],
-				'title' => utf8_decode(html_entity_decode($row['title'], ENT_QUOTES, $this->encoding)),
+				'title' => api_convert_encoding($row['title'],$charset,$this->encoding),
 				'ref'   => $row['ref'],
 				'description' => $row['description'],
 				'parent_item_id' => $row['parent_item_id'],
@@ -8063,6 +8078,8 @@ class learnpath {
 	 function scorm_export()
 	 {
 	 	global $_course;
+		global $charset;
+
 	 	if (!class_exists('DomDocument'))
 	 	{
 	 		error_log('DOM functions not supported for PHP version below 5.0',0);
@@ -8166,8 +8183,7 @@ class learnpath {
 	 	//in the database. Then we convert it to HTML entities again as the "&" character
 	 	//alone is not authorized in XML (must be &amp;)
 	 	//The title is then decoded twice when extracting (see scorm::parse_manifest)
-	 	global $charset;
-	 	$org_title = $xmldoc->createElement('title',htmlentities(htmlentities($this->get_name(),ENT_QUOTES,$charset)));
+	 	$org_title = $xmldoc->createElement('title',htmlentities(api_htmlentities($this->get_name(),ENT_QUOTES,$charset)));
 	 	$organization->appendChild($org_title);
 	 	
 	 	//For each element, add it to the imsmanifest structure, then add it to the zip.
@@ -8189,7 +8205,7 @@ class learnpath {
 		 		$my_item->setAttribute('identifierref','RESOURCE_'.$my_item_id); 
 		 		$my_item->setAttribute('isvisible','true');
 		 		//give a child element <title> to the <item> element
-		 		$my_title = $xmldoc->createElement('title',htmlspecialchars($item->get_title(),ENT_QUOTES));
+		 		$my_title = $xmldoc->createElement('title',htmlspecialchars($item->get_title(), ENT_QUOTES, $this->encoding));
 		 		$my_item->appendChild($my_title);
 		 		//give a child element <adlcp:prerequisites> to the <item> element
 		 		$my_prereqs = $xmldoc->createElement('adlcp:prerequisites',$this->get_scorm_prereq_string($my_item_id));
@@ -8230,9 +8246,9 @@ class learnpath {
 		 		//get the path of the file(s) from the course directory root
 				$my_file_path = $item->get_file_path('scorm/'.$this->path.'/');
 				
-				$my_xml_file_path = htmlentities($my_file_path); 
+				$my_xml_file_path = api_htmlentities($my_file_path, ENT_QUOTES, $this->encoding);
 				$my_sub_dir = dirname($my_file_path); 
-				$my_xml_sub_dir = htmlentities($my_sub_dir);
+				$my_xml_sub_dir = api_htmlentities($my_sub_dir, ENT_QUOTES, $this->encoding);
 		 		//give a <resource> child to the <resources> element
 		 		$my_resource = $xmldoc->createElement('resource');
 		 		$my_resource->setAttribute('identifier','RESOURCE_'.$item->get_id());
@@ -8501,9 +8517,9 @@ class learnpath {
 	 					$url = $link['url'];
 	 					$title = stripslashes($link['title']);
 	 					$links_to_create[$my_file_path] = array('title'=>$title,'url'=>$url);
-						$my_xml_file_path = htmlentities($my_file_path); 
+						$my_xml_file_path = api_htmlentities($my_file_path, ENT_QUOTES, $this->encoding);
 						$my_sub_dir = dirname($my_file_path); 
-						$my_xml_sub_dir = htmlentities($my_sub_dir);
+						$my_xml_sub_dir = api_htmlentities($my_sub_dir, ENT_QUOTES, $this->encoding);
 				 		//give a <resource> child to the <resources> element
 				 		$my_resource = $xmldoc->createElement('resource');
 				 		$my_resource->setAttribute('identifier','RESOURCE_'.$item->get_id());
@@ -8531,7 +8547,7 @@ class learnpath {
 			 		$my_item->setAttribute('identifierref','RESOURCE_'.$item->get_id()); 
 			 		$my_item->setAttribute('isvisible','true');
 			 		//give a child element <title> to the <item> element
-			 		$my_title = $xmldoc->createElement('title',htmlspecialchars($item->get_title(),ENT_QUOTES));
+			 		$my_title = $xmldoc->createElement('title',htmlspecialchars($item->get_title(), ENT_QUOTES, $this->encoding));
 			 		$my_item->appendChild($my_title);
 			 		//give a child element <adlcp:prerequisites> to the <item> element
 			 		$my_prereqs = $xmldoc->createElement('adlcp:prerequisites',$item->get_prereq_string());
@@ -8576,9 +8592,9 @@ class learnpath {
 			 		if($res === false){error_log('Could not write into file '.$tmp_file_path.' '.__FILE__.' '.__LINE__,0);}
 			 		$files_cleanup[] = $tmp_file_path;
 			 		//error_log($tmp_path);die();
-					$my_xml_file_path = htmlentities($my_file_path); 
+					$my_xml_file_path = api_htmlentities($my_file_path, ENT_QUOTES, $this->encoding);
 					$my_sub_dir = dirname($my_file_path); 
-					$my_xml_sub_dir = htmlentities($my_sub_dir);
+					$my_xml_sub_dir = api_htmlentities($my_sub_dir, ENT_QUOTES, $this->encoding);
 			 		//give a <resource> child to the <resources> element
 			 		$my_resource = $xmldoc->createElement('resource');
 			 		$my_resource->setAttribute('identifier','RESOURCE_'.$item->get_id());
@@ -8732,9 +8748,9 @@ class learnpath {
 		 		
 			 		//get the path of the file(s) from the course directory root
 					$my_file_path = 'non_exportable.html';
-					$my_xml_file_path = htmlentities($my_file_path); 
+					$my_xml_file_path = api_htmlentities($my_file_path, ENT_COMPAT, $this->encoding);
 					$my_sub_dir = dirname($my_file_path); 
-					$my_xml_sub_dir = htmlentities($my_sub_dir);
+					$my_xml_sub_dir = api_htmlentities($my_sub_dir, ENT_COMPAT, $this->encoding);
 			 		//give a <resource> child to the <resources> element
 			 		$my_resource = $xmldoc->createElement('resource');
 			 		$my_resource->setAttribute('identifier','RESOURCE_'.$item->get_id());
@@ -8995,7 +9011,7 @@ EOD;
 					// resize the image
 					include_once (api_get_path(LIBRARY_PATH).'image.lib.php');		
 					$temp = new image($image_array['tmp_name']);
-					$picture_infos=getimagesize($image_array['tmp_name']); // $picture_infos[0]-> width
+					$picture_infos=@getimagesize($image_array['tmp_name']); // $picture_infos[0]-> width
 					if ($picture_infos[0]>240)
 						$thumbwidth=240;
 					else

+ 3 - 2
main/newscorm/learnpathItem.class.php

@@ -1971,6 +1971,7 @@ function get_terms()
      * @return  boolean Always return true
      */
     function set_terms($terms) {
+		global $charset;
         $lp_item = Database::get_course_table(TABLE_LP_ITEM);
         require_once(api_get_path(LIBRARY_PATH).'search/DokeosIndexer.class.php');
         $a_terms = split(',',$terms);
@@ -1982,7 +1983,7 @@ function get_terms()
         $new_terms_string = implode(',',$new_terms);
         $terms_update_sql='';
         //TODO: validate csv string
-        $terms_update_sql = "UPDATE $lp_item SET terms = '". Database::escape_string(htmlentities($new_terms_string)) . "' WHERE id=".$this->get_id();
+        $terms_update_sql = "UPDATE $lp_item SET terms = '". Database::escape_string(api_htmlentities($new_terms_string, ENT_QUOTES, $charset)) . "' WHERE id=".$this->get_id();
         $res = api_sql_query($terms_update_sql,__FILE__,__LINE__);
         // save it to search engine
         if (api_get_setting('search_enabled') == 'true') {
@@ -2423,4 +2424,4 @@ function get_terms()
      	return true;
      }
 }
-?>
+?>

+ 4 - 4
main/newscorm/learnpath_functions.inc.php

@@ -1709,7 +1709,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 					//3.1.1 Update the check value for the month bar
 					$barreMois = date("m", strtotime($myrow["start_date"]));
 					//3.1.2	Display the month bar
-					$expcontent .= "<tr><td id=\"title\" colspan=\"2\" class=\"month\" valign=\"top\">".ucfirst(format_locale_date("%B %Y", strtotime($myrow["start_date"])))."</td></tr>";
+					$expcontent .= "<tr><td id=\"title\" colspan=\"2\" class=\"month\" valign=\"top\">".api_ucfirst(format_locale_date("%B %Y", strtotime($myrow["start_date"])))."</td></tr>";
 				}
 
 				//3.2 Display the agenda items (of this month): the date, hour and title
@@ -1725,8 +1725,8 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 				//3.2.2 Mark an anchor for this date
 				$expcontent .= "<a name=\"".(int) date(d, strtotime($myrow["start_date"]))."\"></a>"; // anchoring
 				//3.2.3 Write the date and time of this event to the export string
-				$expcontent .= ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;";
-				$expcontent .= ucfirst(strftime($timeNoSecFormat, strtotime($myrow["start_time"])))."";
+				$expcontent .= api_ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;";
+				$expcontent .= api_ucfirst(strftime($timeNoSecFormat, strtotime($myrow["start_time"])))."";
 				//3.2.4 If a duration is set, write it, otherwise ignore
 				if ($myrow["duration"] == "")
 				{
@@ -1802,7 +1802,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false
 				}
 
 				//3.5 Write this content to the export string (formatted HTML array)
-				$expcontent .= "<tr>\n"."<td class=\"cell_header\">\n"."<font ".$colorBecauseNew.">".$langPubl." : ".ucfirst(format_locale_date($dateFormatLong, strtotime($last_post_date)))."</font>\n"."</td>\n"."</tr>\n"."<tr>\n"."<td>\n".$content."</td>\n"."</tr>\n";
+				$expcontent .= "<tr>\n"."<td class=\"cell_header\">\n"."<font ".$colorBecauseNew.">".$langPubl." : ".api_ucfirst(format_locale_date($dateFormatLong, strtotime($last_post_date)))."</font>\n"."</td>\n"."</tr>\n"."<tr>\n"."<td>\n".$content."</td>\n"."</tr>\n";
 
 			} // while loop
 

+ 2 - 2
main/newscorm/lp_ajax_switch_item.php

@@ -225,10 +225,10 @@ function switch_item_details($lp_id,$user_id,$view_id,$current_item,$next_item)
     $mylp->prerequisites_match(); //check the prerequisites are all complete
     if($debug>1){error_log('Prereq_match() returned '.htmlentities($mylp->error),0);}
     //$objResponse->addScript("update_message_frame('".str_replace("'","\'",htmlentities($mylp->error))."');");
-    $return .= "update_message_frame('".str_replace("'","\'",htmlentities($mylp->error))."');";
+    $return .= "update_message_frame('".str_replace("'","\'",api_htmlentities($mylp->error, ENT_QUOTES, api_get_system_encoding()))."');";
     $_SESSION['scorm_item_id'] = $new_item_id;//Save the new item ID for the exercise tool to use
     $_SESSION['lpobject'] = serialize($mylp);
     return $return;
     //return $objResponse;
 }
-echo switch_item_details($_GET['lid'],$_GET['uid'],$_GET['vid'],$_GET['iid'],$_GET['next']);
+echo switch_item_details($_GET['lid'],$_GET['uid'],$_GET['vid'],$_GET['iid'],$_GET['next']);

+ 5 - 3
main/newscorm/lp_comm.server.php

@@ -248,6 +248,8 @@ function save_objectives($lp_id,$user_id,$view_id,$item_id,$objectives=array())
  */
 function switch_item_details($lp_id,$user_id,$view_id,$current_item,$next_item)
 {
+	global $charset;
+
 	$debug=0;
 	if($debug>0){error_log('In xajax_switch_item_details('.$lp_id.','.$user_id.','.$view_id.','.$current_item.','.$next_item.')',0);}
 	$objResponse = new xajaxResponse();
@@ -430,8 +432,8 @@ function switch_item_details($lp_id,$user_id,$view_id,$current_item,$next_item)
 
 	$mylp->set_error_msg('');
 	$mylp->prerequisites_match(); //check the prerequisites are all complete
-	if($debug>1){error_log('Prereq_match() returned '.htmlentities($mylp->error),0);}
-	$objResponse->addScript("update_message_frame('".str_replace("'","\'",htmlentities($mylp->error))."');");
+	if($debug>1){error_log('Prereq_match() returned '.api_htmlentities($mylp->error, ENT_QUOTES, $charset),0);}
+	$objResponse->addScript("update_message_frame('".str_replace("'","\'",api_htmlentities($mylp->error, ENT_QUOTES, $charset))."');");
 	$_SESSION['scorm_item_id'] = $new_item_id;//Save the new item ID for the exercise tool to use
 	$_SESSION['lpobject'] = serialize($mylp);
 	return $objResponse;
@@ -450,4 +452,4 @@ function start_timer()
 
 require('lp_comm.common.php');
 $xajax->processRequests();
-?>
+?>

+ 3 - 3
main/newscorm/lp_edit.php

@@ -39,13 +39,13 @@ $defaults=array();
 $form = new FormValidator('form1', 'post', 'lp_controller.php');
 
 //Title
-$form -> addElement('text', 'lp_name', ucfirst(get_lang('_title')),array('size'=>43));
+$form -> addElement('text', 'lp_name', api_ucfirst(get_lang('_title')),array('size'=>43));
 $form-> applyFilter('lp_name', 'html_filter');
 //Encoding
 $encoding_select = &$form->addElement('select', 'lp_encoding', get_lang('Charset'));
 $encodings = array('UTF-8','ISO-8859-1','ISO-8859-15','cp1251','cp1252','KOI8-R','BIG5','GB2312','Shift_JIS','EUC-JP');
 foreach($encodings as $encoding){
-	if($encoding == $_SESSION['oLP']->encoding){
+	if (api_equal_encodings($encoding, $_SESSION['oLP']->encoding)) {
   		$s_selected_encoding = $encoding;
   	}
   	$encoding_select->addOption($encoding,$encoding);
@@ -148,7 +148,7 @@ if (api_get_setting('search_enabled') === 'true')
 $content_proximity_select -> setSelected($s_selected_proximity);
 $origin_select -> setSelected($s_selected_origin);
 $encoding_select -> setSelected($s_selected_encoding);
-$defaults['lp_name'] = 	html_entity_decode(utf8_decode(html_entity_decode($_SESSION['oLP']->get_name(), ENT_QUOTES, 'UTF-8')));
+$defaults['lp_name']=$_SESSION['oLP']->get_name();
 $defaults['lp_author'] = $_SESSION['oLP']->get_author();
 
 //Submit button

+ 1 - 1
main/newscorm/lp_list.php

@@ -202,7 +202,7 @@ if (is_array($flat_list))
 	    if (($counter % 2)==0) { $oddclass="row_odd"; } else { $oddclass="row_even"; }
 
 		$url_start_lp = 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$id;
-		$name = utf8_decode(html_entity_decode($details['lp_name'], ENT_QUOTES, 'UTF-8'));
+		$name = $details['lp_name'];
 		$image='<img src="../img/kcmdf.gif" border="0" align="absmiddle" alt="' . $name . '">'."\n";
 	    $dsp_line =	'<tr align="center" class="'.$oddclass.'">'."\n" .
         	'<td align="left" valign="top">' .

+ 8 - 8
main/newscorm/lp_stats.php

@@ -113,9 +113,9 @@ if (!empty ($_GET['extend_all'])) {
 }
 
 if ($origin != 'tracking') {
-	$output .= "<tr><td><div class='title'>" . htmlentities(get_lang('ScormMystatus'), ENT_QUOTES, $dokeos_charset) . "</div></td></tr>";
+	$output .= "<tr><td><div class='title'>" . api_htmlentities(get_lang('ScormMystatus'), ENT_QUOTES, $dokeos_charset) . "</div></td></tr>";
 }
-$output .= "<tr><td>&nbsp;</td></tr>" . "<tr><td>" . "<table border='0' class='data_table'><tr>\n" . '<td width="16">' . $extend_all_link . '</td>' . '<td colspan="4" class="title"><div class="mystatusfirstrow">' . htmlentities(get_lang('ScormLessonTitle'), ENT_QUOTES, $dokeos_charset) . "</div></td>\n" . '<td colspan="2" class="title"><div class="mystatusfirstrow">' . htmlentities(get_lang('ScormStatus'), ENT_QUOTES, $dokeos_charset) . "</div></td>\n" . '<td colspan="2" class="title"><div class="mystatusfirstrow">' . htmlentities(get_lang('ScormScore'), ENT_QUOTES, $dokeos_charset) . "</div></td>\n" . '<td colspan="2" class="title"><div class="mystatusfirstrow">' . htmlentities(get_lang('ScormTime'), ENT_QUOTES, $dokeos_charset) . "</div></td><td class='title'><div class='mystatusfirstrow'>" . htmlentities(get_lang('Actions'), ENT_QUOTES, $dokeos_charset) . "</div></td></tr>\n";
+$output .= "<tr><td>&nbsp;</td></tr>" . "<tr><td>" . "<table border='0' class='data_table'><tr>\n" . '<td width="16">' . $extend_all_link . '</td>' . '<td colspan="4" class="title"><div class="mystatusfirstrow">' . api_htmlentities(get_lang('ScormLessonTitle'), ENT_QUOTES, $dokeos_charset) . "</div></td>\n" . '<td colspan="2" class="title"><div class="mystatusfirstrow">' . api_htmlentities(get_lang('ScormStatus'), ENT_QUOTES, $dokeos_charset) . "</div></td>\n" . '<td colspan="2" class="title"><div class="mystatusfirstrow">' . api_htmlentities(get_lang('ScormScore'), ENT_QUOTES, $dokeos_charset) . "</div></td>\n" . '<td colspan="2" class="title"><div class="mystatusfirstrow">' . api_htmlentities(get_lang('ScormTime'), ENT_QUOTES, $dokeos_charset) . "</div></td><td class='title'><div class='mystatusfirstrow'>" . api_htmlentities(get_lang('Actions'), ENT_QUOTES, $dokeos_charset) . "</div></td></tr>\n";
 //going through the items using the $items[] array instead of the database order ensures
 // we get them in the same order as in the imsmanifest file, which is rather random when using
 // the database table
@@ -340,7 +340,7 @@ foreach ($list as $my_item_id) {
 						$oddclass = "row_even";
 					}
 					$output .= "<tr class='$oddclass'>\n" . '<td></td>' . "\n" . '<td></td>' . "\n" . '<td>&nbsp;</td>' . "\n" . '<td>' . $interaction['order_id'] . '</td>' . "\n" . '<td>' . $interaction['id'] . '</td>' . "\n"
-					//."<td><font color='$color'><div class='mystatus'>".htmlentities($array_status[$lesson_status],ENT_QUOTES,$lp_charset)."</div></font></td>\n"
+					//."<td><font color='$color'><div class='mystatus'>".api_htmlentities($array_status[$lesson_status],ENT_QUOTES,$lp_charset)."</div></font></td>\n"
 					 . '<td colspan="2">' . $interaction['type'] . "</td>\n"
 					//.'<td>'.$interaction['correct_responses']."</td>\n"
 					 . '<td>' . urldecode($interaction['student_response']) . "</td>\n" . '<td>' . $interaction['result'] . "</td>\n" . '<td>' . $interaction['latency'] . "</td>\n" . '<td>' . $interaction['time'] . "</td>\n<td></td>\n</tr>\n";
@@ -426,7 +426,7 @@ foreach ($list as $my_item_id) {
 		//$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
 		$scoIdentifier = $row['myid'];
 		$title = $row['mytitle'];
-		$title = stripslashes(html_entity_decode($title, ENT_QUOTES, $dokeos_charset));
+		$title = stripslashes(api_html_entity_decode($title, ENT_QUOTES, $dokeos_charset));
 		
 		
 		// selecting the exe_id from stats attempts tables in order to look the max score value
@@ -520,7 +520,7 @@ foreach ($list as $my_item_id) {
 			'not attempted' => 'ScormNotAttempted',
 
 		);
-		$my_lesson_status = htmlentities(get_lang($mylanglist[$lesson_status]), ENT_QUOTES, $dokeos_charset);		
+		$my_lesson_status = api_htmlentities(get_lang($mylanglist[$lesson_status]), ENT_QUOTES, $dokeos_charset);
 		
 		if ($row['item_type'] != 'dokeos_chapter') {
 			if ($row['item_type'] == 'quiz') {
@@ -611,7 +611,7 @@ foreach ($list as $my_item_id) {
 					$oddclass = "row_even";
 				}
 				$output .= "<tr class='$oddclass'>\n" . '<td></td>' . "\n" . '<td></td>' . "\n" . '<td>&nbsp;</td>' . "\n" . '<td>' . $interaction['order_id'] . '</td>' . "\n" . '<td>' . $interaction['id'] . '</td>' . "\n"
-				//."<td><font color='$color'><div class='mystatus'>".htmlentities($array_status[$lesson_status],ENT_QUOTES,$lp_charset)."</div></font></td>\n"
+				//."<td><font color='$color'><div class='mystatus'>"api_htmlentities($array_status[$lesson_status],ENT_QUOTES,$lp_charset)."</div></font></td>\n"
 				 . '<td colspan="2">' . $interaction['type'] . "</td>\n"
 				//.'<td>'.$interaction['correct_responses']."</td>\n"
 				 . '<td>' . urldecode($interaction['student_response']) . "</td>\n" . '<td>' . $interaction['result'] . "</td>\n" . '<td>' . $interaction['latency'] . "</td>\n" . '<td>' . $interaction['time'] . "</td>\n<td></td>\n</tr>\n";
@@ -732,7 +732,7 @@ if (($counter % 2) == 0) {
 }
 
 if (empty($extend_all)) {
-	$output .= "<tr class='$oddclass'>\n" . "<td></td>\n" . '<td colspan="4"><div class="mystatus"><i>' . htmlentities(get_lang('AccomplishedStepsTotal'), ENT_QUOTES, $dokeos_charset) . "</i></div></td>\n"
+	$output .= "<tr class='$oddclass'>\n" . "<td></td>\n" . '<td colspan="4"><div class="mystatus"><i>' . api_htmlentities(get_lang('AccomplishedStepsTotal'), ENT_QUOTES, $dokeos_charset) . "</i></div></td>\n"
  			. '<td colspan="2"></td>' . "\n" . '<td colspan="2"><div class="mystatus" align="center">' . $final_score . "</div></td>\n" . '<td colspan="2"><div class="mystatus">' . $total_time . '</div></td><td></td>' . "\n" . "</tr>\n";		
 }
 
@@ -763,4 +763,4 @@ if ($origin != 'tracking') {
 
 if (empty($export_csv)) {
 	echo $output;
-}
+}

+ 2 - 1
main/newscorm/lp_view.php

@@ -48,7 +48,8 @@ if ($is_allowed_in_course == false) api_not_allowed();
 -----------------------------------------------------------
 */
 //$charset = 'UTF-8';
-$charset = 'ISO-8859-1';
+//$charset = 'ISO-8859-1';
+$charset = api_get_system_encoding();
 $oLearnpath = false;
 $course_code = api_get_course_id();
 $user_id = api_get_user_id();

+ 4 - 4
main/newscorm/openoffice_text.class.php

@@ -57,11 +57,11 @@ class OpenofficeText extends OpenofficeDocument {
 		// the file is utf8 encoded and it seems to make problems with special quotes. 
 		// then we htmlentities that, we replace these quotes and html_entity_decode that in good charset
 		$charset = api_get_setting('platform_charset');
-		$content = htmlentities($content,ENT_COMPAT,$this->original_charset); 
+		$content = api_htmlentities($content,ENT_COMPAT,$this->original_charset); 
 		$content = str_replace('&rsquo;','\'',$content);
-		$content = mb_convert_encoding($content, $charset, $this->original_charset);
+		$content = api_convert_encoding($content, $charset, $this->original_charset);
 		$content = str_replace($this->original_charset,$charset,$content);
-		$content = html_entity_decode($content);
+		$content = api_html_entity_decode($content, ENT_COMPAT, $charset);
 		
 		// set the path to pictures to absolute (so that it can be modified in fckeditor)
 		$content = preg_replace("|src=\"([^\"]*)|i", "src=\"".api_get_path(REL_COURSE_PATH).$_course['path'].'/document'.$this->created_dir."/\\1", $content);
@@ -349,4 +349,4 @@ class OpenofficeText extends OpenofficeDocument {
     	  	
     }
 }
-?>
+?>

+ 9 - 9
main/newscorm/openoffice_text_document.class.php

@@ -56,11 +56,11 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
 		// the file is utf8 encoded and it seems to make problems with special quotes. 
 		// then we htmlentities that, we replace these quotes and html_entity_decode that in good charset
 		$charset = api_get_setting('platform_charset');
-		$content = htmlentities($content,ENT_COMPAT,$this->original_charset); 
+		$content = api_htmlentities($content,ENT_COMPAT,$this->original_charset);
 		$content = str_replace('&rsquo;','\'',$content);
-		$content = mb_convert_encoding($content, $charset, $this->original_charset);
+		$content = api_convert_encoding($content, $charset, $this->original_charset);
 		$content = str_replace($this->original_charset,$charset,$content);
-		$content = html_entity_decode($content);
+		$content = api_html_entity_decode($content, ENT_COMPAT, $charset);
 		
 		// set the path to pictures to absolute (so that it can be modified in fckeditor)
 		$content = preg_replace("|src=\"([^\"]*)|i", "src=\"".api_get_path(REL_COURSE_PATH).$_course['path'].'/document'.$this->created_dir."/\\1", $content);
@@ -125,7 +125,7 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
 		}
 		
 		// add intro item
-		$intro_content = substr($content, 0, strpos($content, $matches[0][0]));
+		$intro_content = api_substr($content, 0, api_strpos($content, $matches[0][0]));
 		$items_to_create[get_lang('Introduction')] = $intro_content;
 
 		
@@ -134,10 +134,10 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
 			if(empty($matches[1][$i]))
 				continue;
 			
-			$content = strstr($content,$matches[0][$i]);
+			$content = api_strstr($content, $matches[0][$i]);
 			if($i+1!==count($matches[0]))
 			{
-				$chapter_content = substr($content, 0, strpos($content, $matches[0][$i+1]));
+				$chapter_content = api_substr($content, 0, api_strpos($content, $matches[0][$i+1]));
 			}
 			else
 			{
@@ -168,7 +168,7 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
 				$infos = pathinfo($this->filepath);
 				$slide_name = strip_tags(nl2br($item_title));
 				$slide_name = str_replace(array("\r\n", "\r", "\n"), "", $slide_name);
-				$slide_name = html_entity_decode($slide_name);
+				$slide_name = api_html_entity_decode($slide_name, ENT_COMPAT, api_get_system_encoding());
 				$previous = learnpath::add_item(0, $previous, 'document', $document_id, $slide_name, '');
 				if($this->first_item == 0){
 					$this->first_item = $previous;
@@ -319,7 +319,7 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
 			if(!$defined_width)
 			{
 			
-				list($img_width, $img_height, $type) = getimagesize($this->base_work_dir.$this->created_dir.'/'.$image);
+				list($img_width, $img_height, $type) = @getimagesize($this->base_work_dir.$this->created_dir.'/'.$image);
 				
 				$new_width = $max_width-10;
 				if($img_width > $new_width)
@@ -347,4 +347,4 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
     	  	
     }
 }
-?>
+?>

+ 3 - 3
main/newscorm/resourcelinker.php

@@ -754,8 +754,8 @@ if ($content == "Agenda")
 	{
 		echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\">";
 		echo "<img src='../img/agenda.gif' alt='agenda'>";
-		echo ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["start_date"])))."&nbsp;";
-		echo ucfirst(strftime($timeNoSecFormat, strtotime($myrow["start_date"])))."<br>";
+		echo api_ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["start_date"])))."&nbsp;";
+		echo api_ucfirst(strftime($timeNoSecFormat, strtotime($myrow["start_date"])))."<br />";
 		echo "<b>".$myrow["title"]."</b></td></tr><tr><td>";
 		echo $myrow["content"]."<br />";
 		showorhide_addresourcelink($content, $myrow["id"]);
@@ -825,7 +825,7 @@ if ($content == "Ad_Valvas")
 	{
 		echo "<table width=\"100%\"><tr><td>";
 		echo "<img src='../img/valves.gif' alt='advalvas'>";
-		echo ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["end_date"])));
+		echo api_ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["end_date"])));
 		echo "</td></tr><tr><td>";
 		echo $myrow["title"]."<br />";
 		showorhide_addresourcelink($content, $myrow["id"]);