aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/coursewizardsteps/BasicDataWizardStep.php
diff options
context:
space:
mode:
authorThomas Hackl <hackl@data-quest.de>2022-01-14 13:59:11 +0100
committerThomas Hackl <hackl@data-quest.de>2022-01-14 13:59:11 +0100
commitc2b09a90fb258e3f2aa4135396590d0628bb2140 (patch)
treeab16e91cd31ddadc94a3cfd2d918458d5670582e /lib/classes/coursewizardsteps/BasicDataWizardStep.php
parent45510fb9f2cf3553dcd314db3785c78e4a608b1d (diff)
check if the I18NString is an object or just a string (happens when only one content language is defined), re #154
Diffstat (limited to 'lib/classes/coursewizardsteps/BasicDataWizardStep.php')
-rw-r--r--lib/classes/coursewizardsteps/BasicDataWizardStep.php38
1 files changed, 22 insertions, 16 deletions
diff --git a/lib/classes/coursewizardsteps/BasicDataWizardStep.php b/lib/classes/coursewizardsteps/BasicDataWizardStep.php
index 225b8ff..bb29f06 100644
--- a/lib/classes/coursewizardsteps/BasicDataWizardStep.php
+++ b/lib/classes/coursewizardsteps/BasicDataWizardStep.php
@@ -491,11 +491,12 @@ class BasicDataWizardStep implements CourseWizardStep
'coursetype' => $course->status,
'start_time' => $course->start_time,
'name' => $course->name,
- 'name_i18n' => $course->name->toArray(),
+ 'name_i18n' => is_object($course->name) ? $course->name->toArray() : $course->name,
'number' => $course->veranstaltungsnummer,
'institute' => $course->institut_id,
'description' => $course->beschreibung,
- 'description_i18n' => $course->beschreibung->toArray()
+ 'description_i18n' => is_object($course->beschreibung) ?
+ $course->beschreibung->toArray() : $course->beschreibung
];
$lecturers = $course->members->findBy('status', 'dozent')->pluck('user_id');
$data['lecturers'] = array_flip($lecturers);
@@ -584,26 +585,31 @@ class BasicDataWizardStep implements CourseWizardStep
*/
protected function makeI18N($values, $indices)
{
- /**
- * Create array for configured content languages
- */
- $translations = array_combine(
- array_keys($GLOBALS['CONTENT_LANGUAGES']),
- array_fill(0, count($GLOBALS['CONTENT_LANGUAGES']), '')
- );
+ // We only need to do something if there are several content languages.
+ if (count($GLOBALS['CONTENT_LANGUAGES']) > 1) {
+
+ /**
+ * Create array for configured content languages
+ */
+ $translations = array_combine(
+ array_keys($GLOBALS['CONTENT_LANGUAGES']),
+ array_fill(0, count($GLOBALS['CONTENT_LANGUAGES']), '')
+ );
- foreach ($indices as $index) {
- // There are values given => create an I18NString
- if ($values[$index]) {
+ foreach ($indices as $index) {
+ // There are values given => create an I18NString
+ if ($values[$index]) {
- $values[$index] = new I18NString($values[$index], $values[$index . '_i18n']);
+ $values[$index] = new I18NString($values[$index], $values[$index . '_i18n']);
- // Current index is not set (yet), create an empty I18NString
- } else {
+ // Current index is not set (yet), create an empty I18NString
+ } else {
- $values[$index] = new I18NString('', $translations);
+ $values[$index] = new I18NString('', $translations);
+ }
}
+
}
return $values;