add css grid elements form BT#9893 #TMI

1.10.x
aragonc 10 years ago
parent 04e116bec5
commit ab8f66078b
  1. 27
      main/admin/resource_sequence.php
  2. 5
      main/inc/lib/formvalidator/FormValidator.class.php
  3. 40
      main/inc/lib/pear/HTML/QuickForm/button.php
  4. 50
      main/inc/lib/pear/HTML/QuickForm/select.php
  5. 48
      main/inc/lib/pear/HTML/QuickForm/text.php
  6. 60
      main/template/default/admin/resource_sequence.tpl

@ -22,9 +22,9 @@ if (!empty($sessionListFromDatabase)) {
}
}
$formSequence = new FormValidator('sequence_form', 'post', api_get_self());
$formSequence->addText('name', get_lang('Sequence'));
$formSequence->addButtonCreate(get_lang('AddSequence'), 'submit_sequence');
$formSequence = new FormValidator('sequence_form', 'post', api_get_self(),null,null,'horizontal');
$formSequence->addText('name', get_lang('Sequence'), true, ['cols-size' => [4, 4, 2]]);
$formSequence->addButtonCreate(get_lang('AddSequence'), 'submit_sequence', false, ['cols-size' => [4, 4, 2]]);
$em = Database::getManager();
@ -39,38 +39,41 @@ if ($formSequence->validate()) {
exit;
}
$form = new FormValidator('');
$form->addHidden('sequence_type', 'session');
$saveForm = new FormValidator('');
$saveForm->addHidden('sequence_type', 'session');
$em = Database::getManager();
$sequenceList = $em->getRepository('ChamiloCoreBundle:Sequence')->findAll();
$form->addSelect(
$saveForm->addSelect(
'sequence',
get_lang('Sequence'),
$sequenceList,
['id' => 'sequence_id']
['id' => 'sequence_id', 'cols-size' => [4, 4, 2]]
);
$form->addSelect(
$saveForm->addSelect(
'sessions',
get_lang('Sessions'),
$sessionList,
['id' => 'item']
['id' => 'item', 'cols-size' => [4, 4, 2]]
);
$form->addButtonNext(get_lang('UseAsReference'), 'use_as_reference');
$saveForm->addButtonNext(get_lang('UseAsReference'), 'use_as_reference');
$form = new FormValidator('');
$form->addSelect(
'requirements',
get_lang('Requirements'),
$sessionList,
['id' => 'requirements', 'multiple' => 'multiple']
['id' => 'requirements', 'multiple' => 'multiple', 'cols-size' => [4, 4, 2]]
);
$form->addButtonCreate(get_lang('SetAsRequirementForSelected'), 'set_requirement');
$form->addButtonSave(get_lang('Save'), 'save_resource');
$tpl->assign('left_block', $formSequence->returnForm().$form->returnForm());
$tpl->assign('create_sequence', $formSequence->returnForm());
$tpl->assign('save_sequence', $saveForm->returnForm());
$tpl->assign('left_block', $form->returnForm());
$layout = $tpl->get_template('admin/resource_sequence.tpl');
$tpl->display($layout);

@ -324,9 +324,10 @@ EOT;
* @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method
* @param array $attributes Additional attributes
* @return HTML_QuickForm_button
*/
public function addButtonCreate($label, $name = 'submit', $createElement = false)
public function addButtonCreate($label, $name = 'submit', $createElement = false, $attributes = array())
{
return $this->addButton(
$name,
@ -335,7 +336,7 @@ EOT;
'primary',
null,
null,
array(),
$attributes,
$createElement
);
}

@ -38,6 +38,7 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
private $style;
private $size;
private $class;
private $columnsSize;
/**
* @param string $name input name example 'submit'
@ -61,6 +62,8 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
$this->setStyle($style);
$this->setSize($size);
$this->setClass($class);
$columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null;
$this->setColumnsSize($columnsSize);
parent::__construct(
$name,
@ -161,7 +164,21 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
{
return $this->size;
}
/**
* @return null
*/
public function getColumnsSize()
{
return $this->columnsSize;
}
/**
* @param null $columnsSize
*/
public function setColumnsSize($columnsSize)
{
$this->columnsSize = $columnsSize;
}
/**
* @param mixed $size
*/
@ -204,6 +221,23 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
*/
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
if (empty($size)) {
$size = array(2, 8, 2);
} else {
if (is_array($size)) {
if (count($size) == 1) {
$size = array(2, intval($size[0]), 2);
} elseif (count($size) != 3) {
$size = array(2, 8, 2);
}
// else just keep the $size array as received
} else {
$size = array(2, intval($size), 2);
}
}
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '
@ -213,11 +247,11 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="form-group {error_class}">
<label {label-for} class="col-sm-2 control-label" >
<label {label-for} class="col-sm-'.$size[0].' control-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-8">
<div class="col-sm-'.$size[1].'">
{icon}
{element}
@ -229,7 +263,7 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
<span class="help-inline">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-2">
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->

@ -46,9 +46,9 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* @since 1.0
* @access private
*/
var $_options = array();
private $_options = array();
var $_optgroups = array();
private $_optgroups = array();
/**
* Default values of the SELECT
@ -57,7 +57,9 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
* @since 1.0
* @access private
*/
var $_values = null;
private $_values = null;
private $columnsSize;
// }}}
// {{{ constructor
@ -82,6 +84,8 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
if (is_array($attributes) || empty($attributes)) {
$attributes['class'] = 'form-control';
}
$columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null;
$this->setColumnsSize($columnsSize);
parent::__construct($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'select';
@ -258,6 +262,22 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
// }}}
// {{{ setMultiple()
/**
* @return null
*/
public function getColumnsSize()
{
return $this->columnsSize;
}
/**
* @param null $columnsSize
*/
public function setColumnsSize($columnsSize)
{
$this->columnsSize = $columnsSize;
}
/**
* Sets the select mutiple attribute
*
@ -659,8 +679,22 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
*/
public function getTemplate($layout)
{
/*$size = $this->getInputSize();
$size = empty($size) ? '8' : $size;*/
$size = $this->getColumnsSize();
if (empty($size)) {
$size = array(2, 8, 2);
} else {
if (is_array($size)) {
if (count($size) == 1) {
$size = array(2, intval($size[0]), 2);
} elseif (count($size) != 3) {
$size = array(2, 8, 2);
}
// else just keep the $size array as received
} else {
$size = array(2, intval($size), 2);
}
}
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
@ -676,11 +710,11 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="form-group {error_class}">
<label {label-for} class="col-sm-2 control-label" >
<label {label-for} class="col-sm-'.$size[0].' control-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-8">
<div class="col-sm-'.$size[1].'">
{icon}
{element}
@ -692,7 +726,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
<span class="help-inline">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-2">
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->

@ -34,6 +34,7 @@
class HTML_QuickForm_text extends HTML_QuickForm_input
{
private $inputSize;
private $columnsSize;
/**
* Class constructor
@ -56,6 +57,8 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
}
$inputSize = isset($attributes['input-size']) ? $attributes['input-size'] : null;
$this->setInputSize($inputSize);
$columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null;
$this->setColumnsSize($columnsSize);
$icon = isset($attributes['icon']) ? $attributes['icon'] : null;
$this->setIcon($icon);
@ -98,8 +101,29 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
*/
public function getTemplate($layout)
{
$size = $this->getInputSize();
$size = empty($size) ? '8' : $size;
$size = $this->getColumnsSize();
if (empty($size)) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = array(2, $sizeTemp, 2);
} else {
if (is_array($size)) {
if (count($size) != 3) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = array(2, $sizeTemp, 2);
}
// else just keep the $size array as received
} else {
$size = array(2, intval($size), 2);
}
}
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
@ -115,11 +139,11 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="form-group {error_class}">
<label {label-for} class="col-sm-2 control-label" >
<label {label-for} class="col-sm-'.$size[0].' control-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size.'">
<div class="col-sm-'.$size[1].'">
{icon}
{element}
@ -131,7 +155,7 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
<span class="help-inline">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-2">
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
@ -163,7 +187,21 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
{
$this->inputSize = $inputSize;
}
/**
* @return null
*/
public function getColumnsSize()
{
return $this->columnsSize;
}
/**
* @param null $columnsSize
*/
public function setColumnsSize($columnsSize)
{
$this->columnsSize = $columnsSize;
}
/**
* Sets size of text field
*

@ -167,31 +167,49 @@
});
});
</script>
<div class="row">
<div class="col-md-4">
{{ left_block }}
</div>
<div class="col-md-8">
<h3>
{{ 'ItemsTheReferenceDependsOn' | get_lang }}
</h3>
<div id="parents">
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-md-12">
{{ create_sequence }}
</div>
</div>
</div>
</div>
<h3>{{ 'Item' | get_lang }}</h3>
<div id="resource">
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-md-12">
{{ save_sequence }}
</div>
</div>
<h3>{{ 'Dependencies' | get_lang }}</h3>
<div id="children">
<div class="row">
<div class="col-md-6">
{{ left_block }}
</div>
<div class="col-md-6">
<h3>
{{ 'ItemsTheReferenceDependsOn' | get_lang }}
</h3>
<div id="parents">
</div>
<h3>{{ 'Item' | get_lang }}</h3>
<div id="resource">
</div>
<h3>{{ 'Dependencies' | get_lang }}</h3>
<div id="children">
</div>
<h3>{{ 'Graph' | get_lang }}</h3>
<div id="show_graph"></div>
{{ right_block }}
</div>
</div>
<h3>{{ 'Graph' | get_lang }}</h3>
<div id="show_graph"></div>
{{ right_block }}
</div>
</div>
{% endblock %}

Loading…
Cancel
Save