Skip to content
Snippets Groups Projects
Commit c2b09a90 authored by Thomas Hackl's avatar Thomas Hackl
Browse files

check if the I18NString is an object or just a string (happens when only one...

check if the I18NString is an object or just a string (happens when only one content language is defined), re #154
parent 45510fb9
No related branches found
No related tags found
No related merge requests found
...@@ -132,9 +132,9 @@ class AdvancedBasicDataWizardStep extends BasicDataWizardStep ...@@ -132,9 +132,9 @@ class AdvancedBasicDataWizardStep extends BasicDataWizardStep
$values[__CLASS__] = array_merge($values[__CLASS__], [ $values[__CLASS__] = array_merge($values[__CLASS__], [
'subtitle' => $course->untertitel, 'subtitle' => $course->untertitel,
'subtitle_i18n' => $course->untertitel->toArray(), 'subtitle_i18n' => is_object($course->untertitel) ? $course->untertitel->toArray() : $course->untertitel,
'kind' => $course->art, 'kind' => $course->art,
'kind_i18n' => $course->art->toArray(), 'kind_i18n' => is_object($course->art) ? $course->art->toArray() : $course->art,
'ects' => $course->ects, 'ects' => $course->ects,
'maxmembers' => $course->admission_turnout, 'maxmembers' => $course->admission_turnout,
]); ]);
......
...@@ -491,11 +491,12 @@ class BasicDataWizardStep implements CourseWizardStep ...@@ -491,11 +491,12 @@ class BasicDataWizardStep implements CourseWizardStep
'coursetype' => $course->status, 'coursetype' => $course->status,
'start_time' => $course->start_time, 'start_time' => $course->start_time,
'name' => $course->name, 'name' => $course->name,
'name_i18n' => $course->name->toArray(), 'name_i18n' => is_object($course->name) ? $course->name->toArray() : $course->name,
'number' => $course->veranstaltungsnummer, 'number' => $course->veranstaltungsnummer,
'institute' => $course->institut_id, 'institute' => $course->institut_id,
'description' => $course->beschreibung, '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'); $lecturers = $course->members->findBy('status', 'dozent')->pluck('user_id');
$data['lecturers'] = array_flip($lecturers); $data['lecturers'] = array_flip($lecturers);
...@@ -584,26 +585,31 @@ class BasicDataWizardStep implements CourseWizardStep ...@@ -584,26 +585,31 @@ class BasicDataWizardStep implements CourseWizardStep
*/ */
protected function makeI18N($values, $indices) protected function makeI18N($values, $indices)
{ {
/** // We only need to do something if there are several content languages.
* Create array for configured content languages if (count($GLOBALS['CONTENT_LANGUAGES']) > 1) {
*/
$translations = array_combine( /**
array_keys($GLOBALS['CONTENT_LANGUAGES']), * Create array for configured content languages
array_fill(0, count($GLOBALS['CONTENT_LANGUAGES']), '') */
); $translations = array_combine(
array_keys($GLOBALS['CONTENT_LANGUAGES']),
array_fill(0, count($GLOBALS['CONTENT_LANGUAGES']), '')
);
foreach ($indices as $index) { foreach ($indices as $index) {
// There are values given => create an I18NString // There are values given => create an I18NString
if ($values[$index]) { 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 // Current index is not set (yet), create an empty I18NString
} else { } else {
$values[$index] = new I18NString('', $translations); $values[$index] = new I18NString('', $translations);
}
} }
} }
return $values; return $values;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment