146 lines
3.9 KiB
PHP
146 lines
3.9 KiB
PHP
<?php
|
|
/**
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; under version 2
|
|
* of the License (non-upgradable).
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
* Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
|
|
* 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
|
|
*
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Short description of class tao_helpers_form_elements_MultipleElement
|
|
*
|
|
* @abstract
|
|
* @access public
|
|
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
|
|
* @package tao
|
|
*/
|
|
abstract class tao_helpers_form_elements_MultipleElement extends tao_helpers_form_FormElement
|
|
{
|
|
/** @var array */
|
|
protected $options = [];
|
|
|
|
/** @var array */
|
|
protected $values = [];
|
|
|
|
/** @var array */
|
|
private $disabledValues = [];
|
|
|
|
/** @var array */
|
|
private $optionAttributes = [];
|
|
|
|
public function addOptionAttribute(string $optionValue, string $attribute, string $attributeValue): void
|
|
{
|
|
if (empty($this->optionAttributes[$optionValue])) {
|
|
$this->optionAttributes[$optionValue] = [];
|
|
}
|
|
|
|
$this->optionAttributes[$optionValue][$attribute] = $attributeValue;
|
|
}
|
|
|
|
public function getOptionAttributes(string $optionValue): array
|
|
{
|
|
return $this->optionAttributes[$optionValue] ?? [];
|
|
}
|
|
|
|
/**
|
|
* Short description of method setOptions
|
|
*
|
|
* @access public
|
|
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
|
|
* @param array options
|
|
* @return void
|
|
*/
|
|
public function setOptions(array $options): void
|
|
{
|
|
$this->options = $options;
|
|
}
|
|
|
|
/**
|
|
* Short description of method getOptions
|
|
*
|
|
* @access public
|
|
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
|
|
* @return array
|
|
*/
|
|
public function getOptions()
|
|
{
|
|
return (array)$this->options;
|
|
}
|
|
|
|
/**
|
|
* Short description of method setValue
|
|
*
|
|
* @access public
|
|
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
|
|
* @param string $value
|
|
* @return void
|
|
*/
|
|
public function setValue($value)
|
|
{
|
|
$this->value = tao_helpers_Uri::encode((string)$value);
|
|
}
|
|
|
|
/**
|
|
* Short description of method addValue
|
|
*
|
|
* @access public
|
|
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
|
|
* @param string $value
|
|
* @return void
|
|
*/
|
|
public function addValue(string $value): void
|
|
{
|
|
$this->values[] = tao_helpers_Uri::encode($value);
|
|
}
|
|
|
|
/**
|
|
* Short description of method getValues
|
|
*
|
|
* @access public
|
|
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
|
|
* @return array
|
|
*/
|
|
public function getValues(): array
|
|
{
|
|
return (array)$this->values;
|
|
}
|
|
|
|
/**
|
|
* Short description of method setValues
|
|
*
|
|
* @access public
|
|
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
|
|
* @param array values
|
|
* @return mixed
|
|
*/
|
|
public function setValues(array $values)
|
|
{
|
|
$this->values = $values;
|
|
}
|
|
|
|
public function getDisabledValues(): array
|
|
{
|
|
return $this->disabledValues;
|
|
}
|
|
|
|
public function setDisabledValues(array $disabledValues): void
|
|
{
|
|
$this->disabledValues = $disabledValues;
|
|
}
|
|
}
|