improvement for custom pages, with template

pull/3619/head
Alex Aragon 5 years ago
parent 3c1b201b8c
commit 7d62ad717b
  1. 23
      app/Resources/public/css/base.css
  2. 83
      app/Resources/public/css/themes/chamilo/custompage.css
  3. BIN
      app/Resources/public/css/themes/chamilo/images/favicon.png
  4. 146
      app/Resources/public/css/themes/chamilo/images/header-logo.svg
  5. 114
      custompages/index-unlogged-dist.php
  6. 54
      custompages/lostpassword-dist.php
  7. 112
      custompages/registration-dist.php
  8. BIN
      favicon.png
  9. 4
      main/auth/inscription.php
  10. 13
      main/auth/lostPassword.php
  11. 225
      main/img/icons/svg/favicon.svg
  12. 1
      main/inc/lib/api.lib.php
  13. 410
      main/inc/lib/formvalidator/FormValidator.class.php
  14. 2
      main/inc/lib/pear/HTML/QuickForm/button.php
  15. 2
      main/inc/lib/pear/HTML/QuickForm/select.php
  16. 3
      main/inc/lib/pear/HTML/QuickForm/text.php
  17. 14
      main/inc/lib/template.lib.php
  18. 48
      main/template/default/custompage/login.tpl
  19. 17
      main/template/default/custompage/lostpassword.tpl
  20. 18
      main/template/default/custompage/registration.tpl

@ -46,7 +46,6 @@ body {
margin-bottom: 60px; margin-bottom: 60px;
} }
.footer { .footer {
position: absolute;
bottom: 0; bottom: 0;
width: 100%; width: 100%;
/* Set the fixed height of the footer here */ /* Set the fixed height of the footer here */
@ -8351,10 +8350,6 @@ ul#toolnavbox-two li a.btn {
border-top: none !important; border-top: none !important;
} }
.page-blank {
padding: 20px 30px;
}
/* groups social */ /* groups social */
.group-tool { .group-tool {
padding: 10px; padding: 10px;
@ -9453,10 +9448,24 @@ ul.dropdown-menu.inner > li > a {
} }
.compilation_block .progress { .compilation_block .progress {
margin:0px; margin:0;
width:120px width:120px
} }
#registration .form_list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));;
}
#registration .form_list .form-group{
margin: 10px;
}
#registration .form_list > *:nth-child(3n-2):nth-last-of-type(2) {
border-color: red;
grid-column: span 2;
}
#registration .form_list > *:nth-child(3n-1):nth-last-of-type(1) {
border-color: red;
grid-column: span 2;
}
/* CSS Responsive */ /* CSS Responsive */
@media (min-width: 1025px) and (max-width: 1200px) { @media (min-width: 1025px) and (max-width: 1200px) {
.sidebar-scorm { .sidebar-scorm {

@ -0,0 +1,83 @@
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700;1,900&display=swap');
:root {
--primary-color: #486F88;
--success-color: #16D090;
}
body, html {
height: 100%;
}
body {
margin: 0;
line-height: 1.5;
color: #212529;
background-color: #fff;
font-family: 'Lato', sans-serif;
}
.custompage .limiter {
width: 100%;
margin: 0 auto;
}
.custompage .container-login {
width: 100%;
min-height: 100vh;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
padding: 15px;
background: #f2f2f2;
}
.custompage .wrap-login {
background: #fff;
border-radius: 10px;
padding: 30px 45px;
box-shadow: 0 12px 26px rgba(16, 30, 115, 0.06);
}
.custompage .width-login{
width: 390px;
}
.custompage .width-register{
width: 690px;
}
.custompage h3.title, legend{
font-weight: 900;
font-size: 24px;
color: #486F88;
padding: 1rem 0;
}
.custompage label{
color: #486F88;
font-weight: 400;
}
.custompage .form-control,
.custompage .bootstrap-select .dropdown-toggle.btn-default{
border: 2px solid #B3C8D7;
}
.custompage .last-password{
padding: 2.5rem 0;
text-align: center;
}
.btn-primary {
color: #fff;
background-color: var(--primary-color);
border-color: var(--primary-color);;
text-transform: uppercase;
font-weight: bold;
}
.btn-success {
color: #fff;
background-color: var(--success-color);
border-color: var(--success-color);
text-transform: uppercase;
font-weight: bold;
}
.custompage .software-name{
text-align: center;
padding: 2rem 0;
margin-top: 1rem;
display: inline-block;
width: 100%;
font-size: 12px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

@ -8,6 +8,9 @@
require_once api_get_path(SYS_PATH).'main/inc/global.inc.php'; require_once api_get_path(SYS_PATH).'main/inc/global.inc.php';
require_once __DIR__.'/language.php'; require_once __DIR__.'/language.php';
$template = new Template(get_lang('SignIn'),false,false,false,false,true,true);
/** /**
* Homemade micro-controller. * Homemade micro-controller.
*/ */
@ -15,107 +18,42 @@ if (isset($_GET['loginFailed'])) {
if (isset($_GET['error'])) { if (isset($_GET['error'])) {
switch ($_GET['error']) { switch ($_GET['error']) {
case 'account_expired': case 'account_expired':
$error_message = custompages_get_lang('AccountExpired'); $error_message = get_lang('AccountExpired');
break; break;
case 'account_inactive': case 'account_inactive':
$error_message = custompages_get_lang('AccountInactive'); $error_message = get_lang('AccountInactive');
break; break;
case 'user_password_incorrect': case 'user_password_incorrect':
$error_message = custompages_get_lang('InvalidId'); $error_message = get_lang('InvalidId');
break; break;
case 'access_url_inactive': case 'access_url_inactive':
$error_message = custompages_get_lang('AccountURLInactive'); $error_message = get_lang('AccountURLInactive');
break; break;
default: default:
$error_message = custompages_get_lang('InvalidId'); $error_message = get_lang('InvalidId');
} }
} else { } else {
$error_message = get_lang('InvalidId'); $error_message = get_lang('InvalidId');
} }
} }
$rootWeb = api_get_path('WEB_PATH'); if (isset($error_message)) {
$template->assign('error', $error_message);
/** }
* HTML output.
*/
?>
<html>
<head>
<title>Custompage - login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="<?php echo $rootWeb; ?>web/assets/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $rootWeb; ?>web/assets/flag-icon-css/css/flag-icon.min.css" />
<script type="text/javascript" src="<?php echo $rootWeb; ?>web/assets/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo $rootWeb; ?>web/assets/bootstrap/dist/js/bootstrap.min.js"></script>
<script>
$(document).ready(function() {
if (top.location != location) {
top.location.href = document.location.href;
}
// Handler pour la touche retour
$('input').keyup(function(e) {
if (e.keyCode == 13) {
$('#login-form').submit();
}
});
});
</script>
</head>
<body>
<div id="backgroundimage">
<img src="<?php echo api_get_path(WEB_PATH); ?>/custompages/images/page-background.png" class="backgroundimage" />
</div>
<div id="wrapper">
<div id="header">
<img src="<?php echo api_get_path(WEB_PATH); ?>/custompages/images/header.png" alt="Logo" />
</div> <!-- #header -->
<div id="login-form-box" class="form-box">
<div id="login-form-info" class="form-info">
<?php
echo Display::getFlashToString();
Display::cleanFlashMessages();
if (isset($content['info']) && !empty($content['info'])) {
echo $content['info'];
}
?>
</div>
<?php if (isset($error_message)) {
echo '<div id="login-form-info" class="form-error">'.$error_message.'</div>';
}
?>
<form id="login-form" class="form" action="<?php echo api_get_path(WEB_PATH); ?>index.php" method="post">
<div>
<label for="login">*<?php echo custompages_get_lang('User'); ?></label>
<input name="login" type="text" /><br />
<label for="password">*<?php echo custompages_get_lang('Password'); ?></label>
<input name="password" type="password" /><br />
</div>
</form>
<div id="login-form-submit" class="form-submit" onclick="document.forms['login-form'].submit();">
<span><?php echo custompages_get_lang('LoginEnter'); ?></span>
</div> <!-- #form-submit -->
<div id="links">
<?php if (api_get_setting('allow_registration') === 'true') { $flash = Display::getFlashToString();
?> Display::cleanFlashMessages();
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>auth/inscription.php?language=<?php echo api_get_interface_language(); ?>">
<?php echo custompages_get_lang('Registration'); ?>
</a><br />
<?php
} ?>
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>auth/lostPassword.php?language=<?php echo api_get_interface_language(); ?>"> if (api_get_setting('allow_registration') === 'true') {
<?php echo custompages_get_lang('LostPassword'); ?> $urlRegister = api_get_path(WEB_CODE_PATH).'auth/inscription.php?language='.api_get_interface_language();
</a> $template->assign('url_register', $urlRegister);
</div> }
</div> <!-- #form --> $urlLostPassword = api_get_path(WEB_CODE_PATH).'auth/lostPassword.php?language='.api_get_interface_language();
<div id="footer"> $template->assign('url_lost_password', $urlLostPassword);
<img src="<?php echo api_get_path(WEB_PATH); ?>/custompages/images/footer.png" /> $template->assign('mgs_flash', $flash);
</div> <!-- #footer --> $template->assign('section_name', $this_section);
</div> <!-- #wrapper -->
</body> $layout = $template->get_template('custompage/login.tpl');
</html> $content = $template->fetch($layout);
$template->assign('content', $content);
$template->display_blank_template();

@ -8,48 +8,16 @@
require_once api_get_path(SYS_PATH).'main/inc/global.inc.php'; require_once api_get_path(SYS_PATH).'main/inc/global.inc.php';
require_once __DIR__.'/language.php'; require_once __DIR__.'/language.php';
$rootWeb = api_get_path('WEB_PATH'); $template = new Template(get_lang('LostPassword'),false,false,false,false,true,true);
?>
<html>
<head>
<title><?php echo custompages_get_lang('LostPassword'); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="<?php echo $rootWeb; ?>web/assets/jquery/dist/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $rootWeb; ?>web/assets/bootstrap/dist/css/bootstrap.min.css" /> $error = null;
<script type="text/javascript" src="<?php echo $rootWeb; ?>web/assets/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript"> if (isset($content['info']) && !empty($content['info'])) {
$(document).ready(function() { $error = $content['info'];
// Handler pour la touche retour }
$('input').keyup(function(e) { $template->assign('error');
if (e.keyCode == 13) { $template->assign('form', $content['form']);
$('#lostpassword-form').submit(); $layout = $template->get_template('custompage/lostpassword.tpl');
} $content = $template->fetch($layout);
}); $template->assign('content', $content);
}); $template->display_blank_template();
</script>
</head>
<body>
<div id="backgroundimage">
<img src="/custompages/images/page-background.png" class="backgroundimage" />
</div>
<div id="wrapper">
<div id="header">
<img src="../../custompages/images/header.png" alt="Ambassador logo" />
</div> <!-- #header -->
<div id="lostpassword-form-box" class="form-box">
<?php
if (isset($content['info']) && !empty($content['info'])) {
echo '<div id="registration-form-error" class="form-error"><ul>'.$content['info'].'</ul></div>';
}
echo isset($content['form']) ? $content['form'] : '';
?>
</div> <!-- #form -->
<div id="footer">
<img src="../../custompages/images/footer.png" />
</div> <!-- #footer -->
</div> <!-- #wrapper -->
</body>
</html>

@ -10,6 +10,9 @@
*/ */
require_once api_get_path(SYS_PATH).'main/inc/global.inc.php'; require_once api_get_path(SYS_PATH).'main/inc/global.inc.php';
require_once __DIR__.'/language.php'; require_once __DIR__.'/language.php';
$template = new Template(get_lang('Registration'),false,false,false,false,true,true);
/** /**
* Removes some unwanted elementend of the form object. * Removes some unwanted elementend of the form object.
* 03-26-2020 Added check if element exist. * 03-26-2020 Added check if element exist.
@ -23,104 +26,11 @@ if (isset($content['form']->_elementIndex['extra_mail_notify_message'])) {
if (isset($content['form']->_elementIndex['extra_mail_notify_group_message'])) { if (isset($content['form']->_elementIndex['extra_mail_notify_group_message'])) {
$content['form']->removeElement('extra_mail_notify_group_message'); $content['form']->removeElement('extra_mail_notify_group_message');
} }
$content['form']->removeElement('official_code');
if (isset($content['form']->_elementIndex['status'])) { $content['form']->removeElement('phone');
$content['form']->removeElement('status');
$content['form']->removeElement('status'); $template->assign('form', $content['form']->returnForm());
} $layout = $template->get_template('custompage/registration.tpl');
$rootWeb = api_get_path('WEB_PATH'); $content = $template->fetch($layout);
$template->assign('content', $content);
// Deprecated since 2015-03-26 $template->display_blank_template();
/**
* Code to change the way QuickForm render html.
*/
/*
$renderer = & $content['form']->defaultRenderer();
$form_template = <<<EOT
<form {attributes}>
{content}
<div class="clear">
&nbsp;
</div>
<p><a href="#" class="btn btn-primary" onclick="$('#registration-form').submit()"><span>S'inscrire</span></a></p>
</form>
EOT;
$renderer->setFormTemplate($form_template);
$element_template = <<<EOT
<div class="field decalle">
<label>
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}
</label>
<div class="formw">
<!-- BEGIN error --><span class="form_error">{error}</span><br /><!-- END error --> {element}
</div>
</div>
EOT;
$element_template_wimage = <<<EOT
<div class="field decalle display">
<label>
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}
</label>
<div class="formw">
<!-- BEGIN error --><span class="form_error">{error}</span><br /><!-- END error --> {element}
<img src="/custompages/images/perso.jpg" alt="" />
</div>
</div>
EOT;
$renderer->setElementTemplate($element_template_wimage,'pass1');
$renderer->setElementTemplate($element_template);
$header_template = <<<EOT
<div class="row">
<div class="form_header">{header}</div>
</div>
EOT;
*/
?>
<html>
<head>
<title><?php echo custompages_get_lang('Registration'); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript" src="<?php echo $rootWeb; ?>web/assets/jquery/dist/jquery.min.js"></script>
</head>
<body>
<img id="backgroundimage" src="/custompages/images/page-background.png"">
<section id="registration">
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="form-wrap">
<div class="logo">
<img src="/custompages/images/header.png">
</div>
<?php if (isset($content['error']) && !empty($content['error'])) {
echo '<div id="registration-form-error" class="alert alert-danger">'.$content['error'].'</div>';
}?>
<div id="registration-form-box" class="form-box">
<div class="block-form-login">
<?php
$content['form']->display();
?>
</div>
<div id="links">
<!--<a href="mailto: support@cblue.be"><?php echo custompages_get_lang('NeedContactAdmin'); ?></a><br />-->
</div>
</div>
<div id="footer">
<img src="/custompages/images/footer.png" />
</div> <!-- #footer -->
</div>
</div>
</div>
</div>
</section>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -73,7 +73,7 @@ if ($extraConditions && isset($extraConditions['conditions'])) {
} }
} }
$form = new FormValidator('registration'); $form = new FormValidator('registration','post','','',[],FormValidator::LAYOUT_GRID);
$user_already_registered_show_terms = false; $user_already_registered_show_terms = false;
if (api_get_setting('allow_terms_conditions') === 'true') { if (api_get_setting('allow_terms_conditions') === 'true') {
$user_already_registered_show_terms = isset($_SESSION['term_and_condition']['user_id']); $user_already_registered_show_terms = isset($_SESSION['term_and_condition']['user_id']);
@ -623,7 +623,7 @@ if ($allowDoubleValidation && $showTerms == false) {
$user_already_registered_show_terms || $user_already_registered_show_terms ||
$showTerms $showTerms
) { ) {
$form->addButtonNext(get_lang('RegisterUser')); $form->addButton('register',get_lang('RegisterUser'),null,'primary','btn-block');
$formContainsSendButton = true; $formContainsSendButton = true;
} }
} }

@ -34,15 +34,6 @@ $tool_name = get_lang('LostPassword');
if ($reset && $userId) { if ($reset && $userId) {
$messageText = Login::reset_password($reset, $userId, true); $messageText = Login::reset_password($reset, $userId, true);
/*if (CustomPages::enabled() && CustomPages::exists(CustomPages::INDEX_UNLOGGED)) {
CustomPages::display(
CustomPages::INDEX_UNLOGGED,
['info' => $messageText]
);
exit;
}*/
Display::addFlash( Display::addFlash(
Display::return_message($messageText, 'info', false) Display::return_message($messageText, 'info', false)
); );
@ -50,7 +41,7 @@ if ($reset && $userId) {
exit; exit;
} }
$form = new FormValidator('lost_password'); $form = new FormValidator('lost_password','post','','',[],FormValidator::LAYOUT_GRID);
$form->addHeader($tool_name); $form->addHeader($tool_name);
$form->addText( $form->addText(
'user', 'user',
@ -91,7 +82,7 @@ if ($allowCaptcha) {
$form->addRule('captcha', get_lang('TheTextYouEnteredDoesNotMatchThePicture'), 'CAPTCHA', $captcha_question); $form->addRule('captcha', get_lang('TheTextYouEnteredDoesNotMatchThePicture'), 'CAPTCHA', $captcha_question);
} }
$form->addButtonSend(get_lang('Send')); $form->addButtonSend(get_lang('Send'),'submit',false,[],'btn-block',null);
if ($form->validate()) { if ($form->validate()) {
$values = $form->exportValues(); $values = $form->exportValues();

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 113 KiB

@ -164,6 +164,7 @@ define('SECTION_DASHBOARD', 'dashboard');
define('SECTION_REPORTS', 'reports'); define('SECTION_REPORTS', 'reports');
define('SECTION_GLOBAL', 'global'); define('SECTION_GLOBAL', 'global');
define('SECTION_INCLUDE', 'include'); define('SECTION_INCLUDE', 'include');
define('SECTION_CUSTOMPAGE', 'custompage');
// CONSTANT name for local authentication source // CONSTANT name for local authentication source
define('PLATFORM_AUTH_SOURCE', 'platform'); define('PLATFORM_AUTH_SOURCE', 'platform');

@ -19,13 +19,13 @@ class FormValidator extends HTML_QuickForm
/** /**
* Constructor. * Constructor.
* *
* @param string $name Name of the form * @param string $name Name of the form
* @param string $method (optional) Method ('post' (default) or 'get') * @param string $method (optional) Method ('post' (default) or 'get')
* @param string $action (optional) Action (default is $PHP_SELF) * @param string $action (optional) Action (default is $PHP_SELF)
* @param string $target (optional) Form's target defaults to '_self' * @param string $target (optional) Form's target defaults to '_self'
* @param mixed $attributes (optional) Extra attributes for <form> tag * @param mixed $attributes (optional) Extra attributes for <form> tag
* @param string $layout * @param string $layout
* @param bool $trackSubmit (optional) Whether to track if the form was * @param bool $trackSubmit (optional) Whether to track if the form was
* submitted by adding a special hidden field (default = true) * submitted by adding a special hidden field (default = true)
*/ */
public function __construct( public function __construct(
@ -36,7 +36,8 @@ class FormValidator extends HTML_QuickForm
$attributes = [], $attributes = [],
$layout = self::LAYOUT_HORIZONTAL, $layout = self::LAYOUT_HORIZONTAL,
$trackSubmit = true $trackSubmit = true
) { )
{
// Default form class. // Default form class.
if (is_array($attributes) && !isset($attributes['class']) || empty($attributes)) { if (is_array($attributes) && !isset($attributes['class']) || empty($attributes)) {
$attributes['class'] = 'form-horizontal'; $attributes['class'] = 'form-horizontal';
@ -102,7 +103,7 @@ class FormValidator extends HTML_QuickForm
//Set required field template //Set required field template
$this->setRequiredNote( $this->setRequiredNote(
'<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>' '<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>'
); );
$noteTemplate = <<<EOT $noteTemplate = <<<EOT
@ -133,15 +134,7 @@ EOT;
{ {
return ' return '
<style> <style>
.form_list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));;
grid-gap: 10px 30px;
gap: 10px 30px;
}
.form_list .input-group {
display:block;
}
</style> </style>
<form{attributes}> <form{attributes}>
<div class="form_list"> <div class="form_list">
@ -152,9 +145,9 @@ EOT;
} }
/** /**
* @return string
* @todo this function should be added in the element class * @todo this function should be added in the element class
* *
* @return string
*/ */
public function getDefaultElementTemplate() public function getDefaultElementTemplate()
{ {
@ -203,10 +196,10 @@ EOT;
* Adds a text field to the form. * Adds a text field to the form.
* A trim-filter is attached to the field. * A trim-filter is attached to the field.
* *
* @param string|array $label The label for the form-element * @param string|array $label The label for the form-element
* @param string $name The element name * @param string $name The element name
* @param bool $required (optional) Is the form-element required (default=true) * @param bool $required (optional) Is the form-element required (default=true)
* @param array $attributes (optional) List of attributes for the form-element * @param array $attributes (optional) List of attributes for the form-element
* *
* @return HTML_QuickForm_text * @return HTML_QuickForm_text
*/ */
@ -244,14 +237,14 @@ EOT;
* *
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param bool $required * @param bool $required
* @param array $attributes * @param array $attributes
*/ */
public function addDateRangePicker($name, $label, $required = true, $attributes = []) public function addDateRangePicker($name, $label, $required = true, $attributes = [])
{ {
$this->addElement('date_range_picker', $name, $label, $attributes); $this->addElement('date_range_picker', $name, $label, $attributes);
$this->addElement('hidden', $name.'_start'); $this->addElement('hidden', $name . '_start');
$this->addElement('hidden', $name.'_end'); $this->addElement('hidden', $name . '_end');
if ($required) { if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required'); $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
@ -261,7 +254,7 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param array $attributes * @param array $attributes
* *
* @return DatePicker * @return DatePicker
*/ */
@ -273,7 +266,7 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param array $attributes * @param array $attributes
* *
* @return mixed * @return mixed
*/ */
@ -285,12 +278,12 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param array $options * @param array $options
* @param array $attributes * @param array $attributes
* *
* @return HTML_QuickForm_element
* @throws Exception * @throws Exception
* *
* @return HTML_QuickForm_element
*/ */
public function addSelectAjax($name, $label, $options = [], $attributes = []) public function addSelectAjax($name, $label, $options = [], $attributes = [])
{ {
@ -308,9 +301,9 @@ EOT;
} }
/** /**
* @param string $name * @param string $name
* @param string|array $label * @param string|array $label
* @param array $attributes * @param array $attributes
* *
* @return DateTimePicker * @return DateTimePicker
*/ */
@ -320,9 +313,9 @@ EOT;
} }
/** /**
* @param string $name * @param string $name
* @param string|array $label * @param string|array $label
* @param array $attributes * @param array $attributes
* *
* @return DateTimeRangePicker * @return DateTimeRangePicker
*/ */
@ -334,7 +327,7 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param string $value * @param string $value
* @param array $attributes * @param array $attributes
*/ */
public function addHidden($name, $value, $attributes = []) public function addHidden($name, $value, $attributes = [])
{ {
@ -342,10 +335,10 @@ EOT;
} }
/** /**
* @param string $name * @param string $name
* @param string|array $label * @param string|array $label
* @param array $attributes * @param array $attributes
* @param bool $required * @param bool $required
* *
* @return HTML_QuickForm_textarea * @return HTML_QuickForm_textarea
*/ */
@ -363,12 +356,12 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param string $icon font-awesome * @param string $icon font-awesome
* @param string $style default|primary|success|info|warning|danger|link * @param string $style default|primary|success|info|warning|danger|link
* @param string $size large|default|small|extra-small * @param string $size large|default|small|extra-small
* @param string $class Example plus is transformed to icon fa fa-plus * @param string $class Example plus is transformed to icon fa fa-plus
* @param array $attributes * @param array $attributes
* @param bool $createElement * @param bool $createElement
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -381,7 +374,8 @@ EOT;
$class = null, $class = null,
$attributes = [], $attributes = [],
$createElement = false $createElement = false
) { )
{
if ($createElement) { if ($createElement) {
return $this->createElement( return $this->createElement(
'button', 'button',
@ -410,9 +404,9 @@ EOT;
/** /**
* Returns a button with the primary color and a check mark. * Returns a button with the primary color and a check mark.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -433,9 +427,9 @@ EOT;
/** /**
* Returns a cancel button. * Returns a cancel button.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -456,10 +450,10 @@ EOT;
/** /**
* Returns a button with the primary color and a "plus" icon. * Returns a button with the primary color and a "plus" icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* @param array $attributes Additional attributes * @param array $attributes Additional attributes
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -480,9 +474,9 @@ EOT;
/** /**
* Returns a button with the primary color and a pencil icon. * Returns a button with the primary color and a pencil icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -503,9 +497,9 @@ EOT;
/** /**
* Returns a button with the danger color and a trash icon. * Returns a button with the danger color and a trash icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -526,9 +520,9 @@ EOT;
/** /**
* Returns a move style button. * Returns a move style button.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -549,22 +543,23 @@ EOT;
/** /**
* Returns a button with the primary color and a paper-plane icon. * Returns a button with the primary color and a paper-plane icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* @param array $attributes * @param array $attributes
* * @param $size
* @param $class
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
public function addButtonSend($label, $name = 'submit', $createElement = false, $attributes = []) public function addButtonSend($label, $name = 'submit', $createElement = false, $attributes = [], $size, $class)
{ {
return $this->addButton( return $this->addButton(
$name, $name,
$label, $label,
'paper-plane', 'paper-plane',
'primary', 'primary',
null, $size,
null, $class,
$attributes, $attributes,
$createElement $createElement
); );
@ -574,7 +569,7 @@ EOT;
* Returns a button with the default (grey?) color and a magnifier icon. * Returns a button with the default (grey?) color and a magnifier icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -590,9 +585,9 @@ EOT;
/** /**
* Returns a button with the primary color and a right-pointing arrow icon. * Returns a button with the primary color and a right-pointing arrow icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param array $attributes Additional attributes * @param array $attributes Additional attributes
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -612,9 +607,9 @@ EOT;
/** /**
* Returns a button with the primary color and a check mark icon. * Returns a button with the primary color and a check mark icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -635,9 +630,9 @@ EOT;
/** /**
* Returns a button with the primary color and a check-mark icon. * Returns a button with the primary color and a check-mark icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -658,9 +653,9 @@ EOT;
/** /**
* Shortcut to filter button. * Shortcut to filter button.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -681,9 +676,9 @@ EOT;
/** /**
* Shortcut to reset button. * Shortcut to reset button.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -723,9 +718,9 @@ EOT;
/** /**
* Returns a button with the primary color and an upload icon. * Returns a button with the primary color and an upload icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -746,9 +741,9 @@ EOT;
/** /**
* Returns a button with the primary color and a download icon. * Returns a button with the primary color and a download icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -769,9 +764,9 @@ EOT;
/** /**
* Returns a button with the primary color and a magnifier icon. * Returns a button with the primary color and a magnifier icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -792,9 +787,9 @@ EOT;
/** /**
* Returns a button with the primary color and a copy (double sheet) icon. * Returns a button with the primary color and a copy (double sheet) icon.
* *
* @param string $label Text appearing on the button * @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes) * @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method * @param bool $createElement Whether to use the create or add method
* *
* @return HTML_QuickForm_button * @return HTML_QuickForm_button
*/ */
@ -816,7 +811,7 @@ EOT;
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param string $text * @param string $text
* @param array $attributes * @param array $attributes
* *
* @return HTML_QuickForm_checkbox * @return HTML_QuickForm_checkbox
*/ */
@ -828,8 +823,8 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param array $options * @param array $options
* @param array $attributes * @param array $attributes
* *
* @return HTML_QuickForm_group * @return HTML_QuickForm_group
*/ */
@ -853,8 +848,8 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param array $options * @param array $options
* @param array $attributes * @param array $attributes
* *
* @return HTML_QuickForm_group * @return HTML_QuickForm_group
*/ */
@ -873,9 +868,9 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param mixed $label String, or array if form element with a comment * @param mixed $label String, or array if form element with a comment
* @param array $options * @param array $options
* @param array $attributes * @param array $attributes
* *
* @return HTML_QuickForm_select * @return HTML_QuickForm_select
*/ */
@ -888,9 +883,9 @@ EOT;
* @param $name * @param $name
* @param $label * @param $label
* @param $collection * @param $collection
* @param array $attributes * @param array $attributes
* @param bool $addNoneOption * @param bool $addNoneOption
* @param string $textCallable set a function getStringValue() by default __toString() * @param string $textCallable set a function getStringValue() by default __toString()
* *
* @return HTML_QuickForm_element * @return HTML_QuickForm_element
*/ */
@ -901,7 +896,8 @@ EOT;
$attributes = [], $attributes = [],
$addNoneOption = false, $addNoneOption = false,
$textCallable = '' $textCallable = ''
) { )
{
$options = []; $options = [];
if ($addNoneOption) { if ($addNoneOption) {
@ -924,7 +920,7 @@ EOT;
/** /**
* @param string $label * @param string $label
* @param string $text * @param string $text
* @param bool $createElement * @param bool $createElement
* *
* @return HTML_QuickForm_Element * @return HTML_QuickForm_Element
*/ */
@ -954,11 +950,11 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param array $attributes * @param array $attributes
* *
* @return HTML_QuickForm_file
* @throws Exception if the file doesn't have an id * @throws Exception if the file doesn't have an id
* *
* @return HTML_QuickForm_file
*/ */
public function addFile($name, $label, $attributes = []) public function addFile($name, $label, $attributes = [])
{ {
@ -970,19 +966,19 @@ EOT;
} }
$this->addHtml( $this->addHtml(
' '
<div class="form-group" id="'.$id.'-form-group" style="display: none;"> <div class="form-group" id="' . $id . '-form-group" style="display: none;">
<div class="col-sm-offset-2 col-sm-8"> <div class="col-sm-offset-2 col-sm-8">
<div id="'.$id.'_crop_image" class="cropCanvas thumbnail"> <div id="' . $id . '_crop_image" class="cropCanvas thumbnail">
<img id="'.$id.'_preview_image"> <img id="' . $id . '_preview_image">
</div> </div>
<button class="btn btn-primary" type="button" name="cropButton" id="'.$id.'_crop_button"> <button class="btn btn-primary" type="button" name="cropButton" id="' . $id . '_crop_button">
<em class="fa fa-crop"></em> '.get_lang('CropYourPicture').' <em class="fa fa-crop"></em> ' . get_lang('CropYourPicture') . '
</button> </button>
</div> </div>
</div>' </div>'
); );
$this->addHidden($id.'_crop_result', ''); $this->addHidden($id . '_crop_result', '');
$this->addHidden($id.'_crop_image_base_64', ''); $this->addHidden($id . '_crop_image_base_64', '');
} }
return $element; return $element;
@ -1004,25 +1000,25 @@ EOT;
/** /**
* Draws a panel of options see the course_info/infocours.php page. * Draws a panel of options see the course_info/infocours.php page.
* *
* @param string $name internal name * @param string $name internal name
* @param string $title visible title * @param string $title visible title
* @param array $groupList list of group or elements * @param array $groupList list of group or elements
*/ */
public function addPanelOption($name, $title, $groupList) public function addPanelOption($name, $title, $groupList)
{ {
$this->addHtml('<div class="panel panel-default">'); $this->addHtml('<div class="panel panel-default">');
$this->addHtml( $this->addHtml(
' '
<div class="panel-heading" role="tab" id="heading-'.$name.'-settings"> <div class="panel-heading" role="tab" id="heading-' . $name . '-settings">
<h4 class="panel-title"> <h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion"
href="#collapse-'.$name.'-settings" aria-expanded="false" aria-controls="collapse-'.$name.'-settings"> href="#collapse-' . $name . '-settings" aria-expanded="false" aria-controls="collapse-' . $name . '-settings">
' '
); );
$this->addHtml($title); $this->addHtml($title);
$this->addHtml('</a></h4></div>'); $this->addHtml('</a></h4></div>');
$this->addHtml('<div id="collapse-'.$name.'-settings" class="panel-collapse collapse" role="tabpanel" $this->addHtml('<div id="collapse-' . $name . '-settings" class="panel-collapse collapse" role="tabpanel"
aria-labelledby="heading-'.$name.'-settings"> aria-labelledby="heading-' . $name . '-settings">
<div class="panel-body"> <div class="panel-body">
'); ');
@ -1044,11 +1040,11 @@ EOT;
/** /**
* Adds a HTML-editor to the form. * Adds a HTML-editor to the form.
* *
* @param string $name * @param string $name
* @param string|array $label The label for the form-element * @param string|array $label The label for the form-element
* @param bool $required (optional) Is the form-element required (default=true) * @param bool $required (optional) Is the form-element required (default=true)
* @param bool $fullPage (optional) When it is true, the editor loads completed html code for a full page * @param bool $fullPage (optional) When it is true, the editor loads completed html code for a full page
* @param array $config (optional) Configuration settings for the online editor * @param array $config (optional) Configuration settings for the online editor
*/ */
public function addHtmlEditor( public function addHtmlEditor(
$name, $name,
@ -1056,7 +1052,8 @@ EOT;
$required = true, $required = true,
$fullPage = false, $fullPage = false,
$config = [] $config = []
) { )
{
$attributes = []; $attributes = [];
$attributes['rows'] = isset($config['rows']) ? $config['rows'] : 15; $attributes['rows'] = isset($config['rows']) ? $config['rows'] : 15;
$attributes['cols'] = isset($config['cols']) ? $config['cols'] : 80; $attributes['cols'] = isset($config['cols']) ? $config['cols'] : 80;
@ -1102,8 +1099,8 @@ EOT;
if ($geolocalization && $gMapsPlugin->javascriptIncluded === false) { if ($geolocalization && $gMapsPlugin->javascriptIncluded === false) {
$gmapsApiKey = $gMapsPlugin->get('api_key'); $gmapsApiKey = $gMapsPlugin->get('api_key');
$url = '//maps.googleapis.com/maps/api/js?key='.$gmapsApiKey; $url = '//maps.googleapis.com/maps/api/js?key=' . $gmapsApiKey;
$this->addHtml('<script type="text/javascript" src="'.$url.'" ></script>'); $this->addHtml('<script type="text/javascript" src="' . $url . '" ></script>');
$gMapsPlugin->javascriptIncluded = true; $gMapsPlugin->javascriptIncluded = true;
} }
@ -1115,9 +1112,9 @@ EOT;
); );
$this->addHidden( $this->addHidden(
$name.'_coordinates', $name . '_coordinates',
'', '',
['id' => $name.'_coordinates'] ['id' => $name . '_coordinates']
); );
$this->applyFilter($name, 'stripslashes'); $this->applyFilter($name, 'stripslashes');
@ -1162,16 +1159,16 @@ EOT;
$this->with_progress_bar = true; $this->with_progress_bar = true;
$id = $this->getAttribute('id'); $id = $this->getAttribute('id');
$this->updateAttributes("onsubmit=\"javascript: addProgress('".$id."')\""); $this->updateAttributes("onsubmit=\"javascript: addProgress('" . $id . "')\"");
$this->addHtml('<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>'); $this->addHtml('<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>');
} }
/** /**
* This function has been created for avoiding changes directly within QuickForm class. * This function has been created for avoiding changes directly within QuickForm class.
* When we use it, the element is threated as 'required' to be dealt during validation. * When we use it, the element is threated as 'required' to be dealt during validation.
* *
* @param array $elements The array of elements * @param array $elements The array of elements
* @param string $message The message displayed * @param string $message The message displayed
*/ */
public function add_multiple_required_rule($elements, $message) public function add_multiple_required_rule($elements, $message)
{ {
@ -1203,7 +1200,7 @@ EOT;
$element->setLayout($this->getLayout()); $element->setLayout($this->getLayout());
$elementError = parent::getElementError($element->getName()); $elementError = parent::getElementError($element->getName());
if (!is_null($elementError)) { if (!is_null($elementError)) {
$returnValue .= Display::return_message($elementError, 'warning').'<br />'; $returnValue .= Display::return_message($elementError, 'warning') . '<br />';
break; break;
} }
} }
@ -1214,7 +1211,7 @@ EOT;
if (isset($this->with_progress_bar) && $this->with_progress_bar) { if (isset($this->with_progress_bar) && $this->with_progress_bar) {
// @todo improve UI // @todo improve UI
$returnValue .= '<br /> $returnValue .= '<br />
<div id="loading_div_'.$id.'" class="loading_div" style="display:none;margin-left:40%; margin-top:10px; height:50px;"> <div id="loading_div_' . $id . '" class="loading_div" style="display:none;margin-left:40%; margin-top:10px; height:50px;">
<div class="wobblebar-loader"></div> <div class="wobblebar-loader"></div>
</div> </div>
'; ';
@ -1253,10 +1250,10 @@ EOT;
/** /**
* Adds a input of type url to the form. * Adds a input of type url to the form.
* *
* @param string $name The label for the form-element * @param string $name The label for the form-element
* @param string $label The element name * @param string $label The element name
* @param bool $required Optional. Is the form-element required (default=true) * @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element * @param array $attributes Optional. List of attributes for the form-element
*/ */
public function addUrl($name, $label, $required = true, $attributes = []) public function addUrl($name, $label, $required = true, $attributes = [])
{ {
@ -1273,17 +1270,18 @@ EOT;
* Adds a text field for letters to the form. * Adds a text field for letters to the form.
* A trim-filter is attached to the field. * A trim-filter is attached to the field.
* *
* @param string $name The element name * @param string $name The element name
* @param string $label The label for the form-element * @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true) * @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element * @param array $attributes Optional. List of attributes for the form-element
*/ */
public function addTextLettersOnly( public function addTextLettersOnly(
$name, $name,
$label, $label,
$required = false, $required = false,
$attributes = [] $attributes = []
) { )
{
$attributes = array_merge( $attributes = array_merge(
$attributes, $attributes,
[ [
@ -1319,8 +1317,8 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param array $attributes * @param array $attributes
* @param bool $required * @param bool $required
* *
* @return HTML_QuickForm_element * @return HTML_QuickForm_element
*/ */
@ -1339,17 +1337,18 @@ EOT;
* Adds a text field for alphanumeric characters to the form. * Adds a text field for alphanumeric characters to the form.
* A trim-filter is attached to the field. * A trim-filter is attached to the field.
* *
* @param string $name The element name * @param string $name The element name
* @param string $label The label for the form-element * @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true) * @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element * @param array $attributes Optional. List of attributes for the form-element
*/ */
public function addTextAlphanumeric( public function addTextAlphanumeric(
$name, $name,
$label, $label,
$required = false, $required = false,
$attributes = [] $attributes = []
) { )
{
$attributes = array_merge( $attributes = array_merge(
$attributes, $attributes,
[ [
@ -1385,11 +1384,11 @@ EOT;
/** /**
* @param string $name * @param string $name
* @param $label * @param $label
* @param bool $required * @param bool $required
* @param array $attributes * @param array $attributes
* @param bool $allowNegative * @param bool $allowNegative
* @param int $minValue * @param int $minValue
* @param null $maxValue * @param null $maxValue
*/ */
public function addFloat( public function addFloat(
$name, $name,
@ -1399,7 +1398,8 @@ EOT;
$allowNegative = false, $allowNegative = false,
$minValue = null, $minValue = null,
$maxValue = null $maxValue = null
) { )
{
$this->addElement( $this->addElement(
'FloatNumber', 'FloatNumber',
$name, $name,
@ -1465,17 +1465,18 @@ EOT;
* Adds a text field for letters and spaces to the form. * Adds a text field for letters and spaces to the form.
* A trim-filter is attached to the field. * A trim-filter is attached to the field.
* *
* @param string $name The element name * @param string $name The element name
* @param string $label The label for the form-element * @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true) * @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element * @param array $attributes Optional. List of attributes for the form-element
*/ */
public function addTextLettersAndSpaces( public function addTextLettersAndSpaces(
$name, $name,
$label, $label,
$required = false, $required = false,
$attributes = [] $attributes = []
) { )
{
$attributes = array_merge( $attributes = array_merge(
$attributes, $attributes,
[ [
@ -1512,17 +1513,18 @@ EOT;
* Adds a text field for alphanumeric and spaces characters to the form. * Adds a text field for alphanumeric and spaces characters to the form.
* A trim-filter is attached to the field. * A trim-filter is attached to the field.
* *
* @param string $name The element name * @param string $name The element name
* @param string $label The label for the form-element * @param string $label The label for the form-element
* @param bool $required Optional. Is the form-element required (default=true) * @param bool $required Optional. Is the form-element required (default=true)
* @param array $attributes Optional. List of attributes for the form-element * @param array $attributes Optional. List of attributes for the form-element
*/ */
public function addTextAlphanumericAndSpaces( public function addTextAlphanumericAndSpaces(
$name, $name,
$label, $label,
$required = false, $required = false,
$attributes = [] $attributes = []
) { )
{
$attributes = array_merge( $attributes = array_merge(
$attributes, $attributes,
[ [
@ -1566,17 +1568,17 @@ EOT;
$this->addHtml(' $this->addHtml('
<div class="description-upload"> <div class="description-upload">
'.get_lang('ClickToSelectOrDragAndDropMultipleFilesOnTheUploadField').' ' . get_lang('ClickToSelectOrDragAndDropMultipleFilesOnTheUploadField') . '
</div> </div>
<span class="btn btn-success fileinput-button"> <span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i> <i class="glyphicon glyphicon-plus"></i>
<span>'.get_lang('AddFiles').'</span> <span>' . get_lang('AddFiles') . '</span>
<!-- The file input field used as target for the file upload widget --> <!-- The file input field used as target for the file upload widget -->
<input id="'.$inputName.'" type="file" name="files[]" multiple> <input id="' . $inputName . '" type="file" name="files[]" multiple>
</span> </span>
<div id="dropzone"> <div id="dropzone">
<div class="button-load"> <div class="button-load">
'.get_lang('UploadFiles').' ' . get_lang('UploadFiles') . '
</div> </div>
</div> </div>
<br /> <br />
@ -1590,7 +1592,7 @@ EOT;
/** /**
* @param string $elementName * @param string $elementName
* @param string $groupName if element is inside a group * @param string $groupName if element is inside a group
* *
* @throws Exception * @throws Exception
*/ */
@ -1598,7 +1600,7 @@ EOT;
{ {
// Constant defined in old config/profile.conf.php // Constant defined in old config/profile.conf.php
if (CHECK_PASS_EASY_TO_FIND === true) { if (CHECK_PASS_EASY_TO_FIND === true) {
$message = get_lang('PassTooEasy').': '.api_generate_password(); $message = get_lang('PassTooEasy') . ': ' . api_generate_password();
if (!empty($groupName)) { if (!empty($groupName)) {
$groupObj = $this->getElement($groupName); $groupObj = $this->getElement($groupName);
@ -1634,14 +1636,14 @@ EOT;
* Add an element with user ID and avatar to the form. * Add an element with user ID and avatar to the form.
* It needs a Chamilo\UserBundle\Entity\User as value. The exported value is the Chamilo\UserBundle\Entity\User ID. * It needs a Chamilo\UserBundle\Entity\User as value. The exported value is the Chamilo\UserBundle\Entity\User ID.
* *
* @see \UserAvatar
*
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param string $imageSize Optional. Small, medium or large image * @param string $imageSize Optional. Small, medium or large image
* @param string $subtitle Optional. The subtitle for the field * @param string $subtitle Optional. The subtitle for the field
* *
* @return \UserAvatar * @return \UserAvatar
* @see \UserAvatar
*
*/ */
public function addUserAvatar($name, $label, $imageSize = 'small', $subtitle = '') public function addUserAvatar($name, $label, $imageSize = 'small', $subtitle = '')
{ {
@ -1670,18 +1672,18 @@ EOT;
} }
} }
$url = api_get_path(WEB_AJAX_PATH).'mail.ajax.php?a=select_option'; $url = api_get_path(WEB_AJAX_PATH) . 'mail.ajax.php?a=select_option';
$typeNoDots = 'email_template_option_'.str_replace('.tpl', '', $type); $typeNoDots = 'email_template_option_' . str_replace('.tpl', '', $type);
$this->addSelect( $this->addSelect(
'email_template_option['.$type.']', 'email_template_option[' . $type . ']',
$name, $name,
$options, $options,
['id' => $typeNoDots] ['id' => $typeNoDots]
); );
$templateNoDots = 'email_template_'.str_replace('.tpl', '', $type); $templateNoDots = 'email_template_' . str_replace('.tpl', '', $type);
$templateNoDotsBlock = 'email_template_block_'.str_replace('.tpl', '', $type); $templateNoDotsBlock = 'email_template_block_' . str_replace('.tpl', '', $type);
$this->addHtml('<div id="'.$templateNoDotsBlock.'" style="display:none">'); $this->addHtml('<div id="' . $templateNoDotsBlock . '" style="display:none">');
$this->addTextarea( $this->addTextarea(
$templateNoDots, $templateNoDots,
get_lang('Preview'), get_lang('Preview'),
@ -1723,7 +1725,7 @@ EOT;
} }
/** /**
* @param string $url page that will handle the upload * @param string $url page that will handle the upload
* @param string $inputName * @param string $inputName
* @param string $urlToRedirect * @param string $urlToRedirect
*/ */
@ -1738,25 +1740,25 @@ EOT;
<script> <script>
$(function () { $(function () {
'use strict'; 'use strict';
$('#".$this->getAttribute('id')."').submit(function() { $('#" . $this->getAttribute('id') . "').submit(function() {
return false; return false;
}); });
$('#dropzone').on('click', function() { $('#dropzone').on('click', function() {
$('#".$inputName."').click(); $('#" . $inputName . "').click();
}); });
var url = '".$url."'; var url = '" . $url . "';
var uploadButton = $('<button/>') var uploadButton = $('<button/>')
.addClass('btn btn-primary') .addClass('btn btn-primary')
.prop('disabled', true) .prop('disabled', true)
.text('".addslashes(get_lang('Loading'))."') .text('" . addslashes(get_lang('Loading')) . "')
.on('click', function () { .on('click', function () {
var \$this = $(this), var \$this = $(this),
data = \$this.data(); data = \$this.data();
\$this \$this
.off('click') .off('click')
.text('".addslashes(get_lang('Cancel'))."') .text('" . addslashes(get_lang('Cancel')) . "')
.on('click', function () { .on('click', function () {
\$this.remove(); \$this.remove();
data.abort(); data.abort();
@ -1766,7 +1768,7 @@ EOT;
}); });
}); });
$('#".$inputName."').fileupload({ $('#" . $inputName . "').fileupload({
url: url, url: url,
dataType: 'json', dataType: 'json',
// Enable image resizing, except for Android and Opera, // Enable image resizing, except for Android and Opera,
@ -1790,7 +1792,7 @@ EOT;
if (file.preview) { if (file.preview) {
data.context.prepend($('<div class=\"col-sm-4\">').html(file.preview)); data.context.prepend($('<div class=\"col-sm-4\">').html(file.preview));
} else { } else {
data.context.prepend($('<div class=\"col-sm-4\">').html('".$icon."')); data.context.prepend($('<div class=\"col-sm-4\">').html('" . $icon . "'));
} }
if (index + 1 === data.files.length) { if (index + 1 === data.files.length) {
data.context.find('button') data.context.find('button')
@ -1827,15 +1829,15 @@ EOT;
// Update file name with new one from Chamilo // Update file name with new one from Chamilo
$(data.context.children()[index]).parent().find('.file_name').html(file.name); $(data.context.children()[index]).parent().find('.file_name').html(file.name);
var message = $('<div class=\"col-sm-3\">').html( var message = $('<div class=\"col-sm-3\">').html(
$('<span class=\"message-image-success\"/>').text('".addslashes(get_lang('UplUploadSucceeded'))."') $('<span class=\"message-image-success\"/>').text('" . addslashes(get_lang('UplUploadSucceeded')) . "')
); );
$(data.context.children()[index]).parent().append(message); $(data.context.children()[index]).parent().append(message);
}); });
$('#dropzone').removeClass('hover'); $('#dropzone').removeClass('hover');
".$redirectCondition." " . $redirectCondition . "
}).on('fileuploadfail', function (e, data) { }).on('fileuploadfail', function (e, data) {
$.each(data.files, function (index) { $.each(data.files, function (index) {
var failedMessage = '".addslashes(get_lang('UplUploadFailed'))."'; var failedMessage = '" . addslashes(get_lang('UplUploadFailed')) . "';
var error = $('<div class=\"col-sm-3\">').html( var error = $('<div class=\"col-sm-3\">').html(
$('<span class=\"alert alert-danger\"/>').text(failedMessage) $('<span class=\"alert alert-danger\"/>').text(failedMessage)
); );
@ -1862,7 +1864,7 @@ EOT;
* Cleans HTML text filter. * Cleans HTML text filter.
* *
* @param string $html HTML to clean * @param string $html HTML to clean
* @param int $mode (optional) * @param int $mode (optional)
* *
* @return string The cleaned HTML * @return string The cleaned HTML
*/ */

@ -254,7 +254,7 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
case FormValidator::LAYOUT_GRID: case FormValidator::LAYOUT_GRID:
case FormValidator::LAYOUT_BOX_NO_LABEL: case FormValidator::LAYOUT_BOX_NO_LABEL:
default: default:
$template = ' {element} '; $template = '<div class="form-group"> {element} </div>';
break; break;
} }

@ -611,7 +611,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
case FormValidator::LAYOUT_GRID: case FormValidator::LAYOUT_GRID:
case FormValidator::LAYOUT_BOX: case FormValidator::LAYOUT_BOX:
return ' return '
<div class="input-group" style="z-index: auto"> <div class="form-group">
<label>{label}</label> <label>{label}</label>
{icon} {icon}
{element} {element}

@ -119,6 +119,9 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
{label} {label}
</label> </label>
{element} {element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
</div>'; </div>';
break; break;
case FormValidator::LAYOUT_HORIZONTAL: case FormValidator::LAYOUT_HORIZONTAL:

@ -662,6 +662,12 @@ class Template
$css[] = api_get_path(WEB_CSS_PATH).$this->themeDir.'learnpath.css'; $css[] = api_get_path(WEB_CSS_PATH).$this->themeDir.'learnpath.css';
} }
} }
if (CustomPages::enabled()) {
$cssCustomPage = api_get_path(SYS_CSS_PATH) . $this->themeDir . "custompage.css";
if (is_file($cssCustomPage)) {
$css[] = api_get_path(WEB_CSS_PATH) . $this->themeDir . 'custompage.css';
}
}
$css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).$this->themeDir.'default.css'); $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).$this->themeDir.'default.css');
$css[] = api_get_cdn_path(ChamiloApi::getEditorBlockStylePath()); $css[] = api_get_cdn_path(ChamiloApi::getEditorBlockStylePath());
@ -1833,14 +1839,14 @@ class Template
private function assignFavIcon() private function assignFavIcon()
{ {
// Default root chamilo favicon // Default root chamilo favicon
$favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />'; $favico = '<link rel="icon" href="'.api_get_path(WEB_PATH).'favicon.png" type="image/png" />';
//Added to verify if in the current Chamilo Theme exist a favicon //Added to verify if in the current Chamilo Theme exist a favicon
$favicoThemeUrl = api_get_path(SYS_CSS_PATH).$this->themeDir.'images/'; $favicoThemeUrl = api_get_path(SYS_CSS_PATH).$this->themeDir.'images/';
//If exist pick the current chamilo theme favicon //If exist pick the current chamilo theme favicon
if (is_file($favicoThemeUrl.'favicon.ico')) { if (is_file($favicoThemeUrl.'favicon.png')) {
$favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_CSS_PATH).$this->themeDir.'images/favicon.ico" type="image/x-icon" />'; $favico = '<link rel="icon" href="'.api_get_path(WEB_CSS_PATH).$this->themeDir.'images/favicon.png" type="image/png" />';
} }
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
@ -1857,7 +1863,7 @@ class Template
$icon_real_homep = api_get_path(SYS_HOME_PATH).$clean_url; $icon_real_homep = api_get_path(SYS_HOME_PATH).$clean_url;
//we create the new dir for the new sites //we create the new dir for the new sites
if (is_file($icon_real_homep.'favicon.ico')) { if (is_file($icon_real_homep.'favicon.ico')) {
$favico = '<link rel="shortcut icon" href="'.$homep.'favicon.ico" type="image/x-icon" />'; $favico = '<link rel="icon" href="'.$homep.'favicon.png" type="image/png" />';
} }
} }
} }

@ -0,0 +1,48 @@
<div class="custompage">
<div class="limiter">
<div class="container-login">
<div class="wrap-login width-login">
<form class="login100-form validate-form" action="{{ _p.web }}" method="post">
<div class="logo">
<img width="250px" class="img-responsive" title="{{ _s.site_name }}" src="{{ _p.web_css_theme }}images/header-logo.svg">
</div>
<h3 class="title">{{ 'Login'|get_lang() }}</h3>
{{ mgs_flash }}
{% if error %}
<div class="alert alert-warning" role="alert">
{{ error }}
</div>
{% endif %}
<div class="form-group">
<label for="user">{{ 'LoginOrEmailAddress'|get_lang() }}</label>
<input type="text" class="form-control" id="user" name="login" ">
</div>
<div class="form-group">
<label for="password">{{ 'Password'|get_lang() }}</label>
<input type="password" class="form-control" name="password" id="password" >
</div>
<button type="submit" class="btn btn-primary btn-block">
{{ 'LoginEnter'|get_lang() }}
</button>
{% if url_register %}
<a href="{{ url_register }}" class="btn btn-success btn-block" >
{{ 'Registration'|get_lang() }}
</a >
{% endif %}
<div class="last-password">
<a href="{{ url_lost_password }}">
{{ 'LostPassword'|get_lang() }}
</a>
</div>
</form>
<div class="software-name">
<a href="{{_p.web}}" target="_blank">
{{ "PoweredByX" |get_lang | format(_s.software_name) }}
</a>&copy; {{ "now"|date("Y") }}
</div>
</div>
</div>
</div>
</div>

@ -0,0 +1,17 @@
<div class="custompage">
<div class="limiter">
<div class="container-login">
<div class="wrap-login width-register">
<div class="logo">
<img width="250px" class="img-responsive" title="{{ _s.site_name }}" src="{{ _p.web_css_theme }}images/header-logo.svg">
</div>
{{ form }}
<div class="software-name">
<a href="{{_p.web}}" target="_blank">
{{ "PoweredByX" |get_lang | format(_s.software_name) }}
</a>&copy; {{ "now"|date("Y") }}
</div>
</div>
</div>
</div>
</div>

@ -0,0 +1,18 @@
<div class="custompage">
<div class="limiter">
<div class="container-login">
<div class="wrap-login width-register">
<div class="logo">
<img width="250px" class="img-responsive" title="{{ _s.site_name }}" src="{{ _p.web_css_theme }}images/header-logo.svg">
</div>
<h3 class="title">{{ 'UserRegistrationTitle'|get_lang() }}</h3>
{{ form }}
<div class="software-name">
<a href="{{_p.web}}" target="_blank">
{{ "PoweredByX" |get_lang | format(_s.software_name) }}
</a>&copy; {{ "now"|date("Y") }}
</div>
</div>
</div>
</div>
</div>
Loading…
Cancel
Save