2009-06-30 10:46:00 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-07-01 06:09:17 +00:00
|
|
|
* Classes and functions for the template engine.
|
2009-06-30 10:46:00 +00:00
|
|
|
*
|
2009-07-01 06:09:17 +00:00
|
|
|
* @author The phpLDAPadmin development team
|
|
|
|
* @package phpLDAPadmin
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2009-06-30 10:46:00 +00:00
|
|
|
* Represents an attribute whose values are in a predefined list
|
2009-07-01 06:09:17 +00:00
|
|
|
*
|
|
|
|
* @package phpLDAPadmin
|
|
|
|
* @subpackage Templates
|
2009-06-30 10:46:00 +00:00
|
|
|
*/
|
|
|
|
class SelectionAttribute extends Attribute {
|
2009-07-01 06:09:17 +00:00
|
|
|
protected $selection = array();
|
2009-06-30 10:46:00 +00:00
|
|
|
protected $multiple;
|
2009-07-01 06:09:17 +00:00
|
|
|
protected $default;
|
|
|
|
|
|
|
|
public function __construct($name,$values,$server_id,$source=null) {
|
|
|
|
# Call our parent constructor
|
|
|
|
parent::__construct($name,$values,$server_id,$source);
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
# Our values are set by parent(). If we do have values, and the source was XML, move them to our selection.
|
|
|
|
if ($this->source == 'XML' && $this->values) {
|
|
|
|
$this->selection = $this->values;
|
|
|
|
$this->values = array();
|
|
|
|
}
|
2009-06-30 10:46:00 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (isset($values['type']) && $values['type'] == 'multiselect')
|
|
|
|
$this->multiple = true;
|
|
|
|
else
|
|
|
|
$this->multiple = false;
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function addOption($value,$description) {
|
|
|
|
$this->selection[$value] = $description;
|
2009-06-30 10:46:00 +00:00
|
|
|
}
|
|
|
|
|
2011-05-01 01:39:54 +00:00
|
|
|
public function addValue($new_val,$i=-1) {
|
|
|
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
|
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
|
|
|
2012-09-05 10:02:14 +00:00
|
|
|
$this->addOption($new_val,$i);
|
2011-05-01 01:39:54 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
public function getOptionCount() {
|
|
|
|
return count($this->selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSelection() {
|
|
|
|
return $this->selection;
|
|
|
|
}
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
public function autoValue($value) {
|
|
|
|
$this->selection = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDefault() {
|
|
|
|
return $this->default;
|
|
|
|
}
|
|
|
|
|
2009-06-30 10:46:00 +00:00
|
|
|
public function isMultiple() {
|
|
|
|
return $this->multiple;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMultiple() {
|
|
|
|
$this->multiple = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|