diff --git a/custompages/README.md b/custompages/README.md new file mode 100644 index 000000000..e0c2bea50 --- /dev/null +++ b/custompages/README.md @@ -0,0 +1,24 @@ +Custom pages +============= + +CustomPages looks for alternatives in this directory, and displays them if present. +The user-provided custom pages must exactly be named as such : + +- index-logged.php for the general landing page before login +- index-unlogged.php for the general landing page when already logged-in +- registration.php for the registration form +- registration-feedback.php for the registration success feedback +- lostpassword.php for the password recovery form + + +### Installation + +- Enable the use_custom_pages setting +- Create your own modifications based in the files with the suffix "-dist.php" + +### Important notes + +- Do not replace the images in the images/ directory. + Instead, create new images, as the current ones will be overwritten + by each Chamilo upgrade. + diff --git a/custompages/first_login-dist.php b/custompages/first_login-dist.php new file mode 100644 index 000000000..3e8909aaa --- /dev/null +++ b/custompages/first_login-dist.php @@ -0,0 +1,118 @@ + + + + + Custompage - login + + + + + +
+ +
+
+ +

+ +
+
+ '.$error_message.'
'; +}?> +
+
+ +
+ +
+
+
+
+ +
+
+ + + + diff --git a/custompages/images/footer.png b/custompages/images/footer.png new file mode 100644 index 000000000..2cedac601 Binary files /dev/null and b/custompages/images/footer.png differ diff --git a/custompages/images/header.png b/custompages/images/header.png new file mode 100644 index 000000000..127265a6e Binary files /dev/null and b/custompages/images/header.png differ diff --git a/custompages/images/login-form-submit-bg.jpg b/custompages/images/login-form-submit-bg.jpg new file mode 100644 index 000000000..19fec4a2a Binary files /dev/null and b/custompages/images/login-form-submit-bg.jpg differ diff --git a/custompages/images/page-background.png b/custompages/images/page-background.png new file mode 100644 index 000000000..c897ca158 Binary files /dev/null and b/custompages/images/page-background.png differ diff --git a/custompages/index-logged-dist.php b/custompages/index-logged-dist.php new file mode 100644 index 000000000..eee64f469 --- /dev/null +++ b/custompages/index-logged-dist.php @@ -0,0 +1,15 @@ +assign('error', $error_message); +} + +$flash = Display::getFlashToString(); +Display::cleanFlashMessages(); + +if (api_get_setting('allow_registration') === 'true') { + $urlRegister = api_get_path(WEB_CODE_PATH).'auth/inscription.php?language='.api_get_interface_language(); + $template->assign('url_register', $urlRegister); +} +$urlLostPassword = api_get_path(WEB_CODE_PATH).'auth/lostPassword.php?language='.api_get_interface_language(); +$template->assign('url_lost_password', $urlLostPassword); +$template->assign('mgs_flash', $flash); + +$layout = $template->get_template('custompage/login.tpl'); +$content = $template->fetch($layout); +$template->assign('content', $content); +$template->display_blank_template(); diff --git a/custompages/language.inc.php b/custompages/language.inc.php new file mode 100644 index 000000000..ce3bc9843 --- /dev/null +++ b/custompages/language.inc.php @@ -0,0 +1,53 @@ + + * This requires the Chamilo system to be initialized + * (note that it's easier to do the following include in the parent page). + * + * @package chamilo.custompages + */ +/** + * Returns the best match between available languages and visitor preferences. + * + * @return string the best match as 2-chars code, null when none match + */ +function get_preferred_language($available_langs) +{ + // Parsing the Accept-languages HTTP header + $langs = []; + foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $httplang) { + $rawlang = explode(';q=', $httplang); + if (strpos($rawlang[0], '-') !== false) { + // We ignore the locale part, as in en-GB vs en-US + $rawlang[0] = substr($rawlang[0], 0, strpos($rawlang[0], '-')); + } + if (count($rawlang) == 1) { + $rawlang[1] = 1.0; // The absence of weighting means a weight of 1 (max) + } + $langs[$rawlang[1]][] = $rawlang[0]; + } + krsort($langs, SORT_NUMERIC); + // Choosing the best match + foreach ($langs as $weight => $codes) { + foreach ($codes as $code) { + if (in_array($code, $available_langs)) { + return $code; + } + } + } + + // No match + return null; +} + +/** + * Get a language variable in a specific language. + */ +function custompages_get_lang($variable) +{ + return get_lang($variable, null, $_SESSION['user_language_choice']); +} diff --git a/custompages/language.php b/custompages/language.php new file mode 100644 index 000000000..e7258bab6 --- /dev/null +++ b/custompages/language.php @@ -0,0 +1,50 @@ + 'english', + 'en' => 'english', + 'fr' => 'french', + 'nl' => 'dutch', + 'de' => 'german', + 'es' => 'spanish', + 'gl' => 'galician', + 'eu' => 'basque', +]; +$lang_match = $chamilo_langs[get_preferred_language($available_langs)]; +// recover previous value ... +if (isset($_SESSION['user_language_choice'])) { + $lang_match = $_SESSION['user_language_choice']; +} + +// Chamilo parameter, on logout +if (isset($_REQUEST['language']) && !empty($_REQUEST['language']) && in_array($_REQUEST['language'], $chamilo_langs)) { + $lang_match = $_REQUEST['language']; +} +// Incoming link parameter +if (isset($_REQUEST['lang']) && !empty($_REQUEST['lang']) && in_array($_REQUEST['lang'], $available_langs)) { + $lang_match = $chamilo_langs[$_REQUEST['lang']]; +} + +$detect = api_get_setting('auto_detect_language_custom_pages'); +if ($detect === 'true') { + // Auto detect + $_user['language'] = $lang_match; + $_SESSION['user_language_choice'] = $lang_match; +} else { + // Chamilo default platform. + $defaultLanguage = api_get_interface_language(); + $_user['language'] = $defaultLanguage; + $_SESSION['user_language_choice'] = $defaultLanguage; +} diff --git a/custompages/loggedout-dist.php b/custompages/loggedout-dist.php new file mode 100644 index 000000000..b90b8235b --- /dev/null +++ b/custompages/loggedout-dist.php @@ -0,0 +1,54 @@ + + + + + Custompage - logged out + + + + + +
+ background +
+
+ + +
+
+ You have been logged out. +
+
+ Go to your portal + +
+ + diff --git a/custompages/lostpassword-dist.php b/custompages/lostpassword-dist.php new file mode 100644 index 000000000..8b8d08f50 --- /dev/null +++ b/custompages/lostpassword-dist.php @@ -0,0 +1,23 @@ +assign('error'); +$template->assign('form', $content['form']); +$layout = $template->get_template('custompage/lostpassword.tpl'); +$content = $template->fetch($layout); +$template->assign('content', $content); +$template->display_blank_template(); diff --git a/custompages/registration-dist.php b/custompages/registration-dist.php new file mode 100644 index 000000000..06449d5c6 --- /dev/null +++ b/custompages/registration-dist.php @@ -0,0 +1,36 @@ +_elementIndex['extra_mail_notify_invitation'])) { + $content['form']->removeElement('extra_mail_notify_invitation'); +} +if (isset($content['form']->_elementIndex['extra_mail_notify_message'])) { + $content['form']->removeElement('extra_mail_notify_message'); +} +if (isset($content['form']->_elementIndex['extra_mail_notify_group_message'])) { + $content['form']->removeElement('extra_mail_notify_group_message'); +} +$content['form']->removeElement('official_code'); +$content['form']->removeElement('phone'); + +$template->assign('form', $content['form']->returnForm()); +$layout = $template->get_template('custompage/registration.tpl'); +$content = $template->fetch($layout); +$template->assign('content', $content); +$template->display_blank_template(); diff --git a/custompages/registration-feedback-dist.php b/custompages/registration-feedback-dist.php new file mode 100644 index 000000000..b0b8671a0 --- /dev/null +++ b/custompages/registration-feedback-dist.php @@ -0,0 +1,48 @@ + + + + <?php echo custompages_get_lang('Registration'); ?> + + + + + + + +
+
+
+
+
+ +
+ +
+ +
+
+
+
+
+ + diff --git a/custompages/url-images/README b/custompages/url-images/README new file mode 100644 index 000000000..543a49d0c --- /dev/null +++ b/custompages/url-images/README @@ -0,0 +1,5 @@ +Custom Pages : URL Images + +This features allows each access URL to have a number of images (currently three) specific to this URL. This allows easier customization of landing pages by access URL. + +You can access a URL's images by calling the static function CustomPages::getURLImages() in your custom page.