635
635
* @param array $values list of values to suggest
636
636
* @param int $minLength autocompletion starts after this number of caracters entered (default 1; 0 means immediate start)
637
* @param boolean $multiValue allow multiple autocompletion values in the same fields
637
* @param boolean $multiValue allow multiple autocompletion values in the same fields (default: false)
638
638
* @param String $multiSeparator separator expression if multiple autocompletion values are allowed (default ",\s*")
639
639
* @param String $multiSeparator separator for two values (default ", ")
641
641
public function enableAutocompletion($values, $minLength = 1, $multiValue = false, $multiSeparatorExp = ',\s*', $multiSeparator = ', ') {
642
642
for ($i = 0; $i < sizeof($values); $i++) {
643
$values[$i] = '"' . htmlspecialchars($values[$i]) . '"';
643
$values[$i] = '"' . htmlspecialchars(str_replace(array('"', "\r", "\n"), array('', '', ''), $values[$i])) . '"';
645
645
$this->autocomplete = true;
646
646
$this->autocompleteValues = $values;
2840
* Sets all given elements to the same height.
2844
class htmlEqualHeight extends htmlElement {
2846
/** list of element IDs */
2847
private $elements = array();
2852
* @param array $elements list of element IDs
2854
function __construct($elements) {
2855
foreach ($elements as $element) {
2856
$this->elements[] = htmlspecialchars($element);
2861
* Prints the HTML code for this element.
2863
* @param string $module Name of account module
2864
* @param array $input List of meta-HTML elements
2865
* @param array $values List of values which override the defaults in $input (name => value)
2866
* @param boolean $restricted If true then no buttons will be displayed
2867
* @param integer $tabindex Start value of tabulator index for input fields
2868
* @param string $scope Account type
2869
* @return array List of input field names and their type (name => type)
2871
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
2872
if (sizeof($this->elements) == 0) {
2876
$listContent = "'#" . $this->elements[0] . "'";
2877
for ($i = 1; $i < sizeof($this->elements); $i++) {
2878
$listContent .= ", '#" . $this->elements[$i] . "'";
2880
echo '<script type="text/javascript">';
2881
echo ' jQuery(document).ready(function() {';
2882
echo ' var equalHeightElements = new Array(' . $listContent . ');';
2883
echo ' equalHeight(equalHeightElements);';
2840
2892
* Creates a list of elements that can be sorted by the user via drag'n'drop.
2842
2894
* @package metaHTML
2977
* Creates a list of content elements in accordion style.
2978
* HTML special characters must be escaped before providing to htmlAccordion.
2980
class htmlAccordion extends htmlElement {
2983
private $elements = null;
2984
private $openInitial = '1';
2985
private $collapsible = false;
2990
* @param String $id HTML ID
2991
* @param array $elements list of content elements array('title' => htmlElement)
2992
* @param String $openInitial index of element that is initially opened (default: 0), set to 'false' to close all
2993
* @param boolean $collapsible specifies if all elements may be closed at the same time (default: false, true if $openInitial is false)
2995
function __construct($id, $elements, $openInitial = '0', $collapsible = false) {
2997
$this->elements = $elements;
2998
$this->openInitial = $openInitial;
2999
if (($openInitial === 'false') || ($openInitial === false)) {
3000
$this->collapsible = true;
3003
$this->collapsible = $collapsible;
3008
* Prints the HTML code for this element.
3010
* @param string $module Name of account module
3011
* @param array $input List of meta-HTML elements
3012
* @param array $values List of values which override the defaults in $input (name => value)
3013
* @param boolean $restricted If true then no buttons will be displayed
3014
* @param integer $tabindex Start value of tabulator index for input fields
3015
* @param string $scope Account type
3016
* @return array List of input field names and their type (name => type)
3018
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
3020
$collapsible = 'false';
3021
if ($this->collapsible) {
3022
$collapsible = 'true';
3025
if ($this->openInitial !== false) {
3026
$active = $this->openInitial;
3028
echo '<div id="' . $this->id . '">';
3029
foreach ($this->elements as $label => $content) {
3030
echo '<h3>' . $label . '</h3>';
3032
$result = array_merge($result, $content->generateHTML($module, $input, $values, $restricted, $tabindex, $scope));
3036
$script = 'jQuery(function() {
3037
$( "#' . $this->id . '" ).accordion({
3038
collapsible: ' . $collapsible . ',
3039
active: ' . $active . '
3042
$js = new htmlJavaScript($script);
3043
$js->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);