Add new form layout LAYOUT_BOX_NO_LABEL used in the login page.

1.10.x
Julio Montoya 11 years ago
parent a135e1bd42
commit 41acfabcf1
  1. 2
      main/admin/user_add.php
  2. 6
      main/css/base.css
  3. 16
      main/document/document.php
  4. 2
      main/glossary/glossary_form.class.php
  5. 2
      main/glossary/index.php
  6. 15
      main/inc/lib/course.lib.php
  7. 2
      main/inc/lib/formvalidator/Element/DatePicker.php
  8. 87
      main/inc/lib/formvalidator/Element/DatePickerDate.php
  9. 2
      main/inc/lib/formvalidator/Element/DateRangePicker.php
  10. 2
      main/inc/lib/formvalidator/Element/DateTimePicker.php
  11. 4
      main/inc/lib/formvalidator/Element/HtmlEditor.php
  12. 2
      main/inc/lib/formvalidator/Element/Number.php
  13. 3
      main/inc/lib/formvalidator/Element/calendar_popup.php
  14. 220
      main/inc/lib/formvalidator/Element/style_button.php
  15. 84
      main/inc/lib/formvalidator/Element/style_reset_button.php
  16. 91
      main/inc/lib/formvalidator/Element/style_submit_button.php
  17. 89
      main/inc/lib/formvalidator/FormValidator.class.php
  18. 3
      main/inc/lib/pear/HTML/QuickForm.php
  19. 2
      main/inc/lib/pear/HTML/QuickForm/CAPTCHA.php
  20. 73
      main/inc/lib/pear/HTML/QuickForm/Renderer/Default.php
  21. 17
      main/inc/lib/pear/HTML/QuickForm/advmultiselect.php
  22. 48
      main/inc/lib/pear/HTML/QuickForm/button.php
  23. 2
      main/inc/lib/pear/HTML/QuickForm/checkbox.php
  24. 51
      main/inc/lib/pear/HTML/QuickForm/element.php
  25. 2
      main/inc/lib/pear/HTML/QuickForm/email.php
  26. 2
      main/inc/lib/pear/HTML/QuickForm/file.php
  27. 2
      main/inc/lib/pear/HTML/QuickForm/group.php
  28. 2
      main/inc/lib/pear/HTML/QuickForm/hidden.php
  29. 2
      main/inc/lib/pear/HTML/QuickForm/hiddenselect.php
  30. 2
      main/inc/lib/pear/HTML/QuickForm/image.php
  31. 12
      main/inc/lib/pear/HTML/QuickForm/input.php
  32. 2
      main/inc/lib/pear/HTML/QuickForm/link.php
  33. 35
      main/inc/lib/pear/HTML/QuickForm/password.php
  34. 5
      main/inc/lib/pear/HTML/QuickForm/radio.php
  35. 2
      main/inc/lib/pear/HTML/QuickForm/reset.php
  36. 60
      main/inc/lib/pear/HTML/QuickForm/select.php
  37. 2
      main/inc/lib/pear/HTML/QuickForm/submit.php
  38. 105
      main/inc/lib/pear/HTML/QuickForm/text.php
  39. 77
      main/inc/lib/userportal.lib.php

@ -275,7 +275,7 @@ $form->setDefaults($defaults);
// Submit button
$html_results_enabled[] = $form->createElement('button', 'submit', get_lang('Add'), 'plus', 'primary');
$html_results_enabled[] = $form->createElement('button', 'submit_plus', get_lang('Add').'+');
$html_results_enabled[] = $form->createElement('button', 'submit_plus', get_lang('Add').'+', 'plus', 'primary');
$form->addGroup($html_results_enabled);

@ -5484,4 +5484,8 @@ i.size-32.icon-new-work{
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
text-decoration: none;
}
}
.actions .form-inline {
display:inline-block;
}

@ -1509,17 +1509,21 @@ if (!isset($folders) || $folders === false) {
$actions = '<div class="actions">';
if (!$is_certificate_mode) {
/* BUILD SEARCH FORM */
$actions .= '<span style="display:inline-block;">';
$form = new FormValidator('search_document', 'get', api_get_self().'?'.api_get_cidreq());
$renderer = & $form->defaultRenderer();
$renderer->setElementTemplate('<span>{element}</span> ');
$form = new FormValidator(
'search_document',
'get',
api_get_self().'?'.api_get_cidreq(),
'',
array(),
FormValidator::LAYOUT_INLINE
);
$form->addText('keyword', '', false, array('class' => 'col-md-2'));
$form->addElement('hidden', 'cidReq', api_get_course_id());
$form->addElement('hidden', 'id_session', api_get_session_id());
$form->addElement('hidden', 'gidReq', $groupId);
$form->addButtonSearch(get_lang('Search'));
$actions .= $form->return_form();
$actions .= '</span>';
$actions .= $form->returnForm();
}
/* GO TO PARENT DIRECTORY */

@ -77,7 +77,7 @@ class GlossaryForm extends \FormValidator
$this->addHeader($form_name);
$this->addText('name', get_lang('TermName'), $required = true, array('class' => 'span3'));
$this->addHtmlEditor('description', get_lang('TermDefinition'), true, array('ToolbarSet' => 'Glossary', 'Width' => '90%', 'Height' => '300'));
$this->addHtmlEditor('description', get_lang('TermDefinition'), true, array('ToolbarSet' => 'Glossary', 'Height' => '300'));
$this->addButton('save', get_lang('Save'));
$this->setDefaults($defaults);

@ -134,7 +134,7 @@ if (api_is_allowed_to_edit(null, true)) {
$form->addElement('hidden', 'glossary_id');
$form->addElement('text', 'glossary_title', get_lang('TermName'),array('size'=>'80'));
//$form->applyFilter('glossary_title', 'html_filter');
$form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '90%', 'Height' => '300'));
$form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Height' => '300'));
$element = $form->addElement('text', 'insert_date', get_lang('CreationDate'),array('size'=>'100'));
$element->freeze();
$element = $form->addElement('text', 'update_date', get_lang('UpdateDate'),array('size'=>'100'));

@ -3299,7 +3299,7 @@ class CourseManager
$notifications = isset($params['notifications']) ? $params['notifications'] : null;
$html.= $params['title']. $notifications;
$html.='</li>';
return $html;
}
@ -5321,8 +5321,13 @@ class CourseManager
$result[$content['value']] = $content['content'];
}
$group = $form->addElement('advmultiselect', 'users', get_lang('Users'), $result,
array('select_all_checkbox' => true));
$form->addElement(
'advmultiselect',
'users',
get_lang('Users'),
$result,
array('select_all_checkbox' => true)
);
}
/**
@ -5344,7 +5349,7 @@ class CourseManager
$result[$content['value']] = $content['content'];
}
$group = $form->addElement('advmultiselect', 'users', get_lang('Users'), $result);
$form->addElement('advmultiselect', 'users', get_lang('Users'), $result);
}
/**
@ -5375,7 +5380,7 @@ class CourseManager
) { // $to_already_selected is the array containing the groups (and users) that are already selected
$user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser');
$user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled";
$result [] = array(
$result[] = array(
'disabled' => $user_disabled,
'value' => "GROUP:" . $this_group['id'],
'content' => "G: " . $this_group['name'] . " - " . $this_group['userNb'] . " " . $user_label

@ -20,7 +20,7 @@ class DatePicker extends HTML_QuickForm_text
}
$attributes['class'] = 'form-control';
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->_appendName = true;
$this->_type = 'date_picker';
}

@ -1,87 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Form element to select a date and hour (with popup datepicker)
* @deprecated use DatePicker
*/
class DatePickerDate extends HTML_QuickForm_date
{
/**
* Constructor
* @deprecated use class DatePicker
*/
public function DatePickerDate($elementName = null, $elementLabel = null, $attributes = null)
{
global $myMinYear, $myMaxYear;
$js_form_name = $attributes['form_name'];
unset($attributes['form_name']);
HTML_QuickForm_element :: HTML_QuickForm_element($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_appendName = true;
$this->_type = 'datepicker';
$popup_link = '<a href="javascript:openCalendar(\''.$js_form_name.'\',\''.$elementName.'\')"><img src="'.api_get_path(WEB_IMG_PATH).'calendar_select.gif" style="vertical-align:middle;" alt="Select Date" /></a>';
$special_chars = array ('D', 'l', 'd', 'M', 'F', 'm', 'y', 'H', 'a', 'A', 's', 'i', 'h', 'g', ' ');
foreach ($special_chars as $char) {
$popup_link = str_replace($char, "\\".$char, $popup_link);
}
$lang_code = api_get_language_isocode();
// If translation not available in PEAR::HTML_QuickForm_date, add the Chamilo-translation
if (! array_key_exists($lang_code,$this->_locale)) {
$this->_locale[$lang_code]['months_long'] = api_get_months_long();
}
$this->_options['format'] = 'dFY '.$popup_link;
$this->_options['minYear'] = date('Y')-5;
$this->_options['maxYear'] = date('Y')+10;
$this->_options['language'] = $lang_code;
}
/**
* HTML code to display this datepicker
*/
function toHtml()
{
$js = $this->getElementJS();
return $js.parent :: toHtml();
}
/**
* Get the necessary javascript for this datepicker
*/
function getElementJS()
{
$js = '';
if(!defined('DATEPICKER_JAVASCRIPT_INCLUDED')) {
define('DATEPICKER_JAVASCRIPT_INCLUDED', 1);
$js = "\n";
$js .= '<script src="';
$js .= api_get_path(WEB_CODE_PATH).'inc/lib/formvalidator/Element/';
$js .= 'tbl_change.js.php" type="text/javascript"></script>';
$js .= "\n";
}
return $js;
}
/**
* Export the date value in MySQL format
* @return string YYYY-MM-DD HH:II:SS
*/
function exportValue(&$submitValues, $assoc = false)
{
$values = parent::getValue();
$y = $values['Y'][0];
$m = $values['F'][0];
$d = $values['d'][0];
$m = $m < 10 ? '0'.$m : $m;
$d = $d < 10 ? '0'.$d : $d;
$datetime = $y.'-'.$m.'-'.$d;
$result[$this->getName()]= $datetime;
return $result;
}
/**
* Sets an option to a value
*/
function setLocalOption($name,$value)
{
$this->_options[$name] = $value;
}
}

@ -15,7 +15,7 @@ class DateRangePicker extends HTML_QuickForm_text
$attributes['id'] = $elementName;
}
$attributes['class'] = 'form-control';
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->_appendName = true;
$this->_type = 'date_range_picker';
}

@ -15,7 +15,7 @@ class DateTimePicker extends HTML_QuickForm_text
$attributes['id'] = $elementName;
}
$attributes['class'] = 'form-control';
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->_appendName = true;
$this->_type = 'date_time_picker';
}

@ -24,7 +24,7 @@ class HtmlEditor extends HTML_QuickForm_textarea
* @param array $config Optional configuration settings for the online editor.
* @return bool
*/
public function HtmlEditor(
public function __construct(
$name = null,
$elementLabel = null,
$attributes = null,
@ -34,7 +34,7 @@ class HtmlEditor extends HTML_QuickForm_textarea
return false;
}
HTML_QuickForm_element :: HTML_QuickForm_element($name, $elementLabel, $attributes);
parent::__construct($name, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'html_editor';

@ -22,7 +22,7 @@ class Number extends HTML_QuickForm_text
$attributes['type'] = 'number';
$attributes['class'] = 'form-control';
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->_appendName = true;
$this->_type = 'number';
}

@ -1,5 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @deprecated code use DatePicker or DateTimePicker
*/
require_once dirname(__FILE__).'/../../../global.inc.php';
//session

@ -1,220 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* 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
* 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
* 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.
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @copyright 2001-2007 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: input.php 17344 2008-12-17 08:55:29Z Scara84 $
* @link http://pear.php.net/package/HTML_QuickForm
*/
/**
* Base class for <button></button> form elements
*
* @category HTML
* @package HTML_QuickForm
* @author Hans De Bisschop <hans.de.bisschop@ehb.be>
* @abstract
*/
class HTML_QuickForm_style_button extends HTML_QuickForm_element
{
// {{{ constructor
/**
* Class constructor
*
* @param string Input field name attribute
* @param mixed Label(s) for the input field
* @param mixed Either a typical HTML attribute string or an associative array
* @since 1.0
* @access public
* @return void
*/
function HTML_QuickForm_style_button($elementName=null, $elementLabel=null, $attributes=null)
{
$this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
} //end constructor
// }}}
// {{{ setType()
/**
* Sets the element type
*
* @param string $type Element type
* @since 1.0
* @access public
* @return void
*/
/* Returns an HTML formatted attribute string
* @param array $attributes
* @return string
* @access private
*/
function _getAttrString($attributes) {
$strAttr = '';
if (is_array($attributes)) {
foreach ($attributes as $key => $value) {
if ($key != 'value') $strAttr .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
}
}
return $strAttr;
} // end func _getAttrString
function setType($type)
{
$this->_type = $type;
$this->updateAttributes(array('type'=>$type));
} // end func setType
// }}}
// {{{ setName()
/**
* Sets the input field name
*
* @param string $name Input field name attribute
* @since 1.0
* @access public
* @return void
*/
function setName($name)
{
$this->updateAttributes(array('name'=>$name));
} //end func setName
// }}}
// {{{ getName()
/**
* Returns the element name
*
* @since 1.0
* @access public
* @return string
*/
function getName()
{
return $this->getAttribute('name');
} //end func getName
// }}}
// {{{ setValue()
/**
* Sets the value of the form element
*
* @param string $value Default value of the form element
* @since 1.0
* @access public
* @return void
*/
function setValue($value)
{
$this->updateAttributes(array('value'=>$value));
} // end func setValue
// }}}
// {{{ getValue()
/**
* Returns the value of the form element
*
* @since 1.0
* @access public
* @return string
*/
function getValue()
{
//return $this->getAttribute('value');
return $this->_attributes['value'];
} // end func getValue
// }}}
// {{{ toHtml()
/**
* Returns the input field in HTML
*
* @since 1.0
* @access public
* @return string
*/
function toHtml() {
if ($this->_flagFrozen) {
return $this->getFrozenHtml();
} else {
//Adding the btn class
if (isset($this->_attributes['class'])) {
$this->_attributes['class'] = 'btn '.$this->_attributes['class'];
}
return $this->_getTabs().'<button ' . $this->_getAttrString($this->_attributes) . ' >'.$this->getValue() .'</button>';
}
} //end func toHtml
// }}}
// {{{ onQuickFormEvent()
/**
* Called by HTML_QuickForm whenever form event is made on this element
*
* @param string $event Name of event
* @param mixed $arg event arguments
* @param object &$caller calling object
* @since 1.0
* @access public
* @return void
* @throws
*/
function onQuickFormEvent($event, $arg, &$caller)
{
// do not use submit values for button-type elements
$type = $this->getType();
if (('updateValue' != $event) ||
('submit' != $type && 'reset' != $type && 'button' != $type)) {
parent::onQuickFormEvent($event, $arg, $caller);
} else {
$value = $this->_findValue($caller->_constantValues);
if (null === $value) {
$value = $this->_findValue($caller->_defaultValues);
}
if (null !== $value) {
$this->setValue($value);
}
}
return true;
} // end func onQuickFormEvent
// }}}
// {{{ exportValue()
/**
* We don't need values from button-type elements (except submit) and files
*/
function exportValue(&$submitValues, $assoc = false)
{
$type = $this->getType();
if ('reset' == $type || 'button' == $type) {
return null;
} else {
return parent::exportValue($submitValues, $assoc);
}
}
} // end class HTML_QuickForm_element

@ -1,84 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* HTML class for a submit type element
*
* PHP versions 4 and 5
*
* 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:
* 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
* 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 Bertrand Mansion <bmansion@mamasam.com>
* @copyright 2001-2007 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: submit.php 17344 2008-12-17 08:55:29Z Scara84 $
* @link http://pear.php.net/package/HTML_QuickForm
*/
/**
* HTML class for a submit type element
*
* @category HTML
* @package HTML_QuickForm
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @version Release: 3.2.10
* @since 1.0
*/
class HTML_QuickForm_styleresetbutton extends HTML_QuickForm_style_button
{
// {{{ constructor
/**
* Class constructor
*
* @param string Input field name attribute
* @param string Input field value
* @param mixed Either a typical HTML attribute string or an associative array
* @since 1.0
* @access public
* @return void
*/
function HTML_QuickForm_styleresetbutton($elementName=null, $value=null, $attributes=null)
{
HTML_QuickForm_style_button::HTML_QuickForm_style_button($elementName, null, $attributes, $value);
$this->setValue($value);
$this->setType('reset');
} //end constructor
// }}}
// {{{ freeze()
/**
* Freeze the element so that only its value is returned
*
* @access public
* @return void
*/
function freeze()
{
return false;
} //end func freeze
// }}}
// {{{ exportValue()
/**
* Only return the value if it is found within $submitValues (i.e. if
* this particular submit button was clicked)
*/
function exportValue(&$submitValues, $assoc = false)
{
return $this->_prepareValue($this->_findValue($submitValues), $assoc);
}
// }}}
} //end class HTML_QuickForm_submit
?>

@ -32,10 +32,8 @@
* @version Release: 3.2.10
* @since 1.0
*/
class HTML_QuickForm_style_submit_button extends HTML_QuickForm_style_button
class HTML_QuickForm_style_submit_button extends HTML_QuickForm_input
{
// {{{ constructor
/**
* Class constructor
*
@ -46,7 +44,8 @@ class HTML_QuickForm_style_submit_button extends HTML_QuickForm_style_button
* @access public
* @return void
*/
function HTML_QuickForm_style_submit_button($elementName = null, $value = null, $attributes = null, $img = null) {
public function __construct($elementName = null, $value = null, $attributes = null, $img = null)
{
if (empty($attributes)) {
$attributes = array();
}
@ -56,10 +55,10 @@ class HTML_QuickForm_style_submit_button extends HTML_QuickForm_style_button
$attributes['class'] = 'btn';
}
}
HTML_QuickForm_style_button::HTML_QuickForm_style_button($elementName, null, $attributes, $value, $img);
parent::__construct($elementName, null, $attributes, $value, $img);
$this->setValue($value);
$this->setType('submit');
} //end constructor
}
/**
* Freeze the element so that only its value is returned
@ -67,19 +66,83 @@ class HTML_QuickForm_style_submit_button extends HTML_QuickForm_style_button
* @access public
* @return void
*/
function freeze() {
public function freeze()
{
return false;
} //end func freeze
// }}}
// {{{ exportValue()
}
/**
* Only return the value if it is found within $submitValues (i.e. if
* this particular submit button was clicked)
*/
function exportValue(&$submitValues, $assoc = false) {
public function exportValue(&$submitValues, $assoc = false)
{
return $this->_prepareValue($this->_findValue($submitValues), $assoc);
}
// }}}
} //end class HTML_QuickForm_submit
/**
* @return string
*/
public function toHtml()
{
if ($this->_flagFrozen) {
return $this->getFrozenHtml();
} else {
//Adding the btn class
if (isset($this->_attributes['class'])) {
$this->_attributes['class'] = 'btn '.$this->_attributes['class'];
}
return '<button ' . $this->_getAttrString($this->_attributes) . ' >'.$this->getValue() .'</button>';
}
}
/**
* Called by HTML_QuickForm whenever form event is made on this element
*
* @param string $event Name of event
* @param mixed $arg event arguments
* @param object &$caller calling object
* @since 1.0
* @access public
* @return void
* @throws
*/
public function onQuickFormEvent($event, $arg, &$caller)
{
// do not use submit values for button-type elements
$type = $this->getType();
if (('updateValue' != $event) ||
('submit' != $type && 'reset' != $type && 'button' != $type)) {
parent::onQuickFormEvent($event, $arg, $caller);
} else {
$value = $this->_findValue($caller->_constantValues);
if (null === $value) {
$value = $this->_findValue($caller->_defaultValues);
}
if (null !== $value) {
$this->setValue($value);
}
}
return true;
}
/**
* Returns an HTML formatted attribute string
* @param array $attributes
* @return string
* @access private
*/
public function _getAttrString($attributes)
{
$strAttr = '';
if (is_array($attributes)) {
foreach ($attributes as $key => $value) {
if ($key != 'value') $strAttr .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
}
}
return $strAttr;
}
}

@ -9,7 +9,11 @@ class FormValidator extends HTML_QuickForm
{
const LAYOUT_HORIZONTAL = 'horizontal';
const LAYOUT_INLINE = 'inline';
const LAYOUT_BOX = 'box';
const LAYOUT_BOX_NO_LABEL = 'box-no-label';
public $with_progress_bar = false;
private $layout;
/**
* Constructor
@ -27,7 +31,7 @@ class FormValidator extends HTML_QuickForm
$method = 'post',
$action = '',
$target = '',
$attributes = null,
$attributes = array(),
$layout = self::LAYOUT_HORIZONTAL,
$trackSubmit = true
) {
@ -40,11 +44,14 @@ class FormValidator extends HTML_QuickForm
$layout = 'inline';
}
$this->setLayout($layout);
switch ($layout) {
case self::LAYOUT_HORIZONTAL:
$attributes['class'] = 'form-horizontal';
break;
case self::LAYOUT_INLINE:
case self::LAYOUT_BOX:
$attributes['class'] = 'form-inline';
break;
}
@ -82,7 +89,7 @@ class FormValidator extends HTML_QuickForm
$elementTemplate = ' {label} {element} ';
$renderer->setElementTemplate($elementTemplate);
} else {
$renderer->setElementTemplate($this->getElementTemplate());
$renderer->setElementTemplate($this->getDefaultElementTemplate());
// Display a gray div in the buttons
$templateSimple = '<div class="form-actions">{label} {element}</div>';
@ -135,7 +142,7 @@ EOT;
/**
* @return string
*/
public function getElementTemplate()
public function getDefaultElementTemplate()
{
return '
<div class="form-group {error_class}">
@ -144,6 +151,7 @@ EOT;
{label}
</label>
<div class="col-sm-8">
{icon}
{element}
<!-- BEGIN label_2 -->
@ -162,6 +170,23 @@ EOT;
</div>';
}
/**
* @return string
*/
public function getLayout()
{
return $this->layout;
}
/**
* @param string $layout
*/
public function setLayout($layout)
{
$this->layout = $layout;
}
/**
* Adds a text field to the form.
* A trim-filter is attached to the field.
@ -606,11 +631,13 @@ EOT;
* @param string $label The label for the form-element
* @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 array $config (optional) Configuration settings for the online editor.
* @param array $config (optional) Configuration settings for the online editor.
*/
public function addHtmlEditor($name, $label, $required = true, $fullPage = false, $config = array())
{
$this->addElement('html_editor', $name, $label, 'rows="15" cols="80"', $config);
$config['rows'] = isset($config['rows']) ? $config['rows'] : 15;
$config['cols'] = isset($config['cols']) ? $config['cols'] : 80;
$this->addElement('html_editor', $name, $label, $config);
$this->applyFilter($name, 'trim');
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
@ -731,30 +758,16 @@ EOT;
*/
public function display()
{
echo $this->return_form();
echo $this->returnForm();
}
/**
* Returns the HTML code of the form.
* If an element in the form didn't validate, an error message is showed
* asking the user to complete the form.
*
* @return string $return_value HTML code of the form
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, august 2006
* @author Julio Montoya
*/
public function return_form()
public function returnForm()
{
$error = false;
$addDateLibraries = false;
$dateElementTypes = array(
'date_range_picker',
'date_time_picker',
'date_picker',
'datepicker',
'datetimepicker'
);
/** @var HTML_QuickForm_element $element */
foreach ($this->_elements as $element) {
if (!is_null(parent::getElementError($element->getName()))) {
@ -762,22 +775,40 @@ EOT;
break;
}
}
$return_value = '';
$returnValue = '';
$js = null;
if ($error) {
$return_value = Display::return_message(get_lang('FormHasErrorsPleaseComplete'),
'warning');
$returnValue = Display::return_message(
get_lang('FormHasErrorsPleaseComplete'),
'warning'
);
}
$return_value .= $js;
$return_value .= parent::toHtml();
$returnValue .= $js;
$returnValue .= parent::toHtml();
// Add div-element which is to hold the progress bar
if (isset($this->with_progress_bar) && $this->with_progress_bar) {
$return_value .= '<div id="dynamic_div" style="display:block; margin-left:40%; margin-top:10px; height:50px;"></div>';
$returnValue .= '<div id="dynamic_div" style="display:block; margin-left:40%; margin-top:10px; height:50px;"></div>';
}
return $return_value;
return $returnValue;
}
/**
* Returns the HTML code of the form.
* If an element in the form didn't validate, an error message is showed
* asking the user to complete the form.
*
* @return string $return_value HTML code of the form
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, august 2006
* @author Julio Montoya
* @deprecated use returnForm()
*/
public function return_form()
{
return $this->returnForm();
}
/**
@ -866,7 +897,7 @@ EOT;
}
/**
* @return null
* @return HTML_QuickForm_Renderer_Default
*/
public static function getDefaultRenderer()
{

@ -1761,7 +1761,8 @@ class HTML_QuickForm extends HTML_Common
* @since 1.0
* @access public
*/
function toHtml ($in_data = null) {
public function toHtml($in_data = null)
{
if (!is_null($in_data)) {
$this->addElement('html', $in_data);
}

@ -115,7 +115,7 @@ class HTML_QuickForm_CAPTCHA extends HTML_QuickForm_input
function HTML_QuickForm_CAPTCHA($elementName = null, $elementLabel = null,
$options = null, $attributes = null)
{
HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->setType('CAPTCHA_'.$this->_CAPTCHA_driver);
if (is_array($options)) {

@ -36,6 +36,8 @@
*/
class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer
{
private $form;
/**
* The HTML of the form
* @var string
@ -174,10 +176,30 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer
*/
function startForm(&$form)
{
$this->setForm($form);
$this->_html = '';
$this->_hiddenHtml = '';
}
/**
* @return FormValidator
*/
public function getForm()
{
return $this->form;
}
/**
* @param mixed $form
*/
public function setForm($form)
{
$this->form = $form;
} // end func startForm
/**
* Called when visiting a form, after processing all form elements
* Adds required note, form attributes, validation javascript and form content.
@ -228,51 +250,63 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer
/**
* Helper method for renderElement
*
* @param string Element name
* @param mixed Element label (if using an array of labels, you should set the appropriate template)
* @param HTML_QuickForm_element $element
* @param bool Whether an element is required
* @param string Error message associated with the element
* @param string Label for ID
* @param string $required Error message associated with the element
* @param string $error Label for ID
* @access private
* @see renderElement()
* @return string Html for element
*/
function _prepareTemplate($name, $label, $required, $error, $labelForId = '')
private function _prepareTemplate(HTML_QuickForm_element $element, $required, $error)
{
$name = $element->getName();
$label = $element->getLabel();
$labelForId = $element->getLabelFor();
$icon = $element->getIconToHtml();
if (is_array($label)) {
$nameLabel = array_shift($label);
} else {
$nameLabel = $label;
}
if (!empty($labelForId)) {
$labelFor = 'for="' . $labelForId . '"';
} else {
$labelFor = '';
}
$labelFor = !empty($labelForId) ? 'for="' . $labelForId . '"' : '';
if (isset($this->_templates[$name])) {
// Custom template
$html = str_replace('{label}', $nameLabel, $this->_templates[$name]);
$html = str_replace('{label-for}', $labelFor, $html);
} else {
$html = str_replace('{label}', $nameLabel, $this->_elementTemplate);
$html = str_replace('{label-for}', $labelFor, $html);
if (method_exists($element, 'getTemplate')) {
$template = $element->getTemplate($this->getForm()->getLayout());
} else {
$template = $this->getForm()->getDefaultElementTemplate();
}
$html = str_replace('{label}', $nameLabel, $template);
// Default template
//$html = str_replace('{label}', $nameLabel, $this->_elementTemplate);
}
$html = str_replace('{label-for}', $labelFor, $html);
$html = str_replace('{icon}', $icon, $html);
if ($required) {
$html = str_replace('<!-- BEGIN required -->', '', $html);
$html = str_replace('<!-- END required -->', '', $html);
} else {
$html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->.*<!-- END required -->([ \t\n\r]*)?/isU", '', $html);
}
if (isset($error)) {
$html = str_replace('{error}', $error, $html);
$html = str_replace('{error_class}', 'error has-error', $html);
$html = str_replace('<!-- BEGIN error -->', '', $html);
$html = str_replace('<!-- END error -->', '', $html);
} else {
$html = str_replace('{error_class}', '', $html);
$html = str_replace('{error_class}', '', $html);
$html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN error -->.*<!-- END error -->([ \t\n\r]*)?/isU", '', $html);
}
if (is_array($label)) {
foreach($label as $key => $text) {
foreach ($label as $key => $text) {
$key = is_int($key)? $key + 2: $key;
$html = str_replace("{label_{$key}}", $text, $html);
$html = str_replace("<!-- BEGIN label_{$key} -->", '', $html);
@ -282,6 +316,7 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer
if (strpos($html, '{label_')) {
$html = preg_replace('/\s*<!-- BEGIN label_(\S+) -->.*<!-- END label_\1 -->\s*/is', '', $html);
}
return $html;
} // end func _prepareTemplate
@ -299,11 +334,9 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer
{
if (!$this->_inGroup) {
$html = $this->_prepareTemplate(
$element->getName(),
$element->getLabel(),
$element,
$required,
$error,
$element->getLabelFor()
$error
);
$this->_html .= str_replace('{element}', $element->toHtml(), $html);
@ -360,7 +393,7 @@ class HTML_QuickForm_Renderer_Default extends HTML_QuickForm_Renderer
function startGroup(&$group, $required, $error)
{
$name = $group->getName();
$this->_groupTemplate = $this->_prepareTemplate($name, $group->getLabel(), $required, $error);
$this->_groupTemplate = $this->_prepareTemplate($group, $required, $error);
$this->_groupElementTemplate = empty($this->_groupTemplates[$name])? '': $this->_groupTemplates[$name];
$this->_groupWrap = empty($this->_groupWraps[$name])? '': $this->_groupWraps[$name];
$this->_groupElements = array();

@ -533,15 +533,12 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
} else {
$this->_elementTemplate = '
{javascript}
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
<td valign="top">{unselected}</td>
<td align="center">{add}{remove}</td>
<td valign="top">{selected}</td>
</tr>
</table>
<div class="col-sm-3"><!-- BEGIN label_2 -->{label_2}<!-- END label_2 --> {unselected}</div>
<div class="col-sm-2"><div class="text-center">{add}{remove}</div></div>
<div class="col-sm-3">
<!-- BEGIN label_3 -->{label_3}<!-- END label_3 -->{selected}</div>
';
}
if ($js == false) {
@ -1010,9 +1007,11 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
if ($this->selectAllCheckBox) {
$strHtml .= '
<div class="col-sm-8">
<label class="checkbox" >'.get_lang('SelectAll').'
<input type="checkbox" class="advmultiselect_checkbox" id="'.$selectId.'_select_all'.'">
</label>
</div>
';
}

@ -196,4 +196,52 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
{
return false;
}
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '
{element}
';
break;
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="form-group {error_class}">
<label {label-for} class="col-sm-2 control-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-8">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-2">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
</div>
</div>';
break;
case FormValidator::LAYOUT_BOX:
case FormValidator::LAYOUT_BOX_NO_LABEL:
return '
{element}
';
break;
}
}
}

@ -68,7 +68,7 @@ class HTML_QuickForm_checkbox extends HTML_QuickForm_input
$text = '',
$attributes = null
) {
HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_text = $text;
$this->setType('checkbox');

@ -37,6 +37,9 @@
*/
class HTML_QuickForm_element extends HTML_Common
{
private $layout;
private $icon;
// {{{ properties
/**
@ -88,7 +91,7 @@ class HTML_QuickForm_element extends HTML_Common
* @access public
* @return void
*/
function HTML_QuickForm_element($elementName = null, $elementLabel = null, $attributes = null)
public function __construct($elementName = null, $elementLabel = null, $attributes = null)
{
parent::__construct($attributes);
if (isset($elementName)) {
@ -109,6 +112,46 @@ class HTML_QuickForm_element extends HTML_Common
}
}
/**
* @return string
*/
public function getLayout()
{
return $this->layout;
}
/**
* @param string $layout
*/
public function setLayout($layout)
{
$this->layout = $layout;
}
/**
* @return string
*/
public function getIcon()
{
return $this->icon;
}
/**
* @return string
*/
public function getIconToHtml()
{
return $this->icon;
}
/**
* @param mixed $icon
*/
public function setIcon($icon)
{
$this->icon = $icon;
}
/**
* Returns the current API version
*
@ -238,7 +281,7 @@ class HTML_QuickForm_element extends HTML_Common
* @access public
* @return string
*/
function getFrozenHtml()
public function getFrozenHtml()
{
$value = $this->getValue();
// Modified by Ivan Tcholakov, 16-MAR-2010.
@ -284,7 +327,7 @@ class HTML_QuickForm_element extends HTML_Common
* @access public
* @return bool
*/
function isFrozen()
public function isFrozen()
{
return $this->_flagFrozen;
} // end func isFrozen
@ -318,7 +361,7 @@ class HTML_QuickForm_element extends HTML_Common
* @access public
* @return void
*/
function setLabel($label, $labelFor = null)
public function setLabel($label, $labelFor = null)
{
$this->_label = $label;
if (!empty($labelFor)) {

@ -28,7 +28,7 @@ class HTML_QuickForm_email extends HTML_QuickForm_input
*/
function HTML_QuickForm_email($elementName=null, $elementLabel=null, $attributes=null)
{
HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->setType('email');
} //end constructor

@ -67,7 +67,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
*/
function HTML_QuickForm_file($elementName=null, $elementLabel=null, $attributes=null)
{
HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->setType('file');
} //end constructor

@ -91,7 +91,7 @@ class HTML_QuickForm_group extends HTML_QuickForm_element
* @access public
* @return void
*/
function HTML_QuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true)
public function __construct($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true)
{
parent::__construct($elementName, $elementLabel);
$this->_type = 'group';

@ -49,7 +49,7 @@ class HTML_QuickForm_hidden extends HTML_QuickForm_input
*/
public function HTML_QuickForm_hidden($elementName = null, $value = '', $attributes = null)
{
HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes);
parent::__construct($elementName, null, $attributes);
$this->setType('hidden');
$this->setValue($value);
} //end constructor

@ -53,7 +53,7 @@ class HTML_QuickForm_hiddenselect extends HTML_QuickForm_select
*/
function HTML_QuickForm_hiddenselect($elementName=null, $elementLabel=null, $options=null, $attributes=null)
{
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'hiddenselect';
if (isset($options)) {

@ -49,7 +49,7 @@ class HTML_QuickForm_image extends HTML_QuickForm_input
*/
function HTML_QuickForm_image($elementName=null, $src='', $attributes=null)
{
HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes);
parent::__construct($elementName, null, $attributes);
$this->setType('image');
$this->setSource($src);
} // end class constructor

@ -47,9 +47,9 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
* @access public
* @return void
*/
function HTML_QuickForm_input($elementName=null, $elementLabel=null, $attributes=null)
public function __construct($elementName=null, $elementLabel=null, $attributes=null)
{
$this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
} //end constructor
// }}}
@ -195,4 +195,12 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
return parent::exportValue($submitValues, $assoc);
}
}
/**
* @param string $layout
*/
public function getTemplate($layout)
{
}
}

@ -62,7 +62,7 @@ class HTML_QuickForm_link extends HTML_QuickForm_static
*/
function HTML_QuickForm_link($elementName=null, $elementLabel=null, $href=null, $text=null, $attributes=null)
{
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = false;
$this->_type = 'link';
$this->setHref($href);

@ -32,7 +32,7 @@
* @version Release: 3.2.11
* @since 1.0
*/
class HTML_QuickForm_password extends HTML_QuickForm_input
class HTML_QuickForm_password extends HTML_QuickForm_text
{
// {{{ constructor
@ -48,15 +48,12 @@ class HTML_QuickForm_password extends HTML_QuickForm_input
* @return void
* @throws
*/
function HTML_QuickForm_password($elementName=null, $elementLabel=null, $attributes=null)
public function __construct($elementName=null, $elementLabel=null, $attributes=null)
{
$attributes['class'] = isset($attributes['class']) ? $attributes['class'] : 'form-control';
HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
$this->setType('password');
} //end constructor
// }}}
// {{{ setSize()
}
/**
* Sets size of password element
@ -66,13 +63,10 @@ class HTML_QuickForm_password extends HTML_QuickForm_input
* @access public
* @return void
*/
function setSize($size)
public function setSize($size)
{
$this->updateAttributes(array('size'=>$size));
} //end func setSize
// }}}
// {{{ setMaxlength()
}
/**
* Sets maxlength of password element
@ -82,13 +76,10 @@ class HTML_QuickForm_password extends HTML_QuickForm_input
* @access public
* @return void
*/
function setMaxlength($maxlength)
public function setMaxlength($maxlength)
{
$this->updateAttributes(array('maxlength'=>$maxlength));
} //end func setMaxlength
// }}}
// {{{ getFrozenHtml()
}
/**
* Returns the value of field without HTML tags (in this case, value is changed to a mask)
@ -98,14 +89,10 @@ class HTML_QuickForm_password extends HTML_QuickForm_input
* @return string
* @throws
*/
function getFrozenHtml()
public function getFrozenHtml()
{
$value = $this->getValue();
return ('' != $value? '**********': '&nbsp;') .
$this->_getPersistantData();
} //end func getFrozenHtml
// }}}
} //end class HTML_QuickForm_password
?>
}
}

@ -34,7 +34,6 @@
*/
class HTML_QuickForm_radio extends HTML_QuickForm_input
{
/**
* Radio display text
* @var string
@ -55,14 +54,14 @@ class HTML_QuickForm_radio extends HTML_QuickForm_input
* @access public
* @return void
*/
public function HTML_QuickForm_radio(
public function __construct(
$elementName = null,
$elementLabel = null,
$text = null,
$value = null,
$attributes = null
) {
$this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
parent::__construct($elementName, $elementLabel, $attributes);
if (isset($value)) {
$this->setValue($value);
}

@ -49,7 +49,7 @@ class HTML_QuickForm_reset extends HTML_QuickForm_input
*/
function HTML_QuickForm_reset($elementName=null, $value=null, $attributes=null)
{
HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes);
parent::__construct($elementName, null, $attributes);
$this->setValue($value);
$this->setType('reset');
} //end constructor

@ -645,6 +645,60 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
}
}
// }}}
} //end class HTML_QuickForm_select
?>
/**
* @param string $layout
*
* @return string
*/
public function getTemplate($layout)
{
/*$size = $this->getInputSize();
$size = empty($size) ? '8' : $size;*/
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 {error_class}">
<label {label-for} class="col-sm-2 control-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-8">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-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;
}
}
}

@ -48,7 +48,7 @@ class HTML_QuickForm_submit extends HTML_QuickForm_input
*/
public function __construct($elementName=null, $value=null, $attributes=null)
{
HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes);
parent::__construct($elementName, null, $attributes);
$this->setValue($value);
$this->setType('submit');
} //end constructor

@ -1,5 +1,4 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* HTML class for a text field
@ -39,9 +38,9 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
/**
* Class constructor
*
* @param string $elementName (optional)Input field name attribute
* @param string $elementLabel (optional)Input field label
* @param mixed $attributes (optional)Either a typical HTML attribute string
* @param string $elementName (optional)Input field name attribute
* @param string $elementLabel (optional)Input field label
* @param mixed $attributes (optional)Either a typical HTML attribute string
* or an associative array
* @since 1.0
* @access public
@ -57,53 +56,101 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
}
$inputSize = isset($attributes['input-size']) ? $attributes['input-size'] : null;
$this->setInputSize($inputSize);
$icon = isset($attributes['icon']) ? $attributes['icon'] : null;
$this->setIcon($icon);
if (!empty($inputSize)) {
unset($attributes['input-size']);
}
if (!empty($icon)) {
unset($attributes['icon']);
}
parent::__construct($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->setType('text');
$renderer = FormValidator::getDefaultRenderer();
$renderer->setElementTemplate($this->getTemplate(), $elementName);
//$renderer->setElementTemplate($this->getTemplate(), $elementName);
}
/**
* Show an icon at the left side of an input
* @return string
*/
public function getIconToHtml()
{
$icon = $this->getIcon();
if (empty($icon)) {
return '';
}
return '
<div class="input-group-addon">
<i class="fa fa-'.$icon.'"></i>
</div>';
}
/**
* @param string $layout
*
* @return string
*/
public function getTemplate()
public function getTemplate($layout)
{
$size = $this->getInputSize();
$size = empty($size) ? '8' : $size;
return '
<div class="form-group {error_class}">
<label {label-for} class="col-sm-2 control-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size.'">
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}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-2">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->
</div>
</div>';
</div>';
break;
case FormValidator::LAYOUT_HORIZONTAL:
return '
<div class="form-group {error_class}">
<label {label-for} class="col-sm-2 control-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-'.$size.'">
{icon}
{element}
<!-- BEGIN label_2 -->
<p class="help-block">{label_2}</p>
<!-- END label_2 -->
<!-- BEGIN error -->
<span class="help-inline">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-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;
}
}
/**
* @return null
*/

@ -694,33 +694,29 @@ class IndexManager
* Adds a form to let users login
* @version 1.1
*/
function display_login_form()
public function display_login_form()
{
$form = new FormValidator(
'formLogin',
'POST',
null,
null,
null,
FormValidator::LAYOUT_BOX_NO_LABEL
);
$form->addText('login', get_lang('UserName'), true, array('id' => 'login', 'autofocus' => 'autofocus', 'icon' => 'user'));
$form->addElement('password', 'password', get_lang('Pass'), array('id' => 'password', 'icon' => 'lock'));
$form = new FormValidator('formLogin', 'POST', null, null, null, FormValidator::LAYOUT_INLINE);
$form->addElement('label',get_lang('UserName'));
$form->addHtml('<div class="input-group">');
$form->addHtml('<div class="input-group-addon"><i class="fa fa-user"></i></div>');
$form->addElement('input', 'login','', array('id' => 'login', 'class' => 'form-control autocapitalize_off', 'autofocus' => 'autofocus'));
$form->addHtml('</div>');
$form->addElement('label',get_lang('Pass'));
$form->addHtml('<div class="input-group">');
$form->addHtml('<div class="input-group-addon"><i class="fa fa-lock"></i></div>');
$form->addElement('password', 'password','', array('id' => 'password', 'class' => 'form-control'));
$form->addHtml('</div>');
global $_configuration;
// Captcha
$allowCaptcha = isset($_configuration['allow_captcha']) ? $_configuration['allow_captcha'] : false;
if ($allowCaptcha) {
$useCaptcha = isset($_SESSION['loginFailed']) ? $_SESSION['loginFailed'] : null;
if ($useCaptcha) {
$ajax = api_get_path(WEB_AJAX_PATH).'form.ajax.php?a=get_captcha';
$options = array(
'width' => 250,
'height' => 90,
@ -737,20 +733,18 @@ class IndexManager
// Minimum options using all defaults (including defaults for Image_Text):
//$options = array('callback' => 'qfcaptcha_image.php');
$captcha_question = $form->addElement('CAPTCHA_Image', 'captcha_question', '', $options);
$captcha_question = $form->addElement('CAPTCHA_Image', 'captcha_question', '', $options);
$form->addElement('static', null, null, get_lang('ClickOnTheImageForANewOne'));
$form->addElement('text', 'captcha', get_lang('EnterTheLettersYouSee'));
$form->addRule('captcha', get_lang('EnterTheCharactersYouReadInTheImage'), 'required', null, 'client');
$form->addRule('captcha', get_lang('TheTextYouEnteredDoesNotMatchThePicture'), 'CAPTCHA', $captcha_question);
}
}
$form->addHtml('<div class="form-button-login">');
$form->addElement('style_submit_button','submitAuth', get_lang('LoginEnter'), array('class' => 'btn-primary btn-block'));
$form->addHtml('</div>');
$html = $form->return_form();
$form->addButton('submitAuth', get_lang('LoginEnter'), null, 'primary', null, 'btn-block');
$html = $form->returnForm();
// The validation is located in the local.inc
/*if ($form->validate()) {
// Prevent re-use of the same CAPTCHA phrase
@ -761,10 +755,16 @@ class IndexManager
include_once 'main/auth/openid/login.php';
$html .= '<div>'.openid_form().'</div>';
}
return $html;
}
function return_search_block() {
/**
* @todo use FormValidator
* @return string
*/
public function return_search_block()
{
$html = '';
if (api_get_setting('search_enabled') == 'true') {
$search_btn = get_lang('Search');
@ -775,10 +775,14 @@ class IndexManager
</div></form>';
$html .= self::show_right_block(get_lang('Search'), $search_content, 'search_block');
}
return $html;
}
function return_classes_block()
/**
* @return string
*/
public function return_classes_block()
{
$html = '';
if (api_get_setting('show_groups_to_users') == 'true') {
@ -793,7 +797,10 @@ class IndexManager
}
}
if (api_is_platform_admin()) {
$classes .= Display::tag('li', Display::url(get_lang('AddClasses') ,api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add'));
$classes .= Display::tag(
'li',
Display::url(get_lang('AddClasses') ,api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add')
);
}
if (!empty($classes)) {
$classes = Display::tag('ul', $classes, array('class'=>'nav nav-pills nav-stacked'));
@ -803,18 +810,6 @@ class IndexManager
return $html;
}
function return_reservation_block() {
$html = '';
$booking_content = null;
if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course()) {
$booking_content .='<ul class="nav nav-pills nav-stacked">';
$booking_content .='<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />';
$booking_content .='</ul>';
$html .= self::show_right_block(get_lang('Booking'), $booking_content, 'reservation_block');
}
return $html;
}
/**
* @return null|string
*/
@ -849,7 +844,10 @@ class IndexManager
return $html;
}
function return_profile_block()
/**
* @return null|string|void
*/
public function return_profile_block()
{
global $_configuration;
$user_id = api_get_user_id();
@ -899,7 +897,8 @@ class IndexManager
return $html;
}
function return_navigation_links() {
public function return_navigation_links()
{
$html = '';
// Deleting the myprofile link.

Loading…
Cancel
Save