17 require_once SQ_CORE_PACKAGE_PATH.
'/folder/folder_edit_fns.inc';
40 parent::__construct();
41 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
60 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_field', FALSE,
'major', NULL, TRUE);
61 if (!empty($current_links)) {
63 foreach ($current_links as $link) {
64 $assetids[$link[
'minorid']] =
'details';
66 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($assetids));
67 $asset_href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($assetids);
70 $o->
openField(translate(
'section_description'));
71 $description = $asset->
attr(
'description');
73 text_area($prefix.
'_description', $description, 30, 5);
80 $o->
openField(translate(
'current_restrict'));
81 $restrictions = $asset->
attr(
'restrict');
82 if (!empty($restrictions)) {
84 <table
class=
"sq-backend-table">
86 <td
class=
"sq-backend-table-header"><?php echo translate(
'asset_type'); ?></td>
90 <td align=
"center" class=
"sq-backend-table-header" width=
"70"><?php echo translate(
'remove'); ?></td>
96 foreach ($restrictions as $asset_type => $inheritance) {
99 <td
class=
"sq-backend-table-cell">
100 <?php echo ucfirst(str_replace(
'_',
' ', $asset_type)) ?>
105 <td align=
"center" class=
"sq-backend-table-cell">
106 <?php check_box($prefix.
'_remove_asset_type['.$asset_type.
']'); ?>
119 echo translate(
'no_restriction');
125 $o->
openField(translate(
'new_restriction'));
126 asset_type_chooser($prefix.
'_add_restriction', TRUE, Array(), NULL, FALSE, TRUE);
132 <table
class=
"sq-backend-table">
134 <td
class=
"sq-backend-table-header"><b><?php echo translate(
'field_name'); ?></b></td>
135 <td align=
"center" width=
"150" class=
"sq-backend-table-header"><b><?php echo translate(
'edit_fields'); ?></b></td>
138 ?><td align=
"center" width=
"70" class=
"sq-backend-table-header"><b><?php echo translate(
'delete_question'); ?></b></td><?php
143 foreach ($current_links as $link_data) {
144 $field = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link_data[
'minorid']);
145 if (is_null($field))
continue;
146 $edit_fns = $field->getEditFns();
149 <td align=
"left" class=
"sq-backend-table-cell"><?php echo get_asset_tag_line($field->id);?></td>
150 <td align=
"center" class=
"sq-backend-table-cell">[ <a href=
"<?php echo $asset_href[$field->id];?>"><?php echo translate(
'metadata_edit_fields'); ?></a> ]</td>
153 ?><td align=
"center" class=
"sq-backend-table-cell"><?php
154 check_box($prefix.
'_delete_fields['.$link_data[
'linkid'].
']')
164 $o->
openField(translate(
'new_field_name'));
166 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
167 text_box($prefix.
'_new_field',
'', 20);
171 $o->
openField(translate(
'new_field_type'));
174 $descendant_types = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants(
'metadata_field');
177 foreach ($descendant_types as $type) {
179 $te = explode(
'_', $type, 3);
180 $contents[$type] = ucwords(str_replace(
'_',
' ', $te[2]));
183 combo_box($prefix.
'_field_type', $contents, FALSE,
'metadata_field_text');
206 if (!$asset->
writeAccess(
'attributes'))
return FALSE;
211 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
212 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
215 if (isset($_POST[$prefix.
'_description'])) {
216 $section_description = trim($_POST[$prefix.
'_description']);
217 $asset->
setAttrValue(
'description', $section_description);
223 $current_restrictions = $asset->
attr(
'restrict');
224 $changes_made = FALSE;
225 if (isset($_POST[$prefix.
'_remove_asset_type'])) {
226 foreach($_POST[$prefix.
'_remove_asset_type'] as $remove_type => $ahfortheheckofit) {
227 if (array_key_exists($remove_type, $current_restrictions)) {
228 unset($current_restrictions[$remove_type]);
229 $changes_made = TRUE;
235 $asset->
setAttrValue(
'restrict', $current_restrictions);
241 $current_restrictions = $asset->
attr(
'restrict');
242 $changes_made = FALSE;
243 if (isset($_POST[$prefix.
'_add_restriction']) && (isset($_POST[$prefix.
'_add_restriction'][
'type_code']))) {
244 foreach($_POST[$prefix.
'_add_restriction'][
'type_code'] as $field => $type_code) {
245 if (!empty($type_code)) {
246 $inheritance = $_POST[$prefix.
'_add_restriction'][
'inherit'][$field];
247 if (!isset($current_restrictions[$type_code])) {
248 $current_restrictions[$type_code] = $inheritance;
249 $changes_made = TRUE;
250 }
else if ($current_restrictions[$type_code] !== $inheritance) {
251 $current_restrictions[$type_code] = $inheritance;
252 $changes_made = TRUE;
259 $asset->
setAttrValue(
'restrict', $current_restrictions);
265 if (isset($_POST[$prefix.
'_delete_fields'])) {
266 $delete_fields = $_POST[$prefix.
'_delete_fields'];
267 foreach ($delete_fields as $linkid => $on) {
268 if ($asset->
deleteLink($linkid)) $updated = TRUE;
273 if (isset($_POST[$prefix.
'_new_field']) && trim($_POST[$prefix.
'_new_field']) !=
'') {
274 $new_field_name = trim($_POST[$prefix.
'_new_field']);
275 $new_field_type = trim($_POST[$prefix.
'_field_type']);
277 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($new_field_type);
278 $new_field =
new $new_field_type();
280 $section_link = Array(
'asset' => &$asset,
'link_type' => SQ_LINK_TYPE_2,
'sort_order' => -1,
'is_dependant' => 1,
'is_exclusive' => 0);
281 $new_field->setAttrValue(
'name', $new_field_name);
282 if ($new_field->create($section_link)) $updated = TRUE;
285 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
286 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
311 $restrictions = $asset->
attr(
'restrict');
312 $flag_match_found = FALSE;
315 if (!empty($restrictions)) {
316 foreach ($restrictions as $type_code_restricted => $inherit_it) {
317 if ($inherit_it && !$flag_match_found) {
318 $asset_type_with_parents = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAncestors($type_code);
319 foreach($asset_type_with_parents as $index => $asset_type) {
320 if (($type_code_restricted == $type_code || $asset_type == $type_code_restricted)&& !$flag_match_found) {
321 $flag_match_found = TRUE;
324 }
else if (array_key_exists($type_code, $restrictions)){
325 $flag_match_found = TRUE;
330 if (empty($restrictions) || $flag_match_found ) {
333 if (isset($GLOBALS[
'painted_inline_value_interface'][$asset->id])) {
336 echo
'<span class="sq-backend-warning"><b>'.translate(
'metadata_use_editing_interface').
'</b></span>';
338 $write_access = FALSE;
341 $GLOBALS[
'painted_inline_value_interface'][$asset->id] = TRUE;
345 $section_description = $asset->
attr(
'description');
346 if (!empty($section_description)) {
347 $o->
openField(
'<i>'.translate(
'section_description').
'</i>');
348 echo
'<i>'.$section_description.
'</i>';
352 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_field', FALSE,
'major', NULL, TRUE);
353 foreach ($current_links as $link) {
354 $field = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
355 if (is_null($field))
continue;
356 $edit_fns = $field->getEditFns();
357 if ($edit_fns->paintInlineValueInterface($field, $o, (isset($values[$field->id])) ? $values[$field->id][0][
'value'] : NULL, $write_access, $print_cascade_values_option, $type_code)) {
383 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_field', FALSE,
'major', NULL, TRUE);
384 foreach ($current_links as $link) {
385 $field_cascade_value = FALSE;
386 $field = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
387 if (is_null($field) || !$field->attr(
'editable')) {
390 $edit_fns = $field->getEditFns();
392 if ($edit_fns->processInlineValueInterface($field, $new_value, $field_cascade_value, $type_code)) {
396 if (strpos($new_value,
'%asset_metadata_') !== FALSE) {
397 trigger_localised_error(
'SYS0344', E_USER_WARNING);
398 $new_value = preg_replace(
'/%asset_metadata_([^\s]*?)%/',
'%metadata_field_$1%', $new_value);
401 $new_values[$field->id] = Array (
403 'name' => $field->name,
404 'value' => $new_value,
407 if ($field_cascade_value) $section_cascade_value_asset_ids[$field->id] = 1;
430 $inherited_restriction = Array();
431 $restrictions = $asset->
attr(
'restrict');
433 foreach($restrictions as $restriction => $inheritance) {
434 $inherited_types = Array();
436 $inherited_types = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($restriction);
437 foreach($inherited_types as $inherited_type) {
438 if (!array_key_exists($inherited_type, $restrictions)) {
439 $inherited_restriction = array_merge($inherited_restriction, Array($inherited_type));
445 if(!empty($inherited_restriction)) {
446 $inherited_restriction = array_flip($inherited_restriction);
447 $restrictions = array_merge($restrictions, $inherited_restriction);
451 if (empty($restrictions) || (!is_null($type_code) && array_key_exists($type_code, $restrictions))) {
452 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_field', FALSE,
'major', NULL, TRUE);
453 foreach ($current_links as $link) {
454 $field = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
455 if (is_null($field))
continue;
456 $edit_fns = $field->getEditFns();
457 if (!$edit_fns->requiredFieldsComplete($field, (isset($values[$field->id])) ? $values[$field->id][0][
'value'] : NULL)) {
482 $frontend_option = $asset->
attr(
'frontend');
483 $flag_match_found = FALSE;
486 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
488 $restrictions = $asset->
attr(
'restrict');
489 if (!empty($restrictions)) {
490 foreach ($restrictions as $type_code_restricted => $inherit_it) {
491 if ($inherit_it && !$flag_match_found) {
492 $asset_type_with_parents = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAncestors($type_code);
493 foreach($asset_type_with_parents as $index => $asset_type) {
494 if (($type_code_restricted == $type_code || $asset_type == $type_code_restricted)&& !$flag_match_found) {
495 $flag_match_found = TRUE;
498 }
else if (array_key_exists($type_code, $restrictions)){
499 $flag_match_found = TRUE;
503 if (empty($restrictions) || $flag_match_found ) {
507 echo
'<!-- '.$mm->escapeMetadata($asset->name).
' //-->'.
"\n";
508 $section_description = $asset->
attr(
'description');
509 if ($asset->
attr(
'desc_frontend') == TRUE && !empty($section_description)) {
510 echo
'<!-- '.$mm->escapeMetadata($section_description).
' //-->'.
"\n";
513 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_field', FALSE,
'major', NULL, TRUE);
514 $valid_fields = Array();
515 foreach ($current_links as $link) {
516 $field = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
517 if (is_null($field))
continue;
518 $valid_fields[] = $field->name;
520 $edit_fns = $field->getEditFns();
521 $tag_values[$field->name] =
'';
524 if (!$edit_fns->generateMetadata($field, ((isset($values[$field->id])) ? $values[$field->id][0][
'value'] : NULL), $tag_values[$field->name], $keywords)) {
534 $contents = ob_get_clean();
535 if ($frontend_option) echo $contents;