18 require_once dirname(__FILE__).
'/../../metadata_field/metadata_field_edit_fns.inc';
41 parent::__construct();
65 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
68 $value_components = $asset->
attr(
'value_components');
72 if ($enable_default) {
73 $o->
addJsInclude(sq_web_path(
'data').
'/asset_types/metadata_field_multiple_text/js/metadata_field_multiple_text.js');
75 if (is_null($value_str)) {
86 $value = explode(
'; ', $value);
90 $attribute->value = implode($attribute->delimiter, $value);
94 if ($enable_default) {
95 echo
'<span id="'.$prefix.
'_field">';
97 $attribute->paint($prefix, FALSE);
98 if ($enable_default) echo
'</span>';
100 $attribute->paint($prefix, TRUE);
103 if ($enable_default) {
105 echo
' ';
109 $default_keys = explode(
'; ', $asset->
attr(
'default'));
110 $default_vals_expr =
'[\''.implode(
'\', \
'', $default_keys).
'\']
';
111 check_box($prefix.'_default
', '1
', $is_default, "handleDefaultClickMT(this, '$prefix
', $default_vals_expr); ");
112 label(translate('use_default
'), $prefix.'_default
');
115 <script type="text/javascript"><!--
116 setInputsEnabled(document.getElementById('<?php echo $prefix ?>_field
'), false);
122 echo ' <em style=
"color: #666">(
'.strtolower(translate('default')).')</em>
';
127 if ($write_access && $print_cascade_values_option) {
128 echo '
';
129 check_box($prefix.'_cascade_value
', '1
', FALSE);
130 label(translate('cascade_value
'), $prefix.'_cascade_value
');
133 return $write_access;
135 }//end paintValueInterface()
149 public function processInlineValueInterface(Metadata_Field_Multiple_Text $asset, &$new_value_str, &$field_cascade_value)
151 // nothing for us to do
152 if (!$asset->attr('editable
')) return FALSE;
156 $prefix = $asset->getPrefix();
157 if (!empty($_POST[$prefix.'_default
'])) {
159 $new_value_str = NULL;
163 $attribute = $asset->getOptionListAttribute();
164 $attribute->process($prefix);
165 if ($attribute->processed) {
166 // Get the string into proper form for the metadata field function
167 $value = str_replace($attribute->delimiter, ';
', $attribute->value);
168 $keyword = '%asset_metadata_
'.$asset->name.'%
';
169 $value = trim(str_replace($keyword, '', $value));
170 $new_value_str = Metadata_Field::encodeValueString(trim($value), Array());
172 if(!SQ_IN_BACKEND && !SQ_IN_LIMBO && !SQ_IN_LOGIN && !SQ_IN_CRON && !SQ_PHP_CLI) {
173 $filter_enabled = $GLOBALS['SQ_SYSTEM
']->getUserPrefs('user
', 'SQ_USER_FILTER_FRONT_END_INPUT
');
174 if(isset($GLOBALS['SQ_REVERT_TO_SYSTEM_VERSION
'] ) && $GLOBALS['SQ_REVERT_TO_SYSTEM_VERSION
']) {
175 $filter_enabled = FALSE;
176 } else if (isset($GLOBALS['SQ_CLONE_COMPONENTS
'] ) && $GLOBALS['SQ_CLONE_COMPONENTS
']) {
177 $filter_enabled = FALSE;
180 if ($filter_enabled && !empty($new_value_str)) {
181 $new_value_str = filter_content($new_value_str);
182 if ($new_value_str === FALSE){
183 trigger_localised_error('SYS0347
', E_USER_WARNING, $asset->name, $asset->type());
192 if (isset($_POST[$prefix.'_cascade_value
'])) {
193 $field_cascade_value = TRUE;
199 }//end processInlineValueInterface()
214 public function generateMetadata(Metadata_Field_Multiple_Text $asset, $value_str, &$tag_value, Array &$keywords)
216 if (is_null($value_str)) {
217 $value_str = $asset->attr('default');
220 return parent::generateMetadata($asset, $value_str, $tag_value, $keywords);
222 }//end generateMetadata()
235 public function paintDefault(Metadata_Field_Multiple_Text $asset, Backend_Outputter $o, $prefix)
237 $write_access = $asset->writeAccess('attributes
');
239 $attribute = $asset->getOptionListAttribute();
240 $attribute->paint($prefix, !$write_access);
242 return $write_access;
244 }//end paintDefault()
257 public function processDefault(Metadata_Field_Multiple_Text $asset, Backend_Outputter $o, $prefix)
259 if (!$asset->writeAccess('attributes
')) return FALSE;
261 $is_contextable = (boolean)$asset->attr('is_contextable
');
262 $contextid = $GLOBALS['SQ_SYSTEM
']->getContextId();
264 // change to default asset if we have to
265 if ($is_contextable === FALSE) {
266 if ($contextid !== 0) {
267 $GLOBALS['SQ_SYSTEM
']->changeContext(0);
268 $asset = $GLOBALS['SQ_SYSTEM
']->am->getAsset($asset->id);
272 $attribute = $asset->getOptionListAttribute();
273 $attribute->process($prefix);
275 if ($attribute->processed) {
276 $value = $attribute->value;
277 $value_array = explode($attribute->delimiter, $value);
278 $asset->setAttrValue('default', implode(';
', $value_array));
279 $asset->saveAttributes();
282 // restore previous assets
283 if ($is_contextable === FALSE) {
284 if ($contextid !== 0) {
285 $GLOBALS['SQ_SYSTEM
']->restoreContext();
286 $asset = $GLOBALS['SQ_SYSTEM
']->am->getAsset($asset->id);
290 // No need to save attributes in THIS context
293 }//end processDefault()