18 require_once SQ_INCLUDE_PATH.
'/asset_attribute.inc';
60 $this->_edit_params[
'biggest_units'] = 86400;
61 $this->_edit_params[
'smallest_units'] = 60;
77 if (!parent::setEditParams($node))
return FALSE;
78 $biggest = $this->units[(string)$node->attributes()->biggest_units];
79 $smallest = $this->units[(string)$node->attributes()->smallest_units];
80 $this->_edit_params[
'biggest_units'] = max($biggest, $smallest);
81 $this->_edit_params[
'smallest_units'] = min($biggest, $smallest);
95 $unit_values = Array();
96 $biggest_units = array_get_index($this->_edit_params,
'biggest_units', $this->units[
'days']);
97 $smallest_units = array_get_index($this->_edit_params,
'smallest_units', $this->units[
'minutes']);
98 $remaining_value = $this->value;
99 foreach ($this->units as $current_name => $current_units) {
100 if ($current_units >= $smallest_units && $current_units <= $biggest_units) {
101 $current_value = (int) ($remaining_value / $current_units);
102 $unit_values[$current_name] = $current_value;
103 $remaining_value -= $current_value * $current_units;
120 function paint($prefix, $read_only=FALSE)
122 $biggest_units = array_get_index($this->_edit_params,
'biggest_units', $this->units[
'days']);
123 $smallest_units = array_get_index($this->_edit_params,
'smallest_units', $this->units[
'minutes']);
129 foreach ($all_values as $unit_name => $value) {
130 if ($set) $smallest_units = $this->units[$unit_name];
131 if ($this->units[$unit_name] == $smallest_units) {
140 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
141 $remaining_value = $this->value;
143 $printed_any = FALSE;
144 foreach ($this->units as $current_name => $current_units) {
145 if ($current_units >= $smallest_units && $current_units <= $biggest_units) {
146 $current_value = (int) ($remaining_value / $current_units);
147 $remaining_value -= $current_value * $current_units;
150 if ($smallest_units != $biggest_units) {
152 if ($current_units == $smallest_units) {
154 }
else if ($current_units != $biggest_units) {
158 if ($current_value != 0) {
159 if ($current_units == $smallest_units && $printed_any) {
161 }
else if ($current_units != $biggest_units && $printed_any) {
168 if ($current_value != 0) {
169 if ($current_value == 1) {
171 $current_name = substr($current_name, 0, -1);
173 echo
' '.$current_value.
' '.$current_name;
177 text_box($prefix.
'_'.$current_name, $current_value, 2, 0, FALSE,
' onkeypress="return checkDurationValue(this, event)" onblur="updateDurationValues(this)" style="width:4ex"');
178 echo
'<label for="'.$prefix.
'_'.$current_name.
'"> '.$current_name.
'</label>';
197 $biggest_units = array_get_index($this->_edit_params,
'biggest_units', $this->units[
'days']);
198 $smallest_units = array_get_index($this->_edit_params,
'smallest_units', $this->units[
'minutes']);
200 if (!isset($_REQUEST[$prefix.
'_'.array_search($biggest_units, $this->units)])) {
205 foreach ($this->units as $name => $number) {
206 $res += array_get_index($_REQUEST, $prefix.
'_'.$name, 0) * $number;
210 if ($this->value != $value && $this->
setValue($value)) {
211 $this->processed = TRUE;
213 $this->processed = FALSE;
229 $value = trim($value);
232 if ($value < 0) $value = $this->_default_value;
234 $new_value = (int)$value;
240 if ((
string)$new_value != $value)
return FALSE;
256 foreach ($value_array as $unit => $unit_value) {
257 $value_xml .=
'<'.$unit.
'><![CDATA['.$unit_value.
']]></'.$unit.
'>';
259 $xml =
'<value>'.$value_xml.
'</value>';