18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page_edit_fns.inc';
19 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
20 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
43 var $location_types = Array();
52 parent::__construct();
53 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
73 $types = $asset->attr(
'create_type');
75 echo
'<p class="sq-backend-warning">'.translate(
'cms_asset_builder_no_types_defined').
'</p>';
77 if ($asset->writeAccess(
'attributes')) {
78 asset_type_chooser($prefix.
'_create_types', TRUE, array_keys($types));
80 $type_infos = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypes(NULL, TRUE);
81 foreach ($types as $type => $value) {
82 echo $type_infos[$type][
'name'].
'<br />';
101 if (isset($_POST[$prefix.
'_create_types'])) {
103 foreach ($_POST[$prefix.
'_create_types'] as $type) {
104 if (!empty($type)) $types[$type] = 1;
106 $asset->setAttrValue(
'create_type', $types);
126 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
127 if (!$asset->writeAccess(
'attributes')) {
128 if ($asset->attr(
'create_status')) {
129 echo get_status_description($asset->attr(
'create_status'));
131 echo translate(
'cms_asset_builder_do_not_change_status');
134 $status_options = Array(
135 0 => translate(
'cms_asset_builder_do_not_change_status'),
136 SQ_STATUS_ARCHIVED => translate(
'archived'),
137 SQ_STATUS_UNDER_CONSTRUCTION => translate(
'under_construction'),
138 SQ_STATUS_LIVE => translate(
'live'),
140 combo_box($prefix.
'_create_status', $status_options, FALSE, $asset->attr(
'create_status'));
158 if (!isset($_POST[$prefix.
'_create_status'])) {
161 $create_status = (int)$_POST[$prefix.
'_create_status'];
162 return $asset->setAttrValue(
'create_status', $create_status);
179 return $this->
paintNoticeLinkedAsset($asset,
'schema_to_apply', Array(
'metadata_schema' =>
'D'), $prefix.
'schemas_to_apply', TRUE);
196 if ($asset->writeAccess(
'links')) {
216 $type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($asset->attr(
'create_type')),
'name');
217 $customised_types = $asset->attr(
'create_form_customisations');
218 $wa = $asset->writeAccess(
'attributes');
220 hidden_field($prefix.
'_customise_form_submitted', 1);
223 <table
class=
"sq-backend-table">
227 <th>Customise Create
Form?</th>
232 foreach ($type_names as $code => $name) {
235 <td><?php echo $type_names[$code]; ?></td>
239 echo check_box($prefix.
'_customise_form[]', $code, in_array($code, $customised_types));
241 $fn = in_array($code, $customised_types) ?
'tick' :
'cross';
242 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.$fn.
'.gif" />';
269 if ($asset->writeAccess(
'attributes') && isset($_POST[$prefix.
'_customise_form_submitted'])) {
270 $customised_types = array_get_index($_POST, $prefix.
'_customise_form', Array());
271 $customised_types = array_intersect($customised_types, array_keys($asset->attr(
'create_type')));
272 return $asset->setAttrValue(
'create_form_customisations', $customised_types);
294 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
296 $link_type_names = Array(
297 SQ_LINK_TYPE_1 =>
'',
298 SQ_LINK_TYPE_2 =>
'',
299 SQ_LINK_TYPE_3 =>
'',
300 SQ_LINK_NOTICE =>
'',
302 foreach ($link_type_names as $link_type => $null) {
303 $link_type_names[$link_type] = link_type_name($link_type);
306 $write_access = $asset->writeAccess(
'attributes');
307 $locations = $asset->attr(
'create_location');
309 if (empty($locations)) {
310 echo translate(
'cms_no_fixed_create_locations');
313 <table
class=
"sq-backend-table">
315 <td
class=
"sq-backend-table-header"><?php echo translate(
'asset'); ?></td>
316 <td
class=
"sq-backend-table-header"><?php echo translate(
'link_type'); ?></td>
319 ?><td
class=
"sq-backend-table-header"><?php echo translate(
'delete_question'); ?></td><?php
325 foreach ($locations as $locationid => $link_type) {
326 $location = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($locationid,
'', TRUE);
327 if (is_null($location))
continue;
330 <td
class=
"sq-backend-table-cell"><?php echo get_asset_tag_line($location->id); ?></td>
331 <td
class=
"sq-backend-table-cell"><?php echo $link_type_names[$link_type]; ?>
335 ?><td
class=
"sq-backend-table-cell"><?php check_box($prefix.
'_delete_location['.$location->id.
']'); ?></td><?php
340 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($location);
348 echo
'<p><b>'.translate(
'cms_add_location').
':</b> ';
349 asset_finder($prefix.
'_new_create_location', 0, $this->location_types);
350 echo
' '.translate(
'link_type').
': ';
351 combo_box($prefix.
'_new_link_type', $link_type_names, FALSE,
'');
355 return $write_access;
372 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
374 $old_locations = $asset->attr(
'create_location');
375 $new_locations = $old_locations;
378 if (isset($_POST[$prefix.
'_new_create_location'])) {
379 $new_location = trim($_POST[$prefix.
'_new_create_location'][
'assetid']);
380 if ($new_location && assert_valid_assetid($new_location,
'Invalid Asset Id: #'.$new_location.
' supplied for "create location"', FALSE, FALSE) && !isset($new_locations[$new_location])) {
381 $link_type_name = link_type_name((
int)$_POST[$prefix.
'_new_link_type']);
382 if (!empty($link_type_name)) {
383 $new_locations[$new_location] = (int)$_POST[$prefix.
'_new_link_type'];
389 if (isset($_POST[$prefix.
'_delete_location'])) {
390 foreach ($_POST[$prefix.
'_delete_location'] as $locationid => $on) {
391 if (isset($new_locations[$locationid])) {
392 unset($new_locations[$locationid]);
397 if ($old_locations != $new_locations) {
398 return $asset->setAttrValue(
'create_location', $new_locations);
419 $write_access = $asset->writeAccess(
'attributes');
420 $code_name = str_replace(Array(
' ',
'\''),
'_', strtolower($name));
422 <table
class=
"sq-backend-table">
424 <td colspan=
"2" class=
"sq-backend-table-header">
429 <td
class=
"sq-backend-table-cell">
430 <b><?php echo translate(
'cms_location_options') ?>:</b>
432 <td
class=
"sq-backend-table-cell">
435 multiple_asset_finder($prefix.
'_'.$code_name.
'_location_options', array_keys($data[
'locations']), $this->location_types);
437 echo
'<ul style="margin: 1px 15px;">';
438 foreach ($data[
'locations'] as $assetid => $name) {
439 echo
'<li>'.get_asset_tag_line($assetid).
'</li>';
447 <td
class=
"sq-backend-table-cell">
450 <td
class=
"sq-backend-table-cell">
452 $link_type_names = Array(SQ_LINK_TYPE_1=>
'', SQ_LINK_TYPE_2=>
'', SQ_LINK_TYPE_3=>
'', SQ_LINK_NOTICE=>
'');
453 foreach ($link_type_names as $link_type => $null) {
454 $link_type_names[$link_type] = link_type_name($link_type);
457 combo_box($prefix.
'_'.$code_name.
'_link_type', $link_type_names, FALSE, $data[
'link_type']);
459 echo $link_type_names[$data[
'link_type']];
466 <td
class=
"sq-backend-table-cell">
467 <b><?php echo translate(
'cms_asset_builder_input_style') ?></b>
470 <td
class=
"sq-backend-table-cell">
474 <select name=
"<?php echo $prefix.'_'.$code_name.'_input_style'; ?>">
475 <option value=
"dropdown" <?php echo $data[
'input_style']==
'dropdown' ?
'selected="selected"' :
''; ?>>Dropdown</option>
476 <option value=
"radio" <?php echo $data[
'input_style']==
'radio' ?
'selected="selected"' :
''; ?>>Radio Buttons</option>
479 echo $data[
'input_style'];
487 <td
class=
"sq-backend-table-cell" >
490 <td
class=
"sq-backend-table-cell">
491 <table border=
"0" cellpadding=
"0" cellspacing=
"0" style=
"width: 100%">
493 <td style=
"width: 48%">
497 <input type=
"checkbox" name=
"<?php echo $prefix.'_'.$code_name.'_allow_empty'; ?>" id=
"<?php echo $prefix.'_'.$code_name.'_allow_empty'; ?>" value=
"1" class=
"sq-form-field" <?php echo $data[
'allow_empty'] ?
'checked="checked"' :
''; ?> />
501 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo $data['allow_empty'] ? 'tick' : 'cross'; ?>.gif" width=
"15" height=
"15" />
505 <?php echo translate(
'cms_allow_no_selection'); ?>
508 <td style=
"width: 48%;">
512 <input type=
"checkbox" name=
"<?php echo $prefix.'_'.$code_name.'_allow_multiple'; ?>" id=
"<?php echo $prefix.'_'.$code_name.'_allow_multiple'; ?>" value=
"1" class=
"sq-form-field" <?php echo $data[
'allow_multiple'] ?
'checked="checked"' :
''; ?> />
516 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo $data['allow_multiple'] ? 'tick' : 'cross'; ?>.gif" width=
"15" height=
"15" />
520 <?php echo translate(
'cms_allow_multiple_selections'); ?>
523 <td style=
"width: 4%; text-align: right">
527 <input type=
"hidden" name=
"<?php echo $prefix.'_'.$code_name.'_delete' ?>" id=
"<?php echo $prefix.'_'.$code_name.'_delete' ?>" value=
"0" class=
"sq-form-field" /><input type=
"button" value=
"Delete Set" onclick=
"if (confirm(js_translate('cms_asset_builder_delete_selectable_locations'))) { document.getElementById('<?php echo $prefix.'_'.$code_name.'_delete' ?>').value=1; form.submit(); }" />
555 $write_access = $asset->writeAccess(
'attributes');
556 if (is_array($sets = $asset->attr(
'create_location_optional')) && (!empty($sets))) {
557 foreach ($sets as $name => $data) {
561 echo translate(
'cms_asset_builder_no_selectable_sets');
565 echo
'<p><b>'.translate(
'cms_asset_builder_add_new_set').
': </b> ';
566 text_box($prefix.
'_new_set_name',
'');
570 return $write_access;
588 $sets = $asset->attr(
'create_location_optional');
591 foreach (array_keys($sets) as $name) {
592 $code_name = str_replace(Array(
' ',
'\''),
'_', strtolower($name));
594 if ($_POST[$prefix.
'_'.$code_name.
'_delete']) {
596 $asset->setAttrValue(
'create_location_optional', $sets);
597 $asset->saveAttributes();
604 foreach ($sets as $name => $details) {
605 $code_name = str_replace(Array(
' ',
'\''),
'_', strtolower($name));
607 if (is_array($new_options = array_values($_POST[$prefix.
'_'.$code_name.
'_location_options']))) {
608 $sets[$name][
'locations'] = Array();
609 foreach ($new_options as $option) {
610 if (($new_loc_id = $option[
'assetid']) && (!in_array($new_loc_id, array_keys($sets[$name][
'locations'])))) {
611 $sets[$name][
'locations'][$new_loc_id] =
'';
617 $sets[$name][
'allow_empty'] = (int)isset($_POST[$prefix.
'_'.$code_name.
'_allow_empty']);
618 $sets[$name][
'allow_multiple'] = (int)isset($_POST[$prefix.
'_'.$code_name.
'_allow_multiple']);
619 if (in_array(($input_style = $_POST[$prefix.
'_'.$code_name.
'_input_style']), Array(
'dropdown',
'radio'))) {
620 $sets[$name][
'input_style'] = $input_style;
622 if (in_array(($link_type = $_POST[$prefix.
'_'.$code_name.
'_link_type']), Array(SQ_LINK_TYPE_1, SQ_LINK_TYPE_2, SQ_LINK_TYPE_3, SQ_LINK_NOTICE))) {
623 $sets[$name][
'link_type'] = $link_type;
629 if ($_POST[$prefix.
'_new_set_name']) {
630 $sets[$_POST[$prefix.
'_new_set_name']] = Array(
631 'locations' => Array(),
633 'allow_multiple' => 0,
634 'input_style' =>
'dropdown',
635 'link_type' => SQ_LINK_TYPE_1,
639 $asset->setAttrValue(
'create_location_optional', $sets);
640 $asset->saveAttributes();
660 $current_assets = $asset->attr(
'create_type');
661 if (empty($current_assets)) {
662 echo translate(
'cms_asset_builder_rules_no_asset_type');
666 $write_access = $asset->writeAccess(
'attributes');
667 $current_rules = $asset->attr(
'create_location_rules');
669 $link_type_names = Array(SQ_LINK_TYPE_1 =>
'', SQ_LINK_TYPE_2 =>
'', SQ_LINK_TYPE_3 =>
'', SQ_LINK_NOTICE =>
'');
670 foreach ($link_type_names as $lt => $null) {
671 $link_type_names[$lt] = link_type_name($lt);
674 $comparators = Array(
675 'equals' => translate(
'equals'),
676 'starts_with' => translate(
'starts_with'),
677 'ends_with' => translate(
'ends_with'),
678 'contains' => translate(
'contains'),
681 $create_types = $asset->attr(
'create_type');
683 foreach ($create_types as $create_type => $null) {
684 echo
'<p><b>'.translate(
'cms_asset_builder_rules_for_asset_type', $create_type).
'</b></p>';
686 $attributes = Array();
687 $attrs = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeAttributes($create_type, Array(
'name',
'attrid',
'type'));
688 foreach ($attrs as $name => $data) {
689 $attributes[$name] = ucwords(str_replace(
'_',
' ', $name));
691 $attributes = Array(
''=>
'-- '.translate(
'select_attribute').
' --') + $attributes;
695 if ((isset($current_rules[$create_type])) && (is_array($rules = $current_rules[$create_type])) && (!empty($rules))) {
696 foreach ($rules as $rule) {
697 $parent_names = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($rule[
'locations']);
699 <table
class=
"sq-backend-table" style=
"width: 90%; margin-left: 2em; margin-top: 1ex; "><tr><td
class=
"sq-backend-table-header">
700 <b><?php echo translate(
'rule_number', $i) ?></b>
702 <tr><td
class=
"sq-backend-table-cell">
704 <?php echo translate(
'cms_asset_builder_rules_all_true'); ?><br />
707 for ($j = 0; $j < count($rule[
'attributes']); $j++) {
710 combo_box($prefix.
'_rules['.$create_type.
']['.$i.
'][attributes]['.$j.
']', $attributes, FALSE, $rule[
'attributes'][$j]);
712 combo_box($prefix.
'_rules['.$create_type.
']['.$i.
'][comparators]['.$j.
']', $comparators, FALSE, $rule[
'comparators'][$j]);
714 text_box($prefix.
'_rules['.$create_type.
']['.$i.
'][values]['.$j.
']', $rule[
'values'][$j]);
717 echo
'<li><i>'.$attributes[$rule[
'attributes'][$j]].
'</i> '.$comparators[$rule[
'comparators'][$j]].
' "'.$rule[
'values'][$j].
'"</li>';
723 combo_box($prefix.
'_rules['.$create_type.
']['.$i.
'][attributes]['.$j.
']', $attributes, FALSE,
'');
725 combo_box($prefix.
'_rules['.$create_type.
']['.$i.
'][comparators]['.$j.
']', $comparators, FALSE,
'');
727 text_box($prefix.
'_rules['.$create_type.
']['.$i.
'][values]['.$j.
']',
'');
733 <?php echo translate(
'cms_asset_builder_rules_link_to'); ?><br />
734 <ul style=
"margin-bottom: 3px;">
737 while ($j < count($rule[
'locations'])) {
740 asset_finder($prefix.
'_rules['.$create_type.
']['.$i.
'][locations]['.$j.
']', $rule[
'locations'][$j], $this->location_types);
741 echo
' '.translate(
'link_type').
': ';
742 combo_box($prefix.
'_rules['.$create_type.
']['.$i.
'][link_types]['.$j.
']', $link_type_names, FALSE, $rule[
'link_types'][$j]);
745 $assetid = $rule[
'locations'][$j];
746 $link_type_name = $link_type_names[$rule[
'link_types'][$j]];
747 echo
'<li>'.get_asset_tag_line($assetid).
' ('.$link_type_name.
')</li>';
754 asset_finder($prefix.
'_rules['.$create_type.
']['.$i.
'][locations]['.$j.
']', 0, $this->location_types);
755 echo
' '.translate(
'link_type').
': ';
756 combo_box($prefix.
'_rules['.$create_type.
']['.$i.
'][link_types]['.$j.
']', $link_type_names, FALSE,
'');
764 <input type=
"hidden" name=
"<?php echo $prefix.'_rules['.$create_type.']['.$i.'][delete]'; ?>" id=
"<?php echo $prefix.'_rules_'.$create_type.'_'.$i.'_delete'; ?>" value=
"0" />
765 <input style=
"display: inline; float: right; clear: none; margin: 0px; " type=
"button" onclick=
"if (confirm(js_translate('confirm_delete_rule'))) { document.getElementById('<?php echo $prefix.'_rules_'.$create_type.'_'.$i.'_delete'; ?>').value=1; form.submit(); }" value=
"<?php echo translate('delete_rule'); ?>" />
776 ?><span style=
"margin-left: 2em; "><?php echo translate(
'cms_asset_builder_no_rules_defined') ?><br /></span><?php
782 <table
class=
"sq-backend-table" style=
"width: 90%; margin-left: 2em; margin-top: 1ex; ">
784 <td
class=
"sq-backend-table-header"><a
id=
"<?php echo $prefix.'_'.$create_type; ?>_new_rule_link" href=
"#" onclick=
"document.getElementById('<?php echo $prefix.'_'.$create_type; ?>_new_rule_link').style.display='none'; document.getElementById('<?php echo $prefix.'_'.$create_type; ?>_new_rule_header').style.display='inline'; document.getElementById('<?php echo $prefix.'_'.$create_type; ?>_new_rule_body').style.display='block'; return false;"><b>New Rule</b></a><span style=
"display: none" id=
"<?php echo $prefix.'_'.$create_type; ?>_new_rule_header" style=
"display: none" ><b>New Rule</b></span></td>
788 <td
id=
"<?php echo $prefix.'_'.$create_type; ?>_new_rule_body" class=
"sq-backend-table-cell" style=
"display: none" >
789 <?php echo translate(
'cms_asset_builder_rules_all_true') ?><br />
792 for ($j = 0; $j < 3; $j++) {
794 combo_box($prefix.
'_rules['.$create_type.
']['.$i.
'][attributes]['.$j.
']', $attributes, FALSE,
'');
796 combo_box($prefix.
'_rules['.$create_type.
']['.$i.
'][comparators]['.$j.
']', $comparators, FALSE,
'');
798 text_box($prefix.
'_rules['.$create_type.
']['.$i.
'][values]['.$j.
']',
'');
803 <?php echo translate(
'cms_asset_builder_rules_link_to') ?><br />
807 asset_finder($prefix.
'_rules['.$create_type.
']['.$i.
'][locations][0]', 0, $this->location_types); echo
' Link Type: ';
808 combo_box($prefix.
'_rules['.$create_type.
']['.$i.
'][link_types][0]', $link_type_names, FALSE,
'');
837 if (!isset($_POST[$prefix.
'_rules']))
return FALSE;
838 $rules = $_POST[$prefix.
'_rules'];
841 foreach ($rules as $create_type => $type_rules) {
842 foreach ($type_rules as $i => $rule_data) {
843 foreach ($rule_data[
'attributes'] as $index => $attribute) {
844 if ((empty($attribute)) || empty($rule_data[
'values'][$index])) {
845 unset($rules[$create_type][$i][
'attributes'][$index]);
846 unset($rules[$create_type][$i][
'comparators'][$index]);
847 unset($rules[$create_type][$i][
'values'][$index]);
850 $rules[$create_type][$i][
'values'][$index] = strtolower($rules[$create_type][$i][
'values'][$index]);
853 foreach ($rule_data[
'locations'] as $index => $location) {
854 if (empty($location[
'assetid'])) {
855 unset($rules[$create_type][$i][
'locations'][$index]);
856 unset($rules[$create_type][$i][
'link_types'][$index]);
858 $rules[$create_type][$i][
'locations'][$index] = $location[
'assetid'];
862 if ((isset($rule_data[
'delete']) && $rule_data[
'delete']) || (strlen(implode(
'', $rule_data[
'attributes'])) == 0)) {
863 unset($rules[$create_type][$i]);
865 unset($rules[$create_type][$i][
'delete']);
871 return $asset->setAttrValue(
'create_location_rules', $rules);
888 if ($asset->writeAccess(
'attributes')) {
889 multiple_asset_finder($prefix.
'_additional_location_parents', $asset->attr(
'additional_location_parents'), $this->location_types);
891 $infos = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($asset->attr(
'additional_location_parents'));
892 echo
'<ul style="margin: 1px 15px;">';
893 foreach ($infos as $assetid => $info) {
894 echo
'<li>'.get_asset_tag_line($assetid).
'</li>';
915 $new_parents = Array();
916 if (isset($_POST[$prefix.
'_additional_location_parents']) && is_array($_POST[$prefix.
'_additional_location_parents'])) {
917 foreach ($_POST[$prefix.
'_additional_location_parents'] as $parent) {
918 if ($parent[
'assetid']) {
919 $new_parents[] = $parent[
'assetid'];
923 $asset->setAttrValue(
'additional_location_parents', $new_parents);
940 if (!$asset->writeAccess(
'attributes')) {
941 echo
'<ul style="margin: 1px 15px;">';
942 foreach ($asset->attr(
'additional_location_types') as $type) {
943 echo
'<li>'.ucwords(str_replace(
'_',
' ', $type)).
'</li>';
947 asset_type_chooser($prefix.
'_additional_location_types', TRUE, $asset->attr(
'additional_location_types'));
966 $new_types = Array();
967 if (isset($_POST[$prefix.
'_additional_location_types']) && is_array($_POST[$prefix.
'_additional_location_types'])) {
968 foreach ($_POST[$prefix.
'_additional_location_types'] as $type) {
969 if ($type) $new_types[] = $type;
973 return $asset->setAttrValue(
'additional_location_types', array_unique($new_types));
990 $write_access = $asset->writeAccess(
'attributes');
991 if (is_array($sets = $asset->attr(
'create_location_dynamic')) && (!empty($sets))) {
992 foreach ($sets as $name => $data) {
996 echo translate(
'cms_asset_builder_no_dynamic_sets');
1000 echo
'<p><b>'.translate(
'cms_asset_builder_add_new_set').
': </b> ';
1001 text_box($prefix.
'_new_dynamic_set_name',
'');
1005 return $write_access;
1024 $write_access = $asset->writeAccess(
'attributes');
1025 $code_name =
'dynamic_location_'.str_replace(Array(
' ',
'\''),
'_', strtolower($name));
1027 <table
class=
"sq-backend-table">
1029 <td colspan=
"2" class=
"sq-backend-table-header">
1030 <?php echo $name; ?>
1034 <td
class=
"sq-backend-table-cell">
1037 <td
class=
"sq-backend-table-cell">
1039 if ($write_access) {
1040 asset_finder($prefix.
'_'.$code_name.
'_root', array_get_index($data,
'root', 0), $this->location_types);
1042 $rootid = array_get_index($data,
'root', 0);
1044 if ($rootid > 0 && $GLOBALS[
'SQ_SYSTEM']->am->assetExists($rootid)) {
1045 echo get_asset_tag_line($rootid);
1047 echo translate(
'none_selected');
1055 <td
class=
"sq-backend-table-cell">
1056 <b><?php echo translate(
'depth') ?>:</b>
1058 <td
class=
"sq-backend-table-cell">
1060 if ($write_access) {
1061 int_text_box($prefix.
'_'.$code_name.
'_depth', array_get_index($data,
'depth', 0), FALSE, 3);
1062 echo
' '.translate(
'cms_asset_builder_levels_text');
1064 $levels = array_get_index($data,
'depth', 0);
1065 if ($levels == 0) $levels = translate(
'infinite');
1066 echo
'<p>'.translate(
'cms_asset_builder_num_levels', $levels).
'</p>';
1072 <td
class=
"sq-backend-table-cell">
1073 <b><?php echo translate(
'cms_asset_builder_restrict_types') ?>:</b>
1075 <td
class=
"sq-backend-table-cell">
1077 if (isset($data[
'types'])) {
1078 $selected_asset_types = $data[
'types'];
1080 $selected_asset_types = Array(
1081 'type_code' => Array(),
1082 'inherit' => Array(),
1086 if ($write_access) {
1087 asset_type_chooser($prefix.
'_'.$code_name.
'_types', TRUE, $selected_asset_types, NULL, FALSE, TRUE);
1089 foreach ($selected_asset_types[
'type_code'] as $index => $type) {
1091 unset($selected_asset_types[
'type_code'][$index]);
1093 $selected_asset_types[
'type_code'][$index] = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type,
'name');
1096 echo implode(
",<br />\n", $selected_asset_types[
'type_code']);
1102 <td
class=
"sq-backend-table-cell">
1103 <b><?php echo translate(
'cms_asset_builder_include_link_type') ?>:</b>
1105 <td
class=
"sq-backend-table-cell">
1108 $link_types = Array(
1109 SQ_LINK_TYPE_1 =>
'TYPE_1',
1110 SQ_LINK_TYPE_2 =>
'TYPE_2',
1112 if ($write_access) {
1113 foreach ($link_types as $link_type => $link_name) {
1114 if (isset($data[
'filter_link_type'][$link_type])) {
1119 check_box($prefix.
'_'.$code_name.
'_filter_link_type['.$link_type.
']',
'1', $selected);
1120 ?> <?php echo $link_name; ?><br />
1124 $display_link_types = Array();
1125 foreach (array_get_index($data,
'filter_link_type', Array()) as $filter_link_type => $filter_link_type_data) {
1126 if (isset($link_types[$filter_link_type])) {
1127 $display_link_types[] = $link_types[$filter_link_type];
1130 if (empty($display_link_types)) {
1131 echo translate(
'cms_asset_builder_no_exclusions');
1133 echo implode(
",<br />\n", $display_link_types);
1140 <td
class=
"sq-backend-table-cell">
1141 <b><?php echo translate(
'cms_asset_builder_created_link_type') ?>:</b>
1143 <td
class=
"sq-backend-table-cell">
1145 $link_type_names = get_link_type_names();
1146 $selected_link_type = array_get_index($data,
'link_type', SQ_LINK_TYPE_1);
1147 if ($write_access) {
1148 combo_box($prefix.
'_'.$code_name.
'_link_type', $link_type_names, FALSE, $selected_link_type);
1150 echo $link_type_names[$data[
'link_type']];
1157 <td
class=
"sq-backend-table-cell">
1158 <b><?php echo translate(
'cms_asset_builder_input_style'); ?></b>
1161 <td
class=
"sq-backend-table-cell">
1163 $input_style = array_get_index($data,
'input_style', translate(
'none_selected'));
1164 $display_structured = array_get_index($data,
'display_structured', 0);
1166 'dropdown' => translate(
'dropdown_list'),
1167 'radio' => translate(
'radio_buttons'),
1169 if ($write_access) {
1170 ?><select name=
"<?php echo $prefix.'_'.$code_name.'_input_style'; ?>"><?php
1171 foreach ($options as $opt_value => $opt_text) {
1172 echo
'<option value="'.$opt_value.
'" '.($input_style == $opt_value ?
'selected="selected"' :
'').
'>'.$opt_text.
'</option>'.
"\n";
1174 ?></select> <?php
1177 check_box($prefix.
'_'.$code_name.
'_display_structured',
'1', ($display_structured == 1 ? TRUE : FALSE));
1178 echo
' '.translate(
'cms_asset_builder_display_as_tree').
"\n";
1181 echo
'<p>'.$options[$input_style].
' ('.($display_structured ? translate(
'cms_asset_builder_display_as_tree') : translate(
'cms_asset_builder_display_as_list')).
')</p>';
1187 <td
class=
"sq-backend-table-cell" >
1188 <?php echo translate(
'rules') ?>:
1190 <td
class=
"sq-backend-table-cell">
1191 <table border=
"0" cellpadding=
"0" cellspacing=
"0" style=
"width: 100%">
1193 <td style=
"width: 48%">
1195 $selected_allow_empty = array_get_index($data,
'allow_empty', FALSE);
1196 if ($write_access) {
1198 <input type=
"checkbox" name=
"<?php echo $prefix.'_'.$code_name.'_allow_empty'; ?>" id=
"<?php echo $prefix.'_'.$code_name.'_allow_empty'; ?>" value=
"1" class=
"sq-form-field" <?php echo $selected_allow_empty ?
'checked="checked"' :
''; ?> />
1202 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo $selected_allow_empty ? 'tick' : 'cross'; ?>.gif" width=
"15" height=
"15" />
1205 ?> <?php echo translate(
'cms_allow_no_selection') ?>
1208 <td style=
"width: 48%;">
1210 $selected_allow_multiple = array_get_index($data,
'allow_multiple', FALSE);
1211 if ($write_access) {
1213 <input type=
"checkbox" name=
"<?php echo $prefix.'_'.$code_name.'_allow_multiple'; ?>" id=
"<?php echo $prefix.'_'.$code_name.'_allow_multiple'; ?>" value=
"1" class=
"sq-form-field" <?php echo $selected_allow_multiple ?
'checked="checked"' :
''; ?> />
1217 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo $selected_allow_multiple ? 'tick' : 'cross'; ?>.gif" width=
"15" height=
"15" />
1220 ?> <?php echo translate(
'cms_allow_multiple_selections') ?>
1223 <td style=
"width: 4%; text-align: right">
1225 if ($write_access) {
1227 <input type=
"hidden" name=
"<?php echo $prefix.'_'.$code_name.'_delete' ?>" id=
"<?php echo $prefix.'_'.$code_name.'_delete' ?>" value=
"0" class=
"sq-form-field" /><input type=
"button" value=
"Delete Set" onclick=
"if (confirm(js_translate('cms_asset_builder_delete_dynamic_locations'))) { document.getElementById('<?php echo $prefix.'_'.$code_name.'_delete' ?>').value=1; form.submit(); }" />
1271 $sets = $asset->attr(
'create_location_dynamic');
1274 foreach (array_keys($sets) as $name) {
1275 $code_name =
'dynamic_location_'.str_replace(Array(
' ',
'\''),
'_', strtolower($name));
1277 if ($_POST[$prefix.
'_'.$code_name.
'_delete']) {
1278 unset($sets[$name]);
1279 $asset->setAttrValue(
'create_location_dynamic', $sets);
1280 $asset->saveAttributes();
1288 foreach ($sets as $name => $details) {
1289 $code_name =
'dynamic_location_'.str_replace(Array(
' ',
'\''),
'_', strtolower($name));
1292 if (isset($_POST[$prefix.
'_'.$code_name.
'_root'][
'assetid'])) {
1293 $sets[$name][
'root'] = $_POST[$prefix.
'_'.$code_name.
'_root'][
'assetid'];
1297 if (isset($_POST[$prefix.
'_'.$code_name.
'_depth'])) {
1298 $sets[$name][
'depth'] = $_POST[$prefix.
'_'.$code_name.
'_depth'];
1302 if (isset($_POST[$prefix.
'_'.$code_name.
'_types'])) {
1303 $sets[$name][
'types'] = $_POST[$prefix.
'_'.$code_name.
'_types'];
1307 if (isset($_POST[$prefix.
'_'.$code_name.
'_filter_link_type'])) {
1308 $sets[$name][
'filter_link_type'] = $_POST[$prefix.
'_'.$code_name.
'_filter_link_type'];
1310 $sets[$name][
'filter_link_type'] = Array();
1314 if (in_array(($input_style = $_POST[$prefix.
'_'.$code_name.
'_input_style']), Array(
'dropdown',
'radio'))) {
1315 $sets[$name][
'input_style'] = $input_style;
1319 if (isset($_POST[$prefix.
'_'.$code_name.
'_display_structured'])) {
1320 $sets[$name][
'display_structured'] = $_POST[$prefix.
'_'.$code_name.
'_display_structured'];
1322 $sets[$name][
'display_structured'] = 0;
1326 if (isset($_POST[$prefix.
'_'.$code_name.
'_link_type'])) {
1327 $link_type_list = get_link_type_names();
1328 if (isset($link_type_list[$_POST[$prefix.
'_'.$code_name.
'_link_type']])) {
1329 $sets[$name][
'link_type'] = (int) $_POST[$prefix.
'_'.$code_name.
'_link_type'];
1334 $sets[$name][
'allow_empty'] = (int) isset($_POST[$prefix.
'_'.$code_name.
'_allow_empty']);
1335 $sets[$name][
'allow_multiple'] = (int) isset($_POST[$prefix.
'_'.$code_name.
'_allow_multiple']);
1340 if ($_POST[$prefix.
'_new_dynamic_set_name']) {
1341 $sets[$_POST[$prefix.
'_new_dynamic_set_name']] = Array(
1345 'allow_multiple' => 0,
1346 'input_style' =>
'dropdown',
1347 'link_type' => SQ_LINK_TYPE_1,
1348 'filter_link_type' => Array(
1349 SQ_LINK_TYPE_1 =>
'1',
1350 SQ_LINK_TYPE_2 =>
'1',
1353 'type_code' => Array(),
1354 'inherit' => Array(),
1356 'diplay_structured' => 0,
1360 $asset->setAttrValue(
'create_location_dynamic', $sets);
1361 $asset->saveAttributes();
1384 $write_access = $asset->writeAccess(
'attributes');
1385 $current = $asset->attr(
'required_fields');
1386 $metadata_schemas = Array();
1387 $metadata_schema_list = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major',
'schema_to_apply');
1388 foreach ($metadata_schema_list as $metadata_schema) {
1389 $metadata_schemas[] = $metadata_schema[
'minorid'];
1392 foreach (array_keys($asset->attr(
'create_type')) as $create_type) {
1394 $attributes = Array();
1395 $attrs = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeAttributes($create_type, Array(
'name'));
1396 foreach ($attrs as $name) {
1397 $attributes[$name] = ucwords(str_replace(
'_',
' ', $name));
1400 if (!isset($current[$create_type])) {
1401 $current[$create_type] = Array();
1403 $type_prefix = $prefix.
'_'.$create_type;
1405 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($create_type,
'name');
1406 $o->openSection($type_name);
1409 if (empty($current[$create_type])) {
1410 echo translate(
'cms_asset_builder_no_required_attrs');
1413 <table
class=
"sq-backend-table">
1415 <td
class=
"sq-backend-table-header"><?php echo translate(
'name') ?></td>
1416 <td
class=
"sq-backend-table-header"><?php echo translate(
'error_text') ?></td>
1418 if ($write_access) {
1419 ?><td
class=
"sq-backend-table-header"><?php echo translate(
'delete_question') ?></td><?php
1424 foreach ($current[$create_type] as $attr => $error_text) {
1425 $required_name =
'';
1426 $pos = strpos($attr, $prefix.
'_metadata_');
1427 if ($pos !== FALSE) {
1428 if (empty($metadata_schemas))
continue;
1429 $metadata_field = substr($attr, strlen($prefix.
'_metadata_'));
1430 $am = $GLOBALS[
'SQ_SYSTEM']->am;
1431 $mf_asset = $am->getAsset($metadata_field);
1432 if (!is_null($mf_asset)) {
1433 $required_name =
'Metadata: '.$mf_asset->name;
1435 $required_name = translate(
'unknown_metadata_field');
1438 $required_name = $attributes[$attr];
1442 <td
class=
"sq-backend-table-cell"><?php echo $required_name; ?></td>
1443 <td
class=
"sq-backend-table-cell">
1445 if ($write_access) {
1446 text_box($type_prefix.
'_required_field['.$attr.
']', $error_text, 50);
1453 if ($write_access) {
1455 <td
class=
"sq-backend-table-cell">
1456 <?php check_box($type_prefix.
'_delete_required['.$attr.
']'); ?>
1469 if ($write_access) {
1471 $new_required = Array(
'' =>
'-- '.translate(
'select_attribute').
' --');
1472 foreach ($attributes as $attr => $name) {
1473 if (isset($current[$create_type][$attr]))
continue;
1474 $new_required[$attr] = $name;
1477 if (!empty($metadata_schemas)) {
1478 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
1479 $am = $GLOBALS[
'SQ_SYSTEM']->am;
1480 $metadata_fields = $mm->getMetadataFields($metadata_schemas);
1481 foreach ($metadata_fields as $metadata_field => $metadata_field_type_code) {
1482 if (isset($current[$create_type][$prefix.
'_metadata_'.$metadata_field]))
continue;
1484 $asset = $am->getAsset($metadata_field);
1485 if (!is_null($asset)) {
1486 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'metadata_section', FALSE,
'minor', NULL, TRUE);
1487 foreach ($current_links as $link) {
1488 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'majorid'], $link[
'major_type_code']);
1489 if (is_null($section))
continue;
1490 $restrictions = $section->attr(
'restrict');
1491 if (empty($restrictions) || (!is_null($create_type) && array_key_exists($create_type, $restrictions))) {
1492 $new_required[$prefix.
'_metadata_'.$metadata_field] =
'Metadata: '.$asset->name;
1496 $am->forgetAsset($asset);
1500 echo
'<br/><b>'.translate(
'cms_asset_builder_new_req_attr_question').
' </b>';
1501 combo_box($type_prefix.
'_new_required', $new_required, FALSE,
'');
1509 return $write_access;
1526 $current = $asset->attr(
'required_fields');
1527 $required_fields = Array();
1529 foreach (array_keys($asset->attr(
'create_type')) as $create_type) {
1531 if (!isset($current[$create_type])) {
1532 $current[$create_type] = Array();
1534 $type_prefix = $prefix.
'_'.$create_type;
1537 foreach ($current[$create_type] as $attr => $error_text) {
1538 if (!isset($_POST[$type_prefix.
'_delete_required'][$attr]) || !$_POST[$type_prefix.
'_delete_required'][$attr]) {
1539 if (isset($_POST[$type_prefix.
'_required_field'][$attr])) {
1540 $required_fields[$create_type][$attr] = trim($_POST[$type_prefix.
'_required_field'][$attr]);
1542 $required_fields[$create_type][$attr] = $current[$create_type][$attr];
1548 if (isset($_POST[$type_prefix.
'_new_required']) && !empty($_POST[$type_prefix.
'_new_required'])) {
1549 $new_required = $_POST[$type_prefix.
'_new_required'];
1550 if (!isset($required_fields[$create_type][$new_required])) {
1551 $required_fields[$create_type][$new_required] =
'';
1556 return $asset->setAttrValue(
'required_fields', $required_fields);
1573 if ($asset->writeAccess(
'attributes')) {
1574 asset_finder($prefix.
'_captcha_ttf', $asset->attr(
'captcha_ttf'), Array(
'file' =>
'D'));
1576 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($asset->attr(
'captcha_ttf'));
1577 $ttf_file_id = $asset->attr(
'captcha_ttf');
1578 if ($ttf_file_id > 0) {
1579 echo get_asset_tag_line($ttf_file_id);
1581 echo translate(
'none_selected');
1601 if (isset($_POST[$prefix.
'_captcha_ttf'])) {
1602 $ttf_file_id = $_POST[$prefix.
'_captcha_ttf'][
'assetid'];
1604 if ($ttf_file_id != $asset->attr(
'captcha_ttf')) {
1605 if ($ttf_file_id > 0) {
1607 $ttf_file = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($ttf_file_id);
1609 $ttf_file_info = $ttf_file->getExistingFile();
1610 $filename = strtolower($ttf_file_info[
'filename']);
1612 $extension_index = strpos($filename,
'.ttf');
1613 if (($extension_index !== FALSE) && ($extension_index == strlen($filename)-4)) {
1614 return $asset->setAttrValue(
'captcha_ttf', $ttf_file_id);
1616 trigger_localised_error(
'CMS0109', E_USER_WARNING);
1619 return $asset->setAttrValue(
'captcha_ttf', NULL);
1642 return (count($asset->attr(
'create_location_optional')) > 1);
1657 return (count($asset->attr(
'create_type')) > 1);
1677 $write_access = $asset->writeAccess(
'attributes');
1678 $current = $asset->attr(
'mollom_attributes_to_check');
1679 $metadata_schemas = Array();
1680 $metadata_schema_list = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major',
'schema_to_apply');
1681 foreach ($metadata_schema_list as $metadata_schema) {
1682 $metadata_schemas[] = $metadata_schema[
'minorid'];
1685 foreach (array_keys($asset->attr(
'create_type')) as $create_type) {
1687 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($create_type,
'name');
1688 $attributes = Array();
1689 $attrs = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeAttributes($create_type, Array(
'name'));
1690 foreach ($attrs as $name) {
1691 $attributes[$name] = ucwords(str_replace(
'_',
' ', $name));
1694 if (!isset($current[$create_type])) {
1695 $current[$create_type] = Array();
1697 $type_prefix = $prefix.
'_'.$create_type;
1699 if (empty($current[$create_type])) {
1700 echo translate(
'cms_asset_builder_mollom_no_attr_to_check').
'<br />';
1703 <table
class=
"sq-backend-table">
1704 <tr><td colspan=
"3" style=
"font-style:italic;"><b><?php echo $type_name; ?></b></td></tr>
1706 <td
class=
"sq-backend-table-header"><?php echo translate(
'name') ?></td>
1707 <td
class=
"sq-backend-table-header">Content Type</td>
1709 if ($write_access) {
1710 ?><td
class=
"sq-backend-table-header"><?php echo translate(
'delete_question') ?></td><?php
1715 foreach ($current[$create_type] as $attr => $content_type) {
1716 $required_name =
'';
1717 $pos = strpos($attr, $prefix.
'_metadata_');
1718 if ($pos !== FALSE) {
1719 if (empty($metadata_schemas))
continue;
1720 $metadata_field = substr($attr, strlen($prefix.
'_metadata_'));
1721 $am = $GLOBALS[
'SQ_SYSTEM']->am;
1722 $mf_asset = $am->getAsset($metadata_field);
1723 if (!is_null($mf_asset)) {
1724 $required_name =
'Metadata: '.$mf_asset->name;
1726 $required_name = translate(
'unknown_metadata_field');
1729 $required_name = $attributes[$attr];
1733 <td
class=
"sq-backend-table-cell"><?php echo $required_name; ?></td>
1734 <td
class=
"sq-backend-table-cell">
1736 $content_types = Array();
1737 if (file_exists(SQ_FUDGE_PATH.
'/mollom/mollom.inc')) {
1738 require_once SQ_FUDGE_PATH.
'/mollom/mollom.inc';
1741 if ($write_access) {
1742 combo_box($type_prefix.
'_content_type['.$attr.
']', $content_types, FALSE, $content_type);
1744 echo isset($content_types[$content_type]) ? $content_types[$content_type] :
'';
1749 if ($write_access) {
1751 <td
class=
"sq-backend-table-cell">
1752 <?php check_box($type_prefix.
'_delete_content_type['.$attr.
']'); ?>
1765 if ($write_access) {
1767 $new_required = Array(
'' =>
'-- '.translate(
'select_attribute').
' --');
1768 foreach ($attributes as $attr => $name) {
1769 if (isset($current[$create_type][$attr]))
continue;
1770 $new_required[$attr] = $name;
1773 if (!empty($metadata_schemas)) {
1774 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
1775 $am = $GLOBALS[
'SQ_SYSTEM']->am;
1776 $metadata_fields = $mm->getMetadataFields($metadata_schemas);
1777 foreach ($metadata_fields as $metadata_field => $metadata_field_type_code) {
1778 if (isset($current[$create_type][$prefix.
'_metadata_'.$metadata_field]))
continue;
1780 $m_asset = $am->getAsset($metadata_field);
1781 if (!is_null($m_asset)) {
1782 $current_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($m_asset->id, SQ_LINK_TYPE_2,
'metadata_section', FALSE,
'minor', NULL, TRUE);
1783 foreach ($current_links as $link) {
1784 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'majorid'], $link[
'major_type_code']);
1785 if (is_null($section))
continue;
1786 $restrictions = $section->attr(
'restrict');
1787 if (empty($restrictions) || (!is_null($create_type) && array_key_exists($create_type, $restrictions))) {
1788 $new_required[$prefix.
'_metadata_'.$metadata_field] =
'Metadata: '.$m_asset->name;
1792 $am->forgetAsset($m_asset);
1796 echo
'<b>'.translate(
'cms_asset_builder_new_mollom_attr_question').
' </b>';
1797 combo_box($type_prefix.
'_new_content_type', $new_required, FALSE,
'');
1798 echo
'<br /><br />';
1804 return $write_access;
1821 $current = $asset->attr(
'mollom_attributes_to_check');
1822 $content_types = Array();
1824 foreach (array_keys($asset->attr(
'create_type')) as $create_type) {
1826 if (!isset($current[$create_type])) {
1827 $current[$create_type] = Array();
1829 $type_prefix = $prefix.
'_'.$create_type;
1832 foreach ($current[$create_type] as $attr => $error_text) {
1833 if (!isset($_POST[$type_prefix.
'_delete_content_type'][$attr]) || !$_POST[$type_prefix.
'_delete_content_type'][$attr]) {
1834 if (isset($_POST[$type_prefix.
'_content_type'][$attr])) {
1835 $content_types[$create_type][$attr] = trim($_POST[$type_prefix.
'_content_type'][$attr]);
1837 $content_types[$create_type][$attr] = $current[$create_type][$attr];
1843 if (isset($_POST[$type_prefix.
'_new_content_type']) && !empty($_POST[$type_prefix.
'_new_content_type'])) {
1844 $new_required = $_POST[$type_prefix.
'_new_content_type'];
1845 if (!isset($content_types[$create_type][$new_required])) {
1846 $content_types[$create_type][$new_required] =
'';
1853 return $asset->setAttrValue(
'mollom_attributes_to_check', $content_types);