18 require_once SQ_INCLUDE_PATH.
'/asset_attribute.inc';
54 if (!isset($this->_params[
'allow_empty'])) {
55 $this->_params[
'allow_empty'] =
true;
59 $this->_edit_params[
'true_text'] = translate(
'true');
60 $this->_edit_params[
'false_text'] = translate(
'false');
61 $this->_edit_params[
'empty_text'] =
'';
76 if (!parent::setEditParams($node))
return false;
77 if (isset($node->attributes()->true_text)) {
78 $this->_edit_params[
'true_text'] = translate((
string)$node->attributes()->true_text);
80 if (isset($node->attributes()->false_text)) {
81 $this->_edit_params[
'false_text'] = translate((
string)$node->attributes()->false_text);
83 if (isset($node->attributes()->empty_text)) {
84 $this->_edit_params[
'empty_text'] = translate((
string)$node->attributes()->empty_text);
101 echo
'<b>Boolean Attribute " '.ucwords(str_replace(
'_',
' ', $this->name)).
' " ('.$this->name.
')</b><br />';
103 <table
class=
"sq-backend-table">
105 <td
class=
"sq-backend-section-heading" style=
"width: 100px;"><?php echo translate(
'true_text'); ?></td>
106 <td
class=
"sq-backend-table-cell">
109 text_box($prefix.
'_true', $this->_edit_params[
'true_text']);
111 echo $this->_edit_params[
'true_text'];
117 <td
class=
"sq-backend-section-heading" style=
"width: 100px;"><?php echo translate(
'false_text'); ?></td>
118 <td
class=
"sq-backend-table-cell">
121 text_box($prefix.
'_false', $this->_edit_params[
'false_text']);
123 echo $this->_edit_params[
'false_text'];
129 if ($this->_params[
'allow_empty']) {
132 <td
class=
"sq-backend-section-heading" style=
"width: 100px;"><?php echo translate(
'empty_text'); ?></td>
133 <td
class=
"sq-backend-table-cell">
136 text_box($prefix.
'_empty', $this->_edit_params[
'empty_text']);
138 echo $this->_edit_params[
'empty_text'];
162 if (!empty($_POST[$prefix.
'_true'])) {
163 $this->_edit_params[
'true_text'] = $_POST[$prefix.
'_true'];
166 if (!empty($_POST[$prefix.
'_false'])) {
167 $this->_edit_params[
'false_text'] = $_POST[$prefix.
'_false'];
170 if (!empty($_POST[$prefix.
'_empty'])) {
171 $this->_edit_params[
'empty_text'] = $_POST[$prefix.
'_empty'];
175 $values[
'true_text'] = $this->_edit_params[
'true_text'];
176 $values[
'false_text'] = $this->_edit_params[
'false_text'];
177 $values[
'empty_text'] = $this->_edit_params[
'empty_text'];
193 function paint($prefix, $read_only=
false)
195 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
198 if ($this->_params[
'allow_empty']) {
199 if (empty($this->_edit_params[
'empty_text'])) {
200 $this->_edit_params[
'empty_text'] =
'-- Leave Empty --';
202 $options[
''] = $this->_edit_params[
'empty_text'];
205 $options[
'1'] = $this->_edit_params[
'true_text'];
206 $options[
'0'] = $this->_edit_params[
'false_text'];
209 echo $options[(string)$this->value];
213 combo_box($prefix, $options,
false, $this->value);
227 if (!isset($_REQUEST[$prefix]))
return false;
228 $value = $_REQUEST[$prefix];
229 if ($this->value !== $value && $this->
setValue($value)) {
230 $this->processed =
true;
232 $this->processed =
false;
248 if (array_get_index($this->_params,
'allow_empty',
false) && is_string($value) && $value ==
'') {
252 $new_value = (int) $value;
253 if ((
string) $new_value != (string) $value) {
255 switch (strtolower((
string) $value)) {
271 $value = (empty($new_value)) ? 0 : 1;
285 if ($this->value == 0) {
287 }
else if ($this->value == 1) {