Skip to content

Commit 9156c22

Browse files
committed
remove deprecated utf8 function
1 parent 216b6cc commit 9156c22

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

hup_stats.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function get_cat_veranstids_and_count($ueids) {
6363
$secondlevel_orinins = get_newest_sublevels(implode(", ", $toplevel_origins));
6464
foreach ($secondlevel_orinins as $secondndlevel) {
6565
// Kategoriekopien herausfinden
66-
$secondndlevel->txt = utf8_encode($secondndlevel->txt);
66+
$secondndlevel->txt = mb_convert_encoding($secondndlevel->txt, 'UTF-8', 'ISO-8859-1');
6767
$secondndlevel->copies = $DB->get_records("local_lsf_category",array("origin" => $secondndlevel->origin),null,"ueid");
6868
foreach($secondndlevel->copies as $secondlevel_copy) {
6969
// Semester bestimmen

lib_features.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function send_support_mail($course, $text) {
9999
$params = new stdClass();
100100
$params->a = $USER->firstname." ".$USER->lastname;
101101
$params->b = $USER->id;
102-
$params->c = utf8_encode($course->fullname);
102+
$params->c = mb_convert_encoding($course->fullname, 'UTF-8', 'ISO-8859-1');
103103
$params->d = $course->id;
104104
$params->e = $text;
105105

@@ -124,7 +124,7 @@ function send_course_request_mail($recipientusername, $course, $requestid) {
124124
$user = get_or_create_user($recipientusername, $email);
125125
$params = new stdClass();
126126
$params->a = $USER->firstname." ".$USER->lastname;
127-
$params->c = utf8_encode($course->titel);
127+
$params->c = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1');
128128

129129
$data = array('recipientid' => $user->id, 'requesterid' => $USER->id, 'requesterfirstname' => $USER->firstname,
130130
'requesterlastname' => $USER->lastname, 'requestid' => $requestid, 'params' => $params);
@@ -149,7 +149,7 @@ function send_course_creation_mail($recipient, $course) {
149149
global $USER;
150150
$params = new stdClass();
151151
$params->a = $USER->firstname." ".$USER->lastname;
152-
$params->c = utf8_encode($course->titel);
152+
$params->c = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1');
153153

154154
$data = array('recipientid' => $recipient->id, 'acceptorid' => $USER->id, 'acceptorfirstname' => $USER->firstname,
155155
'acceptorlastname' => $USER->lastname, 'veranstid' => $course->veranstid, 'params' => $params);
@@ -169,7 +169,7 @@ function send_sorry_mail($recipient, $course) {
169169
global $USER;
170170
$params = new stdClass();
171171
$params->a = $USER->firstname." ".$USER->lastname;
172-
$params->c = utf8_encode($course->titel);
172+
$params->c = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1');
173173

174174
$data = array('recipientid' => $recipient->id, 'acceptorid' => $USER->id, 'acceptorfirstname' => $USER->firstname,
175175
'acceptorlastname' => $USER->lastname, 'params' => $params);

lib_his.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Functions that are specific to HIS database, format and helptables containing his-formatted data
44
*/
55
defined('MOODLE_INTERNAL') || die();
6+
global $CFG;
67
require_once ($CFG->dirroot . '/local/lsf_unification/class_pg_lite.php');
78

89
define("HIS_PERSONAL", "public.learnweb_personal");
@@ -278,7 +279,7 @@ function get_default_fullname($lsf_course) {
278279
foreach (get_teachers_of_course($lsf_course->veranstid) as $person) {
279280
$personen .= ", " . trim($person->vorname) . " " . trim($person->nachname);
280281
}
281-
return utf8_encode(($lsf_course->titel) . " " . trim($lsf_course->semestertxt) . $personen);
282+
return mb_convert_encoding(($lsf_course->titel) . " " . trim($lsf_course->semestertxt) . $personen, 'UTF-8', 'ISO-8859-1');
282283
}
283284

284285
/**
@@ -294,8 +295,7 @@ function get_default_shortname($lsf_course, $long = false) {
294295
foreach (explode(" ", $lsf_course->titel) as $word) {
295296
$i .= strtoupper($word[0]) . (($long && !empty($word[1])) ? $word[1] : "");
296297
}
297-
$name = utf8_encode(
298-
$i . "-" . substr($lsf_course->semester, 0, 4) . "_" . substr($lsf_course->semester, -1));
298+
$name = mb_convert_encoding($i . "-" . substr($lsf_course->semester, 0, 4) . "_" . substr($lsf_course->semester, -1), 'UTF-8', 'ISO-8859-1');
299299
if (!$long && $DB->record_exists('course', array('shortname' => $name
300300
))) {
301301
return get_default_shortname($lsf_course, true);
@@ -321,7 +321,7 @@ function get_default_summary($lsf_course) {
321321
$summary .= '<p>' . $sum_object->kommentar . '</p>';
322322
}
323323
}
324-
$summary = utf8_encode($summary) . '<p><a href="' . $lsf_course->urlveranst .
324+
$summary = mb_convert_encoding($summary, 'UTF-8', 'ISO-8859-1') . '<p><a href="' . $lsf_course->urlveranst .
325325
'">Kurs im HIS-LSF</a></p>';
326326
return $summary;
327327
}
@@ -595,7 +595,7 @@ function insert_missing_helptable_entries($debugoutput = false, $tryeverything =
595595
$entry->origin = find_origin_category($hislsf_title->ueid);
596596
$entry->mdlid = 0;
597597
$entry->timestamp = strtotime($hislsf_title->zeitstempel);
598-
$entry->txt = utf8_encode($hislsf_title->txt);
598+
$entry->txt = mb_convert_encoding($hislsf_title->txt, 'UTF-8', 'ISO-8859-1');
599599
if ($debugoutput)
600600
echo "!";
601601
try {
@@ -605,7 +605,7 @@ function insert_missing_helptable_entries($debugoutput = false, $tryeverything =
605605
echo "x";
606606
} catch (Exception $e) {
607607
try {
608-
$entry->txt = utf8_encode(delete_bad_chars($hislsf_title->txt));
608+
$entry->txt = mb_convert_encoding(delete_bad_chars($hislsf_title->txt), 'UTF-8', 'ISO-8859-1');
609609
$DB->insert_record("local_lsf_category", $entry, true);
610610
$records1_unique[$hislsf_title->ueid] = true;
611611
if ($debugoutput)
@@ -655,7 +655,7 @@ function insert_missing_helptable_entries($debugoutput = false, $tryeverything =
655655
$entry = $DB->get_record('local_lsf_category',
656656
array("ueid" => $hislsf_title->ueid
657657
));
658-
$entry->txt2 = utf8_encode($fullname);
658+
$entry->txt2 = mb_convert_encoding($fullname, 'UTF-8', 'ISO-8859-1');
659659
try {
660660
$DB->update_record('local_lsf_category', $entry, true);
661661
} catch (Exception $e) {
@@ -685,7 +685,7 @@ function insert_missing_helptable_entries($debugoutput = false, $tryeverything =
685685
* @return $str
686686
*/
687687
function delete_bad_chars($str) {
688-
return strtr(utf8_encode($str), array(
688+
return strtr(mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1'), array(
689689
"\xc2\x96" => "", // EN DASH
690690
"\xc2\x97" => "", // EM DASH
691691
"\xc2\x84" => "" // DOUBLE LOW-9 QUOTATION MARK

request.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
require_once(dirname(__FILE__) . '/../../config.php');
5+
global $CFG, $USER, $DB, $PAGE, $SESSION, $OUTPUT;
56
//require_once($CFG->dirroot . '/course/lib.php');
67
require_once($CFG->dirroot . '/local/lsf_unification/lib_features.php');
78
require_once($CFG->dirroot . '/local/lsf_unification/request_form.php');
@@ -138,9 +139,9 @@ function print_res_selection() {
138139
}
139140
foreach ($catfiles as $id => $fileinfo) {
140141
$lines = explode("\n", trim($fileinfo->info, " \t\r\n"), 2);
141-
echo '<li style="list-style-image: url(' . $OUTPUT->image_url("i/navigationitem")->out(true) . ')"><a href="duplicate_course.php?courseid=' . $courseid . "&filetype=t&fileid=" . $id . '">' . utf8_encode($lines[0]) . "</a>";
142+
echo '<li style="list-style-image: url(' . $OUTPUT->image_url("i/navigationitem")->out(true) . ')"><a href="duplicate_course.php?courseid=' . $courseid . "&filetype=t&fileid=" . $id . '">' . mb_convert_encoding($lines[0], 'UTF-8', 'ISO-8859-1') . "</a>";
142143
if (count($lines) == 2)
143-
echo "<br/>" . utf8_encode($lines[1]);
144+
echo "<br/>" . mb_convert_encoding($lines[1], 'UTF-8', 'ISO-8859-1');
144145
echo "</li>";
145146
}
146147
if (!empty($name)) echo "</ul></li>";
@@ -247,7 +248,7 @@ function print_request_handler() {
247248
echo get_string('remote_request_select_alternative', 'local_lsf_unification');
248249
$params = new stdClass();
249250
$params->a = $requester->firstname . " " . $requester->lastname;
250-
$params->b = utf8_encode($course->titel);
251+
$params->b = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1');
251252
echo '<p>' .
252253
'<a href="' . $CFG->wwwroot . '/local/lsf_unification/request.php?answer=' . $answer . '&requestid=' . $request->id . '&accept=1">' . get_string('remote_request_accept', 'local_lsf_unification', $params) . '</a>' .
253254
'<br>';

tests/generator/lib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function set_up_params($categorywish = true, $request = false, $answer =
6565
if (!$categorywish) {
6666
$data['recipientid'] = $recipient->id;
6767
$course = $this->create_lsf_course();
68-
$params->c = utf8_encode($course->titel);
68+
$params->c = mb_convert_encoding($course->titel, 'UTF-8', 'ISO-8859-1');
6969
$data['veranstid'] = $course->veranstid;
7070
if ($request) {
7171
$data['requestid'] = '1';
@@ -76,7 +76,7 @@ public function set_up_params($categorywish = true, $request = false, $answer =
7676
$data['supportuserid'] = $recipient->id;
7777
$course = $this->create_course();
7878
$params->b = $sender->id;
79-
$params->c = utf8_encode($course->fullname);
79+
$params->c = mb_convert_encoding($course->fullname, 'UTF-8', 'ISO-8859-1');
8080
$params->d = $course->id;
8181
$params->e = 'I want to change to Category xy';
8282
}

0 commit comments

Comments
 (0)