Merge pull request #5422 from christianbeeznest/ofaj-21557

Internal: Fix HTML escaping, overlapping ui elements, and untranslated labels and options
pull/5423/head
christianbeeznest 1 year ago committed by GitHub
commit 70a28f449b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      assets/css/app.scss
  2. 2
      assets/vue/views/ccalendarevent/CCalendarEventList.vue
  3. 2
      public/main/my_space/myStudents.php
  4. 26
      src/CoreBundle/Settings/AbstractSettingsSchema.php
  5. 14
      src/CoreBundle/Settings/CourseSettingsSchema.php
  6. 8
      src/CoreBundle/Settings/DisplaySettingsSchema.php
  7. 10
      src/CoreBundle/Settings/DocumentSettingsSchema.php
  8. 8
      src/CoreBundle/Settings/ExerciseSettingsSchema.php
  9. 2
      src/CoreBundle/Settings/GlossarySettingsSchema.php
  10. 8
      src/CoreBundle/Settings/PlatformSettingsSchema.php
  11. 8
      src/CoreBundle/Settings/RegistrationSettingsSchema.php
  12. 4
      src/CoreBundle/Settings/SearchSettingsSchema.php
  13. 4
      src/CoreBundle/Settings/SurveySettingsSchema.php

@ -606,7 +606,9 @@ form .field {
} }
.freeze + label, .freeze + label,
.advmultiselect + label { .advmultiselect + label,
textarea + label.settings-label
{
font-size: 13px; font-size: 13px;
@apply absolute top-0 left-0 text-support-3 text-caption px-1 bg-white text-primary; @apply absolute top-0 left-0 text-support-3 text-caption px-1 bg-white text-primary;
} }

@ -79,7 +79,7 @@
v-if="allowToEdit && showEditButton" v-if="allowToEdit && showEditButton"
:label="t('Edit')" :label="t('Edit')"
type="secondary" type="secondary"
icon="delete" icon="edit"
@click="dialog = true" @click="dialog = true"
/> />
</template> </template>

@ -2182,7 +2182,7 @@ if ($allowMessages) {
'javascript: void(0);', 'javascript: void(0);',
[ [
'onClick' => "$('#compose_message').show();", 'onClick' => "$('#compose_message').show();",
'class' => 'btn btn--plain', 'class' => 'btn btn--plain mb-6',
] ]
); );

@ -9,6 +9,7 @@ namespace Chamilo\CoreBundle\Settings;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Sylius\Bundle\SettingsBundle\Schema\AbstractSettingsBuilder; use Sylius\Bundle\SettingsBundle\Schema\AbstractSettingsBuilder;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
@ -62,26 +63,37 @@ abstract class AbstractSettingsSchema implements SchemaInterface
{ {
$settingsInfo = $this->getSettingsInfoFromDatabase(); $settingsInfo = $this->getSettingsInfoFromDatabase();
foreach ($builder->all() as $fieldName => $field) { foreach ($builder->all() as $fieldName => $field) {
$options = $field->getOptions();
$labelAttributes = $options['label_attr'] ?? [];
$labelAttributes['class'] = (isset($labelAttributes['class']) ? $labelAttributes['class'] . ' ' : '') . 'settings-label';
$options['label_attr'] = $labelAttributes;
if (isset($settingsInfo[$fieldName])) { if (isset($settingsInfo[$fieldName])) {
$fieldConfig = $settingsInfo[$fieldName]; $fieldConfig = $settingsInfo[$fieldName];
$options = $field->getOptions();
$labelFromDb = $this->translator->trans($fieldConfig['label']); $labelFromDb = $this->translator->trans($fieldConfig['label']);
$helpFromDb = $this->translator->trans($fieldConfig['help']); $helpFromDb = $this->translator->trans($fieldConfig['help']);
$existingHelp = $options['help'] ?? ''; $existingHelp = $options['help'] ?? '';
if (!empty($existingHelp)) { $combinedHelp = !empty($existingHelp) ? $helpFromDb . '<br>' . $existingHelp : $helpFromDb;
$combinedHelp = $helpFromDb.'<br>'.$existingHelp;
} else {
$combinedHelp = $helpFromDb;
}
$options['label'] = $labelFromDb; $options['label'] = $labelFromDb;
$options['help'] = $combinedHelp; $options['help'] = $combinedHelp;
$options['label_html'] = true;
$options['help_html'] = true;
if ($field->getType()->getInnerType() instanceof ChoiceType && isset($options['choices'])) {
$translatedChoices = [];
foreach ($options['choices'] as $key => $value) {
$readableKey = ucfirst(strtolower(str_replace('_', ' ', $key)));
$translatedChoices[$this->translator->trans($readableKey)] = $value;
}
$options['choices'] = $translatedChoices;
}
}
$builder->remove($fieldName); $builder->remove($fieldName);
$builder->add($fieldName, \get_class($field->getType()->getInnerType()), $options); $builder->add($fieldName, \get_class($field->getType()->getInnerType()), $options);
} }
} }
}
} }

@ -170,9 +170,9 @@ class CourseSettingsSchema extends AbstractSettingsSchema
[ [
'choices' => [ 'choices' => [
'No' => 'false', 'No' => 'false',
'IconsOnly' => 'icons', 'Icons only' => 'icons',
'TextOnly' => 'text', 'Text only' => 'text',
'IconsText' => 'iconstext', 'Icons text' => 'iconstext',
], ],
] ]
) )
@ -182,10 +182,10 @@ class CourseSettingsSchema extends AbstractSettingsSchema
ChoiceType::class, ChoiceType::class,
[ [
'choices' => [ 'choices' => [
'CourseHomepage' => 'course_home', 'Course homepage' => 'course_home',
'CourseCode' => 'course_code', 'Course code' => 'course_code',
'CourseTitle' => 'course_title', 'Course title' => 'course_title',
'SessionNameAndCourseTitle' => 'session_name_and_course_title', 'Session name and course title' => 'session_name_and_course_title',
], ],
] ]
) )

@ -97,10 +97,10 @@ class DisplaySettingsSchema extends AbstractSettingsSchema
ChoiceType::class, ChoiceType::class,
[ [
'choices' => [ 'choices' => [
'DoNotShow' => 'do_not_show', 'Do not show' => 'do_not_show',
'ShowToAdminsOnly' => 'show_to_admin', 'Show to admins only' => 'show_to_admin',
'ShowToAdminsAndTeachers' => 'show_to_admin_and_teachers', 'Show to admins and teachers' => 'show_to_admin_and_teachers',
'ShowToAllUsers' => 'show_to_all', 'Show to all users' => 'show_to_all',
], ],
] ]
) )

@ -91,8 +91,8 @@ class DocumentSettingsSchema extends AbstractSettingsSchema
ChoiceType::class, ChoiceType::class,
[ [
'choices' => [ 'choices' => [
'Blacklist' => 'blacklist', 'Black list' => 'blacklist',
'Whitelist' => 'whitelist', 'White list' => 'whitelist',
], ],
] ]
) )
@ -107,9 +107,9 @@ class DocumentSettingsSchema extends AbstractSettingsSchema
ChoiceType::class, ChoiceType::class,
[ [
'choices' => [ 'choices' => [
'ShowGlossaryInDocumentsIsNone' => 'none', 'Show glossary in documents is none' => 'none',
'ShowGlossaryInDocumentsIsManual' => 'ismanual', 'Show glossary in documents is manual' => 'ismanual',
'ShowGlossaryInDocumentsIsAutomatic' => 'isautomatic', 'Show glossary in documents is automatic' => 'isautomatic',
], ],
] ]
) )

@ -139,10 +139,10 @@ class ExerciseSettingsSchema extends AbstractSettingsSchema
ChoiceType::class, ChoiceType::class,
[ [
'choices' => [ 'choices' => [
'none' => '0', 'None' => '0',
'SCORE_AVERAGE' => '1', 'Score average' => '1',
'SCORE_PERCENT' => '2', 'Score percent' => '2',
'SCORE_DIV_PERCENT' => '3', 'Score div percent' => '3',
], ],
], ],
) )

@ -42,7 +42,7 @@ class GlossarySettingsSchema extends AbstractSettingsSchema
'None' => 'none', 'None' => 'none',
'Exercise' => 'exercise', 'Exercise' => 'exercise',
'LearningPath' => 'lp', 'LearningPath' => 'lp',
'ExerciseAndLearningPath' => 'exercise_and_lp', 'Exercise and LearningPath' => 'exercise_and_lp',
], ],
] ]
) )

@ -144,10 +144,10 @@ class PlatformSettingsSchema extends AbstractSettingsSchema
ChoiceType::class, ChoiceType::class,
[ [
'choices' => [ 'choices' => [
'CatalogueHide' => '-1', 'Catalogue hide' => '-1',
'CatalogueShowOnlyCourses' => '0', 'Catalogue show only courses' => '0',
'CatalogueShowOnlySessions' => '1', 'Catalogue show only sessions' => '1',
'CatalogueShowCoursesAndSessions' => '2', 'Catalogue show courses and sessions' => '2',
], ],
] ]
) )

@ -96,7 +96,7 @@ class RegistrationSettingsSchema extends AbstractSettingsSchema
'choices' => [ 'choices' => [
'Yes' => 'true', 'Yes' => 'true',
'No' => 'false', 'No' => 'false',
'MailConfirmation' => 'confirmation', 'Mail confirmation' => 'confirmation',
'Approval' => 'approval', 'Approval' => 'approval',
], ],
] ]
@ -108,9 +108,9 @@ class RegistrationSettingsSchema extends AbstractSettingsSchema
ChoiceType::class, ChoiceType::class,
[ [
'choices' => [ 'choices' => [
'CampusHomepage' => 'index.php', 'Campus homepage' => 'index.php',
'MyCourses' => 'user_portal.php', 'My courses' => 'user_portal.php',
'CourseCatalog' => 'main/auth/courses.php', 'Course catalog' => 'main/auth/courses.php',
], ],
] ]
) )

@ -38,8 +38,8 @@ class SearchSettingsSchema extends AbstractSettingsSchema
ChoiceType::class, ChoiceType::class,
[ [
'choices' => [ 'choices' => [
'SearchShowUnlinkedResults' => 'true', 'Search show unlinked results' => 'true',
'SearchHideUnlinkedResults' => 'false', 'Search hide unlinked results' => 'false',
], ],
] ]
) )

@ -48,8 +48,8 @@ class SurveySettingsSchema extends AbstractSettingsSchema
ChoiceType::class, ChoiceType::class,
[ [
'choices' => [ 'choices' => [
'CourseCoachEmailSender' => 'coach', 'Course coach email sender' => 'coach',
'NoReplyEmailSender' => 'noreply', 'No reply email sender' => 'noreply',
], ],
] ]
) )

Loading…
Cancel
Save