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. 30
      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,
.advmultiselect + label {
.advmultiselect + label,
textarea + label.settings-label
{
font-size: 13px;
@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"
:label="t('Edit')"
type="secondary"
icon="delete"
icon="edit"
@click="dialog = true"
/>
</template>

@ -2182,7 +2182,7 @@ if ($allowMessages) {
'javascript: void(0);',
[
'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 Sylius\Bundle\SettingsBundle\Schema\AbstractSettingsBuilder;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -62,26 +63,37 @@ abstract class AbstractSettingsSchema implements SchemaInterface
{
$settingsInfo = $this->getSettingsInfoFromDatabase();
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])) {
$fieldConfig = $settingsInfo[$fieldName];
$options = $field->getOptions();
$labelFromDb = $this->translator->trans($fieldConfig['label']);
$helpFromDb = $this->translator->trans($fieldConfig['help']);
$existingHelp = $options['help'] ?? '';
if (!empty($existingHelp)) {
$combinedHelp = $helpFromDb.'<br>'.$existingHelp;
} else {
$combinedHelp = $helpFromDb;
}
$combinedHelp = !empty($existingHelp) ? $helpFromDb . '<br>' . $existingHelp : $helpFromDb;
$options['label'] = $labelFromDb;
$options['help'] = $combinedHelp;
$builder->remove($fieldName);
$builder->add($fieldName, \get_class($field->getType()->getInnerType()), $options);
$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->add($fieldName, \get_class($field->getType()->getInnerType()), $options);
}
}
}

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save