18 require_once SQ_INCLUDE_PATH.
'/asset_attribute.inc';
20 define(
'SQ_OPTION_LIST_DELIMITER_UNIX',
"\n");
21 define(
'SQ_OPTION_LIST_DELIMITER_WINDOWS',
"\r\n");
22 define(
'SQ_OPTION_LIST_DELIMITER_MAC',
"\n");
48 var $delimiter = SQ_OPTION_LIST_DELIMITER_WINDOWS;
62 if (!is_array($delimiter)) {
63 $this->delimiter = $delimiter;
67 $this->_edit_params[
'width'] =
'';
82 if (!parent::setEditParams($node))
return FALSE;
83 if (isset($node->attributes()->allow_reorder)) {
84 if (strtolower($node->attributes()->allow_reorder) ==
'no') {
85 $this->_edit_params[
'allow_reorder'] = FALSE;
87 $this->_edit_params[
'allow_reorder'] = TRUE;
105 function paint($prefix, $read_only=FALSE, $use_delimiter=TRUE)
107 $allow_reorder = array_get_index($this->_edit_params,
'allow_reorder', TRUE);
109 $prefix = str_replace(
':',
'_',$prefix);
110 if (!$use_delimiter) {
111 $value = @unserialize($this->value);
113 $value = explode($this->delimiter, $this->value);
115 if (!is_array($value) && empty($value)) {
117 $value = Array(
'0'=>
'');
122 <div
id=
"option-list-<?php echo $prefix; ?>">
127 $temp_value = $value;
129 $last_number = key($temp_value);
133 }
else if ($last_number >= 0) {
134 $next_number = $last_number + 1;
137 foreach ($value as $k => $v) {
138 $v = htmlspecialchars($v);
140 <input
type=
"text" name=
"<?php echo $prefix; ?>_options[]" value=
"<?php echo $v; ?>" id=
"<?php echo $prefix; ?>_options[<?php echo $order; ?>]" <?php echo ($this->_edit_params[
'width'] ?
'size="'.$this->_edit_params[
'width'].
'"' :
''); ?> /><button type=
"button" tabindex=
"99999" class=
"delete-button"> </button>
142 if ($allow_reorder) {
152 for ($i = $next_number; $i < ($next_number + 2); $i++) {
154 <input
type=
"text" name=
"<?php echo $prefix; ?>_options[]" id=
"<?php echo $prefix; ?>_options[<?php echo $order; ?>]" <?php echo ($this->_edit_params[
'width'] ?
'size="'.$this->_edit_params[
'width'].
'"' :
''); ?> /><button type=
"button" tabindex=
"99999" class=
"delete-button"> </button>
156 if ($allow_reorder) {
158 if ($i < ($next_number + 1)) {
169 <script
type=
"text/javascript" src=
"<?php echo sq_web_path('lib'); ?>/js/edit.js"></script>
170 <script type=
"text/javascript">
175 if (!SQ_IN_BACKEND && !SQ_IN_LIMBO) {
177 buttons = document.getElementsByTagName(
'BUTTON');
178 for (i = 0; i < buttons.length; i++) {
179 if (buttons[i].className ==
'delete-button') {
180 with (buttons[i].style) {
181 backgroundImage =
'url(<?php echo sq_web_path('lib
') ?>/web/images/icons/delete.png)';
182 backgroundPosition =
'50% 50%';
183 backgroundRepeat =
'no-repeat';
186 backgroundColor =
'transparent';
195 var optionItemPrefix =
'<?php echo $prefix; ?>';
197 var optionList = document.getElementById(
'option-list-<?php echo $prefix; ?>');
198 var inputs = optionList.getElementsByTagName(
'INPUT');
199 for (var j=0; j < inputs.length; j++) {
200 <?php
if ($allow_reorder) { ?>
201 inputs[j].onfocus = expandListFn;
203 inputs[j].onfocus = noreorderExpandListFn;
206 var buttons = optionList.getElementsByTagName(
'BUTTON');
207 for (var j=0; j < buttons.length; j++) {
208 <?php
if ($allow_reorder) { ?>
209 buttons[j].onclick = deleteRowFn;
211 buttons[j].onclick = noreorderDeleteRowFn;
215 lastOrder = <?php echo $order; ?>;
219 if (!empty($value)) {
220 echo
'<ul><li>'.implode(
'</li><li>', $value).
'</li></ul>';
222 echo translate(
'not_set');
241 <a href=
"#" style=
"cursor:pointer;" onclick=
"listMoveDown(this, document.getElementById('option-list-<?php echo $prefix; ?>'));return false;" tabindex=
"99999" name=
"movedown" id=
"<?php echo $prefix; ?>_options[<?php echo $order; ?>]"><script
type=
"text/javascript">sq_print_icon(
"<?php echo sq_web_path('lib').'/web/images/icons/down_arrow.png' ?>",
"16",
"16",
"Move Down");</script></a>
259 <a href=
"#" style=
"cursor:pointer;" onclick=
"listMoveUp(this, document.getElementById('option-list-<?php echo $prefix; ?>'));return false;" tabindex=
"99999" name=
"moveup" id=
"<?php echo $prefix; ?>_options[<?php echo $order; ?>]"><script
type=
"text/javascript">sq_print_icon(
"<?php echo sq_web_path('lib').'/web/images/icons/up_arrow.png' ?>",
"16",
"16",
"Move Up");</script></a>
274 function process($prefix, $use_delimiter=TRUE)
276 $prefix = str_replace(
':',
'_',$prefix);
277 if (!isset($_REQUEST[$prefix.
'_options']))
return;
278 $value = $_REQUEST[$prefix.
'_options'];
279 foreach ($value as $i => $v) {
280 if ($v ==
'') unset($value[$i]);
283 if (!$use_delimiter) {
284 $processed_value = serialize($value);
286 $processed_value = implode($this->delimiter,$value);
288 $this->processed = $this->
setValue($processed_value);
302 $option_array = explode($this->delimiter, $this->value);
304 foreach ($option_array as $option) {
305 $option_xml .=
'<option><![CDATA['.$option.
']]></option>';
307 $xml =
'<value>'.$option_xml.
'</value>';