From 1b2ceeb174103205f75a1709f343527ed208d2f4 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Sun, 27 Nov 2022 14:59:31 -0500 Subject: [PATCH] Installer use vue --- assets/css/app.scss | 24 +- assets/css/scss/atoms/_inline_message.scss | 49 + assets/css/scss/atoms/_tags.scss | 63 + assets/css/scss/index.scss | 4 + assets/css/scss/organisms/_install.scss | 35 + assets/css/scss/organisms/_tables.scss | 27 + assets/css/scss/settings/_typography.scss | 4 - assets/vue/AppInstaller.vue | 299 ++++ assets/vue/components/installer/Step1.vue | 74 + assets/vue/components/installer/Step2.vue | 345 +++++ assets/vue/components/installer/Step3.vue | 355 +++++ assets/vue/components/installer/Step4.vue | 227 +++ assets/vue/components/installer/Step5.vue | 519 +++++++ assets/vue/components/installer/Step6.vue | 330 ++++ assets/vue/components/installer/Step7.vue | 69 + assets/vue/main_installer.js | 12 + assets/vue/utils/languages.js | 498 ++++++ public/main/inc/lib/display.lib.php | 55 +- public/main/install/index.php | 437 ++---- public/main/install/install.lib.php | 1605 ++++++-------------- webpack.config.js | 1 + 21 files changed, 3520 insertions(+), 1512 deletions(-) create mode 100644 assets/css/scss/atoms/_inline_message.scss create mode 100644 assets/css/scss/atoms/_tags.scss create mode 100644 assets/css/scss/organisms/_install.scss create mode 100644 assets/css/scss/organisms/_tables.scss create mode 100644 assets/vue/AppInstaller.vue create mode 100644 assets/vue/components/installer/Step1.vue create mode 100644 assets/vue/components/installer/Step2.vue create mode 100644 assets/vue/components/installer/Step3.vue create mode 100644 assets/vue/components/installer/Step4.vue create mode 100644 assets/vue/components/installer/Step5.vue create mode 100644 assets/vue/components/installer/Step6.vue create mode 100644 assets/vue/components/installer/Step7.vue create mode 100644 assets/vue/main_installer.js create mode 100644 assets/vue/utils/languages.js diff --git a/assets/css/app.scss b/assets/css/app.scss index 23ac3f3a14..fa7b63d8b0 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -61,27 +61,6 @@ border: 0; } - // Tables - table { - @apply min-w-full divide-y; - } - - table thead { - } - - table tbody { - } - - table thead th, - table tbody th, - table tbody td { - @apply px-2 py-1; - } - - .table td img { - display: inline-block; - } - // List .list-group { @@ -218,6 +197,9 @@ //@import '~primeflex/primeflex.css'; //@import "~primeicons/primeicons.css"; +@import 'primeflex/src/_variables.scss'; +@import 'primeflex/src/_formlayout.scss'; + //@import "~jquery-ui-timepicker-addon/dist/jquery-ui-timepicker-addon.css"; @import "~@fancyapps/fancybox/dist/jquery.fancybox.css"; @import "~timepicker/jquery.timepicker.min.css"; diff --git a/assets/css/scss/atoms/_inline_message.scss b/assets/css/scss/atoms/_inline_message.scss new file mode 100644 index 0000000000..faf2724a1b --- /dev/null +++ b/assets/css/scss/atoms/_inline_message.scss @@ -0,0 +1,49 @@ +.p-inline-message { + @apply py-3 px-4 m-0 rounded-md border border-solid flex gap-3.5 bg-white; + + .p-inline-message-icon { + font-size: 1rem; + } + + .p-inline-message-text { + font-size: 1rem; + } + + &.p-inline-message-info { + @apply text-info; + + .p-inline-message-icon { + @apply text-info; + } + } + + &.p-inline-message-success { + @apply text-success; + + .p-inline-message-icon { + @apply text-success; + } + } + + &.p-inline-message-warn { + @apply text-warning; + + .p-inline-message-icon { + @apply text-warning; + } + } + + &.p-inline-message-error { + @apply text-error; + + .p-inline-message-icon { + @apply text-error; + } + } + + &.p-inline-message-icon-only { + .p-inline-message-icon { + + } + } +} diff --git a/assets/css/scss/atoms/_tags.scss b/assets/css/scss/atoms/_tags.scss new file mode 100644 index 0000000000..fd2a8c8314 --- /dev/null +++ b/assets/css/scss/atoms/_tags.scss @@ -0,0 +1,63 @@ +.p-tag { + @apply box-decoration-clone text-caption-bold py-1 px-4 rounded-full text-white inline-block; + + &-success { + @apply bg-success; + } + + &-danger { + @apply bg-error; + } + + &-warning { + @apply bg-warning; + } + + &-info { + @apply bg-info; + } + + &-primary { + @apply bg-primary; + } + + &-secondary { + @apply bg-secondary; + } + + &-icon { + @apply mr-1.5; + } +} + +.badge { + @apply box-decoration-clone text-caption-bold py-1 px-4 rounded-full text-white inline-block; + + &--default { + @apply bg-gray-50; + } + + &--error { + @apply bg-error; + } + + &--success { + @apply bg-success; + } + + &--warning { + @apply bg-warning; + } + + &--info { + @apply bg-info; + } + + &--primary { + @apply bg-primary; + } + + &--secondary { + @apply bg-secondary; + } +} \ No newline at end of file diff --git a/assets/css/scss/index.scss b/assets/css/scss/index.scss index 1e2afef64c..e5870bd24e 100755 --- a/assets/css/scss/index.scss +++ b/assets/css/scss/index.scss @@ -17,12 +17,14 @@ @import "atoms/checkbox"; @import "atoms/dropdown"; @import "atoms/form"; +@import "atoms/inline_message"; @import "atoms/input_switch"; @import "atoms/input_text"; @import "atoms/messages"; @import "atoms/overlay"; @import "atoms/radio"; @import "atoms/skeleton"; +@import "atoms/tags"; @import "molecules/course_tool"; @import "molecules/datepicker"; @@ -34,6 +36,8 @@ @import "organisms/modals"; @import "organisms/menu"; @import "organisms/sidebar"; +@import "organisms/tables"; +@import "organisms/install"; @import "components/badges"; //@import 'announcement'; diff --git a/assets/css/scss/organisms/_install.scss b/assets/css/scss/organisms/_install.scss new file mode 100644 index 0000000000..62fc70ba01 --- /dev/null +++ b/assets/css/scss/organisms/_install.scss @@ -0,0 +1,35 @@ +.install-steps { + @apply space-y-4; + + .logo-install { + @apply block mx-auto w-fit; + } + + ol { + @apply list-decimal list-inside flex flex-col gap-1; + } + + &__step { + @apply border-0 border-solid py-3 pl-9 pr-3 text-body-2-bold text-gray-50; + + &--active { + @apply bg-support-1 text-primary border-primary border-l-4 pl-8; + } + } +} + +.install-step { + +} + +table.requirements-list { + .requirements-item { + @apply text-left; + } + .requirements-recommended { + @apply text-center; + } + .requirements-value { + @apply text-center; + } +} \ No newline at end of file diff --git a/assets/css/scss/organisms/_tables.scss b/assets/css/scss/organisms/_tables.scss new file mode 100644 index 0000000000..898128bb87 --- /dev/null +++ b/assets/css/scss/organisms/_tables.scss @@ -0,0 +1,27 @@ +@layer components { + .table-responsive { + @apply overflow-x-auto min-w-full; + } + + table { + @apply w-full border-collapse border-spacing-0 table-auto; + } + + th, + td { + @apply p-1; + } + + th { + @apply text-body-2-bold; + } + + td { + @apply text-body-2; + + strong, + b { + @apply text-body-2-bold; + } + } +} diff --git a/assets/css/scss/settings/_typography.scss b/assets/css/scss/settings/_typography.scss index 816aed4b3e..18157d2758 100644 --- a/assets/css/scss/settings/_typography.scss +++ b/assets/css/scss/settings/_typography.scss @@ -83,10 +83,6 @@ @apply text-body-1; } - header { - @apply text-header; - } - h1 { @apply text-h1; } diff --git a/assets/vue/AppInstaller.vue b/assets/vue/AppInstaller.vue new file mode 100644 index 0000000000..10ca32b7a5 --- /dev/null +++ b/assets/vue/AppInstaller.vue @@ -0,0 +1,299 @@ + + + diff --git a/assets/vue/components/installer/Step1.vue b/assets/vue/components/installer/Step1.vue new file mode 100644 index 0000000000..b8b8dfe97d --- /dev/null +++ b/assets/vue/components/installer/Step1.vue @@ -0,0 +1,74 @@ + + + diff --git a/assets/vue/components/installer/Step2.vue b/assets/vue/components/installer/Step2.vue new file mode 100644 index 0000000000..7487a49080 --- /dev/null +++ b/assets/vue/components/installer/Step2.vue @@ -0,0 +1,345 @@ + + + diff --git a/assets/vue/components/installer/Step3.vue b/assets/vue/components/installer/Step3.vue new file mode 100644 index 0000000000..81ac5bd523 --- /dev/null +++ b/assets/vue/components/installer/Step3.vue @@ -0,0 +1,355 @@ + + + diff --git a/assets/vue/components/installer/Step4.vue b/assets/vue/components/installer/Step4.vue new file mode 100644 index 0000000000..bc2dcaf5fe --- /dev/null +++ b/assets/vue/components/installer/Step4.vue @@ -0,0 +1,227 @@ + + + diff --git a/assets/vue/components/installer/Step5.vue b/assets/vue/components/installer/Step5.vue new file mode 100644 index 0000000000..440bf50617 --- /dev/null +++ b/assets/vue/components/installer/Step5.vue @@ -0,0 +1,519 @@ + + + diff --git a/assets/vue/components/installer/Step6.vue b/assets/vue/components/installer/Step6.vue new file mode 100644 index 0000000000..d9250f4e37 --- /dev/null +++ b/assets/vue/components/installer/Step6.vue @@ -0,0 +1,330 @@ + + + diff --git a/assets/vue/components/installer/Step7.vue b/assets/vue/components/installer/Step7.vue new file mode 100644 index 0000000000..d773e558e4 --- /dev/null +++ b/assets/vue/components/installer/Step7.vue @@ -0,0 +1,69 @@ + + + diff --git a/assets/vue/main_installer.js b/assets/vue/main_installer.js new file mode 100644 index 0000000000..f5e65f8735 --- /dev/null +++ b/assets/vue/main_installer.js @@ -0,0 +1,12 @@ +import { createApp } from 'vue'; +import AppInstaller from './AppInstaller'; +import PrimeVue from 'primevue/config'; +import i18n from './i18n'; + +const app = createApp(AppInstaller); + +app + .use(PrimeVue, { ripple: false }) + .use(i18n) + + .mount('#app'); diff --git a/assets/vue/utils/languages.js b/assets/vue/utils/languages.js new file mode 100644 index 0000000000..99648ce57b --- /dev/null +++ b/assets/vue/utils/languages.js @@ -0,0 +1,498 @@ +export default [ + { + 'original_name': 'العربية', + 'english_name': 'arabic', + 'isocode': 'ar', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + 'direction': 'rtl', + }, + { + 'original_name': 'Asturianu', + 'english_name': 'asturian', + 'isocode': 'ast_ES', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Euskara', + 'english_name': 'basque', + 'isocode': 'eu_ES', + 'available': 1, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'বাংলা', + 'english_name': 'bengali', + 'isocode': 'bn_BD', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Bosanski', + 'english_name': 'bosnian', + 'isocode': 'bs_BA', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Português do Brasil', + 'english_name': 'brazilian', + 'isocode': 'pt_PT', + 'available': 1, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Български', + 'english_name': 'bulgarian', + 'isocode': 'bg', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Català', + 'english_name': 'catalan', + 'isocode': 'ca_ES', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Hrvatski', + 'english_name': 'croatian', + 'isocode': 'hr_HR', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Česky', + 'english_name': 'czech', + 'isocode': 'cs_CZ', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Dansk', + 'english_name': 'danish', + 'isocode': 'da', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'دری', + 'english_name': 'dari', + 'isocode': 'fa_AF', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + 'direction': 'rtl', + }, + { + 'original_name': 'Nederlands', + 'english_name': 'dutch', + 'isocode': 'nl', + 'available': 1, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'English', + 'english_name': 'english', + 'isocode': 'en_US', + 'available': 1, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + /*{ + 'original_name': 'Estonian', + 'english_name': 'estonian', + 'isocode': 'ety', + 'available': 0, + },*/ + { + 'original_name': 'Esperanto', + 'english_name': 'esperanto', + 'isocode': 'eo', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Føroyskt', + 'english_name': 'faroese', + 'isocode': 'fo_FO', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Suomi', + 'english_name': 'finnish', + 'isocode': 'fi_FI', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Français', + 'english_name': 'french', + 'isocode': 'fr_FR', + 'available': 1, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Furlan', + 'english_name': 'friulian', + 'isocode': 'fur', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Galego', + 'english_name': 'galician', + 'isocode': 'gl', + 'available': 0, + 'format': 'title last_name first_name', + 'sort_by': 'last_name', + }, + { + 'original_name': 'ქართული', + 'english_name': 'georgian', + 'isocode': 'ka_GE', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Deutsch', + 'english_name': 'german', + 'isocode': 'de', + 'available': 1, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Ελληνικά', + 'english_name': 'greek', + 'isocode': 'el', + 'available': 1, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'עברית', + 'english_name': 'hebrew', + 'isocode': 'he_IL', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + 'direction': 'rtl', + }, + { + 'original_name': 'हिन्दी', + 'english_name': 'hindi', + 'isocode': 'hi', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Magyar', + 'english_name': 'hungarian', + 'isocode': 'hu_HU', + 'available': 0, + 'format': 'title last_name first_name', + 'sort_by': 'last_name', + }, + { + 'original_name': 'Bahasa Indonesia', + 'english_name': 'indonesian', + 'isocode': 'id_ID', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Italiano', + 'english_name': 'italian', + 'isocode': 'it', + 'available': 1, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': '日本語', + 'english_name': 'japanese', + 'isocode': 'ja', + 'available': 0, + 'format': 'title last_name first_name', + 'sort_by': 'last_name', + }, + { + 'original_name': '한국어', + 'english_name': 'korean', + 'isocode': 'ko_KR', + 'available': 0, + + 'format': 'title last_name first_name', + 'sort_by': 'last_name', + }, + { + 'original_name': 'Latviešu', + 'english_name': 'latvian', + 'isocode': 'lv_LV', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Lietuvių', + 'english_name': 'lithuanian', + 'isocode': 'lt_LT', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Македонски', + 'english_name': 'macedonian', + 'isocode': 'mk_MK', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Bahasa Melayu', + 'english_name': 'malay', + 'isocode': 'ms_MY', + 'available': 0, + 'format': 'title last_name first_name', + 'sort_by': 'last_name', + }, + { + 'original_name': 'Norsk', + 'english_name': 'norwegian', + 'isocode': 'nn_NO', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Occitan', + 'english_name': 'occitan', + 'isocode': 'oc', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'پښتو', + 'english_name': 'pashto', + 'isocode': 'ps', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + 'direction': 'rtl', + }, + { + 'original_name': 'فارسی', + 'english_name': 'persian', + 'isocode': 'fa_IR', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + 'direction': 'rtl', + }, + { + 'original_name': 'Polski', + 'english_name': 'polish', + 'isocode': 'pl_PL', + 'available': 1, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Português europeu', + 'english_name': 'portuguese', + 'isocode': 'pt_PT', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Runasimi', + 'english_name': 'quechua_cusco', + 'isocode': 'quz_PE', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Română', + 'english_name': 'romanian', + 'isocode': 'ro_RO', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Русский', + 'english_name': 'russian', + 'isocode': 'ru_RU', + 'available': 1, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Srpski', + 'english_name': 'serbian', + 'isocode': 'sr_RS', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': '中文(简体', + 'english_name': 'simpl_chinese', + 'isocode': 'zh_CN', + 'available': 0, + + 'format': 'title last_name first_name', + 'sort_by': 'last_name', + }, + { + 'original_name': 'Slovenčina', + 'english_name': 'slovak', + 'isocode': 'sk_SK', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Slovenščina', + 'english_name': 'slovenian', + 'isocode': 'sl_SI', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'الصومالية', + 'english_name': 'somali', + 'isocode': 'so_SO', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Español', + 'english_name': 'spanish', + 'isocode': 'es', + 'available': 1, + + 'format': 'title last_name first_name', + 'sort_by': 'last_name', + }, + { + 'original_name': 'Kiswahili', + 'english_name': 'swahili', + 'isocode': 'sw_KE', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Svenska', + 'english_name': 'swedish', + 'isocode': 'sv_SE', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Tagalog', + 'english_name': 'tagalog', + 'isocode': 'tl_PH', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'ไทย', + 'english_name': 'thai', + 'isocode': 'th', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Tibetan', + 'english_name': 'tibetan', + 'isocode': 'bo_CN', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': '繁體中文', + 'english_name': 'trad_chinese', + 'isocode': 'zh_TW', + 'available': 0, + + 'format': 'title last_name first_name', + 'sort_by': 'last_name', + }, + { + 'original_name': 'Türkçe', + 'english_name': 'turkish', + 'isocode': 'tr', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Українська', + 'english_name': 'ukrainian', + 'isocode': 'uk_UA', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Tiếng Việt', + 'english_name': 'vietnamese', + 'isocode': 'vi_VN', + 'available': 0, + + 'format': 'title last_name first_name', + 'sort_by': 'last_name', + }, + { + 'original_name': 'isiXhosa', + 'english_name': 'xhosa', + 'isocode': 'xh_ZA', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, + { + 'original_name': 'Yorùbá', + 'english_name': 'yoruba', + 'isocode': 'yo_NG', + 'available': 0, + 'format': 'title first_name last_name', + 'sort_by': 'first_name', + }, +]; diff --git a/public/main/inc/lib/display.lib.php b/public/main/inc/lib/display.lib.php index 8b3a60a00e..94f9d761c7 100644 --- a/public/main/inc/lib/display.lib.php +++ b/public/main/inc/lib/display.lib.php @@ -877,42 +877,17 @@ class Display return self::tag('input', '', $attributes); } - /** - * @param $name - * @param $value - * @param array $attributes - * - * @return string - */ - public static function button($name, $value, $attributes = []) - { - if (!empty($name)) { - $attributes['name'] = $name; - } - - return self::tag('button', $value, $attributes); - } - /** * Displays an HTML select tag. - * - * @param string $name - * @param array $values - * @param int $default - * @param array $extra_attributes - * @param bool $show_blank_item - * @param string $blank_item_text - * - * @return string */ public static function select( - $name, - $values, - $default = -1, - $extra_attributes = [], - $show_blank_item = true, - $blank_item_text = '' - ) { + string $name, + array $values, + mixed $default = -1, + array $extra_attributes = [], + bool $show_blank_item = true, + string $blank_item_text = '' + ): string { $html = ''; $extra = ''; $default_id = 'id="'.$name.'" '; @@ -968,6 +943,22 @@ class Display return $html; } + /** + * @param $name + * @param $value + * @param array $attributes + * + * @return string + */ + public static function button($name, $value, $attributes = []) + { + if (!empty($name)) { + $attributes['name'] = $name; + } + + return self::tag('button', $value, $attributes); + } + /** * Creates a tab menu * Requirements: declare the jquery, jquery-ui libraries + the jquery-ui.css diff --git a/public/main/install/index.php b/public/main/install/index.php index 5deaed2e89..7e79c3d102 100644 --- a/public/main/install/index.php +++ b/public/main/install/index.php @@ -192,8 +192,8 @@ if (isset($_POST['step2_install']) || isset($_POST['step2_update_8']) || isset($ $updateFromConfigFile = ''; unset($_GET['running']); } else { - $installType = isset($_GET['installType']) ? $_GET['installType'] : ''; - $updateFromConfigFile = isset($_GET['updateFromConfigFile']) ? $_GET['updateFromConfigFile'] : false; + $installType = $_GET['installType'] ?? ''; + $updateFromConfigFile = $_GET['updateFromConfigFile'] ?? false; } if ('update' === $installType && in_array($my_old_version, $upgradeFromVersion)) { // This is the main configuration file of the system before the upgrade. @@ -277,19 +277,6 @@ if ('1' == $encryptPassForm) { $encryptPassForm = 'none'; } -$form = ''; -$label = ''; -if ('new' === $installType) { - $label = get_lang('New installation'); -} elseif ('update' === $installType) { - $update_from_version = isset($update_from_version) ? $update_from_version : null; - $label = get_lang('Update from Chamilo').(is_array($update_from_version) ? implode('|', $update_from_version) : ''); -} - -if (!empty($label) && empty($_POST['step6'])) { - $form .= ''; -} - if (empty($installationProfile)) { $installationProfile = ''; if (!empty($_POST['installationProfile'])) { @@ -298,64 +285,27 @@ if (empty($installationProfile)) { } $institutionUrlFormResult = ''; -if (api_stristr($institutionUrlForm, 'http://') || api_stristr($institutionUrlForm, 'https://')) { - $institutionUrlFormResult = api_htmlentities($institutionUrlForm, ENT_QUOTES); -} else { - $institutionUrlFormResult = api_htmlentities($institutionUrlForm, ENT_QUOTES); -} +$institutionUrlFormResult = api_htmlentities($institutionUrlForm, ENT_QUOTES); -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; -$form .= ''; +$stepData = []; if (isset($_POST['step2'])) { // STEP 3 : LICENSE - ob_start(); - display_license_agreement(); - $form .= ob_get_contents(); - ob_end_clean(); + $current_step = 3; + $stepData = display_license_agreement(); } elseif (isset($_POST['step3'])) { + $current_step = 4; // STEP 4 : MYSQL DATABASE SETTINGS - ob_start(); - display_database_settings_form( + $stepData = display_database_settings_form( $installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbNameForm, - $dbPortForm, - $installationProfile + $dbPortForm ); - $form .= ob_get_contents(); - ob_end_clean(); } elseif (isset($_POST['step4'])) { + $current_step = 5; // STEP 5 : CONFIGURATION SETTINGS if ('update' === $installType) { $db_name = $dbNameForm; @@ -430,8 +380,7 @@ if (isset($_POST['step2'])) { } } - ob_start(); - display_configuration_settings_form( + $stepData = display_configuration_settings_form( $installType, $urlForm, $languageForm, @@ -448,129 +397,45 @@ if (isset($_POST['step2'])) { $loginForm, $passForm ); - $form .= ob_get_contents(); - ob_end_clean(); } elseif (isset($_POST['step5'])) { - ob_start(); - //STEP 6 : LAST CHECK BEFORE INSTALL?> -
-

-
-
- -
- '.$loginForm.''; - $params[] = get_lang('Administrator password (you may want to change this)').' : '.$passForm.''; + $stepData['loginForm'] = $loginForm; + $stepData['passForm'] = $passForm; } - $params[] = get_lang('Administrator first name').' : '.$adminFirstName; - $params[] = get_lang('Administrator last name').' : '.$adminLastName; - $params[] = get_lang('Administrator e-mail').' : '.$emailForm; - $params[] = get_lang('Administrator telephone').' : '.$adminPhoneForm; + $stepData['adminFirstName'] = $adminFirstName; + $stepData['adminLastName'] = $adminLastName; + $stepData['emailForm'] = $emailForm; + $stepData['adminPhoneForm'] = $adminPhoneForm; - $content = implode('
', $params); - echo Display::panel($content); - $allowSelfRegistrationLiteral = get_lang('No'); - if ('true' === $allowSelfReg) { - $allowSelfRegistrationLiteral = get_lang('Yes'); - } - if ('approval' === $allowSelfReg) { - $allowSelfRegistrationLiteral = get_lang('Approval'); - } + $allowSelfRegistrationLiteral = match ($allowSelfReg) { + 'true' => get_lang('Yes'), + 'approval' => get_lang('Approval'), + default => get_lang('No'), + }; if ('update' === $installType) { $urlForm = get_config_param('root_web'); } - $params = [ - get_lang('Your portal name').' : '.$campusForm, - get_lang('Main language').' : '.$languageForm, - get_lang('Allow self-registration').' : '.$allowSelfRegistrationLiteral, - get_lang('Your company short name').' : '.$institutionForm, - get_lang('URL of this company').' : '.$institutionUrlForm, - //get_lang('Chamilo URL').' : '.$urlForm, - //get_lang('Encryption method').' : '.$encryptPassForm, - ]; - $content = implode('
', $params); - echo Display::panel($content); - - $params = [ - get_lang('Database Host').' : '.$dbHostForm, - get_lang('Port').' : '.$dbPortForm, - get_lang('Database Login').' : '.$dbUsernameForm, - get_lang('Database Password').' : '.str_repeat('*', api_strlen($dbPassForm)), - get_lang('Database name').' : '.$dbNameForm.'', - ]; - $content = implode('
', $params); - echo Display::panel($content); - - if ('new' === $installType) { - echo Display::return_message( - '

'.get_lang( - 'Warning' - ).'

'. - get_lang('The install script will erase all tables of the selected database. We heavily recommend you do a full backup of them before confirming this last install step.'), - 'warning', - false - ); - } ?> - - - - - -
- - - - - - -
- -

'.display_step_sequence().$msg.'

'; - if (!empty($installationProfile)) { - $form .= '

('.$installationProfile.')

'; - } - $form .= '
'. - get_lang('Please wait. This could take a while...').' -
-
- 100% Complete -
-
-
- '; if ('update' === $installType) { $database = connectToDatabase( @@ -734,13 +599,6 @@ if (isset($_POST['step2'])) { error_log('ERROR during installation.'); } } - - $form .= display_after_install_message(); - - // Hide the "please wait" message sent previously - $form .= ''; - $form .= ob_get_contents(); - ob_end_clean(); } elseif (isset($_POST['step1']) || $badUpdatePath) { //STEP 1 : REQUIREMENTS //make sure that proposed path is set, shouldn't be necessary but... @@ -748,27 +606,75 @@ if (isset($_POST['step2'])) { $proposedUpdatePath = $_POST['updatePath']; } - ob_start(); - display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $upgradeFromVersion); - $form .= ob_get_contents(); - ob_end_clean(); + $stepData = display_requirements( + $installType, + $badUpdatePath, + $proposedUpdatePath, + $upgradeFromVersion + ); } else { - ob_start(); // This is the start screen. - display_language_selection(); - if (!empty($_GET['profile'])) { $installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES); } - echo ''; - $form .= ob_get_contents(); - ob_end_clean(); + + $stepData['installationProfile'] = $installationProfile; } -$poweredBy = 'Powered by Chamilo © '.date('Y'); +$installerData = [ + 'poweredBy' => 'Powered by Chamilo © '.date('Y'), + + 'phpRequiredVersion' => REQUIRED_PHP_VERSION, + + 'installType' => $installType, + + 'badUpdatePath' => $badUpdatePath, + + 'upgradeFromVersion' => $upgradeFromVersion, + + 'langIso' => api_get_language_isocode(), + + 'formAction' => api_get_self().'?'.http_build_query([ + 'running' => 1, + 'installType' => $installType, + 'updateFromConfigFile' => $updateFromConfigFile, + ]), + + 'updatePath' => !$badUpdatePath ? api_htmlentities($proposedUpdatePath, ENT_QUOTES) : '', + 'urlAppendPath' => api_htmlentities($urlAppendPath, ENT_QUOTES), + 'pathForm' => api_htmlentities($pathForm, ENT_QUOTES), + 'urlForm' => api_htmlentities($urlForm, ENT_QUOTES), + 'dbHostForm' => api_htmlentities($dbHostForm, ENT_QUOTES), + 'dbPortForm' => api_htmlentities((string) $dbPortForm, ENT_QUOTES), + 'dbUsernameForm' => api_htmlentities($dbUsernameForm, ENT_QUOTES), + 'dbPassForm' => api_htmlentities($dbPassForm, ENT_QUOTES), + 'dbNameForm' => api_htmlentities($dbNameForm, ENT_QUOTES), + 'allowSelfReg' => api_htmlentities($allowSelfReg, ENT_QUOTES), + 'allowSelfRegProf' => api_htmlentities((string) $allowSelfRegProf, ENT_QUOTES), + 'emailForm' => api_htmlentities($emailForm, ENT_QUOTES), + 'adminLastName' => api_htmlentities($adminLastName, ENT_QUOTES), + 'adminFirstName' => api_htmlentities($adminFirstName, ENT_QUOTES), + 'adminPhoneForm' => api_htmlentities($adminPhoneForm, ENT_QUOTES), + 'loginForm' => api_htmlentities($loginForm, ENT_QUOTES), + 'passForm' => api_htmlentities($passForm, ENT_QUOTES), + 'languageForm' => api_htmlentities($languageForm, ENT_QUOTES), + 'campusForm' => api_htmlentities($campusForm, ENT_QUOTES), + 'educationForm' => api_htmlentities($educationForm, ENT_QUOTES), + 'institutionForm' => api_htmlentities($institutionForm, ENT_QUOTES), + 'institutionUrlForm' => $institutionUrlFormResult, + 'checkEmailByHashSent' => api_htmlentities((string) $checkEmailByHashSent, ENT_QUOTES), + 'showEmailNotCheckedToStudent' => api_htmlentities((string) $showEmailNotCheckedToStudent, ENT_QUOTES), + 'userMailCanBeEmpty' => api_htmlentities((string) $userMailCanBeEmpty, ENT_QUOTES), + 'encryptPassForm' => api_htmlentities($encryptPassForm, ENT_QUOTES), + 'session_lifetime' => api_htmlentities((string) $session_lifetime, ENT_QUOTES), + 'old_version' => api_htmlentities($my_old_version, ENT_QUOTES), + 'new_version' => api_htmlentities($new_version, ENT_QUOTES), + 'installationProfile' => api_htmlentities($installationProfile, ENT_QUOTES), + + 'currentStep' => $current_step, + + 'stepData' => $stepData, +]; ?> @@ -781,147 +687,12 @@ $poweredBy = 'Powered by Chamilo + + +
- - -
-
-
- -
-
    -
  1. - 1 - trans('Installation language'); ?> -
  2. -
  3. - 2 - trans('Requirements'); ?> -
  4. -
  5. - 3 - trans('Licence'); ?> -
  6. -
  7. - 4 - trans('Database settings'); ?> -
  8. -
  9. - 5 - trans('Config settings'); ?> -
  10. -
  11. - 6 - trans('Show Overview'); ?> -
  12. -
  13. - 7 - trans('Install'); ?> -
  14. -
-
- -
-
-
- -
-
-
-
- -
-
+ diff --git a/public/main/install/install.lib.php b/public/main/install/install.lib.php index edf88cf49c..4ea1ef5de1 100644 --- a/public/main/install/install.lib.php +++ b/public/main/install/install.lib.php @@ -70,40 +70,58 @@ function isAlreadyInstalledSystem() * If not, mention it's present but not enabled. For example, for opcache, this should be * 'opcache.enable' * - * @return string HTML string reporting the status of this extension. Language-aware. + * @return array * * @author Christophe Gesch?? * @author Patrick Cool , Ghent University * @author Yannick Warnier */ function checkExtension( - $extensionName, - $returnSuccess = 'Yes', - $returnFailure = 'No', - $optional = false, - $enabledTerm = '' -) { + string $extensionName, + string $returnSuccess = 'Yes', + string $returnFailure = 'No', + bool $optional = false, + string $enabledTerm = '' +): array { if (extension_loaded($extensionName)) { if (!empty($enabledTerm)) { $isEnabled = ini_get($enabledTerm); if ('1' == $isEnabled) { - return Display::label($returnSuccess, 'success'); + return [ + 'severity' => 'success', + 'message' => $returnSuccess, + ]; } else { if ($optional) { - return Display::label(get_lang('Extension installed but not enabled'), 'warning'); + return [ + 'severity' => 'warning', + 'message' => get_lang('Extension installed but not enabled'), + ]; } - return Display::label(get_lang('Extension installed but not enabled'), 'important'); + return [ + 'severity' => 'danger', + 'message' => get_lang('Extension installed but not enabled'), + ]; } } - return Display::label($returnSuccess, 'success'); + return [ + 'severity' => 'success', + 'message' => $returnSuccess, + ]; } else { if ($optional) { - return Display::label($returnFailure, 'warning'); + return [ + 'severity' => 'warning', + 'message' => $returnFailure, + ]; } - return Display::label($returnFailure, 'important'); + return [ + 'severity' => 'danger', + 'message' => $returnFailure, + ]; } } @@ -112,25 +130,18 @@ function checkExtension( * * @param string $phpSetting A PHP setting to check * @param string $recommendedValue A recommended value to show on screen - * @param mixed $returnSuccess What to show on success - * @param mixed $returnFailure What to show on failure - * - * @return string A label to show * * @author Patrick Cool , Ghent University */ function checkPhpSetting( - $phpSetting, - $recommendedValue, - $returnSuccess = false, - $returnFailure = false -) { + string $phpSetting, + string $recommendedValue +): array { $currentPhpValue = getPhpSetting($phpSetting); - if ($currentPhpValue == $recommendedValue) { - return Display::label($currentPhpValue.' '.$returnSuccess, 'success'); - } - return Display::label($currentPhpValue.' '.$returnSuccess, 'important'); + return $currentPhpValue == $recommendedValue + ? ['severity' => 'success', 'value' => $currentPhpValue] + : ['severity' => 'danger', 'value' => $currentPhpValue]; } /** @@ -199,11 +210,7 @@ function check_writable($folder, $suggestion = false) if (is_writable($folder)) { return Display::label(get_lang('Writable'), 'success'); } else { - if ($suggestion) { - return Display::label(get_lang('Not writable'), 'info'); - } else { - return Display::label(get_lang('Not writable'), 'important'); - } + return Display::label(get_lang('Not writable'), 'important'); } } @@ -392,7 +399,7 @@ function step_active($param) { global $current_step; if ($param == $current_step) { - echo 'active'; + echo 'install-steps__step--active'; } } @@ -418,46 +425,14 @@ function display_language_selection_box($name = 'language_list', $default_langua 'language_list', array_column(LanguageFixtures::getLanguages(), 'english_name', 'isocode'), $default_language, - ['class' => 'form-control'], + [], false ); } -/** - * This function displays a language dropdown box so that the installatioin - * can be done in the language of the user. - */ -function display_language_selection() -{ - ?> -
- -
-

- - -

- -
- - -
- -
- -
-, Ghent University */ function display_requirements( - $installType, - $badUpdatePath, - $updatePath = '', - $upgradeFromVersion = [] -) { + string $installType, + bool $badUpdatePath, + string $updatePath = '', + array $upgradeFromVersion = [] +): array { global $_setting, $originalMemoryLimit; $dir = api_get_path(SYS_ARCHIVE_PATH).'temp/'; @@ -493,7 +468,7 @@ function display_requirements( $file_course_test_was_created = false; if (is_dir($dir)) { foreach ($perms_fil as $perm) { - if (true == $file_course_test_was_created) { + if ($file_course_test_was_created) { break; } $r = @touch($dir.'/'.$fileToCreate, $perm); @@ -507,299 +482,278 @@ function display_requirements( @unlink($dir.'/'.$fileToCreate); @rmdir($dir); - echo '

'.display_step_sequence().get_lang('Requirements').'

'; - echo '
'; - echo ''.get_lang('Please read the following requirements thoroughly.').'
'; - echo get_lang('For more details').' - '. - get_lang('Read the installation guide').'.
'."\n"; - - if ('update' == $installType) { - echo get_lang( - 'If you plan to upgrade from an older version of Chamilo, you might want to have a look at the changelog to know what\'s new and what has been changed').'
'; - } - echo '
'; - // SERVER REQUIREMENTS - echo '

'.get_lang('Server requirements').'

'; $timezone = checkPhpSettingExists('date.timezone'); - if (!$timezone) { - echo "
-  ". - get_lang('We have detected that your PHP installation does not define the date.timezone setting. This is a requirement of Chamilo. Please make sure it is configured by checking your php.ini configuration, otherwise you will run into problems. We warned you!').'
'; - } - echo '
'.get_lang('Server requirementsInfo').'
'; - echo '
'; - echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'.get_lang('PHP version').' >= '.REQUIRED_PHP_VERSION.''; - if (version_compare(phpversion(), REQUIRED_PHP_VERSION, '>=') > 1) { - echo ''.get_lang('PHP versionError').''; - } else { - echo ''.get_lang('PHP versionOK').' '.phpversion().''; - } - echo '
- Session - '.get_lang('Support').''. - checkExtension('session', get_lang('Yes'), get_lang('Sessions extension not available')).'
- pdo_mysql '.get_lang('Support').''. - checkExtension('pdo_mysql', get_lang('Yes'), get_lang('MySQL extension not available')).'
- Zip '.get_lang('Support').''. - checkExtension('zip', get_lang('Yes'), get_lang('Extension not available')).'
- Zlib '.get_lang('Support').''. - checkExtension('zlib', get_lang('Yes'), get_lang('Zlib extension not available')).'
- Perl-compatible regular expressions '.get_lang('Support').''. - checkExtension('pcre', get_lang('Yes'), get_lang('PCRE extension not available')).'
- XML '.get_lang('Support').''. - checkExtension('xml', get_lang('Yes'), get_lang('No')).'
- Internationalization '.get_lang('Support').''.checkExtension('intl', get_lang('Yes'), get_lang('No')).'
- JSON '.get_lang('Support').''.checkExtension('json', get_lang('Yes'), get_lang('No')).'
- GD '.get_lang('Support').''. - checkExtension('gd', get_lang('Yes'), get_lang('GD Extension not available')).'
- cURL'.get_lang('Support').''. - checkExtension('curl', get_lang('Yes'), get_lang('No')).'
- Multibyte string '.get_lang('Support').''. - checkExtension('mbstring', get_lang('Yes'), get_lang('MBString extension not available'), true).'
- Exif '.get_lang('Support').''. - checkExtension('exif', get_lang('Yes'), get_lang('Exif extension not available'), true).'
- Zend OpCache '.get_lang('Support').' ('.get_lang('Optional').')'. - checkExtension('Zend OPcache', get_lang('Yes'), get_lang('No'), true, 'opcache.enable').'
- APCu '.get_lang('Support').' ('.get_lang('Optional').')'. - checkExtension('apcu', get_lang('Yes'), get_lang('No'), true, 'apc.enabled').'
- Iconv '.get_lang('Support').' ('.get_lang('Optional').')'. - checkExtension('iconv', get_lang('Yes'), get_lang('No'), true).'
- LDAP '.get_lang('Support').' ('.get_lang('Optional').')'. - checkExtension('ldap', get_lang('Yes'), get_lang('LDAP Extension not available'), true).'
- Xapian '.get_lang('Support').' ('.get_lang('Optional').')'. - checkExtension('xapian', get_lang('Yes'), get_lang('No'), true).'
'; - echo '
'; + $phpVersion = phpversion(); + $isVersionPassed = version_compare($phpVersion, REQUIRED_PHP_VERSION, '<=') <= 1; + + $extensions = []; + $extensions[] = [ + 'title' => get_lang('Session support'), + 'url' => 'https://php.net/manual/en/book.session.php', + 'status' => checkExtension( + 'session', + get_lang('Yes'), + get_lang('Sessions extension not available') + ), + ]; + $extensions[] = [ + 'title' => get_lang('MySQL Functions support'), + 'url' => 'https://php.net/manual/en/book.mysql.php', + 'status' => checkExtension( + 'pdo_mysql', + get_lang('Yes'), + get_lang('MySQL extension not available') + ), + ]; + $extensions[] = [ + 'title' => get_lang('Zip support'), + 'url' => 'https://php.net/manual/en/book.zip.php', + 'status' => checkExtension( + 'zip', + get_lang('Yes'), + get_lang('Extension not available') + ), + ]; + $extensions[] = [ + 'title' => get_lang('Zlib support'), + 'url' => 'https://php.net/manual/en/book.zlib.php', + 'status' => checkExtension( + 'zlib', + get_lang('Yes'), + get_lang('Zlib extension not available') + ), + ]; + $extensions[] = [ + 'title' => get_lang('Perl-compatible regular expressions support'), + 'url' => 'https://php.net/manual/en/book.pcre.php', + 'status' => checkExtension( + 'pcre', + get_lang('Yes'), + get_lang('PCRE extension not available') + ), + ]; + $extensions[] = [ + 'title' => get_lang('XML support'), + 'url' => 'https://php.net/manual/en/book.xml.php', + 'status' => checkExtension( + 'xml', + get_lang('Yes'), + get_lang('No') + ), + ]; + $extensions[] = [ + 'title' => get_lang('Internationalization support'), + 'url' => 'https://php.net/manual/en/book.intl.php', + 'status' => checkExtension( + 'intl', + get_lang('Yes'), + get_lang('No') + ), + ]; + $extensions[] = [ + 'title' => get_lang('JSON support'), + 'url' => 'https://php.net/manual/en/book.json.php', + 'status' => checkExtension( + 'json', + get_lang('Yes'), + get_lang('No') + ), + ]; + $extensions[] = [ + 'title' => get_lang('GD support'), + 'url' => 'https://php.net/manual/en/book.image.php', + 'status' => checkExtension( + 'gd', + get_lang('Yes'), + get_lang('GD Extension not available') + ), + ]; + $extensions[] = [ + 'title' => get_lang('cURL support'), + 'url' => 'https://php.net/manual/en/book.curl.php', + 'status' => checkExtension( + 'curl', + get_lang('Yes'), + get_lang('No') + ), + ]; + $extensions[] = [ + 'title' => get_lang('Multibyte string support'), + 'url' => 'https://php.net/manual/en/book.mbstring.php', + 'status' => checkExtension( + 'mbstring', + get_lang('Yes'), + get_lang('MBString extension not available'), + true + ), + ]; + $extensions[] = [ + 'title' => get_lang('Exif support'), + 'url' => 'https://php.net/manual/en/book.exif.php', + 'status' => checkExtension( + 'exif', + get_lang('Yes'), + get_lang('Exif extension not available'), + true + ), + ]; + $extensions[] = [ + 'title' => get_lang('Zend OpCache support'), + 'url' => 'https://php.net/opcache', + 'status' => checkExtension( + 'Zend OPcache', + get_lang('Yes'), + get_lang('No'), + true, + 'opcache.enable' + ), + ]; + $extensions[] = [ + 'title' => get_lang('APCu support'), + 'url' => 'https://php.net/apcu', + 'status' => checkExtension( + 'apcu', + get_lang('Yes'), + get_lang('No'), + true, + 'apc.enabled' + ), + ]; + $extensions[] = [ + 'title' => get_lang('Iconv support'), + 'url' => 'https://php.net/manual/en/book.iconv.php', + 'status' => checkExtension( + 'iconv', + get_lang('Yes'), + get_lang('No'), + true + ), + ]; + $extensions[] = [ + 'title' => get_lang('LDAP support'), + 'url' => 'https://php.net/manual/en/book.ldap.php', + 'status' => checkExtension( + 'ldap', + get_lang('Yes'), + get_lang('LDAP Extension not available'), + true + ), + ]; + $extensions[] = [ + 'title' => get_lang('Xapian support'), + 'url' => 'https://xapian.org/', + 'status' => checkExtension( + 'xapian', + get_lang('Yes'), + get_lang('No'), + true + ), + ]; // RECOMMENDED SETTINGS // Note: these are the settings for Joomla, does this also apply for Chamilo? // Note: also add upload_max_filesize here so that large uploads are possible - echo '

'.get_lang('(recommended) settings').'

'; - echo '
'.get_lang('(recommended) settingsInfo').'
'; - echo '
'; - echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'.get_lang('Setting').''.get_lang('(recommended)').''.get_lang('Currently').'
- Display Errors'.checkPhpSetting('display_errors', 'OFF').'
- File Uploads'.checkPhpSetting('file_uploads', 'ON').'
- Session auto start'.checkPhpSetting('session.auto_start', 'OFF').'
- Short Open Tag'.checkPhpSetting('short_open_tag', 'OFF').'
- Cookie HTTP Only'.checkPhpSetting('session.cookie_httponly', 'ON').'
- Maximum upload file size'.compare_setting_values(ini_get('upload_max_filesize'), REQUIRED_MIN_UPLOAD_MAX_FILESIZE).'
- Maximum post size'.compare_setting_values(ini_get('post_max_size'), REQUIRED_MIN_POST_MAX_SIZE).'
- Memory Limit'.compare_setting_values($originalMemoryLimit, REQUIRED_MIN_MEMORY_LIMIT).'
'; - echo '
'; + $phpIni = []; + $phpIni[] = [ + 'title' => 'Display Errors', + 'url' => 'https://php.net/manual/ref.errorfunc.php#ini.display-errors', + 'recommended' => 'OFF', + 'current' => checkPhpSetting('display_errors', 'OFF'), + ]; + $phpIni[] = [ + 'title' => 'File Uploads', + 'url' => 'https://php.net/manual/ini.core.php#ini.file-uploads', + 'recommended' => 'ON', + 'current' => checkPhpSetting('file_uploads', 'ON'), + ]; + $phpIni[] = [ + 'title' => 'Session auto start', + 'url' => 'https://php.net/manual/ref.session.php#ini.session.auto-start', + 'recommended' => 'OFF', + 'current' => checkPhpSetting('session.auto_start', 'OFF'), + ]; + $phpIni[] = [ + 'title' => 'Short Open Tag', + 'url' => 'https://php.net/manual/ini.core.php#ini.short-open-tag', + 'recommended' => 'OFF', + 'current' => checkPhpSetting('short_open_tag', 'OFF'), + ]; + $phpIni[] = [ + 'title' => 'Cookie HTTP Only', + 'url' => 'https://www.php.net/manual/en/session.configuration.php#ini.session.cookie-httponly', + 'recommended' => 'ON', + 'current' => checkPhpSetting('session.cookie_httponly', 'ON'), + ]; + $phpIni[] = [ + 'title' => 'Maximum upload file size', + 'url' => 'https://php.net/manual/ini.core.php#ini.upload-max-filesize', + 'recommended' => '>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M', + 'current' => compare_setting_values(ini_get('upload_max_filesize'), REQUIRED_MIN_UPLOAD_MAX_FILESIZE), + ]; + $phpIni[] = [ + 'title' => 'Maximum post size', + 'url' => 'https://php.net/manual/ini.core.php#ini.post-max-size', + 'recommended' => '>= '.REQUIRED_MIN_POST_MAX_SIZE.'M', + 'current' => compare_setting_values(ini_get('post_max_size'), REQUIRED_MIN_POST_MAX_SIZE), + ]; + $phpIni[] = [ + 'title' => 'Memory Limit', + 'url' => 'https://www.php.net/manual/en/ini.core.php#ini.memory-limit', + 'recommended' => '>= '.REQUIRED_MIN_MEMORY_LIMIT.'M', + 'current' => compare_setting_values($originalMemoryLimit, REQUIRED_MIN_MEMORY_LIMIT), + ]; // DIRECTORY AND FILE PERMISSIONS - echo '

'.get_lang('Directory and files permissions').'

'; - echo '
'.get_lang('Directory and files permissionsInfo').'
'; - echo '
'; - $_SESSION['permissions_for_new_directories'] = $_setting['permissions_for_new_directories'] = $dir_perm_verified; $_SESSION['permissions_for_new_files'] = $_setting['permissions_for_new_files'] = $fil_perm_verified; - $dir_perm = Display::label('0'.decoct($dir_perm_verified), 'info'); - $file_perm = Display::label('0'.decoct($fil_perm_verified), 'info'); + $dirPerm = '0'.decoct($dir_perm_verified); + $filePerm = '0'.decoct($fil_perm_verified); + + $pathPermissions = []; - $oldConf = ''; if (file_exists(api_get_path(SYS_CODE_PATH).'inc/conf/configuration.php')) { - $oldConf = ' - '.api_get_path(SYS_CODE_PATH).'inc/conf - '.check_writable(api_get_path(SYS_CODE_PATH).'inc/conf').' - '; + $pathPermissions[] = [ + 'requirement' => api_get_path(SYS_CODE_PATH).'inc/conf', + 'status' => is_writable(api_get_path(SYS_CODE_PATH).'inc/conf'), + ]; } $basePath = api_get_path(SYMFONY_SYS_PATH); - echo ' - '.$oldConf.' - - - - - - - - - - - - - - - - - - - - -
'.$basePath.'var/'.check_writable($basePath.'var').'
'.$basePath.'.env.local'.checkCanCreateFile($basePath.'.env.local').'
'.$basePath.'config/'.check_writable($basePath.'config').'
'.get_lang('Permissions for new directories').''.$dir_perm.'
'.get_lang('Permissions for new files').''.$file_perm.'
'; - echo '
'; - - if ('update' === $installType && (empty($updatePath) || $badUpdatePath)) { - if ($badUpdatePath) { - echo '
'; - echo get_lang('Error'); - echo '
'; - echo 'Chamilo '.implode('|', $upgradeFromVersion).' '.get_lang('has not been found in that directory').'
'; - } else { - echo '
'; - } ?> -
-
-

: - -

-

-

- - - -
-

-
-
- $basePath.'var/', + 'status' => is_writable($basePath.'var'), + ]; + $pathPermissions[] = [ + 'item' => $basePath.'.env.local', + 'status' => checkCanCreateFile($basePath.'.env.local'), + ]; + $pathPermissions[] = [ + 'item' => $basePath.'config/', + 'status' => is_writable($basePath.'config'), + ]; + $pathPermissions[] = [ + 'item' => get_lang('Permissions for new directories'), + 'status' => $dirPerm, + ]; + $pathPermissions[] = [ + 'item' => get_lang('Permissions for new files'), + 'status' => $filePerm, + ]; + + $notWritable = []; + $deprecatedToRemove = []; + + $error = false; + + if ('update' !== $installType || !empty($updatePath) && !$badUpdatePath) { // First, attempt to set writing permissions if we don't have them yet //$perm = api_get_permissions_for_new_directories(); $perm = octdec('0777'); //$perm_file = api_get_permissions_for_new_files(); $perm_file = octdec('0666'); - $notWritable = []; $checked_writable = api_get_path(SYS_PUBLIC_PATH); if (!is_writable($checked_writable)) { @@ -807,7 +761,7 @@ function display_requirements( @chmod($checked_writable, $perm); } - if (false == $course_test_was_created) { + if (!$course_test_was_created) { error_log('Installer: Could not create test course - Make sure permissions are fine.'); $error = true; } @@ -822,24 +776,7 @@ function display_requirements( //--> The user would have to adjust the permissions manually if (count($notWritable) > 0) { error_log('Installer: At least one needed directory or file is not writeable'); - $error = true; ?> -
-

-

- ', ''); ?> -

-
- '; - foreach ($notWritable as $value) { - echo '
  • '.$value.'
  • '; - } - echo ''; - } elseif (file_exists(api_get_path(CONFIGURATION_PATH).'configuration.php')) { - // Check wether a Chamilo configuration file already exists. - echo '

    '; - echo get_lang('Warning !ExistingLMSInstallationDetected'); - echo '

    '; + $error = true; } $deprecated = [ @@ -848,59 +785,28 @@ function display_requirements( api_get_path(SYS_PLUGIN_PATH).'ticket/', api_get_path(SYS_PLUGIN_PATH).'skype/', ]; - $deprecatedToRemove = []; + foreach ($deprecated as $deprecatedDirectory) { if (!is_dir($deprecatedDirectory)) { continue; } $deprecatedToRemove[] = $deprecatedDirectory; } - - if (count($deprecatedToRemove) > 0) { - ?> -

    - newscorm and exercice directories were renamed to lp and exercise respectively, is necessary to delete or rename to newscorm_old and exercice_old."); ?> -

    -
      - -
    • - -
    - -

    - - - - -

    - $timezone, + 'isVersionPassed' => $isVersionPassed, + 'phpVersion' => $phpVersion, + 'extensions' => $extensions, + 'phpIni' => $phpIni, + 'pathPermissions' => $pathPermissions, + 'step2_update_6' => isset($_POST['step2_update_6']), + 'notWritable' => $notWritable, + 'existsConfigurationFile' => file_exists(api_get_path(CONFIGURATION_PATH).'configuration.php'), + 'deprecatedToRemove' => $deprecatedToRemove, + 'installError' => $error, + ]; } /** @@ -908,223 +814,91 @@ function display_requirements( * - an "I accept" button named step3 to proceed to step 3; * - a "Back" button named step1 to go back to the first step. */ -function display_license_agreement() +function display_license_agreement(): array { - echo '

    '.display_step_sequence().get_lang('Licence').'

    '; - echo '

    '.get_lang('Chamilo is free software distributed under the GNU General Public licence (GPL).').'

    '; - echo '

    '.get_lang('Printable version').'

    '; $license = api_htmlentities(@file_get_contents(api_get_path(SYMFONY_SYS_PATH).'public/documentation/license.txt')); - echo '
    '; - - echo '
    -
    -            '.$license.'
    -        
    -
    -
    - - -
    -
    -
    -

    '. - get_lang('The images and media galleries of Chamilo use images from Nuvola, Crystal Clear and Tango icon galleries. Other images and media like diagrams and Flash animations are borrowed from Wikimedia and Ali Pakdel\'s and Denis Hoa\'s courses with their agreement and released under BY-SA Creative Commons license. You may find the license details at the CC website, where a link to the full text of the license is provided at the bottom of the page.').' -

    -
    -
    - - -
    -
    '.get_lang('Contact informationDescription').'
    -
    -

    '.get_contact_registration_form().'


    -
    -
    -
    - - - -
    '; -} -/** - * Get contact registration form. - */ -function get_contact_registration_form() -{ - return ' -
    -
    -
    -
    -
    - -
    - -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    - -
    '.get_countries_list_from_array(true).'
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
     
    -
    - -
    -
    -
    -
     
    -
    - *'.get_lang('Mandatory field').' -
    -
    -
    '; + $activtiesList = [ + 'Advertising/Marketing/PR', + 'Agriculture/Forestry', + 'Architecture', + 'Banking/Finance', + 'Biotech/Pharmaceuticals', + 'Business Equipment', + 'Business Services', + 'Construction', + 'Consulting/Research', + 'Education', + 'Engineering', + 'Environmental', + 'Government', + 'Health Care', + 'Hospitality/Lodging/Travel', + 'Insurance', + 'Legal', + 'Manufacturing', + 'Media/Entertainment', + 'Mortgage', + 'Non-Profit', + 'Real Estate', + 'Restaurant', + 'Retail', + 'Shipping/Transportation', + 'Technology', + 'Telecommunications', + 'Other', + ]; + + $rolesList = [ + 'Administration', + 'CEO/President/ Owner', + 'CFO', + 'CIO/CTO', + 'Consultant', + 'Customer Service', + 'Engineer/Programmer', + 'Facilities/Operations', + 'Finance/ Accounting Manager', + 'Finance/ Accounting Staff', + 'General Manager', + 'Human Resources', + 'IS/IT Management', + 'IS/ IT Staff', + 'Marketing Manager', + 'Marketing Staff', + 'Partner/Principal', + 'Purchasing Manager', + 'Sales/ Business Dev. Manager', + 'Sales/ Business Dev.', + 'Vice President/Senior Manager', + 'Other', + ]; + + $countriesList = get_countries_list_from_array(); + + $languagesList = [ + ['bulgarian', 'Bulgarian'], + ['indonesian', 'Bahasa Indonesia'], + ['bosnian', 'Bosanski'], + ['german', 'Deutsch'], + ['english', 'English'], + ['spanish', 'Spanish'], + ['french', 'Français'], + ['italian', 'Italian'], + ['hungarian', 'Magyar'], + ['dutch', 'Nederlands'], + ['brazilian', 'Português do Brasil'], + ['portuguese', 'Português europeu'], + ['slovenian', 'Slovenčina'], + ]; + + return [ + 'license' => $license, + 'activitiesList' => $activtiesList, + 'rolesList' => $rolesList, + 'countriesList' => $countriesList, + 'languagesList' => $languagesList, + ]; } /** @@ -1184,119 +958,27 @@ function displayDatabaseParameter( * Displays step 3 - a form where the user can enter the installation settings * regarding the databases - login and password, names, prefixes, single * or multiple databases, tracking or not... - * - * @param string $installType - * @param string $dbHostForm - * @param string $dbUsernameForm - * @param string $dbPassForm - * @param string $dbNameForm - * @param int $dbPortForm - * @param string $installationProfile */ function display_database_settings_form( - $installType, - $dbHostForm, - $dbUsernameForm, - $dbPassForm, - $dbNameForm, - $dbPortForm = 3306, - $installationProfile = '' -) { + string $installType, + string $dbHostForm, + string $dbUsernameForm, + string $dbPassForm, + string $dbNameForm, + int $dbPortForm = 3306 +): array { if ('update' === $installType) { $dbHostForm = get_config_param('db_host'); $dbUsernameForm = get_config_param('db_user'); $dbPassForm = get_config_param('db_password'); $dbNameForm = get_config_param('main_database'); $dbPortForm = get_config_param('db_port'); - - echo '

    '.display_step_sequence().get_lang('Database settings').'

    '; - echo '
    '; - echo get_lang('The upgrade script will recover and update the Chamilo database(s). In order to do this, this script will use the databases and settings defined below. Because our software runs on a wide range of systems and because all of them might not have been tested, we strongly recommend you do a full backup of your databases before you proceed with the upgrade!'); - echo '
    '; - } else { - echo '

    '.display_step_sequence().get_lang('Database settings').'

    '; - echo '
    '; - echo get_lang('The install script will create (or use) the Chamilo database using the database name given here. Please make sure the user you give has the right to create the database by the name given here. If a database with this name exists, it will be overwritten. Please do not use the root user as the Chamilo database user. This can lead to serious security issues.'); - echo '
    '; } - echo ' -
    -
    -
    -
    '.get_lang('Database Host').'
    '; - if ('update' === $installType) { - echo '
    - '.$dbHostForm.' -
    '; - } else { - echo '
    - - '.get_lang('ex.').'localhost -
    '; - } + $databaseExists = false; + $databaseConnectionError = ''; + $connectionParams = null; - echo '
    '.get_lang('Port').'
    '; - if ('update' === $installType) { - echo '
    - '.$dbPortForm.' -
    '; - } else { - echo ' -
    - - '.get_lang('ex.').' 3306 -
    '; - } - //database user username - $example_login = get_lang('ex.').' root'; - displayDatabaseParameter( - $installType, - get_lang('Database Login'), - 'dbUsernameForm', - $dbUsernameForm, - $example_login - ); - - //database user password - $example_password = get_lang('ex.').' '.api_generate_password(); - displayDatabaseParameter($installType, get_lang('Database Password'), 'dbPassForm', $dbPassForm, $example_password); - // Database Name fix replace weird chars - if (INSTALL_TYPE_UPDATE != $installType) { - $dbNameForm = str_replace(['-', '*', '$', ' ', '.'], '', $dbNameForm); - } - displayDatabaseParameter( - $installType, - get_lang('Database name'), - 'dbNameForm', - $dbNameForm, - ' ', - null, - 'id="optional_param1"' - ); - echo '
    '; - if (INSTALL_TYPE_UPDATE != $installType) { ?> - - getConnection()->createSchemaManager(); $databases = $schemaManager->listDatabases(); - if (in_array($dbNameForm, $databases)) { - $databaseExistsText = '
    '. - get_lang('A database with the same name already exists. It will be deleted.'). - '
    '; - } + $databaseExists = in_array($dbNameForm, $databases); } } catch (Exception $e) { - $databaseExistsText = $e->getMessage(); - $manager = false; + $databaseConnectionError = $e->getMessage(); + $manager = null; } if ($manager && $manager->getConnection()->isConnected()) { $connectionParams = $manager->getConnection()->getParams(); - echo $databaseExistsText; ?> -
    - Database host:
    - Database port:
    - Database driver:
    - Ok'; - echo '
    '; - echo get_lang('AlterTableWorks').' Ok'; - echo '
    '; - echo get_lang('DropColumnWorks').' Ok'; - } ?> -
    - -
    -

    - -

    - -
    - - -
    - - - - - - - -
    - $dbHostForm, + 'dbPortForm' => $dbPortForm, + 'dbUsernameForm' => $dbUsernameForm, + 'dbPassForm' => $dbPassForm, + 'dbNameForm' => $dbNameForm, + 'examplePassword' => api_generate_password(), + 'dbExists' => $databaseExists, + 'dbConnError' => $databaseConnectionError, + 'connParams' => $connectionParams, + ]; } /** @@ -1441,322 +1085,52 @@ function display_configuration_parameter( /** * Displays step 4 of the installation - configuration settings about Chamilo itself. - * - * @param string $installType - * @param string $urlForm - * @param string $languageForm - * @param string $emailForm - * @param string $adminFirstName - * @param string $adminLastName - * @param string $adminPhoneForm - * @param string $campusForm - * @param string $institutionForm - * @param string $institutionUrlForm - * @param string $encryptPassForm - * @param bool $allowSelfReg - * @param bool $allowSelfRegProf - * @param string $loginForm - * @param string $passForm */ function display_configuration_settings_form( - $installType, - $urlForm, - $languageForm, - $emailForm, - $adminFirstName, - $adminLastName, - $adminPhoneForm, - $campusForm, - $institutionForm, - $institutionUrlForm, - $encryptPassForm, - $allowSelfReg, - $allowSelfRegProf, - $loginForm, - $passForm -) { + string $installType, + string $urlForm, + string $languageForm, + string $emailForm, + string $adminFirstName, + string $adminLastName, + string $adminPhoneForm, + string $campusForm, + string $institutionForm, + string $institutionUrlForm, + string $encryptPassForm, + string $allowSelfReg, + string $allowSelfRegProf, + string $loginForm, + string $passForm +): array { if ('update' !== $installType && empty($languageForm)) { $languageForm = $_SESSION['install_language']; } - echo '
    '; - echo '

    '.display_step_sequence().get_lang('Configuration settings').'

    '; - echo '
    '; - - // Parameter 1: administrator's login - if ('update' === $installType) { - $rootSys = get_config_param('root_web'); - $html = display_configuration_parameter( - $installType, - get_lang('Chamilo URL'), - 'loginForm', - $rootSys, - true - ); - $rootSys = get_config_param('root_sys'); - $html .= display_configuration_parameter( - $installType, - get_lang('Path'), - 'loginForm', - $rootSys, - true - ); - $systemVersion = get_config_param('system_version'); - $html .= display_configuration_parameter( - $installType, - get_lang('Version'), - 'loginForm', - $systemVersion, - true - ); - echo Display::panel($html, get_lang('System')); - } - - $html = display_configuration_parameter( - $installType, - get_lang('Administrator login'), - 'loginForm', - $loginForm, - 'update' == $installType - ); - - // Parameter 2: administrator's password - if ('update' !== $installType) { - $html .= display_configuration_parameter( - $installType, - get_lang('Administrator password (you may want to change this)'), - 'passForm', - $passForm, - false - ); - } - // Parameters 3 and 4: administrator's names - $html .= display_configuration_parameter( - $installType, - get_lang('Administrator first name'), - 'adminFirstName', - $adminFirstName - ); - $html .= display_configuration_parameter( - $installType, - get_lang('Administrator last name'), - 'adminLastName', - $adminLastName - ); - - // Parameter 3: administrator's email - $html .= display_configuration_parameter($installType, get_lang('Admin-mail'), 'emailForm', $emailForm); - - // Parameter 6: administrator's telephone - $html .= display_configuration_parameter( - $installType, - get_lang('Administrator telephone'), - 'adminPhoneForm', - $adminPhoneForm - ); - echo Display::panel($html, get_lang('Administrator')); + $stepData = []; - // First parameter: language. - $html = '
    '; - $html .= ''; if ('update' === $installType) { - $html .= ''. - $languageForm; - } else { - $html .= '
    '; - $html .= display_language_selection_box('languageForm', $languageForm); - $html .= '
    '; - } - $html .= '
    '; - - // Second parameter: Chamilo URL - if ('install' === $installType) { - $html .= '
    '; - $html .= ''; - $html .= '
    '; - $html .= ''; - $html .= '
    '; - - $html .= '
    '; - } - - // Parameter 9: campus name - $html .= display_configuration_parameter( - $installType, - get_lang('Your portal name'), - 'campusForm', - $campusForm - ); - - // Parameter 10: institute (short) name - $html .= display_configuration_parameter( - $installType, - get_lang('Your company short name'), - 'institutionForm', - $institutionForm - ); - - // Parameter 11: institute (short) name - $html .= display_configuration_parameter( - $installType, - get_lang('URL of this company'), - 'institutionUrlForm', - $institutionUrlForm - ); - - $html .= '
    - -
    '; - if ('update' === $installType) { - $html .= ''.$encryptPassForm; - } else { - $html .= '
    - '; - - $html .= ''; - - $html .= ''; - - $html .= ''; - $html .= '
    '; - } - $html .= '
    '; - - $html .= '
    - -
    '; - if ('update' === $installType) { - if ('true' === $allowSelfReg) { - $label = get_lang('Yes'); - } elseif ('false' === $allowSelfReg) { - $label = get_lang('No'); - } else { - $label = get_lang('After approval'); - } - $html .= ''.$label; - } else { - $html .= '
    '; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= '
    '; - } - $html .= '
    '; - $html .= '
    '; - - $html .= '
    '; - $html .= ' -
    '; - if ('update' === $installType) { - if ('true' === $allowSelfRegProf) { - $label = get_lang('Yes'); - } else { - $label = get_lang('No'); - } - $html .= ''.$label; - } else { - $html .= '
    - '; - $html .= ''; - $html .= '
    '; - } - $html .= '
    -
    '; - echo Display::panel($html, get_lang('Portal')); ?> -
    - - - -
    - get('translator'); - $html = '
    '. - $trans->trans( - 'When you enter your portal for the first time, the best way to understand it is to create a course with the \'Create course\' link in the menu and play around a little.').'
    '; - $html .= '
    '; - $html .= ''.$trans->trans('Security advice').''; - $html .= ': '; - $html .= sprintf($trans->trans( - 'To protect your site, make the whole %s directory read-only (chmod -R 0555 on Linux) and delete the %s directory.'), 'var/config/', 'main/install/'); - $html .= '
    -
    - - '.$trans->trans('Go to your newly created portal.').' - '; - - return $html; + $stepData['rootWeb'] = get_config_param('root_web'); + $stepData['rootSys'] = get_config_param('root_sys'); + $stepData['systemVersion'] = get_config_param('system_version'); + } + + $stepData['loginForm'] = $loginForm; + $stepData['passForm'] = $passForm; + $stepData['adminFirstName'] = $adminFirstName; + $stepData['adminLastName'] = $adminLastName; + $stepData['emailForm'] = $emailForm; + $stepData['adminPhoneForm'] = $adminPhoneForm; + $stepData['languageForm'] = $languageForm; + $stepData['urlForm'] = $urlForm; + $stepData['campusForm'] = $campusForm; + $stepData['institutionForm'] = $institutionForm; + $stepData['institutionUrlForm'] = $institutionUrlForm; + $stepData['encryptPassForm'] = $encryptPassForm; + $stepData['allowSelfReg'] = $allowSelfReg; + $stepData['allowSelfRegProf'] = $allowSelfRegProf; + + return $stepData; } /** @@ -1794,15 +1168,15 @@ function get_countries_list_from_array($combo = false) 'Yemen', 'Zambia', 'Zimbabwe', ]; + $options = array_combine($a_countries, $a_countries); if ($combo) { - $country_select = ''; - - return $country_select; + return Display::select( + 'country', + $options + ['' => get_lang('Select one')], + '', + ['id' => 'country'], + false + ); } return $a_countries; @@ -1851,23 +1225,15 @@ function updateDirAndFilesPermissions() } } -/** - * @param $current_value - * @param $wanted_value - * - * @return string - */ -function compare_setting_values($current_value, $wanted_value) +function compare_setting_values(string $current_value, string $wanted_value): array { $current_value_string = $current_value; $current_value = (float) $current_value; $wanted_value = (float) $wanted_value; - if ($current_value >= $wanted_value) { - return Display::label($current_value_string, 'success'); - } - - return Display::label($current_value_string, 'important'); + return $current_value >= $wanted_value + ? ['severity' => 'success', 'value' => $current_value_string] + : ['severity' => 'danger', 'value' => $current_value_string]; } /** @@ -2341,25 +1707,20 @@ function generateRandomToken() * This function checks if the given file can be created or overwritten. * * @param string $file Full path to a file - * - * @return string An HTML coloured label showing success or failure */ -function checkCanCreateFile($file) +function checkCanCreateFile(string $file): bool { if (file_exists($file)) { - if (is_writable($file)) { - return Display::label(get_lang('Writable'), 'success'); - } else { - return Display::label(get_lang('Not writable'), 'important'); - } - } else { - $write = @file_put_contents($file, ''); - if (false !== $write) { - unlink($file); + return is_writable($file); + } - return Display::label(get_lang('Writable'), 'success'); - } else { - return Display::label(get_lang('Not writable'), 'important'); - } + $write = @file_put_contents($file, ''); + + if (false !== $write) { + unlink($file); + + return true; } + + return false; } diff --git a/webpack.config.js b/webpack.config.js index bc2d214a35..e22768ea08 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -25,6 +25,7 @@ Encore .addEntry('free-jqgrid', './assets/js/free-jqgrid.js') .addEntry('lp', './assets/js/lp.js') .addEntry('vue', './assets/vue/main.js') + .addEntry('vue_installer', './assets/vue/main_installer.js') .addEntry('translatehtml', './assets/js/translatehtml.js') .addEntry('document', './assets/js/document.js')