From 8f036917b351c9a9a0f6c57cc94fe2b7ec548b2b Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Thu, 30 Sep 2010 05:18:28 +0300 Subject: [PATCH] Task #1765 - Removing/changing obsolete code for encoding management (2). --- main/newscorm/learnpath.class.php | 32 ++++++++++++++++++++++++------- main/newscorm/lp_controller.php | 6 +++--- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 8966fea83f..81b50c774a 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -3683,11 +3683,14 @@ class learnpath { /** * Sets the encoding * @param string New encoding + * TODO (as of Chamilo 1.8.8): Check in the future whether this method is needed. */ - public function set_encoding($enc = 'ISO-8859-15') { + public function set_encoding($enc = 'UTF-8') { if ($this->debug > 0) { error_log('New LP - In learnpath::set_encoding()', 0); } + + /* // Deprecated code (Chamilo 1.8.8). $enc = strtoupper($enc); $encodings = array ( 'UTF-8', @@ -3712,6 +3715,22 @@ class learnpath { } } return false; + */ + + $enc = api_refine_encoding_id($enc); + if (empty($enc)) { + $enc = api_get_system_encoding(); + } + if (api_is_encoding_supported($enc)) { + $lp = $this->get_id(); + if ($lp != 0) { + $tbl_lp = Database :: get_course_table(TABLE_LP_MAIN); + $sql = "UPDATE $tbl_lp SET default_encoding = '$enc' WHERE id = " . $lp; + $res = Database::query($sql); + return $res; + } + } + return false; } /** @@ -4327,7 +4346,6 @@ class learnpath { public function overview() { $is_allowed_to_edit = api_is_allowed_to_edit(null,true); - $platform_charset = api_get_system_encoding(); if ($this->debug > 0) { error_log('New LP - In learnpath::overview()', 0); } @@ -4343,8 +4361,8 @@ class learnpath { $result = Database::query($sql); $arrLP = array (); while ($row = Database :: fetch_array($result)) { - $row['title'] = Security :: remove_XSS(api_convert_encoding($row['title'], $platform_charset, $this->encoding)); - $row['description'] = Security :: remove_XSS(api_convert_encoding($row['description'], $platform_charset, $this->encoding)); + $row['title'] = Security :: remove_XSS($row['title']); + $row['description'] = Security :: remove_XSS($row['description']); $arrLP[] = array ( 'id' => $row['id'], 'item_type' => $row['item_type'], @@ -4537,7 +4555,7 @@ class learnpath { * @uses dtree.js :: necessary javascript for building this tree */ public function build_tree() { - $platform_charset = api_get_system_encoding(); + $return = "