18 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
43 parent::__construct();
44 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
62 ?><a href=
"#" onClick=
"Javascript: var win = window.open('<?php echo sq_web_path('data')?>/asset_types/metadata_field/popups/keywords.php?assetid=<?php echo $asset->id; ?>&all=1', 'keywords', 'toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,width=580,height=520'); return false;">click here </a></b><?php
63 $replacements_link = ob_get_contents();
65 $o->
note(translate(
'metadata_keyword_replacements_usage', $replacements_link));
102 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
103 $is_default_context = ($contextid === 0) ? TRUE : FALSE;
104 $is_contextable = $asset->
attr(
'is_contextable');
105 $can_change_keys = ($is_contextable === FALSE) || ($is_default_context = TRUE);
107 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
111 if ($write_access_perm === TRUE) {
112 if ($can_change_keys === TRUE) {
113 if ($write_access === TRUE) {
114 text_box($prefix.
'_new_vc',
'', 30);
117 echo
'<i>'.translate(
'core_lock_asset_to_create_value_component').
'</i>';
121 echo
'<em>'.translate(
'core_cannot_create_value_component_in_alternate_context').
'</em>';
125 echo
'<i>'.translate(
'core_cannot_create_value_component').
'</i>';
131 $default_vc = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'value_components',
'metadata_field', Array($asset->id), 0);
132 $default_vc = unserialize($default_vc[$asset->id]);
134 if ($can_change_keys === FALSE) {
135 $current_vc = $asset->
attr(
'value_components');
137 $current_vc = $default_vc;
140 if (!empty($current_vc)) {
145 <table
class=
"sq-backend-table">
148 foreach ($default_vc as $vc_name => $default_vc_value) {
149 $vc_value = array_get_index($current_vc, $vc_name, $default_vc_value);
151 if ($num_done >= $num_per_row) {
156 echo
'<td width="150" valign="top" class="sq-backend-table-cell">';
157 if ($write_access === TRUE) {
158 if ($can_change_keys === FALSE) {
162 echo
'<b>'.$vc_name.
'</b>';
163 hidden_field($prefix.
'_vc_name['.$vc_name.
']', $vc_name);
165 text_box($prefix.
'_vc_name['.$vc_name.
']', $vc_name, 30);
168 echo
'<b>'.$vc_name.
'</b>';
172 text_area($prefix.
'_vc_value['.$vc_name.
']', $vc_value, 30, 4);
177 if ($can_change_keys === TRUE) {
179 check_box($prefix.
'_vc_delete['.$vc_name.
']');
180 label(translate(
'delete_question'), $prefix.
'_vc_delete['.$vc_name.
']');
187 if ($num_done && $num_done != $num_per_row) {
188 for ($i = ($num_per_row - $num_done); $i > 0; $i--) {
189 echo
'<td width="200" class="sq-backend-table-cell"> </td>';
216 if (!$asset->
writeAccess(
'attributes'))
return FALSE;
217 $is_contextable = (boolean)$asset->
attr(
'is_contextable');
218 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
220 if (($is_contextable === FALSE) && ($contextid !== 0)) {
221 $GLOBALS[
'SQ_SYSTEM']->changeContext(0);
222 $contexted_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($asset->id);
224 $contexted_asset = $asset;
227 $current_vc = $contexted_asset->
attr(
'value_components');
231 foreach ($current_vc as $vc_name => $vc_value) {
232 if (isset($_POST[$prefix.
'_vc_delete'][$vc_name]) && $_POST[$prefix.
'_vc_delete'][$vc_name]) {
233 unset($current_vc[$vc_name]);
238 if (isset($_POST[$prefix.
'_vc_name'][$vc_name])) {
239 $new_vc_name = trim($_POST[$prefix.
'_vc_name'][$vc_name]);
241 if (isset($_POST[$prefix.
'_vc_value'][$vc_name])) {
242 $new_vc_value = trim($_POST[$prefix.
'_vc_value'][$vc_name]);
244 if (empty($new_vc_name))
continue;
247 if ($vc_value != $new_vc_value) {
248 $current_vc[$vc_name] = $new_vc_value;
253 if ($vc_name != $new_vc_name) {
254 $current_vc[$new_vc_name] = $current_vc[$vc_name];
255 unset($current_vc[$vc_name]);
261 if (isset($_POST[$prefix.
'_new_vc']) && trim($_POST[$prefix.
'_new_vc']) !=
'') {
262 $new_vc = trim($_POST[$prefix.
'_new_vc']);
263 if (isset($current_vc[$new_vc])) {
264 trigger_localised_error(
'CORE0206', E_USER_WARNING, $contexted_asset->name);
265 }
else if (preg_match(
'/^[1-9][0-9]+$/', $new_vc)) {
268 trigger_localised_error(
'CORE0207', E_USER_WARNING);
270 $current_vc[$new_vc] =
'';
276 $contexted_asset->setAttrValue(
'value_components', $current_vc);
279 if (($is_contextable === FALSE) && ($contextid !== 0)) {
283 $contexted_asset->saveAttributes();
287 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($contexted_asset);
288 $GLOBALS[
'SQ_SYSTEM']->restoreContext();
313 $field_name = $asset->
attr(
'friendly_name');
314 if (!$field_name) $field_name = $asset->name;
316 if ($asset->
attr(
'required')) {
317 $field_name .=
' <span class="sq-backend-warning">*</span>';
318 if (!$complete && $write_access) {
319 $field_name .=
'<br /><span class="sq-backend-warning">'.translate(
'currently_empty').
'</span>';
325 $writable = $write_access && $asset->
attr(
'editable');
326 $res = $this->
paintValueInterface($asset, $o, $value_str, $writable, TRUE, $print_cascade_values_option, $type_code);
327 if (!$write_access && $asset->
attr(
'required') && !$complete) {
328 echo
'<b class="sq-backend-warning">['.strtoupper(translate(
'empty')).
']</b>';
392 if (!$asset->
attr(
'required'))
return TRUE;
394 if (is_null($value_str)) {
395 $value = $asset->
attr(
'default');
396 $value_components = $asset->
attr(
'value_components');
399 $value_components = $asset->
attr(
'value_components');
403 if (trim($value) !=
'')
return TRUE;
406 foreach ($value_components as $vc_name => $vc_value) {
407 if (trim($vc_value) !=
'')
return TRUE;
431 if (trim($asset->name) ===
'') {
435 require_once SQ_FUDGE_PATH.
'/general/text.inc';
436 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
438 $frontend_option = $asset->
attr(
'frontend');
441 if (is_null($value_str)) {
442 $value = $asset->
attr(
'default');
443 $value_components = $asset->
attr(
'value_components');
447 $value_components = $asset->
attr(
'value_components');
451 $keywords = array_merge($keywords, retrieve_keywords_replacements($value_str,
'.'));
455 foreach ($value_components as $vc_name => $vc_value) {
457 if ($vc_value !=
'') $empty_vc = FALSE;
461 if (($frontend_option ==
'fill') && $value ==
'' && $empty_vc) {
465 $tag_value = $value_str;
467 if ($frontend_option ==
'hide')
return TRUE;
469 echo
'<meta name="'.$mm->escapeMetadata($asset->name).
'"';
470 if (trim($asset->
attr(
'language')) !=
'') {
471 echo
' lang="'.$mm->escapeMetadata($asset->
attr(
'language')).
'"';
473 if (trim($asset->
attr(
'scheme')) !=
'') {
474 echo
' scheme="'.$mm->escapeMetadata($asset->
attr(
'scheme')).
'"';
477 echo
' content="<?php echo $mm->escapeMetadata($metadata_values[\''.$mm->escapeMetadata(addslashes($asset->name), TRUE).
'\']);
foreach ($metadata_value_components[\
''.$mm->escapeMetadata(addslashes($asset->name), TRUE).
'\'] as $k => $v) {echo \
'; \'.$k.\'=\'.$v; } ?>" />'.
"\n";
514 if (($asset->
attr(
'is_contextable') === FALSE) && ($GLOBALS[
'SQ_SYSTEM']->getContextId() !== 0)) {