upgrade
This commit is contained in:
86
main/inc/lib/formvalidator/Element/BigUpload.php
Normal file
86
main/inc/lib/formvalidator/Element/BigUpload.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Input file with progress element.
|
||||
*
|
||||
* Class BigUpload
|
||||
*/
|
||||
class BigUpload extends HTML_QuickForm_file
|
||||
{
|
||||
/**
|
||||
* @param string $elementName
|
||||
* @param string $elementLabel
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($elementName = null, $elementLabel = null, $attributes = null)
|
||||
{
|
||||
parent::__construct($elementName, $elementLabel, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
$origin = $this->getAttribute('data-origin');
|
||||
$id = $this->getAttribute('id');
|
||||
$maxSize = getIniMaxFileSizeInBytes();
|
||||
$errorUploadMessage = get_lang('FileSizeIsTooBig').' '.get_lang('MaxFileSize').' : '.getIniMaxFileSizeInBytes(true);
|
||||
$html = parent::toHtml();
|
||||
$html .= '<div id="'.$id.'-bigUploadProgressBarContainer">
|
||||
<div id="'.$id.'-bigUploadProgressBarFilled"></div>
|
||||
</div>
|
||||
<div id="'.$id.'-bigUploadTimeRemaining"></div>
|
||||
<div id="'.$id.'-bigUploadResponse"></div>';
|
||||
$js = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'bigupload/js/bigUpload.js"></script>';
|
||||
$js .= '<script>
|
||||
var bigUpload = new bigUpload();
|
||||
var uploadForm, formId, submitButtonId;
|
||||
$(function() {
|
||||
uploadForm = $("#'.$id.'").closest("form");
|
||||
formId = uploadForm.attr("id");
|
||||
submitButtonId = uploadForm.find("[type=\'submit\']").attr("id");
|
||||
$("#"+submitButtonId).click(function(e) {
|
||||
if ($("#'.$id.'").val()) {
|
||||
e.preventDefault();
|
||||
setBigUploadSettings();
|
||||
bigUpload.fire();
|
||||
}
|
||||
});
|
||||
});
|
||||
function setBigUploadSettings() {
|
||||
//The id of the file input
|
||||
bigUpload.settings.inputField = "'.$id.'";
|
||||
//The id of the form with the file upload.
|
||||
bigUpload.settings.formId = formId;
|
||||
//The id of the progress bar
|
||||
bigUpload.settings.progressBarField = "'.$id.'-bigUploadProgressBarFilled";
|
||||
//The id of the time remaining field
|
||||
bigUpload.settings.timeRemainingField = "'.$id.'-bigUploadTimeRemaining";
|
||||
//The id of the text response field
|
||||
bigUpload.settings.responseField = "'.$id.'-bigUploadResponse";
|
||||
//The id of the submit button
|
||||
bigUpload.settings.submitButton = submitButtonId;
|
||||
//Color of the background of the progress bar
|
||||
bigUpload.settings.progressBarColor = "#5bb75b";
|
||||
//Color of the background of the progress bar when an error is triggered
|
||||
bigUpload.settings.progressBarColorError = "#da4f49";
|
||||
//Path to the php script for handling the uploads
|
||||
bigUpload.settings.scriptPath = "'.api_get_path(WEB_LIBRARY_JS_PATH).'bigupload/inc/bigUpload.php";
|
||||
//cid Req
|
||||
bigUpload.settings.cidReq = "'.api_get_cidreq().'";
|
||||
//Set the origin upload
|
||||
bigUpload.settings.origin = "'.$origin.'";
|
||||
//The parameters from the upload form
|
||||
bigUpload.settings.formParams = uploadForm.serialize();
|
||||
//Max file size allowed
|
||||
bigUpload.settings.maxFileSize = "'.$maxSize.'";
|
||||
// Message error upload filesize
|
||||
bigUpload.settings.errMessageFileSize = "'.$errorUploadMessage.'";
|
||||
}
|
||||
</script>';
|
||||
|
||||
return $js.$html;
|
||||
}
|
||||
}
|
||||
52
main/inc/lib/formvalidator/Element/Color.php
Normal file
52
main/inc/lib/formvalidator/Element/Color.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Input Color element.
|
||||
*
|
||||
* Class Color
|
||||
*/
|
||||
class Color extends HTML_QuickForm_text
|
||||
{
|
||||
/**
|
||||
* @param string $elementName
|
||||
* @param string $elementLabel
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($elementName = null, $elementLabel = null, $attributes = null)
|
||||
{
|
||||
if (!isset($attributes['id'])) {
|
||||
$attributes['id'] = $elementName;
|
||||
}
|
||||
|
||||
$attributes['type'] = 'color';
|
||||
$attributes['class'] = 'form-control';
|
||||
$attributes['cols-size'] = isset($attributes['cols-size']) ? $attributes['cols-size'] : [2, 1, 9];
|
||||
|
||||
parent::__construct($elementName, $elementLabel, $attributes);
|
||||
|
||||
$this->_appendName = true;
|
||||
$this->setType('color');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
return parent::toHtml().<<<JS
|
||||
<script>
|
||||
$(function() {
|
||||
var txtColor = $('#{$this->getAttribute('id')}'),
|
||||
lblColor = txtColor.parent().next();
|
||||
|
||||
lblColor.text(txtColor.val());
|
||||
|
||||
txtColor.on('change', function () {
|
||||
lblColor.text(txtColor.val());
|
||||
})
|
||||
});
|
||||
</script>
|
||||
JS;
|
||||
}
|
||||
}
|
||||
186
main/inc/lib/formvalidator/Element/DatePicker.php
Normal file
186
main/inc/lib/formvalidator/Element/DatePicker.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Form element to select a date.
|
||||
*
|
||||
* Class DatePicker
|
||||
*/
|
||||
class DatePicker extends HTML_QuickForm_text
|
||||
{
|
||||
/**
|
||||
* @param string $elementName
|
||||
* @param string|array $elementLabel
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($elementName, $elementLabel = null, $attributes = null)
|
||||
{
|
||||
if (!isset($attributes['id'])) {
|
||||
$attributes['id'] = $elementName;
|
||||
}
|
||||
$attributes['class'] = 'form-control';
|
||||
|
||||
parent::__construct($elementName, $elementLabel, $attributes);
|
||||
$this->_appendName = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML code to display this datepicker.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
if ($this->_flagFrozen) {
|
||||
return $this->getFrozenHtml();
|
||||
}
|
||||
|
||||
$id = $this->getAttribute('id');
|
||||
$value = $this->getValue();
|
||||
|
||||
if (!empty($value)) {
|
||||
$value = api_format_date($value, DATE_FORMAT_LONG_NO_DAY);
|
||||
}
|
||||
|
||||
return '
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon cursor-pointer">
|
||||
<input '.$this->_getAttrString($this->_attributes).'>
|
||||
</span>
|
||||
<p class="form-control disabled" id="'.$id.'_alt_text">'.$value.'</p>
|
||||
<input class="form-control" type="hidden" id="'.$id.'_alt" value="'.$value.'">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button"
|
||||
title="'.sprintf(get_lang('ResetFieldX'), $this->_label).'">
|
||||
<span class="fa fa-trash text-danger" aria-hidden="true"></span>
|
||||
<span class="sr-only">'.sprintf(get_lang('ResetFieldX'), $this->_label).'</span>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
'.$this->getElementJS();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$value = substr($value, 0, 16);
|
||||
$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>';
|
||||
case FormValidator::LAYOUT_HORIZONTAL:
|
||||
return '
|
||||
<div class="form-group {error_class}">
|
||||
<label {label-for} class="col-sm-'.$size[0].' control-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>';
|
||||
case FormValidator::LAYOUT_BOX_NO_LABEL:
|
||||
return '{element}';
|
||||
}
|
||||
|
||||
return '<div class="form-group">
|
||||
<label {label-for}>{label}</label>
|
||||
{element}
|
||||
</div>'
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the necessary javascript for this datepicker.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getElementJS()
|
||||
{
|
||||
$js = null;
|
||||
$id = $this->getAttribute('id');
|
||||
|
||||
$js .= "<script>
|
||||
$(function() {
|
||||
var txtDate = $('#$id'),
|
||||
inputGroup = txtDate.parents('.input-group'),
|
||||
txtDateAlt = $('#{$id}_alt'),
|
||||
txtDateAltText = $('#{$id}_alt_text');
|
||||
|
||||
txtDate
|
||||
.hide()
|
||||
.datepicker({
|
||||
defaultDate: '".$this->getValue()."',
|
||||
dateFormat: 'yy-mm-dd',
|
||||
altField: '#{$id}_alt',
|
||||
altFormat: \"".get_lang('DateFormatLongNoDayJS')."\",
|
||||
showOn: 'both',
|
||||
buttonImage: '".Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true)."',
|
||||
buttonImageOnly: true,
|
||||
buttonText: '".get_lang('SelectDate')."',
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
yearRange: 'c-60y:c+5y'
|
||||
})
|
||||
.on('change', function (e) {
|
||||
txtDateAltText.text(txtDateAlt.val());
|
||||
});
|
||||
|
||||
txtDateAltText.on('click', function () {
|
||||
txtDate.datepicker('show');
|
||||
});
|
||||
|
||||
inputGroup
|
||||
.find('button')
|
||||
.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#$id, #{$id}_alt').val('');
|
||||
$('#{$id}_alt_text').html('');
|
||||
});
|
||||
});
|
||||
</script>";
|
||||
|
||||
return $js;
|
||||
}
|
||||
}
|
||||
231
main/inc/lib/formvalidator/Element/DateRangePicker.php
Normal file
231
main/inc/lib/formvalidator/Element/DateRangePicker.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Form element to select a range of dates (with popup datepicker).
|
||||
*/
|
||||
class DateRangePicker extends HTML_QuickForm_text
|
||||
{
|
||||
/**
|
||||
* DateRangePicker constructor.
|
||||
*
|
||||
* @param string $elementName
|
||||
* @param string|array $elementLabel
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($elementName, $elementLabel = null, $attributes = null)
|
||||
{
|
||||
if (!isset($attributes['id'])) {
|
||||
$attributes['id'] = $elementName;
|
||||
}
|
||||
$attributes['class'] = 'form-control';
|
||||
parent::__construct($elementName, $elementLabel, $attributes);
|
||||
$this->_appendName = true;
|
||||
$this->_type = 'date_range_picker';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
$js = $this->getElementJS();
|
||||
|
||||
$this->removeAttribute('format');
|
||||
$this->removeAttribute('timepicker');
|
||||
$this->removeAttribute('validate_format');
|
||||
|
||||
return $js.parent::toHtml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->updateAttributes(
|
||||
[
|
||||
'value' => $value,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $dateRange
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function parseDateRange($dateRange)
|
||||
{
|
||||
$dateRange = Security::remove_XSS($dateRange);
|
||||
$dates = explode('/', $dateRange);
|
||||
$dates = array_map('trim', $dates);
|
||||
$start = isset($dates[0]) ? $dates[0] : '';
|
||||
$end = isset($dates[1]) ? $dates[1] : '';
|
||||
|
||||
$pattern = 'yyyy-MM-dd HH:mm';
|
||||
if ('false' === $this->getAttribute('timePicker') &&
|
||||
false === strpos($this->getAttribute('format'), 'HH:mm')) {
|
||||
$pattern = 'yyyy-MM-dd';
|
||||
}
|
||||
|
||||
$formatter = new IntlDateFormatter(
|
||||
'en',
|
||||
IntlDateFormatter::NONE,
|
||||
IntlDateFormatter::NONE,
|
||||
'UTC',
|
||||
IntlDateFormatter::GREGORIAN,
|
||||
$pattern
|
||||
);
|
||||
$resultStart = $formatter->format($formatter->parse($start));
|
||||
$resultEnd = $formatter->format($formatter->parse($end));
|
||||
|
||||
return [
|
||||
'start' => $resultStart,
|
||||
'end' => $resultEnd,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $dates result of parseDateRange()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validateDates($dates, $format = null)
|
||||
{
|
||||
if (empty($dates['start']) || empty($dates['end'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$format = $format ? $format : 'Y-m-d H:i';
|
||||
$d = DateTime::createFromFormat($format, $dates['start']);
|
||||
$resultStart = $d && $d->format($format) == $dates['start'];
|
||||
|
||||
$d = DateTime::createFromFormat($format, $dates['end']);
|
||||
$resultEnd = $d && $d->format($format) == $dates['end'];
|
||||
|
||||
if (!$resultStart || !$resultEnd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param array $submitValues
|
||||
* @param array $errors
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubmitValue($value, &$submitValues, &$errors)
|
||||
{
|
||||
/** @var DateRangePicker $element */
|
||||
$elementName = $this->getName();
|
||||
$parsedDates = $this->parseDateRange($value);
|
||||
$validateFormat = $this->getAttribute('validate_format');
|
||||
|
||||
if (!$this->validateDates($parsedDates, $validateFormat)) {
|
||||
$errors[$elementName] = get_lang('CheckDates');
|
||||
}
|
||||
$submitValues[$elementName.'_start'] = $parsedDates['start'];
|
||||
$submitValues[$elementName.'_end'] = $parsedDates['end'];
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the necessary javascript for this datepicker.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getElementJS()
|
||||
{
|
||||
$js = null;
|
||||
$id = $this->getAttribute('id');
|
||||
$dateRange = $this->getAttribute('value');
|
||||
|
||||
$defaultDates = null;
|
||||
if (!empty($dateRange)) {
|
||||
$dates = $this->parseDateRange($dateRange);
|
||||
$defaultDates = "
|
||||
startDate: '".$dates['start']."',
|
||||
endDate: '".$dates['end']."', ";
|
||||
}
|
||||
|
||||
$minDate = null;
|
||||
$minDateValue = Security::remove_XSS($this->getAttribute('minDate'));
|
||||
if (!empty($minDateValue)) {
|
||||
$minDate = "
|
||||
minDate: '{$minDateValue}',
|
||||
";
|
||||
}
|
||||
|
||||
$maxDate = null;
|
||||
$maxDateValue = Security::remove_XSS($this->getAttribute('maxDate'));
|
||||
if (!empty($maxDateValue)) {
|
||||
$maxDate = "
|
||||
maxDate: '{$maxDateValue}',
|
||||
";
|
||||
}
|
||||
|
||||
$format = 'YYYY-MM-DD HH:mm';
|
||||
$formatValue = Security::remove_XSS($this->getAttribute('format'));
|
||||
if (!empty($formatValue)) {
|
||||
$format = $formatValue;
|
||||
}
|
||||
|
||||
$timePicker = 'true';
|
||||
$timePickerValue = Security::remove_XSS($this->getAttribute('timePicker'));
|
||||
if (!empty($timePickerValue)) {
|
||||
$timePicker = 'false';
|
||||
}
|
||||
|
||||
$timeIncrement = FormValidator::getTimepickerIncrement();
|
||||
|
||||
// timeFormat: 'hh:mm'
|
||||
$js .= "<script>
|
||||
$(function() {
|
||||
$('#$id').daterangepicker({
|
||||
timePicker: $timePicker,
|
||||
timePickerIncrement: $timeIncrement,
|
||||
timePicker24Hour: true,
|
||||
$defaultDates
|
||||
$maxDate
|
||||
$minDate
|
||||
ranges: {
|
||||
'".addslashes(get_lang('Today'))."': [moment(), moment()],
|
||||
'".addslashes(get_lang('Yesterday'))."': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'".addslashes(get_lang('ThisMonth'))."': [moment().startOf('month'), moment().endOf('month')],
|
||||
'".addslashes(get_lang('LastMonth'))."': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
|
||||
'".addslashes(get_lang('ThisWeek'))."': [moment().weekday(1), moment().weekday(5)],
|
||||
'".addslashes(get_lang('NextWeek'))."': [moment().weekday(8), moment().weekday(12)]
|
||||
},
|
||||
//showDropdowns : true,
|
||||
|
||||
locale: {
|
||||
separator: ' / ',
|
||||
format: '$format',
|
||||
applyLabel: '".addslashes(get_lang('Ok'))."',
|
||||
cancelLabel: '".addslashes(get_lang('Cancel'))."',
|
||||
fromLabel: '".addslashes(get_lang('From'))."',
|
||||
toLabel: '".addslashes(get_lang('Until'))."',
|
||||
customRangeLabel: '".addslashes(get_lang('CustomRange'))."',
|
||||
}
|
||||
});
|
||||
|
||||
$('#$id').on('change', function() {
|
||||
var myPickedDates = $('#$id').val().split('/');
|
||||
var {$id}_start = myPickedDates[0].trim();
|
||||
var {$id}_end = myPickedDates[1].trim();
|
||||
|
||||
$('input[name={$id}_start]').val({$id}_start);
|
||||
$('input[name={$id}_end]').val({$id}_end);
|
||||
});
|
||||
});
|
||||
</script>";
|
||||
|
||||
return $js;
|
||||
}
|
||||
}
|
||||
191
main/inc/lib/formvalidator/Element/DateTimePicker.php
Normal file
191
main/inc/lib/formvalidator/Element/DateTimePicker.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Form element to select a date and hour.
|
||||
*/
|
||||
class DateTimePicker extends HTML_QuickForm_text
|
||||
{
|
||||
/**
|
||||
* DateTimePicker constructor.
|
||||
*
|
||||
* @param string $elementName
|
||||
* @param string|array $elementLabel
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($elementName, $elementLabel = null, $attributes = null)
|
||||
{
|
||||
if (!isset($attributes['id'])) {
|
||||
$attributes['id'] = $elementName;
|
||||
}
|
||||
$attributes['class'] = 'form-control';
|
||||
parent::__construct($elementName, $elementLabel, $attributes);
|
||||
$this->_appendName = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML code to display this datepicker.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
if ($this->_flagFrozen) {
|
||||
return $this->getFrozenHtml();
|
||||
}
|
||||
|
||||
$id = $this->getAttribute('id');
|
||||
$value = $this->getValue();
|
||||
|
||||
$formattedValue = '';
|
||||
if (!empty($value)) {
|
||||
$formattedValue = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
|
||||
}
|
||||
|
||||
$label = $this->getLabel();
|
||||
if (is_array($label) && isset($label[0])) {
|
||||
$label = $label[0];
|
||||
}
|
||||
|
||||
$resetFieldX = sprintf(get_lang('ResetFieldX'), $label);
|
||||
|
||||
return '
|
||||
<div class="input-group" id="date_time_wrapper_'.$id.'">
|
||||
<span class="input-group-addon cursor-pointer">
|
||||
<input '.$this->_getAttrString($this->_attributes).'>
|
||||
</span>
|
||||
<p class="form-control disabled" id="'.$id.'_alt_text">'.$formattedValue.'</p>
|
||||
<input class="form-control" type="hidden" id="'.$id.'_alt" value="'.$value.'">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button"
|
||||
title="'.$resetFieldX.'">
|
||||
<span class="fa fa-trash text-danger" aria-hidden="true"></span>
|
||||
<span class="sr-only">'.$resetFieldX.'</span>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
'.$this->getElementJS();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$value = substr($value, 0, 16);
|
||||
$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>';
|
||||
case FormValidator::LAYOUT_HORIZONTAL:
|
||||
return '
|
||||
<div class="form-group {error_class}">
|
||||
<label {label-for} class="col-sm-'.$size[0].' control-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>';
|
||||
case FormValidator::LAYOUT_BOX_NO_LABEL:
|
||||
return '{element}';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the necessary javascript for this datepicker.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getElementJS()
|
||||
{
|
||||
$timeIncrement = FormValidator::getTimepickerIncrement();
|
||||
|
||||
$js = null;
|
||||
$id = $this->getAttribute('id');
|
||||
//timeFormat: 'hh:mm'
|
||||
$js .= "<script>
|
||||
$(function() {
|
||||
var txtDateTime = $('#$id'),
|
||||
inputGroup = txtDateTime.parents('.input-group'),
|
||||
txtDateTimeAlt = $('#{$id}_alt'),
|
||||
txtDateTimeAltText = $('#{$id}_alt_text');
|
||||
|
||||
txtDateTime
|
||||
.hide()
|
||||
.datetimepicker({
|
||||
defaultDate: '".$this->getValue()."',
|
||||
dateFormat: 'yy-mm-dd',
|
||||
controlType: 'select',
|
||||
oneLine: true,
|
||||
stepMinute: $timeIncrement,
|
||||
timeFormat: 'HH:mm',
|
||||
altField: '#{$id}_alt',
|
||||
altFormat: \"".get_lang('DateFormatLongNoDayJS')."\",
|
||||
altTimeFormat: \"".get_lang('TimeFormatNoSecJS')."\",
|
||||
altSeparator: \" ".get_lang('AtTime')." \",
|
||||
altFieldTimeOnly: false,
|
||||
showOn: 'both',
|
||||
buttonImage: '".Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true)."',
|
||||
buttonImageOnly: true,
|
||||
buttonText: '".get_lang('SelectDate')."',
|
||||
changeMonth: true,
|
||||
changeYear: true
|
||||
})
|
||||
.on('change', function (e) {
|
||||
txtDateTimeAltText.text(txtDateTimeAlt.val());
|
||||
});
|
||||
|
||||
txtDateTimeAltText.on('click', function () {
|
||||
txtDateTime.datepicker('show');
|
||||
});
|
||||
|
||||
inputGroup
|
||||
.find('button')
|
||||
.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#$id, #{$id}_alt').val('');
|
||||
$('#{$id}_alt_text').html('');
|
||||
});
|
||||
});
|
||||
</script>";
|
||||
|
||||
return $js;
|
||||
}
|
||||
}
|
||||
239
main/inc/lib/formvalidator/Element/DateTimeRangePicker.php
Normal file
239
main/inc/lib/formvalidator/Element/DateTimeRangePicker.php
Normal file
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Form element to select a date.
|
||||
*
|
||||
* Class DatePicker
|
||||
*/
|
||||
class DateTimeRangePicker extends DateRangePicker
|
||||
{
|
||||
/**
|
||||
* HTML code to display this datepicker.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
if ($this->_flagFrozen) {
|
||||
return $this->getFrozenHtml();
|
||||
}
|
||||
|
||||
$id = $this->getAttribute('id');
|
||||
$dateRange = $this->getValue();
|
||||
|
||||
$value = '';
|
||||
if (!empty($dateRange)) {
|
||||
$dates = $this->parseDateRange($dateRange);
|
||||
$value = api_format_date($dates['date'], DATE_FORMAT_LONG_NO_DAY);
|
||||
}
|
||||
|
||||
return '
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon cursor-pointer">
|
||||
<input '.$this->_getAttrString($this->_attributes).'>
|
||||
</span>
|
||||
<p class="form-control disabled" id="'.$id.'_alt_text">'.$value.'</p>
|
||||
<input class="form-control" type="hidden" id="'.$id.'_alt" value="'.$value.'">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button"
|
||||
title="'.sprintf(get_lang('ResetFieldX'), $this->_label).'">
|
||||
<span class="fa fa-trash text-danger" aria-hidden="true"></span>
|
||||
<span class="sr-only">'.sprintf(get_lang('ResetFieldX'), $this->_label).'</span>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
'.$this->getElementJS();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $layout
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTemplate($layout)
|
||||
{
|
||||
$size = $this->calculateSize();
|
||||
$id = $this->getAttribute('id');
|
||||
|
||||
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 '
|
||||
<span id="'.$id.'_date_time_wrapper">
|
||||
<div class="form-group {error_class}">
|
||||
<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[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>
|
||||
<div class="form-group {error_class}">
|
||||
<label class="col-sm-'.$size[0].' control-label" >
|
||||
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
|
||||
'.get_lang('Hour').'
|
||||
</label>
|
||||
<div class="col-sm-'.$size[1].'">
|
||||
<div class="input-group">
|
||||
<p id="'.$id.'_time_range">
|
||||
<input type="text" id="'.$id.'_time_range_start" name="'.$id.'_time_range_start" class="time start" autocomplete="off">
|
||||
'.get_lang('To').'
|
||||
<input type="text" id="'.$id.'_time_range_end" name="'.$id.'_time_range_end" class="time end " autocomplete="off">
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
';
|
||||
break;
|
||||
case FormValidator::LAYOUT_BOX_NO_LABEL:
|
||||
return '
|
||||
<label {label-for}>{label}</label>
|
||||
<div class="input-group">
|
||||
|
||||
{icon}
|
||||
{element}
|
||||
</div>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $dateRange
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function parseDateRange($dateRange)
|
||||
{
|
||||
$dateRange = Security::remove_XSS($dateRange);
|
||||
$dates = explode('@@', $dateRange);
|
||||
$dates = array_map('trim', $dates);
|
||||
$start = isset($dates[0]) ? $dates[0] : '';
|
||||
$end = isset($dates[1]) ? $dates[1] : '';
|
||||
|
||||
$date = substr($start, 0, 10);
|
||||
$start = isset($dates[0]) ? $dates[0] : '';
|
||||
//$start = substr($start, 11, strlen($start));
|
||||
//$end = substr($end, 11, strlen($end));
|
||||
|
||||
return [
|
||||
'date' => $date,
|
||||
'start_time' => $start,
|
||||
'end_time' => $end,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->updateAttributes(
|
||||
[
|
||||
'value' => $value,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the necessary javascript for this datepicker.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getElementJS()
|
||||
{
|
||||
$js = null;
|
||||
$id = $this->getAttribute('id');
|
||||
|
||||
$dateRange = $this->getValue();
|
||||
|
||||
$defaultDate = '';
|
||||
$startTime = '';
|
||||
$endTime = '';
|
||||
if (!empty($dateRange)) {
|
||||
$dates = $this->parseDateRange($dateRange);
|
||||
$defaultDate = $dates['date'];
|
||||
$startTime = $dates['start_time'];
|
||||
$endTime = $dates['end_time'];
|
||||
}
|
||||
|
||||
$js .= "<script>
|
||||
$(function() {
|
||||
var txtDate = $('#$id'),
|
||||
inputGroup = txtDate.parents('.input-group'),
|
||||
txtDateAlt = $('#{$id}_alt'),
|
||||
txtDateAltText = $('#{$id}_alt_text');
|
||||
|
||||
txtDate
|
||||
.hide()
|
||||
.datepicker({
|
||||
defaultDate: '".$defaultDate."',
|
||||
dateFormat: 'yy-mm-dd',
|
||||
altField: '#{$id}_alt',
|
||||
altFormat: \"".get_lang('DateFormatLongNoDayJS')."\",
|
||||
showOn: 'both',
|
||||
buttonImage: '".Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true)."',
|
||||
buttonImageOnly: true,
|
||||
buttonText: '".get_lang('SelectDate')."',
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
yearRange: 'c-60y:c+5y'
|
||||
})
|
||||
.on('change', function (e) {
|
||||
txtDateAltText.text(txtDateAlt.val());
|
||||
});
|
||||
|
||||
txtDateAltText.on('click', function () {
|
||||
txtDate.datepicker('show');
|
||||
});
|
||||
|
||||
inputGroup
|
||||
.find('button')
|
||||
.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
$('#$id, #{$id}_alt').val('');
|
||||
$('#{$id}_alt_text').html('');
|
||||
});
|
||||
|
||||
$('#".$id."_time_range .time').timepicker({
|
||||
'showDuration': true,
|
||||
'timeFormat': 'H:i:s',
|
||||
'scrollDefault': 'now',
|
||||
});
|
||||
|
||||
$('#".$id."_time_range_start').timepicker('setTime', new Date('".$startTime."'));
|
||||
$('#".$id."_time_range_end').timepicker('setTime', new Date('".$endTime."'));
|
||||
|
||||
var timeOnlyExampleEl = document.getElementById('".$id."_time_range');
|
||||
var timeOnlyDatepair = new Datepair(timeOnlyExampleEl);
|
||||
});
|
||||
</script>";
|
||||
|
||||
return $js;
|
||||
}
|
||||
}
|
||||
84
main/inc/lib/formvalidator/Element/FloatNumber.php
Normal file
84
main/inc/lib/formvalidator/Element/FloatNumber.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Float element.
|
||||
*
|
||||
* Accepts values like 3.1415 and 3,1415 (its processed and converted to 3.1415)
|
||||
*
|
||||
* Class Float
|
||||
*/
|
||||
class FloatNumber extends HTML_QuickForm_text
|
||||
{
|
||||
/**
|
||||
* @param string $elementName
|
||||
* @param string $elementLabel
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($elementName = null, $elementLabel = null, $attributes = null)
|
||||
{
|
||||
if (!isset($attributes['id'])) {
|
||||
$attributes['id'] = $elementName;
|
||||
}
|
||||
|
||||
$attributes['type'] = 'float';
|
||||
$attributes['class'] = 'form-control';
|
||||
|
||||
parent::__construct($elementName, $elementLabel, $attributes);
|
||||
$this->_appendName = true;
|
||||
$this->setType('float');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$value = api_float_val($value);
|
||||
$this->updateAttributes(
|
||||
[
|
||||
'value' => $value,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
$value = $this->getAttribute('value');
|
||||
$value = api_float_val($value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param array $submitValues
|
||||
* @param array $errors
|
||||
*/
|
||||
public function getSubmitValue($value, &$submitValues, &$errors)
|
||||
{
|
||||
$value = api_float_val($value);
|
||||
$elementName = $this->getName();
|
||||
$submitValues[$elementName] = $value;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* We check the options and return only the values that _could_ have been
|
||||
* selected. We also return a scalar value if select is not "multiple".
|
||||
*/
|
||||
public function exportValue(&$submitValues, $assoc = false)
|
||||
{
|
||||
$value = $this->_findValue($submitValues);
|
||||
$value = api_float_val($value);
|
||||
if (!$value) {
|
||||
$value = '';
|
||||
}
|
||||
|
||||
return $this->_prepareValue($value, $assoc);
|
||||
}
|
||||
}
|
||||
119
main/inc/lib/formvalidator/Element/HtmlEditor.php
Normal file
119
main/inc/lib/formvalidator/Element/HtmlEditor.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
use Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor;
|
||||
use Chamilo\CoreBundle\Component\HTMLPurifier\Filter\RemoveOnAttributes;
|
||||
|
||||
/**
|
||||
* A html editor field to use with QuickForm.
|
||||
*/
|
||||
class HtmlEditor extends HTML_QuickForm_textarea
|
||||
{
|
||||
/** @var \Chamilo\CoreBundle\Component\Editor\Editor */
|
||||
public $editor;
|
||||
|
||||
/**
|
||||
* Full page.
|
||||
*/
|
||||
public $fullPage;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string|array $label HTML editor label
|
||||
* @param array $attributes Attributes for the textarea
|
||||
* @param array $config optional configuration settings for the online editor
|
||||
*/
|
||||
public function __construct(
|
||||
$name,
|
||||
$label = null,
|
||||
$attributes = [],
|
||||
$config = []
|
||||
) {
|
||||
if (empty($name)) {
|
||||
throw new \Exception('Name is required');
|
||||
}
|
||||
|
||||
parent::__construct($name, $label, $attributes);
|
||||
$id = $this->getAttribute('id');
|
||||
$this->_persistantFreeze = true;
|
||||
$this->_type = 'html_editor';
|
||||
$editor = new CkEditor();
|
||||
if ($editor) {
|
||||
$this->editor = $editor;
|
||||
$this->editor->setTextareaId($id);
|
||||
$this->editor->setName($name);
|
||||
$this->editor->processConfig($config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the HTML editor in HTML.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
if ($this->editor) {
|
||||
if ($this->editor->getConfigAttribute('fullPage')) {
|
||||
$value = $this->getValue();
|
||||
if (strlen(trim($value)) == 0) {
|
||||
// TODO: To be considered whether here to add
|
||||
// language and character set declarations.
|
||||
$value = '<!DOCTYPE html><html><head><title></title></head><body></body></html>';
|
||||
$this->setValue($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isFrozen()) {
|
||||
return $this->getFrozenHtml();
|
||||
} else {
|
||||
$styleCss = $this->editor->getConfigAttribute('style');
|
||||
$style = false;
|
||||
if ($styleCss) {
|
||||
$style = true;
|
||||
}
|
||||
|
||||
return $this->buildEditor($style);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html area content in HTML.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFrozenHtml()
|
||||
{
|
||||
return Security::remove_XSS($this->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildEditor($style = false)
|
||||
{
|
||||
$result = '';
|
||||
if ($this->editor) {
|
||||
$value = $this->getCleanValue();
|
||||
|
||||
$this->editor->setName($this->getName());
|
||||
if ($style === true) {
|
||||
$result = $this->editor->createHtmlStyle($value);
|
||||
} else {
|
||||
$result = $this->editor->createHtml($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getValue(): ?string
|
||||
{
|
||||
return RemoveOnAttributes::filter($this->_value);
|
||||
}
|
||||
}
|
||||
31
main/inc/lib/formvalidator/Element/InternalUrl.php
Normal file
31
main/inc/lib/formvalidator/Element/InternalUrl.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* InternalUrl element (URL without the domain as prefix).
|
||||
*
|
||||
* Class InternalUrl
|
||||
*/
|
||||
class InternalUrl extends HTML_QuickForm_text
|
||||
{
|
||||
/**
|
||||
* InternalUrl constructor.
|
||||
*
|
||||
* @param string $elementName
|
||||
* @param string $elementLabel
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($elementName = null, $elementLabel = null, $attributes = null)
|
||||
{
|
||||
if (!isset($attributes['id'])) {
|
||||
$attributes['id'] = $elementName;
|
||||
}
|
||||
|
||||
$attributes['type'] = 'text';
|
||||
$attributes['class'] = 'form-control';
|
||||
|
||||
parent::__construct($elementName, $elementLabel, $attributes);
|
||||
|
||||
$this->setType('text');
|
||||
}
|
||||
}
|
||||
28
main/inc/lib/formvalidator/Element/Number.php
Normal file
28
main/inc/lib/formvalidator/Element/Number.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Number element.
|
||||
*
|
||||
* Class Number
|
||||
*/
|
||||
class Number extends HTML_QuickForm_text
|
||||
{
|
||||
/**
|
||||
* @param string $elementName
|
||||
* @param string $elementLabel
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($elementName = null, $elementLabel = null, $attributes = null)
|
||||
{
|
||||
if (!isset($attributes['id'])) {
|
||||
$attributes['id'] = $elementName;
|
||||
}
|
||||
|
||||
$attributes['type'] = 'number';
|
||||
|
||||
parent::__construct($elementName, $elementLabel, $attributes);
|
||||
$this->_appendName = true;
|
||||
$this->setType('number');
|
||||
}
|
||||
}
|
||||
212
main/inc/lib/formvalidator/Element/SelectAjax.php
Normal file
212
main/inc/lib/formvalidator/Element/SelectAjax.php
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* A drop down list with all languages to use with QuickForm.
|
||||
*/
|
||||
class SelectAjax extends HTML_QuickForm_select
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($elementName, $elementLabel = '', $options = null, $attributes = null)
|
||||
{
|
||||
parent::__construct($elementName, $elementLabel, $options, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ajax call must contain an array of id and text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
$iso = api_get_language_isocode(api_get_interface_language());
|
||||
$dropdownParent = $this->getAttribute('dropdownParent');
|
||||
$dropdownParentCondition = $dropdownParent ? "dropdownParent: '$dropdownParent'," : '';
|
||||
$formatResult = $this->getAttribute('formatResult');
|
||||
$formatSelection = $this->getAttribute('formatSelection');
|
||||
$formatCondition = '';
|
||||
|
||||
if (!empty($formatResult)) {
|
||||
$formatCondition .= ',
|
||||
templateResult : '.$formatResult;
|
||||
}
|
||||
|
||||
if (!empty($formatSelection)) {
|
||||
$formatCondition .= ',
|
||||
templateSelection : '.$formatSelection;
|
||||
}
|
||||
|
||||
$width = 'element';
|
||||
$givenWidth = '100%';
|
||||
if (!empty($givenWidth)) {
|
||||
$width = $givenWidth;
|
||||
}
|
||||
|
||||
//Get the minimumInputLength for select2
|
||||
$minimumInputLength = $this->getAttribute('minimumInputLength') > 3 ?
|
||||
$this->getAttribute('minimumInputLength') : 3
|
||||
;
|
||||
|
||||
$plHolder = $this->getAttribute('placeholder');
|
||||
if (empty($plHolder)) {
|
||||
$plHolder = preg_replace("/'/", "\\'", get_lang('SelectAnOption'));
|
||||
}
|
||||
|
||||
$id = $this->getAttribute('id');
|
||||
|
||||
if (empty($id)) {
|
||||
$id = $this->getAttribute('name');
|
||||
$this->setAttribute('id', $id);
|
||||
}
|
||||
// URL must return ajax json_encode arrady [items => [['id'=>1, 'text'='content']]
|
||||
$url = $this->getAttribute('url');
|
||||
|
||||
if (!$url) {
|
||||
$url = $this->getAttribute('url_function');
|
||||
} else {
|
||||
$url = "'$url'";
|
||||
}
|
||||
|
||||
$tagsAttr = $this->getAttribute('tags');
|
||||
$multipleAttr = $this->getAttribute('multiple');
|
||||
|
||||
$tags = !empty($tagsAttr) ? (bool) $tagsAttr : false;
|
||||
$tags = $tags ? 'true' : 'false';
|
||||
|
||||
$multiple = !empty($multipleAttr) ? (bool) $multipleAttr : false;
|
||||
$multiple = $multiple ? 'true' : 'false';
|
||||
|
||||
$max = $this->getAttribute('maximumSelectionLength');
|
||||
$max = !empty($max) ? "maximumSelectionLength: $max, " : '';
|
||||
|
||||
// wait XX milliseconds before triggering the request
|
||||
$delay = ((int) $this->getAttribute('delay')) ?: 1000;
|
||||
|
||||
$html = <<<JS
|
||||
<script>
|
||||
$(function(){
|
||||
$('#{$this->getAttribute('id')}').select2({
|
||||
language: '$iso',
|
||||
placeholder: '$plHolder',
|
||||
allowClear: true,
|
||||
width: '$width',
|
||||
minimumInputLength: '$minimumInputLength',
|
||||
tags: $tags,
|
||||
$dropdownParentCondition
|
||||
ajax: {
|
||||
url: $url,
|
||||
delay: $delay,
|
||||
dataType: 'json',
|
||||
data: function(params) {
|
||||
return {
|
||||
q: params.term, // search term
|
||||
page_limit: 10,
|
||||
};
|
||||
},
|
||||
processResults: function (data, page) {
|
||||
// Parse the results into the format expected by Select2
|
||||
if (data.items) {
|
||||
return {
|
||||
results: data.items
|
||||
};
|
||||
}
|
||||
return {
|
||||
results: ''
|
||||
};
|
||||
}
|
||||
}
|
||||
$formatCondition
|
||||
});
|
||||
});
|
||||
</script>
|
||||
JS;
|
||||
|
||||
$this->removeAttribute('formatResult');
|
||||
$this->removeAttribute('formatSelection');
|
||||
$this->removeAttribute('minimumInputLength');
|
||||
$this->removeAttribute('maximumSelectionLength');
|
||||
$this->removeAttribute('tags');
|
||||
$this->removeAttribute('placeholder');
|
||||
$this->removeAttribute('class');
|
||||
$this->removeAttribute('url');
|
||||
$this->removeAttribute('url_function');
|
||||
$this->removeAttribute('dropdownParent');
|
||||
$this->setAttribute('style', 'width: 100%;');
|
||||
|
||||
return parent::toHtml().$html;
|
||||
}
|
||||
|
||||
/**
|
||||
* We check the options and return only the values that _could_ have been
|
||||
* selected. We also return a scalar value if select is not "multiple".
|
||||
*/
|
||||
public function exportValue(&$submitValues, $assoc = false)
|
||||
{
|
||||
$value = $this->_findValue($submitValues);
|
||||
|
||||
if (!$value) {
|
||||
$value = '';
|
||||
}
|
||||
|
||||
return $this->_prepareValue($value, $assoc);
|
||||
}
|
||||
|
||||
public static function templateResultForUsersInCourse(): string
|
||||
{
|
||||
return "function (state) {
|
||||
if (state.loading) {
|
||||
return state.text;
|
||||
}
|
||||
|
||||
var \$container = \$(
|
||||
'<div class=\"select2-result-user clearfix\">' +
|
||||
'<div class=\"select2-result-user__avatar pull-left\">' +
|
||||
'<img>' +
|
||||
'</div>' +
|
||||
'<div class=\"select2-result-user__info pull-left\">' +
|
||||
'<div class=\"select2-result-user__name\"></div>' +
|
||||
'<div class=\"select2-result-user__username small\"></div>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
);
|
||||
|
||||
\$container.find('.select2-result-user__avatar img')
|
||||
.prop({ 'src': state.avatarUrl, 'alt': state.username })
|
||||
.css({ 'width': '40px', 'height': '40px' });
|
||||
\$container.find('.select2-result-user__info').css({ 'paddingLeft': '6px' });
|
||||
\$container.find('.select2-result-user__name').text(state.completeName);
|
||||
\$container.find('.select2-result-user__username').text(state.username);
|
||||
|
||||
return \$container;
|
||||
}";
|
||||
}
|
||||
|
||||
public static function templateSelectionForUsersInCourse(): string
|
||||
{
|
||||
return "function (state) {
|
||||
if (!state.id) {
|
||||
return state.text;
|
||||
}
|
||||
|
||||
if (!state.avatarUrl) {
|
||||
var avatarUrl = $(state.element).data('avatarurl');
|
||||
var username = $(state.element).data('username');
|
||||
|
||||
state.avatarUrl = avatarUrl;
|
||||
state.username = username;
|
||||
state.completeName = state.text;
|
||||
}
|
||||
|
||||
var \$container = \$('<span><img> ' + state.completeName + '</span>');
|
||||
|
||||
\$container.find('img')
|
||||
.prop({ 'src': state.avatarUrl, 'alt': state.username })
|
||||
.css({ 'width': '20px', 'height': '20px' });
|
||||
|
||||
return \$container;
|
||||
}";
|
||||
}
|
||||
}
|
||||
38
main/inc/lib/formvalidator/Element/SelectLanguage.php
Normal file
38
main/inc/lib/formvalidator/Element/SelectLanguage.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Class SelectLanguage
|
||||
* A dropdownlist with all languages to use with QuickForm.
|
||||
*/
|
||||
class SelectLanguage extends HTML_QuickForm_select
|
||||
{
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
$elementName = null,
|
||||
$elementLabel = null,
|
||||
$options = [],
|
||||
$attributes = []
|
||||
) {
|
||||
parent::__construct($elementName, $elementLabel, $options, $attributes);
|
||||
|
||||
$default = isset($attributes['set_custom_default']) ? $attributes['set_custom_default'] : false;
|
||||
|
||||
// Get all languages
|
||||
$languages = api_get_languages();
|
||||
foreach ($languages['name'] as $index => $name) {
|
||||
if (!empty($default)) {
|
||||
$defaultValue = $default;
|
||||
} else {
|
||||
$defaultValue = api_get_setting('platformLanguage');
|
||||
}
|
||||
if ($languages['folder'][$index] == $defaultValue) {
|
||||
$this->addOption($name, $languages['folder'][$index], ['selected' => 'selected']);
|
||||
} else {
|
||||
$this->addOption($name, $languages['folder'][$index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
main/inc/lib/formvalidator/Element/SelectTheme.php
Normal file
28
main/inc/lib/formvalidator/Element/SelectTheme.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* A dropdownlist with all themes to use with QuickForm.
|
||||
*/
|
||||
class SelectTheme extends HTML_QuickForm_select
|
||||
{
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
$elementName = null,
|
||||
$elementLabel = null,
|
||||
$options = null,
|
||||
$attributes = null
|
||||
) {
|
||||
parent::__construct($elementName, $elementLabel, $options, $attributes);
|
||||
// Get all languages
|
||||
$themes = api_get_themes();
|
||||
$this->_options = [];
|
||||
$this->_values = [];
|
||||
$this->addOption('--', ''); // no theme select
|
||||
foreach ($themes as $themeValue => $themeName) {
|
||||
$this->addOption($themeName, $themeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
31
main/inc/lib/formvalidator/Element/Url.php
Normal file
31
main/inc/lib/formvalidator/Element/Url.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Url element.
|
||||
*
|
||||
* Class Url
|
||||
*/
|
||||
class Url extends HTML_QuickForm_text
|
||||
{
|
||||
/**
|
||||
* Url constructor.
|
||||
*
|
||||
* @param string $elementName
|
||||
* @param string $elementLabel
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($elementName = null, $elementLabel = null, $attributes = null)
|
||||
{
|
||||
if (!isset($attributes['id'])) {
|
||||
$attributes['id'] = $elementName;
|
||||
}
|
||||
|
||||
$attributes['type'] = 'url';
|
||||
$attributes['class'] = 'form-control';
|
||||
|
||||
parent::__construct($elementName, $elementLabel, $attributes);
|
||||
|
||||
$this->setType('url');
|
||||
}
|
||||
}
|
||||
87
main/inc/lib/formvalidator/Element/UserAvatar.php
Normal file
87
main/inc/lib/formvalidator/Element/UserAvatar.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
use Chamilo\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* Class UserAvatar
|
||||
* FormValidator element to add an user avatar wrapping a hidden input with its user ID
|
||||
* Is necessary set an instance of Chamilo\UserBundle\Entity\User as value. The exported value is the user ID.
|
||||
*/
|
||||
class UserAvatar extends HTML_QuickForm_input
|
||||
{
|
||||
/** @var User */
|
||||
private $user = null;
|
||||
private $imageSize = 'small';
|
||||
private $subTitle = '';
|
||||
|
||||
/**
|
||||
* UserAvatar constructor.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $label
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct($name, $label, $attributes = [])
|
||||
{
|
||||
if (isset($attributes['image_size'])) {
|
||||
$this->imageSize = $attributes['image_size'];
|
||||
unset($attributes['image_size']);
|
||||
}
|
||||
|
||||
if (isset($attributes['sub_title'])) {
|
||||
$this->subTitle = $attributes['sub_title'];
|
||||
unset($attributes['sub_title']);
|
||||
}
|
||||
|
||||
parent::__construct($name, $label, $attributes);
|
||||
|
||||
$this->setType('hidden');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->user = !is_a($value, 'Chamilo\UserBundle\Entity\User')
|
||||
? UserManager::getManager()->find($value)
|
||||
: $value;
|
||||
|
||||
parent::setValue($this->user->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toHtml()
|
||||
{
|
||||
if (!$this->user) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$userInfo = api_get_user_info($this->user->getId());
|
||||
$userPicture = isset($userInfo["avatar_{$this->imageSize}"])
|
||||
? $userInfo["avatar_{$this->imageSize}"]
|
||||
: $userInfo["avatar"];
|
||||
|
||||
if (!$this->subTitle) {
|
||||
$this->subTitle = $this->user->getUsername();
|
||||
}
|
||||
|
||||
$html = parent::toHtml();
|
||||
$html .= '
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<img src="'.$userPicture.'" alt="'.UserManager::formatUserFullName($this->user).'">
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading">'.UserManager::formatUserFullName($this->user).'</h4>
|
||||
'.$this->subTitle.'
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
6
main/inc/lib/formvalidator/Element/index.html
Normal file
6
main/inc/lib/formvalidator/Element/index.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
2112
main/inc/lib/formvalidator/FormValidator.class.php
Normal file
2112
main/inc/lib/formvalidator/FormValidator.class.php
Normal file
File diff suppressed because it is too large
Load Diff
31
main/inc/lib/formvalidator/Rule/CompareDateTimeText.php
Normal file
31
main/inc/lib/formvalidator/Rule/CompareDateTimeText.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* QuickForm rule to compare 2 dates.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_CompareDateTimeText extends HTML_QuickForm_Rule_Compare
|
||||
{
|
||||
/**
|
||||
* Validate 2 dates.
|
||||
*
|
||||
* @param string $operator The operator to use (default '==')
|
||||
*
|
||||
* @return bool True if the 2 given dates match the operator
|
||||
*/
|
||||
public function validate($values, $operator = null)
|
||||
{
|
||||
$datetime1 = api_strtotime($values[0]);
|
||||
$datetime2 = api_strtotime($values[1]);
|
||||
|
||||
if (strpos($operator, 'allow_empty') !== false) {
|
||||
$operator = str_replace('allow_empty', '', $operator);
|
||||
if (!$datetime2 || empty($datetime2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$result = parent::validate([$datetime1, $datetime2], $operator);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
35
main/inc/lib/formvalidator/Rule/CompareFields.php
Normal file
35
main/inc/lib/formvalidator/Rule/CompareFields.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* QuickForm rule to check a date.
|
||||
*/
|
||||
class HTML_QuickForm_Compare_Fields extends HTML_QuickForm_Rule_Compare
|
||||
{
|
||||
/**
|
||||
* Function to check an array of fields.
|
||||
*
|
||||
* @param array of field names
|
||||
* @param string operator ==, >=, etc
|
||||
* @param string the value to compare
|
||||
*
|
||||
* @return bool True if date is valid
|
||||
*/
|
||||
public function validate($values = [], $operator_and_max_value = null)
|
||||
{
|
||||
if (is_array($values) && !empty($values) && !empty($operator_and_max_value)) {
|
||||
$final_value = 0;
|
||||
foreach ($values as $value) {
|
||||
$value = (float) $value;
|
||||
$final_value += $value;
|
||||
}
|
||||
$params = explode('@', $operator_and_max_value);
|
||||
$operator = $params[0];
|
||||
$max_value = $params[1];
|
||||
|
||||
return parent::validate([$final_value, $max_value], $operator);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
24
main/inc/lib/formvalidator/Rule/Date.php
Normal file
24
main/inc/lib/formvalidator/Rule/Date.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
/** @author Bart Mollet, Julio Montoya */
|
||||
|
||||
/**
|
||||
* Class HTML_QuickForm_Rule_Date.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_Date extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Check a date.
|
||||
*
|
||||
* @see HTML_QuickForm_Rule
|
||||
*
|
||||
* @param string $date example 2014-04-30
|
||||
* @param array $options
|
||||
*
|
||||
* @return bool True if date is valid
|
||||
*/
|
||||
public function validate($date, $options)
|
||||
{
|
||||
return api_is_valid_date($date, 'Y-m-d');
|
||||
}
|
||||
}
|
||||
23
main/inc/lib/formvalidator/Rule/DateCompare.php
Normal file
23
main/inc/lib/formvalidator/Rule/DateCompare.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Class HTML_QuickForm_Rule_DateCompare.
|
||||
*
|
||||
* @author Julio Montoya
|
||||
*/
|
||||
class HTML_QuickForm_Rule_DateCompare extends HTML_QuickForm_Rule_Compare
|
||||
{
|
||||
/**
|
||||
* Validate 2 dates.
|
||||
*
|
||||
* @param array $values array with the 2 dates
|
||||
* @param $operator
|
||||
*
|
||||
* @return bool true if the 2 given dates match the operator
|
||||
*/
|
||||
public function validate($values, $operator = null)
|
||||
{
|
||||
return api_strtotime($values[0]) < api_strtotime($values[1]);
|
||||
}
|
||||
}
|
||||
25
main/inc/lib/formvalidator/Rule/DateTimeRule.php
Normal file
25
main/inc/lib/formvalidator/Rule/DateTimeRule.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Class DateTimeRule.
|
||||
*
|
||||
* @author Julio Montoya
|
||||
*/
|
||||
class DateTimeRule extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Check a date.
|
||||
*
|
||||
* @param string $date example 2014-04-30 18:00
|
||||
* @param array $options
|
||||
*
|
||||
* @return bool True if date is valid
|
||||
*
|
||||
* @see HTML_QuickForm_Rule
|
||||
*/
|
||||
public function validate($date, $options)
|
||||
{
|
||||
return api_is_valid_date($date, 'Y-m-d H:i');
|
||||
}
|
||||
}
|
||||
26
main/inc/lib/formvalidator/Rule/FileName.php
Normal file
26
main/inc/lib/formvalidator/Rule/FileName.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/** @author Julio Montoya */
|
||||
|
||||
/**
|
||||
* Class HTML_QuickForm_Rule_FileName.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_FileName extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* @param $value array Uploaded file info (from $_FILES)
|
||||
* @param null $options
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validate($value, $options = null)
|
||||
{
|
||||
if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
|
||||
(!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
|
||||
return is_uploaded_file($elementValue['tmp_name']);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
main/inc/lib/formvalidator/Rule/Filetype.php
Normal file
31
main/inc/lib/formvalidator/Rule/Filetype.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* QuickForm rule to check if a filetype.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_Filetype extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Function to check if a filetype is allowed.
|
||||
*
|
||||
* @see HTML_QuickForm_Rule
|
||||
*
|
||||
* @param array $file Uploaded file
|
||||
* @param array $extensions Allowed extensions
|
||||
*
|
||||
* @return bool True if filetype is allowed
|
||||
*/
|
||||
public function validate($file, $extensions = [])
|
||||
{
|
||||
$parts = explode('.', $file['name']);
|
||||
if (count($parts) < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ext = $parts[count($parts) - 1];
|
||||
$extensions = array_map('strtolower', $extensions);
|
||||
|
||||
return in_array(api_strtolower($ext), $extensions);
|
||||
}
|
||||
}
|
||||
60
main/inc/lib/formvalidator/Rule/HTML.php
Normal file
60
main/inc/lib/formvalidator/Rule/HTML.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
require_once api_get_path(SYS_PATH).'main/inc/lib/kses-0.2.2/kses.php';
|
||||
|
||||
/**
|
||||
* QuickForm rule to check a html.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_HTML extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Function to validate HTML.
|
||||
*
|
||||
* @see HTML_QuickForm_Rule
|
||||
*
|
||||
* @param string $html
|
||||
*
|
||||
* @return bool True if html is valid
|
||||
*/
|
||||
public function validate($html, $mode = NO_HTML)
|
||||
{
|
||||
$allowed_tags = self::get_allowed_tags($mode, $fullpage);
|
||||
$cleaned_html = kses($html, $allowed_tags);
|
||||
|
||||
return $html == $cleaned_html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allowed tags.
|
||||
*
|
||||
* @param int $mode NO_HTML, STUDENT_HTML, TEACHER_HTML,
|
||||
* STUDENT_HTML_FULLPAGE or TEACHER_HTML_FULLPAGE
|
||||
*/
|
||||
public static function get_allowed_tags($mode)
|
||||
{
|
||||
// Include the allowed tags.
|
||||
//include __DIR__.'/allowed_tags.inc.php';
|
||||
global $allowed_tags_student, $allowed_tags_student_full_page, $allowed_tags_teacher, $allowed_tags_teacher_full_page;
|
||||
switch ($mode) {
|
||||
case NO_HTML:
|
||||
return [];
|
||||
break;
|
||||
case STUDENT_HTML:
|
||||
return $allowed_tags_student;
|
||||
break;
|
||||
case STUDENT_HTML_FULLPAGE:
|
||||
return array_merge($allowed_tags_student, $allowed_tags_student_full_page);
|
||||
break;
|
||||
case TEACHER_HTML:
|
||||
return $allowed_tags_teacher;
|
||||
break;
|
||||
case TEACHER_HTML_FULLPAGE:
|
||||
return array_merge($allowed_tags_teacher, $allowed_tags_teacher_full_page);
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
use Chamilo\UserBundle\Entity\User;
|
||||
|
||||
class HTML_QuickForm_Rule_NoSameCurrentPassword extends HTML_QuickForm_Rule
|
||||
{
|
||||
public function validate($value, $options)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $options;
|
||||
|
||||
return !UserManager::isPasswordValid($user->getPassword(), $value, $user->getSalt());
|
||||
}
|
||||
}
|
||||
24
main/inc/lib/formvalidator/Rule/InternalUrl.php
Normal file
24
main/inc/lib/formvalidator/Rule/InternalUrl.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Abstract base class for QuickForm validation rules.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Validate internal urls (URLs without the domain).
|
||||
*/
|
||||
class HTML_QuickForm_Rule_InternalUrl extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Validates internal url.
|
||||
* We cheat a little by using the adding the domain as prefix to use the domain validation process of filter_var().
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return bool returns true if valid, false otherwise
|
||||
*/
|
||||
public function validate($url, $options)
|
||||
{
|
||||
return (bool) filter_var(api_get_path(WEB_PATH).$url, FILTER_VALIDATE_URL);
|
||||
}
|
||||
}
|
||||
30
main/inc/lib/formvalidator/Rule/MaxFileSize.php
Normal file
30
main/inc/lib/formvalidator/Rule/MaxFileSize.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/** @author Julio Montoya */
|
||||
|
||||
/**
|
||||
* Class HTML_QuickForm_Rule_MaxFileSize.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_MaxFileSize extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* @param array $elementValue Uploaded file info (from $_FILES)
|
||||
* @param int $maxSize
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validate($elementValue, $maxSize = 0)
|
||||
{
|
||||
if (!empty($elementValue['error']) &&
|
||||
(UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $maxSize >= @filesize($elementValue['tmp_name']);
|
||||
}
|
||||
}
|
||||
32
main/inc/lib/formvalidator/Rule/MimeType.php
Normal file
32
main/inc/lib/formvalidator/Rule/MimeType.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/** @author Julio Montoya */
|
||||
|
||||
/**
|
||||
* Class HTML_QuickForm_Rule_MimeType.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_MimeType extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Checks if the given element contains an uploaded file of the right mime type.
|
||||
*
|
||||
* @param array Uploaded file info (from $_FILES)
|
||||
* @param mixed Mime Type (can be an array of allowed types)
|
||||
*
|
||||
* @return bool true if mimetype is correct, false otherwise
|
||||
*/
|
||||
public function validate($elementValue, $mimeType)
|
||||
{
|
||||
if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
|
||||
return true;
|
||||
}
|
||||
if (is_array($mimeType)) {
|
||||
return in_array($elementValue['type'], $mimeType);
|
||||
}
|
||||
|
||||
return $elementValue['type'] == $mimeType;
|
||||
}
|
||||
|
||||
// end func _ruleCheckMimeType
|
||||
}
|
||||
27
main/inc/lib/formvalidator/Rule/MobilePhoneNumber.php
Normal file
27
main/inc/lib/formvalidator/Rule/MobilePhoneNumber.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Abstract base class for QuickForm validation rules.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Validate telephones.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_Mobile_Phone_Number extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Validates mobile phone number.
|
||||
*
|
||||
* @param string Mobile phone number to be validated
|
||||
* @param string Not using it. Just to respect the declaration
|
||||
*
|
||||
* @return bool returns true if valid, false otherwise
|
||||
*/
|
||||
public function validate($mobilePhoneNumber, $options = null)
|
||||
{
|
||||
$rule = "/^\d{11}$/";
|
||||
|
||||
return preg_match($rule, $mobilePhoneNumber);
|
||||
}
|
||||
}
|
||||
47
main/inc/lib/formvalidator/Rule/MultipleRequired.php
Normal file
47
main/inc/lib/formvalidator/Rule/MultipleRequired.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP version 4.0 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copy of the existing rule "required" to check if at least one element|
|
||||
// | has been filled. Then $value can be an array |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Eric Marguin <e.marguin@elixir-interactive.com> |
|
||||
// +----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* Required elements validation.
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
class HTML_QuickForm_Rule_MultipleRequired extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Checks if all the elements are empty.
|
||||
*
|
||||
* @param string $value Value to check (can be an array)
|
||||
* @param mixed $options Not used yet
|
||||
*
|
||||
* @return bool true if value is not empty
|
||||
*/
|
||||
public function validate($value, $options = null)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = implode(null, $value);
|
||||
}
|
||||
if ((string) $value == '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// end func validate
|
||||
|
||||
public function getValidationScript($options = null)
|
||||
{
|
||||
return ['', "{jsVar} == ''"];
|
||||
}
|
||||
}
|
||||
30
main/inc/lib/formvalidator/Rule/UploadFile.php
Normal file
30
main/inc/lib/formvalidator/Rule/UploadFile.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/** @author Julio Montoya */
|
||||
|
||||
/**
|
||||
* Class HTML_QuickForm_Rule_UploadFile.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_UploadFile extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Checks if the given element contains an uploaded file of the filename regex.
|
||||
*
|
||||
* @param array Uploaded file info (from $_FILES)
|
||||
* @param string Regular expression
|
||||
*
|
||||
* @return bool true if name matches regex, false otherwise
|
||||
*/
|
||||
public function validate($elementValue, $regex)
|
||||
{
|
||||
if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
|
||||
(!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
|
||||
return is_uploaded_file($elementValue['tmp_name']);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// end func _ruleCheckFileName
|
||||
}
|
||||
23
main/inc/lib/formvalidator/Rule/Url.php
Normal file
23
main/inc/lib/formvalidator/Rule/Url.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Abstract base class for QuickForm validation rules.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Validate urls.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_Url extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Validates url.
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return bool returns true if valid, false otherwise
|
||||
*/
|
||||
public function validate($url, $options)
|
||||
{
|
||||
return (bool) filter_var($url, FILTER_VALIDATE_URL);
|
||||
}
|
||||
}
|
||||
30
main/inc/lib/formvalidator/Rule/Username.php
Normal file
30
main/inc/lib/formvalidator/Rule/Username.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* QuickForm rule to check if a username is of the correct format.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_Username extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Function to check if a username is of the correct format.
|
||||
*
|
||||
* @param string $username Wanted username
|
||||
* @param array $options
|
||||
*
|
||||
* @return bool True if username is of the correct format
|
||||
*
|
||||
* @author Modified by Ivan Tcholakov, 15-SEP-2009.
|
||||
*
|
||||
* @see HTML_QuickForm_Rule
|
||||
* The validation rule is served by the UserManager class as of this moment.
|
||||
*/
|
||||
public function validate($username, $options)
|
||||
{
|
||||
if (api_get_setting('login_is_email') == 'true') {
|
||||
return api_valid_email($username);
|
||||
} else {
|
||||
return UserManager::is_username_valid($username);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
main/inc/lib/formvalidator/Rule/UsernameAvailable.php
Normal file
34
main/inc/lib/formvalidator/Rule/UsernameAvailable.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* QuickForm rule to check if a username is available.
|
||||
*/
|
||||
class HTML_QuickForm_Rule_UsernameAvailable extends HTML_QuickForm_Rule
|
||||
{
|
||||
/**
|
||||
* Function to check if a username is available.
|
||||
*
|
||||
* @see HTML_QuickForm_Rule
|
||||
*
|
||||
* @param string $username Wanted username
|
||||
* @param string $current_username
|
||||
*
|
||||
* @return bool True if username is available
|
||||
*/
|
||||
public function validate($username, $current_username = null)
|
||||
{
|
||||
$user_table = Database::get_main_table(TABLE_MAIN_USER);
|
||||
$username = Database::escape_string($username);
|
||||
$current_username = Database::escape_string($current_username);
|
||||
|
||||
$sql = "SELECT * FROM $user_table WHERE username = '$username'";
|
||||
if (!is_null($current_username)) {
|
||||
$sql .= " AND username != '$current_username'";
|
||||
}
|
||||
$res = Database::query($sql);
|
||||
$number = Database::num_rows($res);
|
||||
|
||||
return $number == 0;
|
||||
}
|
||||
}
|
||||
990
main/inc/lib/formvalidator/Rule/allowed_tags.inc.php
Normal file
990
main/inc/lib/formvalidator/Rule/allowed_tags.inc.php
Normal file
@@ -0,0 +1,990 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This page defines all HTML-tages and their attributes that are allowed in
|
||||
* Chamilo. 2 arrays are defined, one contains the allowed HTML for students and
|
||||
* the other the allowed HTML for teachers.
|
||||
*
|
||||
* Modifying this page:
|
||||
* - for each allowed tag there should be a line like
|
||||
* $allowed_tags_XXXX ['tagname'] = array();
|
||||
* - for each of the attributes allowed in the tag, there should be a line like
|
||||
* $allowed_tags_XXXX['tagname']['attributename'] = array();
|
||||
* - please keep the content of this file alphabetically structured
|
||||
*
|
||||
* @see http://www.w3schools.com/tags/
|
||||
*/
|
||||
|
||||
// KSES-COMPATIBLE SETTINGS
|
||||
|
||||
// ALLOWED HTML FOR STUDENTS
|
||||
|
||||
// a
|
||||
$allowed_tags_student['a'] = [];
|
||||
$allowed_tags_student['a']['class'] = [];
|
||||
$allowed_tags_student['a']['dir'] = [];
|
||||
$allowed_tags_student['a']['id'] = [];
|
||||
$allowed_tags_student['a']['href'] = [];
|
||||
$allowed_tags_student['a']['lang'] = [];
|
||||
$allowed_tags_student['a']['name'] = [];
|
||||
$allowed_tags_student['a']['rel'] = [];
|
||||
$allowed_tags_student['a']['rev'] = [];
|
||||
$allowed_tags_student['a']['style'] = [];
|
||||
$allowed_tags_student['a']['target'] = [];
|
||||
$allowed_tags_student['a']['title'] = [];
|
||||
$allowed_tags_student['a']['xml:lang'] = [];
|
||||
|
||||
// abbr
|
||||
$allowed_tags_student['abbr'] = [];
|
||||
$allowed_tags_student['abbr']['class'] = [];
|
||||
$allowed_tags_student['abbr']['dir'] = [];
|
||||
$allowed_tags_student['abbr']['id'] = [];
|
||||
$allowed_tags_student['abbr']['lang'] = [];
|
||||
$allowed_tags_student['abbr']['style'] = [];
|
||||
$allowed_tags_student['abbr']['title'] = [];
|
||||
$allowed_tags_student['abbr']['xml:lang'] = [];
|
||||
|
||||
// acronym
|
||||
$allowed_tags_student['acronym'] = [];
|
||||
$allowed_tags_student['acronym']['class'] = [];
|
||||
$allowed_tags_student['acronym']['dir'] = [];
|
||||
$allowed_tags_student['acronym']['id'] = [];
|
||||
$allowed_tags_student['acronym']['lang'] = [];
|
||||
$allowed_tags_student['acronym']['style'] = [];
|
||||
$allowed_tags_student['acronym']['title'] = [];
|
||||
$allowed_tags_student['acronym']['xml:lang'] = [];
|
||||
|
||||
// address
|
||||
$allowed_tags_student['address'] = [];
|
||||
$allowed_tags_student['address']['class'] = [];
|
||||
$allowed_tags_student['address']['dir'] = [];
|
||||
$allowed_tags_student['address']['id'] = [];
|
||||
$allowed_tags_student['address']['lang'] = [];
|
||||
$allowed_tags_student['address']['style'] = [];
|
||||
$allowed_tags_student['address']['title'] = [];
|
||||
$allowed_tags_student['address']['xml:lang'] = [];
|
||||
|
||||
// b
|
||||
$allowed_tags_student['b'] = [];
|
||||
$allowed_tags_student['b']['class'] = [];
|
||||
$allowed_tags_student['b']['dir'] = [];
|
||||
$allowed_tags_student['b']['id'] = [];
|
||||
$allowed_tags_student['b']['lang'] = [];
|
||||
$allowed_tags_student['b']['style'] = [];
|
||||
$allowed_tags_student['b']['title'] = [];
|
||||
$allowed_tags_student['b']['xml:lang'] = [];
|
||||
|
||||
// base
|
||||
$allowed_tags_student_full_page['base'] = [];
|
||||
$allowed_tags_student_full_page['base']['href'] = [];
|
||||
$allowed_tags_student_full_page['base']['target'] = [];
|
||||
|
||||
// basefont (IE only)
|
||||
$allowed_tags_student['basefont'] = [];
|
||||
$allowed_tags_student['basefont']['face'] = [];
|
||||
$allowed_tags_student['basefont']['color'] = [];
|
||||
$allowed_tags_student['basefont']['id'] = [];
|
||||
$allowed_tags_student['basefont']['size'] = [];
|
||||
|
||||
// bdo
|
||||
$allowed_tags_student['bdo'] = [];
|
||||
$allowed_tags_student['bdo']['class'] = [];
|
||||
$allowed_tags_student['bdo']['dir'] = [];
|
||||
$allowed_tags_student['bdo']['id'] = [];
|
||||
$allowed_tags_student['bdo']['lang'] = [];
|
||||
$allowed_tags_student['bdo']['style'] = [];
|
||||
$allowed_tags_student['bdo']['title'] = [];
|
||||
$allowed_tags_student['bdo']['xml:lang'] = [];
|
||||
|
||||
// big
|
||||
$allowed_tags_student['big'] = [];
|
||||
$allowed_tags_student['big']['class'] = [];
|
||||
$allowed_tags_student['big']['dir'] = [];
|
||||
$allowed_tags_student['big']['id'] = [];
|
||||
$allowed_tags_student['big']['lang'] = [];
|
||||
$allowed_tags_student['big']['style'] = [];
|
||||
$allowed_tags_student['big']['title'] = [];
|
||||
$allowed_tags_student['big']['xml:lang'] = [];
|
||||
|
||||
// blockquote
|
||||
$allowed_tags_student['blockquote'] = [];
|
||||
$allowed_tags_student['blockquote']['cite'] = [];
|
||||
$allowed_tags_student['blockquote']['class'] = [];
|
||||
$allowed_tags_student['blockquote']['dir'] = [];
|
||||
$allowed_tags_student['blockquote']['id'] = [];
|
||||
$allowed_tags_student['blockquote']['lang'] = [];
|
||||
$allowed_tags_student['blockquote']['style'] = [];
|
||||
$allowed_tags_student['blockquote']['title'] = [];
|
||||
$allowed_tags_student['blockquote']['xml:lang'] = [];
|
||||
|
||||
// body
|
||||
$allowed_tags_student_full_page['body'] = [];
|
||||
$allowed_tags_student_full_page['body']['alink'] = [];
|
||||
$allowed_tags_student_full_page['body']['background'] = [];
|
||||
$allowed_tags_student_full_page['body']['bgcolor'] = [];
|
||||
$allowed_tags_student_full_page['body']['link'] = [];
|
||||
$allowed_tags_student_full_page['body']['text'] = [];
|
||||
$allowed_tags_student_full_page['body']['vlink'] = [];
|
||||
$allowed_tags_student_full_page['body']['class'] = [];
|
||||
$allowed_tags_student_full_page['body']['dir'] = [];
|
||||
$allowed_tags_student_full_page['body']['id'] = [];
|
||||
$allowed_tags_student_full_page['body']['lang'] = [];
|
||||
$allowed_tags_student_full_page['body']['style'] = [];
|
||||
$allowed_tags_student_full_page['body']['title'] = [];
|
||||
$allowed_tags_student_full_page['body']['xml:lang'] = [];
|
||||
|
||||
// br
|
||||
$allowed_tags_student['br'] = [];
|
||||
$allowed_tags_student['br']['class'] = [];
|
||||
$allowed_tags_student['br']['id'] = [];
|
||||
$allowed_tags_student['br']['style'] = [];
|
||||
$allowed_tags_student['br']['title'] = [];
|
||||
|
||||
// caption
|
||||
$allowed_tags_student['caption'] = [];
|
||||
$allowed_tags_student['caption']['align'] = [];
|
||||
$allowed_tags_student['caption']['class'] = [];
|
||||
$allowed_tags_student['caption']['dir'] = [];
|
||||
$allowed_tags_student['caption']['id'] = [];
|
||||
$allowed_tags_student['caption']['lang'] = [];
|
||||
$allowed_tags_student['caption']['style'] = [];
|
||||
$allowed_tags_student['caption']['title'] = [];
|
||||
$allowed_tags_student['caption']['xml:lang'] = [];
|
||||
|
||||
// center
|
||||
$allowed_tags_student['center'] = [];
|
||||
$allowed_tags_student['center']['class'] = [];
|
||||
$allowed_tags_student['center']['dir'] = [];
|
||||
$allowed_tags_student['center']['id'] = [];
|
||||
$allowed_tags_student['center']['lang'] = [];
|
||||
$allowed_tags_student['center']['style'] = [];
|
||||
$allowed_tags_student['center']['title'] = [];
|
||||
|
||||
// cite
|
||||
$allowed_tags_student['cite'] = [];
|
||||
$allowed_tags_student['cite']['class'] = [];
|
||||
$allowed_tags_student['cite']['dir'] = [];
|
||||
$allowed_tags_student['cite']['id'] = [];
|
||||
$allowed_tags_student['cite']['lang'] = [];
|
||||
$allowed_tags_student['cite']['style'] = [];
|
||||
$allowed_tags_student['cite']['title'] = [];
|
||||
$allowed_tags_student['cite']['xml:lang'] = [];
|
||||
|
||||
// code
|
||||
$allowed_tags_student['code'] = [];
|
||||
$allowed_tags_student['code']['class'] = [];
|
||||
$allowed_tags_student['code']['dir'] = [];
|
||||
$allowed_tags_student['code']['id'] = [];
|
||||
$allowed_tags_student['code']['lang'] = [];
|
||||
$allowed_tags_student['code']['style'] = [];
|
||||
$allowed_tags_student['code']['title'] = [];
|
||||
$allowed_tags_student['code']['xml:lang'] = [];
|
||||
|
||||
// col
|
||||
$allowed_tags_student['col'] = [];
|
||||
$allowed_tags_student['col']['align'] = [];
|
||||
$allowed_tags_student['col']['class'] = [];
|
||||
$allowed_tags_student['col']['dir'] = [];
|
||||
$allowed_tags_student['col']['id'] = [];
|
||||
$allowed_tags_student['col']['lang'] = [];
|
||||
$allowed_tags_student['col']['span'] = [];
|
||||
$allowed_tags_student['col']['style'] = [];
|
||||
$allowed_tags_student['col']['title'] = [];
|
||||
$allowed_tags_student['col']['valign'] = [];
|
||||
$allowed_tags_student['col']['width'] = [];
|
||||
$allowed_tags_student['col']['xml:lang'] = [];
|
||||
|
||||
// colgroup
|
||||
$allowed_tags_student['colgroup'] = [];
|
||||
$allowed_tags_student['colgroup']['align'] = [];
|
||||
$allowed_tags_student['colgroup']['class'] = [];
|
||||
$allowed_tags_student['colgroup']['dir'] = [];
|
||||
$allowed_tags_student['colgroup']['id'] = [];
|
||||
$allowed_tags_student['colgroup']['lang'] = [];
|
||||
$allowed_tags_student['colgroup']['span'] = [];
|
||||
$allowed_tags_student['colgroup']['style'] = [];
|
||||
$allowed_tags_student['colgroup']['title'] = [];
|
||||
$allowed_tags_student['colgroup']['valign'] = [];
|
||||
$allowed_tags_student['colgroup']['width'] = [];
|
||||
$allowed_tags_student['colgroup']['xml:lang'] = [];
|
||||
|
||||
// dd
|
||||
$allowed_tags_student['dd'] = [];
|
||||
$allowed_tags_student['dd']['class'] = [];
|
||||
$allowed_tags_student['dd']['dir'] = [];
|
||||
$allowed_tags_student['dd']['id'] = [];
|
||||
$allowed_tags_student['dd']['lang'] = [];
|
||||
$allowed_tags_student['dd']['style'] = [];
|
||||
$allowed_tags_student['dd']['title'] = [];
|
||||
$allowed_tags_student['dd']['xml:lang'] = [];
|
||||
|
||||
// del
|
||||
$allowed_tags_student['del'] = [];
|
||||
$allowed_tags_student['del']['cite'] = [];
|
||||
$allowed_tags_student['del']['class'] = [];
|
||||
$allowed_tags_student['del']['dir'] = [];
|
||||
$allowed_tags_student['del']['id'] = [];
|
||||
$allowed_tags_student['del']['lang'] = [];
|
||||
$allowed_tags_student['del']['style'] = [];
|
||||
$allowed_tags_student['del']['title'] = [];
|
||||
$allowed_tags_student['del']['xml:lang'] = [];
|
||||
|
||||
// dfn
|
||||
$allowed_tags_student['dfn'] = [];
|
||||
$allowed_tags_student['dfn']['class'] = [];
|
||||
$allowed_tags_student['dfn']['dir'] = [];
|
||||
$allowed_tags_student['dfn']['id'] = [];
|
||||
$allowed_tags_student['dfn']['lang'] = [];
|
||||
$allowed_tags_student['dfn']['style'] = [];
|
||||
$allowed_tags_student['dfn']['title'] = [];
|
||||
$allowed_tags_student['dfn']['xml:lang'] = [];
|
||||
|
||||
// dir
|
||||
$allowed_tags_student['dir'] = [];
|
||||
$allowed_tags_student['dir']['class'] = [];
|
||||
$allowed_tags_student['dir']['compact'] = [];
|
||||
$allowed_tags_student['dir']['dir'] = [];
|
||||
$allowed_tags_student['dir']['id'] = [];
|
||||
$allowed_tags_student['dir']['lang'] = [];
|
||||
$allowed_tags_student['dir']['style'] = [];
|
||||
$allowed_tags_student['dir']['title'] = [];
|
||||
|
||||
// div
|
||||
$allowed_tags_student['div'] = [];
|
||||
$allowed_tags_student['div']['align'] = [];
|
||||
$allowed_tags_student['div']['class'] = [];
|
||||
$allowed_tags_student['div']['dir'] = [];
|
||||
$allowed_tags_student['div']['id'] = [];
|
||||
$allowed_tags_student['div']['lang'] = [];
|
||||
$allowed_tags_student['div']['style'] = [];
|
||||
$allowed_tags_student['div']['title'] = [];
|
||||
$allowed_tags_student['div']['xml:lang'] = [];
|
||||
|
||||
// dl
|
||||
$allowed_tags_student['dl'] = [];
|
||||
$allowed_tags_student['dl']['class'] = [];
|
||||
$allowed_tags_student['dl']['dir'] = [];
|
||||
$allowed_tags_student['dl']['id'] = [];
|
||||
$allowed_tags_student['dl']['lang'] = [];
|
||||
$allowed_tags_student['dl']['style'] = [];
|
||||
$allowed_tags_student['dl']['title'] = [];
|
||||
$allowed_tags_student['dl']['xml:lang'] = [];
|
||||
|
||||
// dt
|
||||
$allowed_tags_student['dt'] = [];
|
||||
$allowed_tags_student['dt']['class'] = [];
|
||||
$allowed_tags_student['dt']['dir'] = [];
|
||||
$allowed_tags_student['dt']['id'] = [];
|
||||
$allowed_tags_student['dt']['lang'] = [];
|
||||
$allowed_tags_student['dt']['style'] = [];
|
||||
$allowed_tags_student['dt']['title'] = [];
|
||||
$allowed_tags_student['dt']['xml:lang'] = [];
|
||||
|
||||
// em
|
||||
$allowed_tags_student['em'] = [];
|
||||
$allowed_tags_student['em']['class'] = [];
|
||||
$allowed_tags_student['em']['dir'] = [];
|
||||
$allowed_tags_student['em']['id'] = [];
|
||||
$allowed_tags_student['em']['lang'] = [];
|
||||
$allowed_tags_student['em']['style'] = [];
|
||||
$allowed_tags_student['em']['title'] = [];
|
||||
$allowed_tags_student['em']['xml:lang'] = [];
|
||||
|
||||
// embed
|
||||
$allowed_tags_student['embed'] = [];
|
||||
$allowed_tags_student['embed']['height'] = [];
|
||||
$allowed_tags_student['embed']['width'] = [];
|
||||
$allowed_tags_student['embed']['type'] = [];
|
||||
//$allowed_tags_student['embed']['quality'] = array();
|
||||
$allowed_tags_student['embed']['src'] = [];
|
||||
$allowed_tags_student['embed']['flashvars'] = [];
|
||||
$allowed_tags_student['embed']['allowscriptaccess'] = [];
|
||||
//$allowed_tags_student['embed']['allowfullscreen'] = array();
|
||||
//$allowed_tags_student['embed']['bgcolor'] = array();
|
||||
//$allowed_tags_student['embed']['pluginspage'] = array();
|
||||
|
||||
// embed
|
||||
$allowed_tags_student['video'] = [];
|
||||
$allowed_tags_student['video']['height'] = [];
|
||||
$allowed_tags_student['video']['width'] = [];
|
||||
$allowed_tags_student['video']['type'] = [];
|
||||
$allowed_tags_student['video']['poster'] = [];
|
||||
$allowed_tags_student['video']['preload'] = [];
|
||||
$allowed_tags_student['video']['src'] = [];
|
||||
$allowed_tags_student['video']['controls'] = [];
|
||||
$allowed_tags_student['video']['id'] = [];
|
||||
$allowed_tags_student['video']['class'] = [];
|
||||
|
||||
$allowed_tags_student['audio'] = [];
|
||||
$allowed_tags_student['audio']['autoplay'] = [];
|
||||
$allowed_tags_student['audio']['src'] = [];
|
||||
$allowed_tags_student['audio']['loop'] = [];
|
||||
$allowed_tags_student['audio']['preload'] = [];
|
||||
$allowed_tags_student['audio']['controls'] = [];
|
||||
$allowed_tags_student['audio']['muted'] = [];
|
||||
$allowed_tags_student['audio']['id'] = [];
|
||||
$allowed_tags_student['audio']['class'] = [];
|
||||
|
||||
$allowed_tags_student['source'] = [];
|
||||
$allowed_tags_student['source']['type'] = [];
|
||||
$allowed_tags_student['source']['src'] = [];
|
||||
|
||||
// font
|
||||
$allowed_tags_student['font'] = [];
|
||||
$allowed_tags_student['font']['face'] = [];
|
||||
$allowed_tags_student['font']['class'] = [];
|
||||
$allowed_tags_student['font']['color'] = [];
|
||||
$allowed_tags_student['font']['dir'] = [];
|
||||
$allowed_tags_student['font']['id'] = [];
|
||||
$allowed_tags_student['font']['lang'] = [];
|
||||
$allowed_tags_student['font']['size'] = [];
|
||||
$allowed_tags_student['font']['style'] = [];
|
||||
$allowed_tags_student['font']['title'] = [];
|
||||
|
||||
// frame
|
||||
$allowed_tags_student_full_page['frame'] = [];
|
||||
$allowed_tags_student_full_page['frame']['class'] = [];
|
||||
$allowed_tags_student_full_page['frame']['frameborder'] = [];
|
||||
$allowed_tags_student_full_page['frame']['id'] = [];
|
||||
$allowed_tags_student_full_page['frame']['longsesc'] = [];
|
||||
$allowed_tags_student_full_page['frame']['marginheight'] = [];
|
||||
$allowed_tags_student_full_page['frame']['marginwidth'] = [];
|
||||
$allowed_tags_student_full_page['frame']['name'] = [];
|
||||
$allowed_tags_student_full_page['frame']['noresize'] = [];
|
||||
$allowed_tags_student_full_page['frame']['scrolling'] = [];
|
||||
$allowed_tags_student_full_page['frame']['src'] = [];
|
||||
$allowed_tags_student_full_page['frame']['style'] = [];
|
||||
$allowed_tags_student_full_page['frame']['title'] = [];
|
||||
|
||||
// frameset
|
||||
$allowed_tags_student_full_page['frameset'] = [];
|
||||
$allowed_tags_student_full_page['frameset']['class'] = [];
|
||||
$allowed_tags_student_full_page['frameset']['cols'] = [];
|
||||
$allowed_tags_student_full_page['frameset']['id'] = [];
|
||||
$allowed_tags_student_full_page['frameset']['rows'] = [];
|
||||
$allowed_tags_student_full_page['frameset']['style'] = [];
|
||||
$allowed_tags_student_full_page['frameset']['title'] = [];
|
||||
|
||||
// head
|
||||
$allowed_tags_student_full_page['head'] = [];
|
||||
$allowed_tags_student_full_page['head']['dir'] = [];
|
||||
$allowed_tags_student_full_page['head']['lang'] = [];
|
||||
$allowed_tags_student_full_page['head']['profile'] = [];
|
||||
$allowed_tags_student_full_page['head']['xml:lang'] = [];
|
||||
|
||||
// h1
|
||||
$allowed_tags_student['h1'] = [];
|
||||
$allowed_tags_student['h1']['align'] = [];
|
||||
$allowed_tags_student['h1']['class'] = [];
|
||||
$allowed_tags_student['h1']['dir'] = [];
|
||||
$allowed_tags_student['h1']['id'] = [];
|
||||
$allowed_tags_student['h1']['lang'] = [];
|
||||
$allowed_tags_student['h1']['style'] = [];
|
||||
$allowed_tags_student['h1']['title'] = [];
|
||||
$allowed_tags_student['h1']['xml:lang'] = [];
|
||||
|
||||
// h2
|
||||
$allowed_tags_student['h2'] = [];
|
||||
$allowed_tags_student['h2']['align'] = [];
|
||||
$allowed_tags_student['h2']['class'] = [];
|
||||
$allowed_tags_student['h2']['dir'] = [];
|
||||
$allowed_tags_student['h2']['id'] = [];
|
||||
$allowed_tags_student['h2']['lang'] = [];
|
||||
$allowed_tags_student['h2']['style'] = [];
|
||||
$allowed_tags_student['h2']['title'] = [];
|
||||
$allowed_tags_student['h2']['xml:lang'] = [];
|
||||
|
||||
// h3
|
||||
$allowed_tags_student['h3'] = [];
|
||||
$allowed_tags_student['h3']['align'] = [];
|
||||
$allowed_tags_student['h3']['class'] = [];
|
||||
$allowed_tags_student['h3']['dir'] = [];
|
||||
$allowed_tags_student['h3']['id'] = [];
|
||||
$allowed_tags_student['h3']['lang'] = [];
|
||||
$allowed_tags_student['h3']['style'] = [];
|
||||
$allowed_tags_student['h3']['title'] = [];
|
||||
$allowed_tags_student['h3']['xml:lang'] = [];
|
||||
|
||||
// h4
|
||||
$allowed_tags_student['h4'] = [];
|
||||
$allowed_tags_student['h4']['align'] = [];
|
||||
$allowed_tags_student['h4']['class'] = [];
|
||||
$allowed_tags_student['h4']['dir'] = [];
|
||||
$allowed_tags_student['h4']['id'] = [];
|
||||
$allowed_tags_student['h4']['lang'] = [];
|
||||
$allowed_tags_student['h4']['style'] = [];
|
||||
$allowed_tags_student['h4']['title'] = [];
|
||||
$allowed_tags_student['h4']['xml:lang'] = [];
|
||||
|
||||
// h5
|
||||
$allowed_tags_student['h5'] = [];
|
||||
$allowed_tags_student['h5']['align'] = [];
|
||||
$allowed_tags_student['h5']['class'] = [];
|
||||
$allowed_tags_student['h5']['dir'] = [];
|
||||
$allowed_tags_student['h5']['id'] = [];
|
||||
$allowed_tags_student['h5']['lang'] = [];
|
||||
$allowed_tags_student['h5']['style'] = [];
|
||||
$allowed_tags_student['h5']['title'] = [];
|
||||
$allowed_tags_student['h5']['xml:lang'] = [];
|
||||
|
||||
// h6
|
||||
$allowed_tags_student['h6'] = [];
|
||||
$allowed_tags_student['h6']['align'] = [];
|
||||
$allowed_tags_student['h6']['class'] = [];
|
||||
$allowed_tags_student['h6']['dir'] = [];
|
||||
$allowed_tags_student['h6']['id'] = [];
|
||||
$allowed_tags_student['h6']['lang'] = [];
|
||||
$allowed_tags_student['h6']['style'] = [];
|
||||
$allowed_tags_student['h6']['title'] = [];
|
||||
$allowed_tags_student['h6']['xml:lang'] = [];
|
||||
|
||||
// hr
|
||||
$allowed_tags_student['hr'] = [];
|
||||
$allowed_tags_student['hr']['align'] = [];
|
||||
$allowed_tags_student['hr']['class'] = [];
|
||||
$allowed_tags_student['hr']['dir'] = [];
|
||||
$allowed_tags_student['hr']['id'] = [];
|
||||
$allowed_tags_student['hr']['lang'] = [];
|
||||
$allowed_tags_student['hr']['noshade'] = [];
|
||||
$allowed_tags_student['hr']['size'] = [];
|
||||
$allowed_tags_student['hr']['style'] = [];
|
||||
$allowed_tags_student['hr']['title'] = [];
|
||||
$allowed_tags_student['hr']['width'] = [];
|
||||
$allowed_tags_student['hr']['xml:lang'] = [];
|
||||
|
||||
// html
|
||||
$allowed_tags_student_full_page['html'] = [];
|
||||
$allowed_tags_student_full_page['html']['dir'] = [];
|
||||
$allowed_tags_student_full_page['html']['lang'] = [];
|
||||
$allowed_tags_student_full_page['html']['xml:lang'] = [];
|
||||
$allowed_tags_student_full_page['html']['xmlns'] = [];
|
||||
|
||||
// i
|
||||
$allowed_tags_student['i'] = [];
|
||||
$allowed_tags_student['i']['class'] = [];
|
||||
$allowed_tags_student['i']['dir'] = [];
|
||||
$allowed_tags_student['i']['id'] = [];
|
||||
$allowed_tags_student['i']['lang'] = [];
|
||||
$allowed_tags_student['i']['style'] = [];
|
||||
$allowed_tags_student['i']['title'] = [];
|
||||
$allowed_tags_student['i']['xml:lang'] = [];
|
||||
|
||||
// img
|
||||
$allowed_tags_student['img'] = [];
|
||||
$allowed_tags_student['img']['alt'] = [];
|
||||
$allowed_tags_student['img']['align'] = [];
|
||||
$allowed_tags_student['img']['border'] = [];
|
||||
$allowed_tags_student['img']['class'] = [];
|
||||
$allowed_tags_student['img']['dir'] = [];
|
||||
$allowed_tags_student['img']['id'] = [];
|
||||
$allowed_tags_student['img']['height'] = [];
|
||||
$allowed_tags_student['img']['hspace'] = [];
|
||||
//$allowed_tags_student['img']['ismap'] = array();
|
||||
$allowed_tags_student['img']['lang'] = [];
|
||||
$allowed_tags_student['img']['longdesc'] = [];
|
||||
$allowed_tags_student['img']['style'] = [];
|
||||
$allowed_tags_student['img']['src'] = [];
|
||||
$allowed_tags_student['img']['title'] = [];
|
||||
//$allowed_tags_student['img']['usemap'] = array();
|
||||
$allowed_tags_student['img']['vspace'] = [];
|
||||
$allowed_tags_student['img']['width'] = [];
|
||||
$allowed_tags_student['img']['xml:lang'] = [];
|
||||
|
||||
// ins
|
||||
$allowed_tags_student['ins'] = [];
|
||||
$allowed_tags_student['ins']['cite'] = [];
|
||||
$allowed_tags_student['ins']['class'] = [];
|
||||
$allowed_tags_student['ins']['dir'] = [];
|
||||
$allowed_tags_student['ins']['id'] = [];
|
||||
$allowed_tags_student['ins']['lang'] = [];
|
||||
$allowed_tags_student['ins']['style'] = [];
|
||||
$allowed_tags_student['ins']['title'] = [];
|
||||
$allowed_tags_student['ins']['xml:lang'] = [];
|
||||
|
||||
// kbd
|
||||
$allowed_tags_student['kbd'] = [];
|
||||
$allowed_tags_student['kbd']['class'] = [];
|
||||
$allowed_tags_student['kbd']['dir'] = [];
|
||||
$allowed_tags_student['kbd']['id'] = [];
|
||||
$allowed_tags_student['kbd']['lang'] = [];
|
||||
$allowed_tags_student['kbd']['style'] = [];
|
||||
$allowed_tags_student['kbd']['title'] = [];
|
||||
$allowed_tags_student['kbd']['xml:lang'] = [];
|
||||
|
||||
// li
|
||||
$allowed_tags_student['li'] = [];
|
||||
$allowed_tags_student['li']['class'] = [];
|
||||
$allowed_tags_student['li']['dir'] = [];
|
||||
$allowed_tags_student['li']['id'] = [];
|
||||
$allowed_tags_student['li']['lang'] = [];
|
||||
$allowed_tags_student['li']['style'] = [];
|
||||
$allowed_tags_student['li']['title'] = [];
|
||||
$allowed_tags_student['li']['type'] = [];
|
||||
$allowed_tags_student['li']['value'] = [];
|
||||
$allowed_tags_student['li']['xml:lang'] = [];
|
||||
|
||||
// link
|
||||
$allowed_tags_student_full_page['link'] = [];
|
||||
$allowed_tags_student_full_page['link']['charset'] = [];
|
||||
$allowed_tags_student_full_page['link']['href'] = [];
|
||||
$allowed_tags_student_full_page['link']['hreflang'] = [];
|
||||
$allowed_tags_student_full_page['link']['media'] = [];
|
||||
$allowed_tags_student_full_page['link']['rel'] = [];
|
||||
$allowed_tags_student_full_page['link']['rev'] = [];
|
||||
$allowed_tags_student_full_page['link']['target'] = [];
|
||||
$allowed_tags_student_full_page['link']['type'] = [];
|
||||
|
||||
// map
|
||||
/*
|
||||
$allowed_tags_student['map'] = array();
|
||||
$allowed_tags_student['map']['class'] = array();
|
||||
$allowed_tags_student['map']['dir'] = array();
|
||||
$allowed_tags_student['map']['id'] = array();
|
||||
$allowed_tags_student['map']['lang'] = array();
|
||||
$allowed_tags_student['map']['name'] = array();
|
||||
$allowed_tags_student['map']['style'] = array();
|
||||
$allowed_tags_student['map']['title'] = array();
|
||||
$allowed_tags_student['map']['xml:lang'] = array();
|
||||
*/
|
||||
|
||||
// menu
|
||||
$allowed_tags_student['menu'] = [];
|
||||
$allowed_tags_student['menu']['class'] = [];
|
||||
$allowed_tags_student['menu']['compact'] = [];
|
||||
$allowed_tags_student['menu']['dir'] = [];
|
||||
$allowed_tags_student['menu']['id'] = [];
|
||||
$allowed_tags_student['menu']['lang'] = [];
|
||||
$allowed_tags_student['menu']['style'] = [];
|
||||
$allowed_tags_student['menu']['title'] = [];
|
||||
|
||||
// meta
|
||||
$allowed_tags_student_full_page['meta'] = [];
|
||||
$allowed_tags_student_full_page['meta']['content'] = [];
|
||||
$allowed_tags_student_full_page['meta']['dir'] = [];
|
||||
$allowed_tags_student_full_page['meta']['http-equiv'] = [];
|
||||
$allowed_tags_student_full_page['meta']['lang'] = [];
|
||||
$allowed_tags_student_full_page['meta']['name'] = [];
|
||||
$allowed_tags_student_full_page['meta']['scheme'] = [];
|
||||
$allowed_tags_student_full_page['meta']['xml:lang'] = [];
|
||||
|
||||
// noframes
|
||||
$allowed_tags_student_full_page['noframes'] = [];
|
||||
$allowed_tags_student_full_page['noframes']['class'] = [];
|
||||
$allowed_tags_student_full_page['noframes']['dir'] = [];
|
||||
$allowed_tags_student_full_page['noframes']['id'] = [];
|
||||
$allowed_tags_student_full_page['noframes']['lang'] = [];
|
||||
$allowed_tags_student_full_page['noframes']['style'] = [];
|
||||
$allowed_tags_student_full_page['noframes']['title'] = [];
|
||||
$allowed_tags_student_full_page['noframes']['xml:lang'] = [];
|
||||
|
||||
// object
|
||||
$allowed_tags_student['object'] = [];
|
||||
//$allowed_tags_student['object']['align'] = array();
|
||||
//$allowed_tags_student['object']['archive'] = array();
|
||||
//$allowed_tags_student['object']['border'] = array();
|
||||
$allowed_tags_student['object']['class'] = [];
|
||||
//$allowed_tags_student['object']['classid'] = array();
|
||||
$allowed_tags_student['object']['codebase'] = [];
|
||||
//$allowed_tags_student['object']['codetype'] = array();
|
||||
$allowed_tags_student['object']['data'] = [];
|
||||
//$allowed_tags_student['object']['declare'] = array();
|
||||
$allowed_tags_student['object']['dir'] = [];
|
||||
$allowed_tags_student['object']['id'] = [];
|
||||
$allowed_tags_student['object']['height'] = [];
|
||||
//$allowed_tags_student['object']['hspace'] = array();
|
||||
$allowed_tags_student['object']['lang'] = [];
|
||||
//$allowed_tags_student['object']['name'] = array();
|
||||
//$allowed_tags_student['object']['standby'] = array();
|
||||
$allowed_tags_student['object']['style'] = [];
|
||||
$allowed_tags_student['object']['title'] = [];
|
||||
$allowed_tags_student['object']['type'] = [];
|
||||
//$allowed_tags_student['object']['usemap'] = array();
|
||||
//$allowed_tags_student['object']['vspace'] = array();
|
||||
$allowed_tags_student['object']['width'] = [];
|
||||
$allowed_tags_student['object']['xml:lang'] = [];
|
||||
|
||||
// ol
|
||||
$allowed_tags_student['ol'] = [];
|
||||
$allowed_tags_student['ol']['class'] = [];
|
||||
$allowed_tags_student['ol']['compact'] = [];
|
||||
$allowed_tags_student['ol']['dir'] = [];
|
||||
$allowed_tags_student['ol']['id'] = [];
|
||||
$allowed_tags_student['ol']['lang'] = [];
|
||||
$allowed_tags_student['ol']['start'] = [];
|
||||
$allowed_tags_student['ol']['style'] = [];
|
||||
$allowed_tags_student['ol']['title'] = [];
|
||||
$allowed_tags_student['ol']['type'] = [];
|
||||
$allowed_tags_student['ol']['xml:lang'] = [];
|
||||
|
||||
// p
|
||||
$allowed_tags_student['p'] = [];
|
||||
$allowed_tags_student['p']['align'] = [];
|
||||
$allowed_tags_student['p']['class'] = [];
|
||||
$allowed_tags_student['p']['dir'] = [];
|
||||
$allowed_tags_student['p']['id'] = [];
|
||||
$allowed_tags_student['p']['lang'] = [];
|
||||
$allowed_tags_student['p']['style'] = [];
|
||||
$allowed_tags_student['p']['title'] = [];
|
||||
$allowed_tags_student['p']['xml:lang'] = [];
|
||||
|
||||
// param
|
||||
$allowed_tags_student['param'] = [];
|
||||
$allowed_tags_student['param']['name'] = [];
|
||||
//$allowed_tags_student['param']['type'] = array();
|
||||
$allowed_tags_student['param']['value'] = [];
|
||||
//$allowed_tags_student['param']['valuetype'] = array();
|
||||
|
||||
// pre
|
||||
$allowed_tags_student['pre'] = [];
|
||||
$allowed_tags_student['pre']['class'] = [];
|
||||
$allowed_tags_student['pre']['dir'] = [];
|
||||
$allowed_tags_student['pre']['id'] = [];
|
||||
$allowed_tags_student['pre']['lang'] = [];
|
||||
$allowed_tags_student['pre']['style'] = [];
|
||||
$allowed_tags_student['pre']['title'] = [];
|
||||
$allowed_tags_student['pre']['width'] = [];
|
||||
$allowed_tags_student['pre']['xml:lang'] = [];
|
||||
|
||||
// q
|
||||
$allowed_tags_student['q'] = [];
|
||||
$allowed_tags_student['q']['cite'] = [];
|
||||
$allowed_tags_student['q']['class'] = [];
|
||||
$allowed_tags_student['q']['dir'] = [];
|
||||
$allowed_tags_student['q']['id'] = [];
|
||||
$allowed_tags_student['q']['lang'] = [];
|
||||
$allowed_tags_student['q']['style'] = [];
|
||||
$allowed_tags_student['q']['title'] = [];
|
||||
$allowed_tags_student['q']['xml:lang'] = [];
|
||||
|
||||
// s
|
||||
$allowed_tags_student['s'] = [];
|
||||
$allowed_tags_student['s']['class'] = [];
|
||||
$allowed_tags_student['s']['dir'] = [];
|
||||
$allowed_tags_student['s']['id'] = [];
|
||||
$allowed_tags_student['s']['lang'] = [];
|
||||
$allowed_tags_student['s']['style'] = [];
|
||||
$allowed_tags_student['q']['title'] = [];
|
||||
|
||||
// samp
|
||||
$allowed_tags_student['samp'] = [];
|
||||
$allowed_tags_student['samp']['class'] = [];
|
||||
$allowed_tags_student['samp']['dir'] = [];
|
||||
$allowed_tags_student['samp']['id'] = [];
|
||||
$allowed_tags_student['samp']['lang'] = [];
|
||||
$allowed_tags_student['samp']['style'] = [];
|
||||
$allowed_tags_student['samp']['title'] = [];
|
||||
$allowed_tags_student['samp']['xml:lang'] = [];
|
||||
|
||||
// small
|
||||
$allowed_tags_student['small'] = [];
|
||||
$allowed_tags_student['small']['class'] = [];
|
||||
$allowed_tags_student['small']['dir'] = [];
|
||||
$allowed_tags_student['small']['id'] = [];
|
||||
$allowed_tags_student['small']['lang'] = [];
|
||||
$allowed_tags_student['small']['style'] = [];
|
||||
$allowed_tags_student['small']['title'] = [];
|
||||
$allowed_tags_student['small']['xml:lang'] = [];
|
||||
|
||||
// span
|
||||
$allowed_tags_student['span'] = [];
|
||||
$allowed_tags_student['span']['class'] = [];
|
||||
$allowed_tags_student['span']['dir'] = [];
|
||||
$allowed_tags_student['span']['id'] = [];
|
||||
$allowed_tags_student['span']['lang'] = [];
|
||||
$allowed_tags_student['span']['style'] = [];
|
||||
$allowed_tags_student['span']['title'] = [];
|
||||
$allowed_tags_student['span']['xml:lang'] = [];
|
||||
|
||||
// strike
|
||||
$allowed_tags_student['strike'] = [];
|
||||
$allowed_tags_student['strike']['class'] = [];
|
||||
$allowed_tags_student['strike']['dir'] = [];
|
||||
$allowed_tags_student['strike']['id'] = [];
|
||||
$allowed_tags_student['strike']['lang'] = [];
|
||||
$allowed_tags_student['strike']['style'] = [];
|
||||
$allowed_tags_student['strike']['title'] = [];
|
||||
|
||||
// strong
|
||||
$allowed_tags_student['strong'] = [];
|
||||
$allowed_tags_student['strong']['class'] = [];
|
||||
$allowed_tags_student['strong']['dir'] = [];
|
||||
$allowed_tags_student['strong']['id'] = [];
|
||||
$allowed_tags_student['strong']['lang'] = [];
|
||||
$allowed_tags_student['strong']['style'] = [];
|
||||
$allowed_tags_student['strong']['title'] = [];
|
||||
$allowed_tags_student['strong']['xml:lang'] = [];
|
||||
|
||||
// style
|
||||
$allowed_tags_student_full_page['style'] = [];
|
||||
$allowed_tags_student_full_page['style']['dir'] = [];
|
||||
$allowed_tags_student_full_page['style']['lang'] = [];
|
||||
$allowed_tags_student_full_page['style']['media'] = [];
|
||||
$allowed_tags_student_full_page['style']['title'] = [];
|
||||
$allowed_tags_student_full_page['style']['type'] = [];
|
||||
$allowed_tags_student_full_page['style']['xml:lang'] = [];
|
||||
|
||||
// sub
|
||||
$allowed_tags_student['sub'] = [];
|
||||
$allowed_tags_student['sub']['class'] = [];
|
||||
$allowed_tags_student['sub']['dir'] = [];
|
||||
$allowed_tags_student['sub']['id'] = [];
|
||||
$allowed_tags_student['sub']['lang'] = [];
|
||||
$allowed_tags_student['sub']['style'] = [];
|
||||
$allowed_tags_student['sub']['title'] = [];
|
||||
$allowed_tags_student['sub']['xml:lang'] = [];
|
||||
|
||||
// sup
|
||||
$allowed_tags_student['sup'] = [];
|
||||
$allowed_tags_student['sup']['class'] = [];
|
||||
$allowed_tags_student['sup']['dir'] = [];
|
||||
$allowed_tags_student['sup']['id'] = [];
|
||||
$allowed_tags_student['sup']['lang'] = [];
|
||||
$allowed_tags_student['sup']['style'] = [];
|
||||
$allowed_tags_student['sup']['title'] = [];
|
||||
$allowed_tags_student['sup']['xml:lang'] = [];
|
||||
|
||||
// table
|
||||
$allowed_tags_student['table'] = [];
|
||||
$allowed_tags_student['table']['align'] = [];
|
||||
$allowed_tags_student['table']['bgcolor'] = [];
|
||||
$allowed_tags_student['table']['border'] = [];
|
||||
$allowed_tags_student['table']['cellpadding'] = [];
|
||||
$allowed_tags_student['table']['cellspacing'] = [];
|
||||
$allowed_tags_student['table']['class'] = [];
|
||||
$allowed_tags_student['table']['dir'] = [];
|
||||
$allowed_tags_student['table']['frame'] = [];
|
||||
$allowed_tags_student['table']['id'] = [];
|
||||
$allowed_tags_student['table']['lang'] = [];
|
||||
$allowed_tags_student['table']['rules'] = [];
|
||||
$allowed_tags_student['table']['style'] = [];
|
||||
$allowed_tags_student['table']['summary'] = [];
|
||||
$allowed_tags_student['table']['title'] = [];
|
||||
$allowed_tags_student['table']['width'] = [];
|
||||
$allowed_tags_student['table']['xml:lang'] = [];
|
||||
|
||||
// tbody
|
||||
$allowed_tags_student['tbody'] = [];
|
||||
$allowed_tags_student['tbody']['align'] = [];
|
||||
//$allowed_tags_student['tbody']['char'] = array();
|
||||
//$allowed_tags_student['tbody']['charoff'] = array();
|
||||
$allowed_tags_student['tbody']['class'] = [];
|
||||
$allowed_tags_student['tbody']['dir'] = [];
|
||||
$allowed_tags_student['tbody']['id'] = [];
|
||||
$allowed_tags_student['tbody']['lang'] = [];
|
||||
$allowed_tags_student['tbody']['style'] = [];
|
||||
$allowed_tags_student['tbody']['title'] = [];
|
||||
$allowed_tags_student['tbody']['valign'] = [];
|
||||
$allowed_tags_student['tbody']['xml:lang'] = [];
|
||||
|
||||
// td
|
||||
$allowed_tags_student['td'] = [];
|
||||
$allowed_tags_student['td']['abbr'] = [];
|
||||
$allowed_tags_student['td']['align'] = [];
|
||||
//$allowed_tags_student['td']['axis'] = array();
|
||||
$allowed_tags_student['td']['bgcolor'] = [];
|
||||
//$allowed_tags_student['td']['char'] = array();
|
||||
//$allowed_tags_student['td']['charoff'] = array();
|
||||
$allowed_tags_student['td']['class'] = [];
|
||||
$allowed_tags_student['td']['colspan'] = [];
|
||||
$allowed_tags_student['td']['dir'] = [];
|
||||
//$allowed_tags_student['td']['headers'] = array();
|
||||
$allowed_tags_student['td']['height'] = [];
|
||||
$allowed_tags_student['td']['id'] = [];
|
||||
$allowed_tags_student['td']['lang'] = [];
|
||||
$allowed_tags_student['td']['nowrap'] = [];
|
||||
$allowed_tags_student['td']['rowspan'] = [];
|
||||
//$allowed_tags_student['td']['scope'] = array();
|
||||
$allowed_tags_student['td']['style'] = [];
|
||||
$allowed_tags_student['td']['title'] = [];
|
||||
$allowed_tags_student['td']['valign'] = [];
|
||||
$allowed_tags_student['td']['width'] = [];
|
||||
$allowed_tags_student['td']['xml:lang'] = [];
|
||||
|
||||
// tfoot
|
||||
$allowed_tags_student['tfoot'] = [];
|
||||
$allowed_tags_student['tfoot']['align'] = [];
|
||||
//$allowed_tags_student['tfoot']['char'] = array();
|
||||
//$allowed_tags_student['tfoot']['charoff'] = array();
|
||||
$allowed_tags_student['tfoot']['class'] = [];
|
||||
$allowed_tags_student['tfoot']['dir'] = [];
|
||||
$allowed_tags_student['tfoot']['id'] = [];
|
||||
$allowed_tags_student['tfoot']['lang'] = [];
|
||||
$allowed_tags_student['tfoot']['style'] = [];
|
||||
$allowed_tags_student['tfoot']['title'] = [];
|
||||
$allowed_tags_student['tfoot']['valign'] = [];
|
||||
$allowed_tags_student['tfoot']['xml:lang'] = [];
|
||||
|
||||
// th
|
||||
$allowed_tags_student['th'] = [];
|
||||
$allowed_tags_student['th']['abbr'] = [];
|
||||
$allowed_tags_student['th']['align'] = [];
|
||||
//$allowed_tags_student['th']['axis'] = array();
|
||||
$allowed_tags_student['th']['bgcolor'] = [];
|
||||
//$allowed_tags_student['th']['char'] = array();
|
||||
//$allowed_tags_student['th']['charoff'] = array();
|
||||
$allowed_tags_student['th']['class'] = [];
|
||||
$allowed_tags_student['th']['colspan'] = [];
|
||||
$allowed_tags_student['th']['dir'] = [];
|
||||
//$allowed_tags_student['th']['headers'] = array();
|
||||
$allowed_tags_student['th']['height'] = [];
|
||||
$allowed_tags_student['th']['id'] = [];
|
||||
$allowed_tags_student['th']['lang'] = [];
|
||||
$allowed_tags_student['th']['nowrap'] = [];
|
||||
$allowed_tags_student['th']['rowspan'] = [];
|
||||
//$allowed_tags_student['th']['scope'] = array();
|
||||
$allowed_tags_student['th']['style'] = [];
|
||||
$allowed_tags_student['th']['title'] = [];
|
||||
$allowed_tags_student['th']['valign'] = [];
|
||||
$allowed_tags_student['th']['width'] = [];
|
||||
$allowed_tags_student['th']['xml:lang'] = [];
|
||||
|
||||
// thead
|
||||
$allowed_tags_student['thead'] = [];
|
||||
$allowed_tags_student['thead']['align'] = [];
|
||||
$allowed_tags_student['thead']['class'] = [];
|
||||
//$allowed_tags_student['thead']['char'] = array();
|
||||
//$allowed_tags_student['thead']['charoff'] = array();
|
||||
$allowed_tags_student['thead']['dir'] = [];
|
||||
$allowed_tags_student['thead']['id'] = [];
|
||||
$allowed_tags_student['thead']['lang'] = [];
|
||||
$allowed_tags_student['thead']['style'] = [];
|
||||
$allowed_tags_student['thead']['title'] = [];
|
||||
$allowed_tags_student['thead']['valign'] = [];
|
||||
$allowed_tags_student['thead']['xml:lang'] = [];
|
||||
|
||||
// title
|
||||
$allowed_tags_student_full_page['title'] = [];
|
||||
$allowed_tags_student_full_page['title']['dir'] = [];
|
||||
$allowed_tags_student_full_page['title']['lang'] = [];
|
||||
$allowed_tags_student_full_page['title']['xml:lang'] = [];
|
||||
|
||||
// tr
|
||||
$allowed_tags_student['tr'] = [];
|
||||
$allowed_tags_student['tr']['align'] = [];
|
||||
$allowed_tags_student['tr']['bgcolor'] = [];
|
||||
//$allowed_tags_student['tr']['char'] = array();
|
||||
//$allowed_tags_student['tr']['charoff'] = array();
|
||||
$allowed_tags_student['tr']['class'] = [];
|
||||
$allowed_tags_student['tr']['dir'] = [];
|
||||
$allowed_tags_student['tr']['id'] = [];
|
||||
$allowed_tags_student['tr']['lang'] = [];
|
||||
$allowed_tags_student['tr']['style'] = [];
|
||||
$allowed_tags_student['tr']['title'] = [];
|
||||
$allowed_tags_student['tr']['valign'] = [];
|
||||
$allowed_tags_student['tr']['xml:lang'] = [];
|
||||
|
||||
// tt
|
||||
$allowed_tags_student['tt'] = [];
|
||||
$allowed_tags_student['tt']['class'] = [];
|
||||
$allowed_tags_student['tt']['dir'] = [];
|
||||
$allowed_tags_student['tt']['id'] = [];
|
||||
$allowed_tags_student['tt']['lang'] = [];
|
||||
$allowed_tags_student['tt']['style'] = [];
|
||||
$allowed_tags_student['tt']['title'] = [];
|
||||
$allowed_tags_student['tt']['xml:lang'] = [];
|
||||
|
||||
// u
|
||||
$allowed_tags_student['u'] = [];
|
||||
$allowed_tags_student['u']['class'] = [];
|
||||
$allowed_tags_student['u']['dir'] = [];
|
||||
$allowed_tags_student['u']['id'] = [];
|
||||
$allowed_tags_student['u']['lang'] = [];
|
||||
$allowed_tags_student['u']['style'] = [];
|
||||
$allowed_tags_student['u']['title'] = [];
|
||||
|
||||
// ul
|
||||
$allowed_tags_student['ul'] = [];
|
||||
$allowed_tags_student['ul']['class'] = [];
|
||||
$allowed_tags_student['ul']['compact'] = [];
|
||||
$allowed_tags_student['ul']['dir'] = [];
|
||||
$allowed_tags_student['ul']['id'] = [];
|
||||
$allowed_tags_student['ul']['lang'] = [];
|
||||
$allowed_tags_student['ul']['style'] = [];
|
||||
$allowed_tags_student['ul']['title'] = [];
|
||||
$allowed_tags_student['ul']['type'] = [];
|
||||
$allowed_tags_student['ul']['xml:lang'] = [];
|
||||
|
||||
// var
|
||||
$allowed_tags_student['var'] = [];
|
||||
$allowed_tags_student['var']['class'] = [];
|
||||
$allowed_tags_student['var']['dir'] = [];
|
||||
$allowed_tags_student['var']['id'] = [];
|
||||
$allowed_tags_student['var']['lang'] = [];
|
||||
$allowed_tags_student['var']['style'] = [];
|
||||
$allowed_tags_student['var']['title'] = [];
|
||||
$allowed_tags_student['var']['xml:lang'] = [];
|
||||
|
||||
// ALLOWED HTML FOR TEACHERS
|
||||
|
||||
// Allow all HTML allowed for students
|
||||
$allowed_tags_teacher = $allowed_tags_student;
|
||||
|
||||
// noscript
|
||||
//$allowed_tags_teacher['noscript'] = array();
|
||||
|
||||
// script
|
||||
//$allowed_tags_teacher['script'] = array();
|
||||
//$allowed_tags_teacher['script']['type'] = array();
|
||||
|
||||
// TODO:
|
||||
// 1. The tags <html>, <head>, <body> should not be allowed for document fragments.
|
||||
// 2. To be checked whether HTMLPurifier "silently" passes these tags.
|
||||
|
||||
/*$allowed_tags_teacher['html'] = array();
|
||||
$allowed_tags_teacher['html']['xmlns'] = array();
|
||||
|
||||
$allowed_tags_teacher['head'] = array();
|
||||
$allowed_tags_teacher['head']['profile'] = array();*/
|
||||
|
||||
// body
|
||||
/*
|
||||
$allowed_tags_teacher['body'] = array();
|
||||
$allowed_tags_teacher['body']['alink'] = array();
|
||||
$allowed_tags_teacher['body']['background'] = array();
|
||||
$allowed_tags_teacher['body']['bgcolor'] = array();
|
||||
$allowed_tags_teacher['body']['link'] = array();
|
||||
$allowed_tags_teacher['body']['text'] = array();
|
||||
$allowed_tags_teacher['body']['vlink'] = array();*/
|
||||
|
||||
$allowed_tags_teacher_full_page = $allowed_tags_student_full_page;
|
||||
|
||||
// ALLOWED HTML FOR ANONYMOUS USERS
|
||||
|
||||
$allowed_tags_anonymous = $allowed_tags_student;
|
||||
$allowed_tags_anonymous_full_page = $allowed_tags_student_full_page;
|
||||
// Add restrictions here.
|
||||
unset($allowed_tags_anonymous['embed']);
|
||||
unset($allowed_tags_anonymous['object']);
|
||||
unset($allowed_tags_anonymous['param']);
|
||||
|
||||
// HTMLPURIFIER-COMPATIBLE SETTINGS
|
||||
|
||||
function convert_kses_to_htmlpurifier($allowed_tags)
|
||||
{
|
||||
$allowed_html = [];
|
||||
foreach ($allowed_tags as $key1 => &$value1) {
|
||||
$result[0][] = $key1;
|
||||
if (count($value1) > 0) {
|
||||
$attr = [];
|
||||
foreach ($value1 as $key2 => &$value2) {
|
||||
$attr[] = $key2;
|
||||
}
|
||||
$allowed_html[] = $key1.'['.implode('|', $attr).']';
|
||||
} else {
|
||||
$allowed_html[] = $key1;
|
||||
}
|
||||
}
|
||||
|
||||
return implode(",\n", $allowed_html);
|
||||
}
|
||||
|
||||
global $allowed_html_student, $allowed_html_teacher, $allowed_html_anonymous;
|
||||
|
||||
// TODO: Support for full-page tags is needed for HTMLPurifier.
|
||||
//$allowed_html_student = convert_kses_to_htmlpurifier(array_merge($allowed_tags_student, $allowed_tags_student_full_page));
|
||||
//$allowed_html_teacher = convert_kses_to_htmlpurifier(array_merge($allowed_tags_teacher, $allowed_tags_teacher_full_page));
|
||||
//$allowed_html_anonymous = convert_kses_to_htmlpurifier(array_merge($allowed_tags_anonymous, $allowed_tags_anonymous_full_page));
|
||||
$allowed_html_student = convert_kses_to_htmlpurifier(array_merge($allowed_tags_student));
|
||||
$allowed_html_teacher = convert_kses_to_htmlpurifier(array_merge($allowed_tags_teacher));
|
||||
$allowed_html_anonymous = convert_kses_to_htmlpurifier(array_merge($allowed_tags_anonymous));
|
||||
6
main/inc/lib/formvalidator/Rule/index.html
Normal file
6
main/inc/lib/formvalidator/Rule/index.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
6
main/inc/lib/formvalidator/index.html
Normal file
6
main/inc/lib/formvalidator/index.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user