Update form/table styles WIP

pull/3890/head
Julio Montoya 4 years ago
parent c2cc7f4548
commit cdc9a9c322
  1. 3
      public/main/admin/course_edit.php
  2. 2
      public/main/admin/index.php
  3. 8
      public/main/admin/user_edit.php
  4. 2
      public/main/inc/lib/display.lib.php
  5. 52
      public/main/inc/lib/formvalidator/Element/DatePicker.php
  6. 53
      public/main/inc/lib/formvalidator/Element/DateTimePicker.php
  7. 64
      public/main/inc/lib/formvalidator/FormValidator.class.php
  8. 11
      public/main/inc/lib/pear/HTML/QuickForm/advanced_settings.php
  9. 53
      public/main/inc/lib/pear/HTML/QuickForm/advmultiselect.php
  10. 20
      public/main/inc/lib/pear/HTML/QuickForm/button.php
  11. 68
      public/main/inc/lib/pear/HTML/QuickForm/checkbox.php
  12. 103
      public/main/inc/lib/pear/HTML/QuickForm/element.php
  13. 96
      public/main/inc/lib/pear/HTML/QuickForm/file.php
  14. 88
      public/main/inc/lib/pear/HTML/QuickForm/group.php
  15. 15
      public/main/inc/lib/pear/HTML/QuickForm/input.php
  16. 10
      public/main/inc/lib/pear/HTML/QuickForm/radio.php
  17. 81
      public/main/inc/lib/pear/HTML/QuickForm/select.php
  18. 127
      public/main/inc/lib/pear/HTML/QuickForm/text.php
  19. 81
      public/main/inc/lib/pear/HTML/QuickForm/textarea.php
  20. 26
      public/main/inc/lib/pear/HTML/Table.php
  21. 14
      public/main/inc/lib/pear/Pager/Common.php
  22. 10
      public/main/inc/lib/sessionmanager.lib.php
  23. 59
      public/main/inc/lib/sortable_table.class.php

@ -509,7 +509,6 @@ function valide() {
} }
</script>"; </script>";
// Display the form
$form->display(); $form->display();
Display :: display_footer(); Display::display_footer();

@ -200,7 +200,7 @@ if (api_is_platform_admin()) {
$searchForm = new FormValidator( $searchForm = new FormValidator(
'search_session', 'search_session',
'GET', 'GET',
api_get_path(WEB_CODE_PATH).'admin/session_list.php', $sessionPath.'session_list.php',
null, null,
null, null,
FormValidator::LAYOUT_BOX_SEARCH FormValidator::LAYOUT_BOX_SEARCH

@ -537,14 +537,8 @@ $content = Display::toolbarAction('toolbar-user-information', [implode(PHP_EOL,
$bigImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL); $bigImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL);
$normalImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG); $normalImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG);
$content .= '<div class="row">';
$content .= '<div class="col-md-10">';
// Display form
$content .= $form->returnForm(); $content .= $form->returnForm();
$content .= '</div>';
$content .= '<div class="col-md-2">';
$content .= '<a class="thumbnail expand-image" href="'.$bigImage.'" /><img src="'.$normalImage.'" /></a>';
$content .= '</div>';
$tpl = new Template($tool_name); $tpl = new Template($tool_name);
$tpl->assign('content', $content); $tpl->assign('content', $content);

@ -2547,7 +2547,7 @@ class Display
{ {
$col = count($contentList); $col = count($contentList);
$html = ' <div id="'.$id.'" class="q-card">'; $html = ' <div id="'.$id.'" class="q-card">';
$html .= ' <div class="flex justify-between '.$col.'">'; $html .= ' <div class="flex justify-between mb-3 '.$col.'">';
foreach ($contentList as $item) { foreach ($contentList as $item) {
$html .= '<div class=" flex p-3 gap-2 ">'.$item.'</div>'; $html .= '<div class=" flex p-3 gap-2 ">'.$item.'</div>';
} }

@ -72,58 +72,6 @@ class DatePicker extends HTML_QuickForm_text
); );
} }
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '
<div class="form-group {error_class}">
<label {label-for} >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
{element}
</div>';
break;
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="form-group row {error_class}">
<label {label-for} class="col-sm-'.$size[0].' col-form-label {extra_label_class}" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size[1].'">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline help-block">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
</div>
</div>';
break;
case FormValidator::LAYOUT_BOX_NO_LABEL:
return '{element}';
break;
}
}
/** /**
* Get the necessary javascript for this datepicker. * Get the necessary javascript for this datepicker.
* *

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
@ -91,58 +92,6 @@ class DateTimePicker extends HTML_QuickForm_text
$this->updateAttributes(['value' => $value]); $this->updateAttributes(['value' => $value]);
} }
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '
<div class="form-group {error_class}">
<label {label-for} >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
{element}
</div>';
break;
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="form-group row {error_class}">
<label {label-for} class="col-sm-'.$size[0].' col-form-label {extra_label_class}" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size[1].'">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline help-block">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
</div>
</div>';
break;
case FormValidator::LAYOUT_BOX_NO_LABEL:
return '{element}';
break;
}
}
/** /**
* Get the necessary javascript for this datepicker. * Get the necessary javascript for this datepicker.
* *

@ -38,7 +38,7 @@ class FormValidator extends HTML_QuickForm
) { ) {
// 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 q-pt-md';
} }
if (isset($attributes['class']) && false !== strpos($attributes['class'], 'form-search')) { if (isset($attributes['class']) && false !== strpos($attributes['class'], 'form-search')) {
@ -52,13 +52,18 @@ class FormValidator extends HTML_QuickForm
switch ($layout) { switch ($layout) {
case self::LAYOUT_HORIZONTAL: case self::LAYOUT_HORIZONTAL:
$attributes['class'] = 'form-horizontal'; $attributes['class'] = 'w-full ';
break;
case self::LAYOUT_BOX_SEARCH:
$attributes['class'] = 'w-full flex gap-2';
$formTemplate = $this->getInLineTemplate();
break; break;
case self::LAYOUT_INLINE: case self::LAYOUT_INLINE:
$attributes['class'] = 'form-inline'; $attributes['class'] = ' flex gap-1 ';
$formTemplate = $this->getInLineTemplate();
break; break;
case self::LAYOUT_BOX: case self::LAYOUT_BOX:
$attributes['class'] = 'form-inline-box'; $attributes['class'] = 'flex gap-1 ';
break; break;
case self::LAYOUT_GRID: case self::LAYOUT_GRID:
$attributes['class'] = 'form-grid'; $attributes['class'] = 'form-grid';
@ -70,11 +75,12 @@ class FormValidator extends HTML_QuickForm
// Modify the default templates // Modify the default templates
$renderer = &$this->defaultRenderer(); $renderer = &$this->defaultRenderer();
$renderer->setFormTemplate($formTemplate); $renderer->setFormTemplate($formTemplate);
// Element template // Element template
if (isset($attributes['class']) && 'form-inline' === $attributes['class']) { if ((isset($attributes['class']) && 'form-inline' === $attributes['class']) ||
(self::LAYOUT_INLINE === $layout || self::LAYOUT_BOX_SEARCH === $layout)
) {
$elementTemplate = ' {label} {element} '; $elementTemplate = ' {label} {element} ';
$renderer->setElementTemplate($elementTemplate); $renderer->setElementTemplate($elementTemplate);
} elseif (isset($attributes['class']) && 'form-search' === $attributes['class']) { } elseif (isset($attributes['class']) && 'form-search' === $attributes['class']) {
@ -97,12 +103,14 @@ class FormValidator extends HTML_QuickForm
} }
//Set Header template //Set Header template
$renderer->setHeaderTemplate('<legend>{header}</legend>'); $renderer->setHeaderTemplate(' <h1 class="text-2xl font-small text-gray-800 mb-4">{header}<hr /></h1>');
//Set required field template $required = '<span class="form_required">*</span> <small>'.get_lang('Required field').'</small>';
$this->setRequiredNote( if ((self::LAYOUT_INLINE === $layout || self::LAYOUT_BOX_SEARCH === $layout)) {
'<span class="form_required">*</span> <small>'.get_lang('Required field').'</small>' $required = '';
); }
// Set required field template
$this->setRequiredNote($required);
$noteTemplate = <<<EOT $noteTemplate = <<<EOT
<div class="form-group"> <div class="form-group">
@ -112,23 +120,29 @@ EOT;
$renderer->setRequiredNoteTemplate($noteTemplate); $renderer->setRequiredNoteTemplate($noteTemplate);
} }
/** public function getFormTemplate(): string
* @return string {
*/ return '
public function getFormTemplate() <div class="pt-4">
<div class="q-card p-4">
<form{attributes}>
{content}
{hidden}
</form>
</div>
</div>
';
}
public function getInLineTemplate(): string
{ {
return '<form{attributes}> return '<form{attributes}>
<fieldset>
{content} {content}
</fieldset>
{hidden} {hidden}
</form>'; </form>';
} }
/** public function getGridFormTemplate(): string
* @return string
*/
public function getGridFormTemplate()
{ {
return ' return '
<style> <style>
@ -152,13 +166,11 @@ EOT;
/** /**
* @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(): string
{ {
return ' return '
<div class="form-group row {error_class}"> <div class="row mb-3 {error_class}">
<label {label-for} class="col-sm-2 col-form-label {extra_label_class}" > <label {label-for} class="col-sm-2 col-form-label {extra_label_class}" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required --> <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label} {label}
@ -491,7 +503,7 @@ EOT;
return $this->addButton( return $this->addButton(
$name, $name,
$label, $label,
'pencil', 'fa fas fa-pencil-alt',
'primary', 'primary',
null, null,
null, null,

@ -5,12 +5,6 @@
*/ */
class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static
{ {
/**
* Class constructor
*
* @param string $name
* @param string $label
*/
public function __construct($name = '', $label = '') public function __construct($name = '', $label = '')
{ {
if (empty($label)) { if (empty($label)) {
@ -46,14 +40,15 @@ class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static
$text = $this->getAttribute('label'); $text = $this->getAttribute('label');
$label = is_array($text) ? $text[0] : $text; $label = is_array($text) ? $text[0] : $text;
$html = '<div class="form-group row"><label class="col-sm-2 col-form-label"></label>'; $html = '<div class="md:flex md:items-center mb-6">
<label class="ch-form-label h-4 md:w-1/4 flex justify-left md:justify-end pr-3 text-gray-600"></label>';
if (is_array($text) && isset($text[1])) { if (is_array($text) && isset($text[1])) {
$html .= '<span class="clearfix">'.$text[1].'</span>'; $html .= '<span class="clearfix">'.$text[1].'</span>';
} }
$html .= ' $html .= '
<div class="col-sm-10"> <div class="md:w-3/4 ">
<button id="'.$name.'" type="button" class="btn btn-secondary advanced_options" <button id="'.$name.'" type="button" class="btn btn-secondary advanced_options"
data-toggle="button" aria-pressed="false" autocomplete="off"> data-toggle="button" aria-pressed="false" autocomplete="off">
<em class="fa fa-bars"></em> '.$label.' <em class="fa fa-bars"></em> '.$label.'

@ -1,4 +1,7 @@
<?php <?php
define('HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT', 1);
/** /**
* Copyright (c) 2005-2009, Laurent Laville <pear@laurent-laville.org> * Copyright (c) 2005-2009, Laurent Laville <pear@laurent-laville.org>
* *
@ -29,8 +32,6 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* PHP versions 4 and 5
*
* @category HTML * @category HTML
* @package HTML_QuickForm_advmultiselect * @package HTML_QuickForm_advmultiselect
* @author Laurent Laville <pear@laurent-laville.org> * @author Laurent Laville <pear@laurent-laville.org>
@ -39,33 +40,10 @@
* @version CVS: $Id: advmultiselect.php,v 1.36 2009/04/05 07:03:39 farell Exp $ * @version CVS: $Id: advmultiselect.php,v 1.36 2009/04/05 07:03:39 farell Exp $
* @link http://pear.php.net/package/HTML_QuickForm_advmultiselect * @link http://pear.php.net/package/HTML_QuickForm_advmultiselect
* @since File available since Release 0.4.0 * @since File available since Release 0.4.0
*/
/**
* Basic error codes
*
* @var integer
* @since 1.5.0
*/
define('HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT', 1);
/**
* @todo clean class to use only with the multiselect.js library
*
* Element for HTML_QuickForm that emulate a multi-select.
* *
* The HTML_QuickForm_advmultiselect package adds an element to the * The HTML_QuickForm_advmultiselect package adds an element to the
* HTML_QuickForm package that is two select boxes next to each other * HTML_QuickForm package that is two select boxes next to each other
* emulating a multi-select. * emulating a multi-select.
*
* @category HTML
* @package HTML_QuickForm_advmultiselect
* @author Laurent Laville <pear@laurent-laville.org>
* @copyright 2005-2009 Laurent Laville
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: @package_version@
* @link http://pear.php.net/package/HTML_QuickForm_advmultiselect
* @since Class available since Release 0.4.0
*/ */
class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
{ {
@ -260,11 +238,11 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
} }
if (is_null($this->getAttribute('class'))) { if (is_null($this->getAttribute('class'))) {
// default width of each select box // default width of each select box
$this->updateAttributes(array('class' => 'form-control')); $this->updateAttributes(array('class' => 'form-control w-full'));
} }
$this->removeAttribute('class'); $this->removeAttribute('class');
$this->setAttribute('class','form-control'); $this->setAttribute('class','form-control w-full');
// set default add button attributes // set default add button attributes
$this->setButtonAttributes('add'); $this->setButtonAttributes('add');
@ -490,10 +468,10 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
} else { } else {
$this->_elementTemplate = ' $this->_elementTemplate = '
{javascript} {javascript}
<div class="row"> <div class="grid grid-cols-3">
<div class="col-sm"><!-- BEGIN label_2 -->{label_2}<!-- END label_2 --> {unselected}</div> <div><!-- BEGIN label_2 -->{label_2}<!-- END label_2 --> {unselected}</div>
<div class="col-sm-auto"><div class="text-center">{add}{remove}</div></div> <div><div class="text-center">{add}{remove}</div></div>
<div class="col-sm"><!-- BEGIN label_3 -->{label_3}<!-- END label_3 -->{selected}</div> <div><!-- BEGIN label_3 -->{label_3}<!-- END label_3 -->{selected}</div>
</div> </div>
'; ';
} }
@ -571,8 +549,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$checkbox_id_suffix = 0; $checkbox_id_suffix = 0;
foreach ($this->_options as $option) { foreach ($this->_options as $option) {
$_labelAttributes $_labelAttributes = ['style', 'class', 'onmouseover', 'onmouseout'];
= array('style', 'class', 'onmouseover', 'onmouseout');
$labelAttributes = array(); $labelAttributes = array();
foreach ($_labelAttributes as $attr) { foreach ($_labelAttributes as $attr) {
if (isset($option['attr'][$attr])) { if (isset($option['attr'][$attr])) {
@ -644,20 +621,18 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$attrUnselected = $this->_getAttrString($this->_attributesUnselected); $attrUnselected = $this->_getAttrString($this->_attributesUnselected);
// set name of Select To Box // set name of Select To Box
$this->_attributesSelected $this->_attributesSelected = [
= array(
'id' => $selectId.'_to', 'id' => $selectId.'_to',
'name' => $selectNameTo, 'name' => $selectNameTo,
); ];
$this->_attributesSelected = array_merge($this->_attributes, $this->_attributesSelected); $this->_attributesSelected = array_merge($this->_attributes, $this->_attributesSelected);
$attrSelected = $this->_getAttrString($this->_attributesSelected); $attrSelected = $this->_getAttrString($this->_attributesSelected);
// set name of Select hidden Box // set name of Select hidden Box
$this->_attributesHidden $this->_attributesHidden = [
= array(
'name' => $selectName, 'name' => $selectName,
'style' => 'overflow: hidden; visibility: hidden; width: 1px; height: 0;', 'style' => 'overflow: hidden; visibility: hidden; width: 1px; height: 0;',
); ];
$this->_attributesHidden $this->_attributesHidden
= array_merge($this->_attributes, $this->_attributesHidden); = array_merge($this->_attributes, $this->_attributesHidden);
$attrHidden = $this->_getAttrString($this->_attributesHidden); $attrHidden = $this->_getAttrString($this->_attributesHidden);

@ -1,5 +1,4 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* HTML class for an <input type="button" /> elements * HTML class for an <input type="button" /> elements
@ -91,16 +90,14 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
unset($this->_attributes['class']); unset($this->_attributes['class']);
$icon = $this->getIcon(); $icon = $this->getIcon();
if (!empty($icon)) { if (!empty($icon)) {
$icon = '<em class="' . $this->getIcon() . '"></em> '; $icon = '<em class="' . $this->getIcon() . '"></em> ';
} }
$class = $this->getClass().' '.$this->getStyle().' '.$this->getSize(); $class = $this->getClass().' '.$this->getStyle().' '.$this->getSize();
return return
$this->_getTabs() . ' $this->_getTabs() . '
<button class="'.$class.'" ' . $this->_getAttrString($this->_attributes) . '>'. <button class="'.$class.'"' . $this->_getAttrString($this->_attributes) . '>'.
$icon. $icon.
$value. $value.
'</button>'; '</button>';
@ -203,12 +200,7 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
return false; return false;
} }
/** public function getTemplate(string $layout): string
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{ {
$size = $this->calculateSize(); $size = $this->calculateSize();
$attributes = $this->getAttributes(); $attributes = $this->getAttributes();
@ -224,12 +216,12 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
'; ';
} else { } else {
$template = ' $template = '
<div class="row form-group {error_class}"> <div class="md:flex md:items-center mb-6 {error_class}">
<label {label-for} class="col-sm-'.$size[0].' col-form-label" > <label {label-for} class="ch-form-label h-4 md:w-1/4 flex justify-left md:justify-end pr-3 text-gray-600 '.$size[0].' " >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required --> <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label} {label}
</label> </label>
<div class="col-sm-'.$size[1].'"> <div class="md:w-3/4 '.$size[1].'">
{icon} {icon}
{element} {element}
@ -251,6 +243,8 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
break; break;
case FormValidator::LAYOUT_INLINE: case FormValidator::LAYOUT_INLINE:
$template = ' {element} ';
break;
case FormValidator::LAYOUT_GRID: case FormValidator::LAYOUT_GRID:
case FormValidator::LAYOUT_BOX_NO_LABEL: case FormValidator::LAYOUT_BOX_NO_LABEL:
default: default:

@ -1,4 +1,5 @@
<?php <?php
/** /**
* HTML class for a checkbox type field. * HTML class for a checkbox type field.
* *
@ -153,73 +154,6 @@ class HTML_QuickForm_checkbox extends HTML_QuickForm_input
return HTML_QuickForm_input::toHtml().$label; return HTML_QuickForm_input::toHtml().$label;
} }
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '
<div class="input-group">
<label {label-for} >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
</div>
<div class="input-group {error_class}">
{element}
</div>
';
break;
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="row form-group {error_class}">
<label {label-for} class="col-sm-'.$size[0].' col-form-label {extra_label_class}" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size[1].'">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline help-block">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
</div>
</div>';
break;
case FormValidator::LAYOUT_BOX_NO_LABEL:
return '
<div class="input-group">
{icon}
{element}
</div>';
break;
case FormValidator::LAYOUT_GRID:
case FormValidator::LAYOUT_BOX:
return '
<div class="input-group">
<label>{label}</label>
{icon}
{element}
</div>';
break;
}
}
/** /**
* Returns the value of field without HTML tags. * Returns the value of field without HTML tags.
* *

@ -1,10 +1,6 @@
<?php <?php
/** /**
* Base class for form elements
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license * LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI: * that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt If you did not receive a copy of * http://www.php.net/license/3_01.txt If you did not receive a copy of
@ -12,7 +8,6 @@
* send a note to license@php.net so we can mail you a copy immediately. * send a note to license@php.net so we can mail you a copy immediately.
* *
* @category HTML * @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com> * @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com> * @author Bertrand Mansion <bmansion@mamasam.com>
* @author Alexey Borzov <avb@php.net> * @author Alexey Borzov <avb@php.net>
@ -20,15 +15,6 @@
* @license http://www.php.net/license/3_01.txt PHP License 3.01 * @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: element.php,v 1.37 2009/04/04 21:34:02 avb Exp $ * @version CVS: $Id: element.php,v 1.37 2009/04/04 21:34:02 avb Exp $
* @link http://pear.php.net/package/HTML_QuickForm * @link http://pear.php.net/package/HTML_QuickForm
*/
/**
* Base class for form elements
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Alexey Borzov <avb@php.net> * @author Alexey Borzov <avb@php.net>
* @version Release: 3.2.11 * @version Release: 3.2.11
* @since 1.0 * @since 1.0
@ -78,7 +64,6 @@ class HTML_QuickForm_element extends HTML_Common
* @access private * @access private
*/ */
public $_persistantFreeze = false; public $_persistantFreeze = false;
protected $columnsSize; protected $columnsSize;
/** /**
@ -624,4 +609,92 @@ class HTML_QuickForm_element extends HTML_Common
return $size; return $size;
} }
public function getTemplate(string $layout): string
{
$size = $this->calculateSize();
$attributes = $this->getAttributes();
$hasBottomLabel = is_array($this->getLabel());
$height = 'h-4';
if ($hasBottomLabel) {
$height = 'h-8';
}
$template = '<label {label-for}>{label}</label>
<div class="input-group">
{icon}
{element}
</div>';
switch ($layout) {
case FormValidator::LAYOUT_BOX_SEARCH:
case FormValidator::LAYOUT_INLINE:
// <label {label-for} >
// <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
// {label}
// </label>
$template = '{element}';
break;
case FormValidator::LAYOUT_GRID:
$template = '
<div class="form-group {error_class}">
<label {label-for} >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
{element}
</div>';
break;
case FormValidator::LAYOUT_HORIZONTAL:
$template = '
<div class="md:flex md:items-center mb-6 '.$size[0].' {error_class}">
<label {label-for} class="
ch-form-label '.$height.'
md:w-1/4
flex justify-left
text-sm font-medium text-gray-700
md:justify-end pr-3
" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="md:w-3/4 '.$size[1].'">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN label_3 -->
<p class="help-block">{label_3}</p>
<!-- END label_3 -->
<!-- BEGIN error -->
<span class="help-inline help-block">{error}</span>
<!-- END error -->
</div>
</div>';
break;
case FormValidator::LAYOUT_BOX_NO_LABEL:
if (isset($attributes['custom']) && $attributes['custom'] == true) {
$template = '
<div class="input-group">
{icon}
{element}
<div class="input-group-btn">
<button class="btn btn-default" type="submit">
<em class="fa fa-search"></em>
</button>
</div>
</div>
';
}
break;
}
return $template;
}
} }

@ -386,100 +386,4 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
'<input class="'.$class.'" '.$this->_getAttrString($this->_attributes).' />'; '<input class="'.$class.'" '.$this->_getAttrString($this->_attributes).' />';
} }
} }
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
$name = $this->getName();
$attributes = $this->getAttributes();
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '
<div class="form-group {error_class}">
<label {label-for} >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
{element}
</div>';
break;
case FormValidator::LAYOUT_HORIZONTAL:
if (isset($attributes['custom']) && $attributes['custom']) {
$template = '
<div class="input-file-container">
{element}
<label tabindex="0" {label-for} class="input-file-trigger">
<i class="fa fa-picture-o fa-lg" aria-hidden="true"></i> {label}
</label>
</div>
<p class="file-return"></p>
<script>
document.querySelector("html").classList.add(\'js\');
var fileInput = document.querySelector( ".input-file" ),
button = document.querySelector( ".input-file-trigger" ),
the_return = document.querySelector(".file-return");
button.addEventListener("keydown", function(event) {
if ( event.keyCode == 13 || event.keyCode == 32 ) {
fileInput.focus();
}
});
button.addEventListener("click", function(event) {
fileInput.focus();
return false;
});
fileInput.addEventListener("change", function(event) {
fileName = this.value;
if (this.files[0]) {
fileName = this.files[0].name;
}
the_return.innerHTML = fileName;
});
</script>
';
} else {
$template = '
<div id="file_'.$name.'" class="row form-group {error_class}">
<label {label-for} class="col-sm-'.$size[0].' col-form-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size[1].'">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline help-block">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
</div>
</div>';
}
return $template;
break;
case FormValidator::LAYOUT_BOX_NO_LABEL:
return '
<label {label-for}>{label}</label>
<div class="input-group">
{icon}
{element}
</div>';
break;
}
}
} }

@ -1,10 +1,6 @@
<?php <?php
/** /**
* HTML class for a form element group.
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license * LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI: * that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt If you did not receive a copy of * http://www.php.net/license/3_01.txt If you did not receive a copy of
@ -18,24 +14,7 @@
* @author Alexey Borzov <avb@php.net> * @author Alexey Borzov <avb@php.net>
* @copyright 2001-2009 The PHP Group * @copyright 2001-2009 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01 * @license http://www.php.net/license/3_01.txt PHP License 3.01
*
* @version CVS: $Id: group.php,v 1.40 2009/04/04 21:34:03 avb Exp $ * @version CVS: $Id: group.php,v 1.40 2009/04/04 21:34:03 avb Exp $
*
* @see http://pear.php.net/package/HTML_QuickForm
*/
/**
* HTML class for a form element group.
*
* @category HTML
*
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Alexey Borzov <avb@php.net>
*
* @version Release: 3.2.11
*
* @since 1.0
*/ */
class HTML_QuickForm_group extends HTML_QuickForm_element class HTML_QuickForm_group extends HTML_QuickForm_element
{ {
@ -544,71 +523,4 @@ class HTML_QuickForm_group extends HTML_QuickForm_element
$this->_elements[$key]->setPersistantFreeze($persistant); $this->_elements[$key]->setPersistantFreeze($persistant);
} }
} }
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '
<div class="input-group">
<label {label-for} >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
</div>
<div class="input-group {error_class}">
{element}
</div>
';
break;
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="row form-group {error_class}" id="'.$this->getName().'-group">
<label {label-for} class="col-sm-'.$size[0].' {extra_label_class}" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size[1].'">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline help-block">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
</div>
</div>';
break;
case FormValidator::LAYOUT_BOX_NO_LABEL:
return '
<div class="input-group">
{icon}
{element}
</div>';
break;
case FormValidator::LAYOUT_BOX:
return '
<div class="input-group">
<label>{label}</label>
{icon}
{element}
</div>';
break;
}
}
} }

@ -2,32 +2,19 @@
/** /**
* Base class for <input /> form elements * Base class for <input /> form elements
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license * LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI: * that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt If you did not receive a copy of * http://www.php.net/license/3_01.txt If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please * the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately. * send a note to license@php.net so we can mail you a copy immediately.
* *
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com> * @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com> * @author Bertrand Mansion <bmansion@mamasam.com>
* @copyright 2001-2009 The PHP Group * @copyright 2001-2009 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01 * @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: input.php,v 1.10 2009/04/04 21:34:03 avb Exp $ * @version CVS: $Id: input.php,v 1.10 2009/04/04 21:34:03 avb Exp $
* @link http://pear.php.net/package/HTML_QuickForm * @link http://pear.php.net/package/HTML_QuickForm
*/
/**
* Base class for <input /> form elements
*
* @category HTML * @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @version Release: 3.2.11 * @version Release: 3.2.11
* @since 1.0 * @since 1.0
* @abstract * @abstract
@ -35,8 +22,6 @@
class HTML_QuickForm_input extends HTML_QuickForm_element class HTML_QuickForm_input extends HTML_QuickForm_element
{ {
/** /**
* Sets the element type
*
* @param string $type Element type * @param string $type Element type
* @since 1.0 * @since 1.0
* @access public * @access public

@ -56,8 +56,8 @@ class HTML_QuickForm_radio extends HTML_QuickForm_input
$value = null, $value = null,
$attributes = [] $attributes = []
) { ) {
$this->labelClass = isset($attributes['label-class']) ? $attributes['label-class'] : ''; $this->labelClass = $attributes['label-class'] ?? '';
$this->radioClass = isset($attributes['radio-class']) ? $attributes['radio-class'] : 'form-check'; $this->radioClass = $attributes['radio-class'] ?? 'form-check';
if (isset($attributes['label-class'])) { if (isset($attributes['label-class'])) {
unset($attributes['label-class']); unset($attributes['label-class']);
@ -68,7 +68,7 @@ class HTML_QuickForm_radio extends HTML_QuickForm_input
} }
$attributes['class'] = ' form-check-input'; $attributes['class'] = ' form-check-input';
$columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null; $columnsSize = $attributes['cols-size'] ?? null;
$this->setColumnsSize($columnsSize); $this->setColumnsSize($columnsSize);
parent::__construct($elementName, $elementLabel, $attributes); parent::__construct($elementName, $elementLabel, $attributes);
@ -103,12 +103,10 @@ class HTML_QuickForm_radio extends HTML_QuickForm_input
$radioClass = $this->radioClass; $radioClass = $this->radioClass;
$id = $this->getAttribute('id'); $id = $this->getAttribute('id');
$label = '<div class="'.$radioClass.'"> return '<div class="'.$radioClass.'">
'.HTML_QuickForm_input::toHtml().' '.HTML_QuickForm_input::toHtml().'
<label for="'.$id.'" class="form-check-label '.$labelClass.'">'.$this->_text.'</label> <label for="'.$id.'" class="form-check-label '.$labelClass.'">'.$this->_text.'</label>
</div>'; </div>';
return $label;
} }
return parent::toHtml().$label; return parent::toHtml().$label;

@ -1,10 +1,6 @@
<?php <?php
/** /**
* Class to dynamically create an HTML SELECT
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license * LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI: * that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt If you did not receive a copy of * http://www.php.net/license/3_01.txt If you did not receive a copy of
@ -20,15 +16,6 @@
* @license http://www.php.net/license/3_01.txt PHP License 3.01 * @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: select.php,v 1.34 2009/04/04 21:34:04 avb Exp $ * @version CVS: $Id: select.php,v 1.34 2009/04/04 21:34:04 avb Exp $
* @link http://pear.php.net/package/HTML_QuickForm * @link http://pear.php.net/package/HTML_QuickForm
*/
/**
* Class to dynamically create an HTML SELECT
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Alexey Borzov <avb@php.net> * @author Alexey Borzov <avb@php.net>
* @version Release: 3.2.11 * @version Release: 3.2.11
* @since 1.0 * @since 1.0
@ -79,7 +66,8 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
if (empty($attributes)) { if (empty($attributes)) {
$attributes = []; // Initialize variable to avoid warning in PHP 7.1 $attributes = []; // Initialize variable to avoid warning in PHP 7.1
} }
$attributes['class'] = $oldClass . ' selectpicker form-control'; //selectpicker
$attributes['class'] = $oldClass . ' form-control mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-indigo-500 sm:text-sm';
$attributes['data-live-search'] = 'true'; $attributes['data-live-search'] = 'true';
if (isset($attributes['disable_js']) && $attributes['disable_js']) { if (isset($attributes['disable_js']) && $attributes['disable_js']) {
@ -554,69 +542,4 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
</script>' </script>'
); );
} }
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '
<div class="row mb-3 {error_class}">
<label {label-for} >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
{element}
</div>';
break;
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="row form-group {error_class}">
<label {label-for} class="col-sm-'.$size[0].' col-form-label {extra_label_class}" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size[1].'">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline help-block">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
</div>
</div>';
break;
case FormValidator::LAYOUT_BOX_NO_LABEL:
return '
<div class="input-group">
{icon}
{element}
</div>';
break;
case FormValidator::LAYOUT_GRID:
case FormValidator::LAYOUT_BOX:
return '
<div class="input-group" style="z-index: auto">
<label>{label}</label>
{icon}
{element}
</div>';
break;
}
}
} }

@ -1,10 +1,6 @@
<?php <?php
/** /**
* HTML class for a text field
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license * LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI: * that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt If you did not receive a copy of * http://www.php.net/license/3_01.txt If you did not receive a copy of
@ -18,24 +14,13 @@
* @copyright 2001-2009 The PHP Group * @copyright 2001-2009 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01 * @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: text.php,v 1.7 2009/04/04 21:34:04 avb Exp $ * @version CVS: $Id: text.php,v 1.7 2009/04/04 21:34:04 avb Exp $
* @link http://pear.php.net/package/HTML_QuickForm * @link http://pear.php.net/package/HTML_QuickForm *
*/
/**
* HTML class for a text field
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @version Release: 3.2.11 * @version Release: 3.2.11
* @since 1.0 * @since 1.0
*/ */
class HTML_QuickForm_text extends HTML_QuickForm_input class HTML_QuickForm_text extends HTML_QuickForm_input
{ {
/** /**
* Class constructor
*
* @param string $elementName (optional)Input field name attribute * @param string $elementName (optional)Input field name attribute
* @param string $elementLabel (optional)Input field label * @param string $elementLabel (optional)Input field label
* @param mixed $attributes (optional)Either a typical HTML attribute string * @param mixed $attributes (optional)Either a typical HTML attribute string
@ -44,23 +29,30 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
* @access public * @access public
* @return void * @return void
*/ */
public function __construct( public function __construct($elementName = null, $elementLabel = null, $attributes = [])
$elementName = null, {
$elementLabel = null,
$attributes = []
) {
if (is_string($attributes) && empty($attributes)) { if (is_string($attributes) && empty($attributes)) {
$attributes = []; $attributes = [];
} }
if (is_array($attributes) || empty($attributes)) { if (is_array($attributes) || empty($attributes)) {
$classFromAttributes = isset($attributes['class']) ? $attributes['class'] : ''; $classFromAttributes = $attributes['class'] ?? '';
$attributes['class'] = $classFromAttributes.' form-control'; //w-1/2
$attributes['class'] = $classFromAttributes.'
sm:text-sm
text-gray-600
focus:outline-none
focus:border
focus:border-blue-700
bg-white font-normal
flex items-center pl-3 border-gray-300 rounded-md border shadow';
} }
$inputSize = isset($attributes['input-size']) ? $attributes['input-size'] : null; $inputSize = $attributes['input-size'] ?? null;
$this->setInputSize($inputSize); $this->setInputSize($inputSize);
$columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null; $columnsSize = $attributes['cols-size'] ?? null;
$this->setColumnsSize($columnsSize); $this->setColumnsSize($columnsSize);
$icon = isset($attributes['icon']) ? $attributes['icon'] : null; $icon = $attributes['icon'] ?? null;
$this->setIcon($icon); $this->setIcon($icon);
if (!empty($inputSize)) { if (!empty($inputSize)) {
@ -93,89 +85,6 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
</div>'; </div>';
} }
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
$size = $this->calculateSize();
$attributes = $this->getAttributes();
$template = '<label {label-for}>{label}</label>
<div class="input-group">
{icon}
{element}
</div>';
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
// <div class="form-group {error_class}">
$template = '
<label {label-for} >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
{element}
';
break;
case FormValidator::LAYOUT_GRID:
$template = '
<div class="form-group {error_class}">
<label {label-for} >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
{element}
</div>';
break;
case FormValidator::LAYOUT_HORIZONTAL:
$template = '
<div class="row form-group {error_class}">
<label {label-for} class="col-sm-'.$size[0].' col-form-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size[1].'">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline help-block">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
</div>
</div>';
break;
case FormValidator::LAYOUT_BOX_NO_LABEL:
if (isset($attributes['custom']) && $attributes['custom'] == true) {
$template = '
<div class="input-group">
{icon}
{element}
<div class="input-group-btn">
<button class="btn btn-default" type="submit">
<em class="fa fa-search"></em>
</button>
</div>
</div>
';
}
break;
}
return $template;
}
/** /**
* Sets size of text field * Sets size of text field
* *

@ -146,13 +146,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->updateAttributes(array('cols' => $cols)); $this->updateAttributes(array('cols' => $cols));
} }
/**
* Returns the textarea element in HTML
*
* @since 1.0
* @access public
* @return string
*/
public function toHtml() public function toHtml()
{ {
if ($this->_flagFrozen) { if ($this->_flagFrozen) {
@ -186,78 +179,4 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
} }
return $html . $this->_getPersistantData(); return $html . $this->_getPersistantData();
} }
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
$this->removeAttribute('cols-size');
if (empty($size)) {
$size = [2, 8, 2];
}
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '
<div class="form-group {error_class}">
<label {label-for} >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
{element}
</div>';
break;
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="row form-group {error_class}">
<label class="col-sm-'.$size[0].' col-form-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size[1].'">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline help-block">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
</div>
</div>';
break;
case FormValidator::LAYOUT_BOX_NO_LABEL:
return '
<label {label-for}>{label}</label>
<div class="input-group">
{icon}
{element}
</div>';
break;
case FormValidator::LAYOUT_GRID:
case FormValidator::LAYOUT_BOX:
return '
<label {label-for}>{label}</label>
<div class="input-group">
{label}
{icon}
{element}
</div>';
break;
}
}
} }

@ -1,5 +1,5 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and * PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and
* efficient. * efficient.
@ -193,12 +193,15 @@ class HTML_Table extends HTML_Common
{ {
if (is_null($this->_thead)) { if (is_null($this->_thead)) {
$this->_useTGroups = true; $this->_useTGroups = true;
$this->_thead = new HTML_Table_Storage($this->_tabOffset, $this->_thead = new HTML_Table_Storage(
$this->_useTGroups); $this->_tabOffset,
$this->_useTGroups
);
for ($i = 0; $i < $this->_tbodyCount; $i++) { for ($i = 0; $i < $this->_tbodyCount; $i++) {
$this->_tbodies[$i]->setUseTGroups(true); $this->_tbodies[$i]->setUseTGroups(true);
} }
} }
return $this->_thead; return $this->_thead;
} }
@ -211,12 +214,15 @@ class HTML_Table extends HTML_Common
{ {
if (is_null($this->_tfoot)) { if (is_null($this->_tfoot)) {
$this->_useTGroups = true; $this->_useTGroups = true;
$this->_tfoot = new HTML_Table_Storage($this->_tabOffset, $this->_tfoot = new HTML_Table_Storage(
$this->_useTGroups); $this->_tabOffset,
$this->_useTGroups
);
for ($i = 0; $i < $this->_tbodyCount; $i++) { for ($i = 0; $i < $this->_tbodyCount; $i++) {
$this->_tbodies[$i]->setUseTGroups(true); $this->_tbodies[$i]->setUseTGroups(true);
} }
} }
return $this->_tfoot; return $this->_tfoot;
} }
@ -235,6 +241,7 @@ class HTML_Table extends HTML_Common
if (PEAR::isError($ret)) { if (PEAR::isError($ret)) {
return $ret; return $ret;
} }
return $this->_tbodies[$body]; return $this->_tbodies[$body];
} }
@ -255,10 +262,13 @@ class HTML_Table extends HTML_Common
} }
$body = $this->_tbodyCount++; $body = $this->_tbodyCount++;
$this->_tbodies[$body] = new HTML_Table_Storage($this->_tabOffset, $this->_tbodies[$body] = new HTML_Table_Storage(
$this->_useTGroups); $this->_tabOffset,
$this->_useTGroups
);
$this->_tbodies[$body]->setAutoFill($this->_autoFill); $this->_tbodies[$body]->setAutoFill($this->_autoFill);
$this->_tbodies[$body]->setAttributes($attributes); $this->_tbodies[$body]->setAttributes($attributes);
return $body; return $body;
} }
@ -1026,7 +1036,7 @@ class HTML_Table extends HTML_Common
for ($i = 0; $i < $this->_tbodyCount; $i++) { for ($i = 0; $i < $this->_tbodyCount; $i++) {
$this->_tbodies[$i]->setColCount($maxColCount); $this->_tbodies[$i]->setColCount($maxColCount);
if ($this->_tbodies[$i]->getRowCount() > 0) { if ($this->_tbodies[$i]->getRowCount() > 0) {
$strHtml .= $tabs . $tab . '<tbody' . $strHtml .= $tabs . $tab . '<tbody ' .
$this->_getAttrString($this->_tbodies[$i]->_attributes) . $this->_getAttrString($this->_tbodies[$i]->_attributes) .
'>' . $lnEnd; '>' . $lnEnd;
$strHtml .= $this->_tbodies[$i]->toHtml($tabs, $tab); $strHtml .= $this->_tbodies[$i]->toHtml($tabs, $tab);

@ -847,10 +847,12 @@ class Pager_Common
if (array_key_exists($this->_urlVar, $this->_linkData)) { if (array_key_exists($this->_urlVar, $this->_linkData)) {
$onclick = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_onclick); $onclick = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_onclick);
} }
return sprintf('<a class="btn btn-outline-secondary" href="%s"%s%s%s%s title="%s">%s</a>',
return sprintf(
'<a class="btn btn-link" href="%s"%s%s%s%s title="%s">%s</a>',
// Modified by Ivan Tcholakov, 17-OCT-2008. // Modified by Ivan Tcholakov, 17-OCT-2008.
//htmlentities($this->_url . $href, ENT_COMPAT, 'UTF-8'), //htmlentities($this->_url . $href, ENT_COMPAT, 'UTF-8'),
api_htmlentities($this->_url . $href), api_htmlentities($this->_url.$href),
// //
empty($this->_classString) ? '' : ' '.$this->_classString, empty($this->_classString) ? '' : ' '.$this->_classString,
empty($this->_attributes) ? '' : ' '.$this->_attributes, empty($this->_attributes) ? '' : ' '.$this->_attributes,
@ -859,12 +861,14 @@ class Pager_Common
$altText, $altText,
$linkText $linkText
); );
} elseif ($this->_httpMethod == 'POST') { } elseif ($this->_httpMethod === 'POST') {
$href = $this->_url; $href = $this->_url;
if (!empty($_GET)) { if (!empty($_GET)) {
$href .= '?' . $this->_http_build_query_wrapper($_GET); $href .= '?'.$this->_http_build_query_wrapper($_GET);
} }
return sprintf("<a href='javascript:void(0)' onclick='%s'%s%s%s title='%s'>%s</a>",
return sprintf(
"<a href='javascript:void(0)' onclick='%s'%s%s%s title='%s'>%s</a>",
$this->_generateFormOnClick($href, $this->_linkData), $this->_generateFormOnClick($href, $this->_linkData),
empty($this->_classString) ? '' : ' '.$this->_classString, empty($this->_classString) ? '' : ' '.$this->_classString,
empty($this->_attributes) ? '' : ' '.$this->_attributes, empty($this->_attributes) ? '' : ' '.$this->_attributes,

@ -7848,9 +7848,7 @@ class SessionManager
$orderClause; $orderClause;
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
$userRelAccessUrlTable = Database::get_main_table( $userRelAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
TABLE_MAIN_ACCESS_URL_REL_USER
);
$accessUrlId = api_get_current_access_url_id(); $accessUrlId = api_get_current_access_url_id();
if (-1 != $accessUrlId) { if (-1 != $accessUrlId) {
$sql = "SELECT user.id as user_id, username, lastname, firstname $sql = "SELECT user.id as user_id, username, lastname, firstname
@ -7872,8 +7870,7 @@ class SessionManager
api_get_person_name($coachItem['firstname'], $coachItem['lastname']).' ('.$coachItem['username'].')'; api_get_person_name($coachItem['firstname'], $coachItem['lastname']).' ('.$coachItem['username'].')';
} }
$form->addElement( $form->addSelect(
'select',
'coach_username', 'coach_username',
get_lang('Coach name'), get_lang('Coach name'),
$coachesOptions, $coachesOptions,
@ -7883,8 +7880,7 @@ class SessionManager
] ]
); );
} else { } else {
$form->addElement( $form->addSelectAjax(
'select_ajax',
'coach_username', 'coach_username',
get_lang('Coach name'), get_lang('Coach name'),
$coachInfo ? [$coachInfo['id'] => $coachInfo['complete_name_with_username']] : [], $coachInfo ? [$coachInfo['id'] => $coachInfo['complete_name_with_username']] : [],

@ -144,7 +144,8 @@ class SortableTable extends HTML_Table
if (empty($attributes)) { if (empty($attributes)) {
$attributes = []; $attributes = [];
$attributes['class'] = 'table table-hover table-striped table-bordered data_table'; //$attributes['class'] = 'table table-hover table-striped table-bordered data_table';
$attributes['class'] = 'q-table';
$attributes['id'] = $table_id; $attributes['id'] = $table_id;
} }
@ -299,26 +300,33 @@ class SortableTable extends HTML_Table
$params['urlVar'] = $this->param_prefix.'page_nr'; $params['urlVar'] = $this->param_prefix.'page_nr';
$params['currentPage'] = $this->page_nr; $params['currentPage'] = $this->page_nr;
$icon_attributes = ['style' => 'vertical-align: middle;']; $icon_attributes = ['style' => 'vertical-align: middle;'];
$params['prevImg'] = Display:: return_icon( /*$params['prevImg'] = Display:: return_icon(
'action_prev.png', 'action_prev.png',
get_lang('Previous page'), get_lang('Previous page'),
$icon_attributes $icon_attributes
); );*/
$params['nextImg'] = Display:: return_icon( $params['prevImg'] = Display::returnFontAwesomeIcon('caret-left');
/*$params['nextImg'] = Display:: return_icon(
'action_next.png', 'action_next.png',
get_lang('Next page'), get_lang('Next page'),
$icon_attributes $icon_attributes
); );*/
$params['firstPageText'] = Display:: return_icon( $params['nextImg'] = Display::returnFontAwesomeIcon('caret-right');
/*$params['firstPageText'] = Display:: return_icon(
'action_first.png', 'action_first.png',
get_lang('First page'), get_lang('First page'),
$icon_attributes $icon_attributes
); );*/
$params['lastPageText'] = Display:: return_icon( $params['firstPageText'] = Display::returnFontAwesomeIcon('step-backward');
/*$params['lastPageText'] = Display:: return_icon(
'action_last.png', 'action_last.png',
get_lang('Last page'), get_lang('Last page'),
$icon_attributes $icon_attributes
); );*/
$params['lastPageText'] = Display::returnFontAwesomeIcon('step-forward');
$params['firstPagePre'] = ''; $params['firstPagePre'] = '';
$params['lastPagePre'] = ''; $params['lastPagePre'] = '';
$params['firstPagePost'] = ''; $params['firstPagePost'] = '';
@ -391,16 +399,16 @@ class SortableTable extends HTML_Table
if (false === $this->hideNavigation) { if (false === $this->hideNavigation) {
$form = $this->get_page_select_form(); $form = $this->get_page_select_form();
$nav = $this->get_navigation_html(); $nav = $this->get_navigation_html();
$html = '<div class="card-action">'; $html = '<div class="q-card">';
$html .= '<div class="row">'; $html .= '<div class="q-pa-md fit row wrap justify-between items-start content-start">';
$html .= '<div class="col-12 col-md-4">'; $html .= '<div class="col">';
$html .= '<div class="page-select pb-2 pt-2">'.$form.'</div>'; $html .= '<div class="page-select pb-2 pt-2">'.$form.'</div>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div class="col-12 col-md-4">'; $html .= '<div class="col">';
$html .= '<div class="page-number pb-2 pt-2">'.$this->get_table_title().'</div>'; $html .= '<div class="row justify-center">'.$this->get_table_title().'</div>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div class="col-12 col-md-4">'; $html .= '<div class="col">';
$html .= '<div class="page-nav pb-2 pt-2">'.$nav.'</div>'; $html .= '<div class="row justify-end">'.$nav.'</div>';
$html .= '</div>'; $html .= '</div>';
$html .= '</div>'; $html .= '</div>';
$html .= '</div>'; $html .= '</div>';
@ -416,7 +424,9 @@ class SortableTable extends HTML_Table
name="form_'.$this->table_name.'">'; name="form_'.$this->table_name.'">';
} }
$html .= '<div class="table-responsive">'.$content.'</div>'; //$html .= '<div class="table-responsive">'.$content.'</div>';
$html .= '<div class="q-table__container q-table--horizontal-separator column no-wrap q-table__card q-table--no-wrap">'.
$content.'</div>';
if (!empty($this->additional_parameters)) { if (!empty($this->additional_parameters)) {
foreach ($this->additional_parameters as $key => $value) { foreach ($this->additional_parameters as $key => $value) {
@ -425,19 +435,18 @@ class SortableTable extends HTML_Table
} }
} }
$html .= '<input type="hidden" name="action">'; $html .= '<input type="hidden" name="action">';
$html .= '<div class="card-action">';
$html .= '<div class="row">'; $html .= '<div class="q-card">';
$html .= '<div class="col-12 col-md-6">'; $html .= '<div class="flex p-3">';
$html .= '<div class="page-action pb-2 pt-2">';
if (count($this->form_actions) > 0) { if (count($this->form_actions) > 0) {
$html .= '<div class="btn-group" role="group">'; $html .= '<div class="btn-group" role="group">';
$html .= '<a $html .= '<a
class="btn btn-outline-primary" class="btn btn-primary"
href="?'.$params.'&amp;'.$this->param_prefix.'selectall=1" href="?'.$params.'&amp;'.$this->param_prefix.'selectall=1"
onclick="javascript: setCheckbox(true, \''.$table_id.'\'); return false;">'.get_lang('Select all').'</a>'; onclick="javascript: setCheckbox(true, \''.$table_id.'\'); return false;">'.get_lang('Select all').'</a>';
$html .= '<a $html .= '<a
class="btn btn-outline-primary" class="btn btn-primary"
href="?'.$params.'" href="?'.$params.'"
onclick="javascript: setCheckbox(false, \''.$table_id.'\'); return false;">'.get_lang('UnSelect all').'</a> '; onclick="javascript: setCheckbox(false, \''.$table_id.'\'); return false;">'.get_lang('UnSelect all').'</a> ';
$html .= '<div class="btn-group" role="group"> $html .= '<div class="btn-group" role="group">
@ -465,7 +474,7 @@ class SortableTable extends HTML_Table
} }
$html .= '</div>'; $html .= '</div>';
$html .= '</div>';
// Pagination // Pagination
if ($this->get_total_number_of_items() > $this->default_items_per_page) { if ($this->get_total_number_of_items() > $this->default_items_per_page) {
$html .= '<div class="col-12 col-md-6">'; $html .= '<div class="col-12 col-md-6">';
@ -473,7 +482,6 @@ class SortableTable extends HTML_Table
$html .= '</div>'; $html .= '</div>';
} }
$html .= '</div>';
$html .= '</div>'; $html .= '</div>';
if (count($this->form_actions) > 0) { if (count($this->form_actions) > 0) {
$html .= '</form>'; $html .= '</form>';
@ -694,7 +702,6 @@ class SortableTable extends HTML_Table
$from = $offset[0] - 1; $from = $offset[0] - 1;
$table_data = $this->get_table_data($from, $this->per_page, $this->column); $table_data = $this->get_table_data($from, $this->per_page, $this->column);
$this->processHeaders(); $this->processHeaders();
$this->addBody();
if (is_array($table_data)) { if (is_array($table_data)) {
$count = 1; $count = 1;
foreach ($table_data as &$row) { foreach ($table_data as &$row) {

Loading…
Cancel
Save