18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page_edit_fns.inc';
19 require_once SQ_FUDGE_PATH.
'/general/general.inc';
51 parent::__construct($assetid);
52 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
53 $this->static_screens[
'details'][
'lock_type'] =
'content';
70 $types = $asset->attr(
'types');
71 if ($asset->writeAccess(
'content')) {
73 $display_values = Array(
'type_code' => Array(),
'inherit' => Array());
74 foreach ($types as $type => $inherit) {
75 $display_values[
'type_code'][] = $type;
76 $display_values[
'inherit'][] = $inherit;
78 asset_type_chooser($prefix.
'_types', TRUE, $display_values, NULL, TRUE, TRUE);
83 echo
'<p class="sq-backend-warning">'.translate(
'cms_listing_no_asset_types_selected').
'</p>';
85 $type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($types),
'name');
87 <table
class=
"sq-backend-table">
89 <th><?php echo translate(
'type') ?></th>
90 <th><?php echo translate(
'inherit_question') ?></th>
93 $inherit_image_path = sq_web_path(
'lib').
'/web/images/';
94 foreach ($types as $type => $inherit) {
95 $inherit_image = $inherit_image_path.($inherit ?
'tick' :
'cross').
'.gif';
96 $inherit_alt = $inherit ? translate(
'yes') : translate(
'no');
100 echo get_asset_type_icon($type);
101 echo $type_names[$type];
103 <td><img src=
"<?php echo $inherit_image; ?>" alt=
"<?php echo $inherit_alt; ?>" /></td>
133 $proxy_settings = $asset->attr(
'proxy_types');
135 if (isset($_POST[$prefix.
'_types'])) {
136 $existing_types = $asset->attr(
'types');
138 $submitted_types = Array();
139 foreach ($_POST[$prefix.
'_types'][
'type_code'] as $i => $type_code) {
140 if (!empty($type_code)) {
141 $submitted_types[$type_code] = $_POST[$prefix.
'_types'][
'inherit'][$i];
145 $proxy_child_types = Array();
146 $delete_proxy_types = Array();
147 foreach ($proxy_settings as $proxy_type => $child_types) {
148 if (!empty($child_types)) {
149 if (in_array($proxy_type, array_keys($submitted_types))) {
150 $proxy_child_types = array_merge($proxy_child_types, array_keys($child_types));
152 $delete_proxy_types[] = $proxy_type;
154 $existing_types = array_merge($existing_types, $child_types);
158 $folder = $asset->getFolder(
'type_formats');
159 $formats = $asset->getFormats(
'type_formats');
162 foreach ($existing_types as $type => $inherit) {
164 if (!isset($submitted_types[$type]) && !in_array($type, $proxy_child_types)) {
165 if (in_array($type, $formats)) {
167 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $type);
169 $folder->deleteLink($link[
'linkid']);
175 $asset->setAttrValue(
'types', $submitted_types);
178 foreach ($delete_proxy_types as $delete_proxy_type) {
179 unset($proxy_settings[$delete_proxy_type]);
181 $asset->setAttrValue(
'proxy_types', $proxy_settings);
203 $write_access = $asset->writeAccess(
'attributes');
204 $asset_positions = $asset->attr(
'asset_positions');
207 $groups = $asset->attr(
'asset_grouping');
208 if ($asset->attr(
'group_by') ==
'grouped' && !empty($groups)) {
209 $o->note(translate(
'cms_listing_cannot_use_asset_postitions_with_groups'));
211 if (!empty($asset_positions)) {
212 ksort($asset_positions, SORT_NUMERIC);
213 if (!$write_access) {
214 $asset_ids = Array();
215 foreach ($asset_positions as $asset_data) {
216 $asset_ids[] = $asset_data[
'id'];
218 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($asset_ids);
221 <table
class=
"sq-backend-table">
223 <th><?php echo translate(
'position'); ?></th>
224 <th><?php echo translate(
'asset'); ?></th>
227 ?><th><?php echo translate(
'delete_question'); ?></th><?php
232 foreach ($asset_positions as $position => $asset_data) {
233 $assetid = $asset_data[
'id'];
236 <td><?php echo $position; ?></td>
240 asset_finder($prefix.
'_asset_position['.$position.
']', $assetid, Array(
'asset' =>
'D'));
242 echo get_asset_tag_line($assetid);
251 check_box($prefix.
'_delete_asset_position['.$position.
']');
264 echo translate(
'cms_listing_no_positions_defined');
268 echo
'<p><b>'.translate(
'cms_listing_new_asset_position').
'</b> ';
269 text_box($prefix.
'_new_asset_position_pos',
'', 5);
271 asset_finder($prefix.
'_new_asset_position_asset',
'', Array(
'asset' =>
'D'));
276 return $write_access;
293 $asset_positions = Array();
296 if(!isset($_POST[$prefix.
'_asset_position']) && !isset($_POST[$prefix.
'_delete_asset_position']) && !isset($_POST[$prefix.
'_new_asset_position_pos']))
return FALSE;
299 $current_asset_positions = array_get_index($_POST, $prefix.
'_asset_position', Array());
300 foreach ($current_asset_positions as $position => $data) {
301 if ($data[
'assetid']) {
302 $asset_positions[$position] = $data[
'assetid'];
307 $delete_asset_position = array_get_index($_POST, $prefix.
'_delete_asset_position', Array());
308 foreach ($delete_asset_position as $position => $on) {
309 unset($asset_positions[$position]);
313 $new_position_pos = (int) array_get_index($_POST, $prefix.
'_new_asset_position_pos', 0);
314 if ($new_position_pos > 0) {
315 $new_position_data = array_get_index($_POST, $prefix.
'_new_asset_position_asset', Array());
316 if ($new_position_assetid = $new_position_data[
'assetid']) {
317 $asset_positions[$new_position_pos] = $new_position_assetid;
321 $asset_types = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_values($asset_positions),
'asset', FALSE,
'type_code');
322 foreach ($asset_positions as $position=>$id) {
323 $asset_positions[$position] = Array(
'id'=>$id,
'type'=>$asset_types[$id]);
325 ksort($asset_positions, SORT_NUMERIC);
327 return $asset->setAttrValue(
'asset_positions', $asset_positions);
344 $write_access = $asset->writeAccess(
'attributes');
345 $current = $asset->attr(
'column_layout');
348 <table
class=
"sq-backend-table">
350 <th><?php echo translate(
'row'); ?></th>
351 <th><?php echo translate(
'column(s)'); ?></th>
355 <th><?php echo translate(
'delete_question') ?></th>
361 if (count($current) > 1) {
362 foreach ($current as $row => $columns) {
363 if ($row == 0)
continue;
366 <td><?php echo $row; ?></td>
370 text_box($prefix.
'_columns['.$row.
']', $columns, 5);
380 <?php check_box($prefix.
'_delete_row['.$row.
']'); ?>
392 <td><?php echo translate(
'cms_listing_all_remaining'); ?></td>
396 text_box($prefix.
'_columns[0]', $current[
'0'], 5);
404 ?><td> </td><?php
413 $o->openField(translate(
'cms_listing_customise_row'));
414 echo strtolower(translate(
'row')).
' ';
415 text_box($prefix.
'_new_row',
'', 5);
416 echo
' '.strtolower(translate(
'columns')).
' ';
417 text_box($prefix.
'_new_column',
'', 5);
421 return $write_access;
439 $column_layout = array_get_index($_POST, $prefix.
'_columns', Array());
440 $deleted_rows = array_get_index($_POST, $prefix.
'_delete_row', Array());
441 foreach ($deleted_rows as $row => $on) {
442 if (isset($column_layout[$row])) {
443 unset($column_layout[$row]);
448 for (reset($column_layout); NULL !== ($row = key($column_layout)); next($column_layout)) {
449 if ((
int)$column_layout[$row] < 1) {
453 trigger_localised_error(
'CMS0061', E_USER_NOTICE);
455 trigger_localised_error(
'CMS0060', E_USER_NOTICE, $row);
457 $column_layout[$row] = 1;
462 $new_row = (int)array_get_index($_POST, $prefix.
'_new_row', 0);
463 $new_column = (int)array_get_index($_POST, $prefix.
'_new_column', 0);
465 if ($new_column > 0) {
466 if (!isset($column_layout[$new_row])) {
467 $column_layout[$new_row] = $new_column;
469 trigger_localised_error(
'CMS0040', E_USER_WARNING, $new_row);
472 trigger_localised_error(
'CMS0041', E_USER_WARNING, $new_row);
476 return $asset->setAttrValue(
'column_layout', $column_layout);
493 $column_layout = $asset->attr(
'column_layout');
494 $num_per_page = $asset->attr(
'num_per_page');
496 $num_rows = max(array_keys($column_layout)) + 1;
497 $num_columns = max(array_values($column_layout));
500 <table
class=
"sq-backend-table">
503 for ($i = 1; $i <= $num_rows; $i++) {
505 $cols_in_row = array_get_index($column_layout, $i, $column_layout[
'0']);
506 $each_colspan = (int)($num_columns / $cols_in_row);
507 $first_colspan = $each_colspan + $num_columns - ($cols_in_row * $each_colspan);
509 for ($c = 1; $c <= $cols_in_row; $c++) {
510 $colspan = ($c == 1) ? $first_colspan : $each_colspan;
511 $class =
'sq-backend-table-cell';
512 if ($num_per_page > 0 && $cell_num > $num_per_page) {
516 <td
class=
"<?php echo $class; ?>" style=
"<?php echo ($c < $cols_in_row) ? ' border-right: 1px solid #CCCCCC;' : ''; ?>"<?php echo ($colspan > 1) ?
' colspan="'.$colspan.
'"' :
''; ?>>
517 <b><?php echo $cell_num; ?></b>
526 <td style=
"text-align: center;" colspan=
"<?php echo $num_columns; ?>">
527 <?php echo translate(
'cms_listing_column_all_remaining_rows', $column_layout[0]); ?>
529 if ($num_per_page > 0 && $cell_num > $num_per_page) {
530 echo
'<br /><b>'.translate(
'cms_listing_column_page_note', $num_per_page).
'</b>';
571 <table
class=
"sq-backend-table">
573 <th><?php echo translate(
'edit_format') ?></th>
574 <th><?php echo translate(
'note') ?></th>
580 $folder = $asset->getFolder(
'type_formats');
603 function _paintDefaultFormatLink($root_assetid, $bodycopy_name, $bodycopy_description, $type_code=
'bodycopy', $screen=
'contents')
605 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($root_assetid, SQ_LINK_TYPE_2, $type_code, TRUE, $bodycopy_name);
607 $info = Array($link[
'minorid'] =>
'contents');
608 $href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($info);
612 <?php echo get_asset_tag_line($link[
'minorid'], $screen); ?>
615 <?php echo $bodycopy_description; ?>
637 $formats = $asset->getFormats(
'group_formats');
639 if (empty($formats)) {
640 echo translate(
'cms_listing_no_groups');
643 <table
class=
"sq-backend-table">
645 <th><?php echo translate(
'edit_format'); ?></th>
648 foreach (array_keys($formats) as $assetid) {
649 $_format = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($assetid));
650 $format = reset($_format);
651 $link = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref(Array($assetid =>
'contents'))
654 <td><?php echo get_asset_tag_line($assetid,
'contents'); ?></td>
678 $types = $asset->attr(
'types');
679 $proxy_settings = $asset->attr(
'proxy_types');
681 foreach ($proxy_settings as $proxy_type => $proxy_children) {
682 if (!empty($proxy_children)) {
683 $types = array_merge($proxy_children, $types);
704 $write_access = $asset->writeAccess(
'links');
706 $formats = $asset->getFormats(
'type_formats');
708 if (count($formats) > 1) {
710 <table
class=
"sq-backend-table">
712 <th><?php echo translate(
'asset_type') ?></th>
713 <th><?php echo translate(
'edit_format') ?></th>
717 <th><?php echo translate(
'delete_question') ?></th>
723 foreach ($formats as $minorid => $value) {
724 if ($value ==
'default_format')
continue;
726 $info = Array($minorid =>
'contents');
727 $href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($info);
728 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($value,
'name');
731 <td style=
"width: 200px;">
733 echo get_asset_type_icon($value);
739 echo get_asset_tag_line($minorid,
'contents');
745 <td style=
"width: 100px;">
747 check_box($prefix.
'_delete_type['.$value.
']');
760 echo translate(
'cms_listing_no_type_formats');
764 $new_format_options = Array(
'' =>
'');
765 foreach ($types as $type => $inherit) {
766 if (in_array($type, $formats))
continue;
767 $new_format_options[$type] = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type,
'name');
769 if (count($new_format_options) > 1) {
770 echo
'<p><b>'.translate(
'cms_listing_new_type_format').
'</b> ';
771 combo_box($prefix.
'_new_type', $new_format_options, FALSE,
'');
792 $folder = $asset->getFolder(
'type_formats');
795 $deleted_formats = array_get_index($_POST, $prefix.
'_delete_type', Array());
796 $new_type = array_get_index($_POST, $prefix.
'_new_type',
'');
797 if (isset($deleted_formats[$new_type])) {
798 trigger_localised_error(
'CMS0042', E_USER_WARNING, $new_type);
799 unset($deleted_formats[$new_type]);
803 foreach ($deleted_formats as $type => $on) {
804 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $type);
805 if (empty($current_link)) {
806 trigger_localised_error(
'CMS0043', E_USER_WARNING, $type);
808 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($current_link[
'linkid'])) {
809 trigger_localised_error(
'CMS0044', E_USER_WARNING, $type);
815 if ($new_type !=
'' && !isset($types[$new_type])) {
816 trigger_localised_error(
'CMS0045', E_USER_WARNING, $new_type);
820 if ($new_type !=
'') {
822 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $new_type);
823 if (empty($current_link)) {
825 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
826 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
827 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
829 $copy_link = Array(
'asset' => &$folder,
'value' => $new_type,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
832 $bodycopy->setAttrValue(
'name', $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($new_type,
'name').
' Format');
834 if (!$bodycopy->create($copy_link)) {
835 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
836 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
839 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
840 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
842 trigger_localised_error(
'CMS0046', E_USER_WARNING, $new_type);
845 if (isset($asset->_tmp[
'formats'][
'type_formats'])) {
846 unset($asset->_tmp[
'formats'][
'type_formats']);
866 $write_access = $asset->writeAccess(
'links');
867 $formats = $asset->getFormats(
'position_formats');
869 if (!empty($formats)) {
871 <table
class=
"sq-backend-table">
873 <th><?php echo translate(
'position') ?></th>
874 <th><?php echo translate(
'edit_format') ?></th>
877 ?><th><?php echo translate(
'delete_question') ?></th><?php
882 foreach ($formats as $minorid => $value) {
883 $info = Array($minorid =>
'contents');
884 $href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($info);
885 $position = substr($value, 9);
888 <td style=
"width: 200px;">
895 echo get_asset_tag_line($minorid,
'contents');
901 <td style=
"width: 100px;">
903 check_box($prefix.
'_delete_position['.$position.
']');
916 echo translate(
'cms_listing_no_position_formats');
920 echo
'<p><b>'.translate(
'cms_listing_new_position_format').
'</b> ';
921 text_box($prefix.
'_new_position',
'', 5);
925 return $write_access;
942 $folder = $asset->getFolder(
'position_formats');
944 $deleted_formats = array_get_index($_POST, $prefix.
'_delete_position', Array());
945 $new_position = (int) array_get_index($_POST, $prefix.
'_new_position', 0);
946 if (isset($deleted_formats[$new_position])) {
947 trigger_localised_error(
'CMS0047', E_USER_WARNING, $new_position);
948 unset($deleted_formats[$new_position]);
952 foreach ($deleted_formats as $position => $on) {
953 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE,
'position_'.$position);
954 if (empty($current_link)) {
955 trigger_localised_error(
'CMS0048', E_USER_WARNING, $position);
957 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($current_link[
'linkid'])) {
958 trigger_localised_error(
'CMS0049', E_USER_WARNING, $position);
963 if ($new_position != 0) {
965 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE,
'position_'.$new_position);
966 if (empty($current_link)) {
969 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
970 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
971 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
973 $copy_link = Array(
'asset' => &$folder,
'value' =>
'position_'.$new_position,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
976 $bodycopy->setAttrValue(
'name', translate(
'cms_listing_position_number_format', $new_position));
978 if (!$bodycopy->create($copy_link)) {
979 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
980 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
983 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
984 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
986 trigger_localised_error(
'CMS0050', E_USER_POSITION, $new_position);
989 if (isset($asset->_tmp[
'formats'][
'position_formats'])) {
990 unset($asset->_tmp[
'formats'][
'position_formats']);
1010 if ($asset->attr(
'group_by') ==
'random') {
1012 echo translate(
'cms_listing_random_selected_no_sort');
1018 $types = $asset->attr(
'types');
1019 if (empty($types)) {
1021 echo translate(
'cms_listing_no_types_no_sort');
1026 $wa = $asset->writeAccess(
'attributes');
1028 $o->openSection(translate(
'cms_listing_sort_by_standard_field'));
1032 $o->openSection(translate(
'cms_listing_sort_by_attribute'));
1036 $o->openSection(translate(
'cms_listing_sort_by_metadata_field'));
1040 $o->openSection((
'Sorting by Asset Keyword Value'));
1044 $o->openSection(translate(
'cms_listing_sort_by_extras'));
1067 $this->_tmp[
'previous_sort_options'] = $asset->attr(
'sort_by');
1078 return $asset->setAttrValue(
'sort_by', array_values($asset->attr(
'sort_by')));
1097 $wa = $asset->writeAccess(
'attributes');
1099 $o->openField($wa ? translate(
'current') :
'');
1101 foreach ($asset->attr(
'sort_by') as $option_id => $info) {
1102 if ($info[
'type'] ==
'field') {
1103 $fields[$option_id] = $info;
1106 if (!empty($fields)) {
1108 <table
class=
"sq-backend-table" >
1110 <th style=
"width: 60ex"><?php echo translate(
'asset_field'); ?></td>
1111 <th><?php echo translate(
'display_name') ?></th>
1115 <th style=
"width: 12ex"><?php echo translate(
'remove_question'); ?></td>
1121 foreach ($fields as $id => $info) {
1122 if (empty($sort_by_options[$info[
'params'][
'field']])) {
1129 echo $sort_by_options[$info[
'params'][
'field']];
1135 text_box($prefix.
'_current['.$id.
'][name]', $info[
'name']);
1137 echo array_get_index($info,
'name',
'');
1146 check_box($prefix.
'_current['.$id.
'][remove]',
'1');
1159 echo translate(
'cms_listing_sort_by_standard_field_none');
1164 $o->openField(translate(
'new'));
1166 <table
class=
"sq-backend-table" style=
"width: 60ex">
1168 <th style=
"width: 20ex"><?php echo translate(
'asset_field'); ?></th>
1171 combo_box($prefix.
'_new[field]', $sort_by_options, FALSE,
'');
1176 <th><?php echo translate(
'display_name'); ?></th>
1177 <td><?php text_box($prefix.
'_new[name]',
''); ?></td>
1199 $val = $asset->attr(
'sort_by');
1201 if (!empty($_POST[$prefix.
'_current'])) {
1202 foreach ($_POST[$prefix.
'_current'] as $i => $details) {
1203 if (!empty($details[
'remove'])) {
1206 $val[$i][
'name'] = $details[
'name'];
1211 if (!empty($_POST[$prefix.
'_new'][
'name'])) {
1214 'name' => $_POST[$prefix.
'_new'][
'name'],
1215 'params' => Array(
'field' => $_POST[$prefix.
'_new'][
'field']),
1221 return $asset->setAttrValue(
'sort_by', $val);
1240 $wa = $asset->writeAccess(
'attributes');
1241 $types = $asset->attr(
'types');
1242 $type_info = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($types),
'name');
1245 $o->openField($wa ? translate(
'current') :
'');
1248 foreach ($asset->attr(
'sort_by') as $id => $info) {
1249 if ($info[
'type'] ==
'asset_attrib') {
1250 $attrs[$id] = $info;
1254 if (!empty($attrs)) {
1256 <table
class=
"sq-backend-table">
1258 <th style=
"width: 30ex"><?php echo translate(
'asset_type'); ?></th>
1259 <th style=
"width: 30ex; padding-left: 0px; padding-right: 0px"><?php echo translate(
'attribute_name'); ?></th>
1260 <th><?php echo translate(
'display_name') ?></th>
1264 <th style=
"width: 12ex"><?php echo translate(
'remove_question'); ?></th>
1270 foreach ($attrs as $id => $info) {
1276 combo_box($prefix.
'_current['.$id.
'][type_code]', $type_info, FALSE, $info[
'params'][
'type_code']);
1278 echo get_asset_type_icon($info[
'params'][
'type_code']);
1279 echo $type_info[$info[
'params'][
'type_code']];
1285 $attributes = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeAttributes($info[
'params'][
'type_code']);
1286 $display_attributes = Array();
1287 foreach (array_keys($attributes) as $attribute) {
1288 $display_attributes[$attribute] = ucwords(str_replace(
'_',
' ', $attribute));
1291 combo_box($prefix.
'_current['.$id.
'][attribute]', $display_attributes, FALSE, $info[
'params'][
'attribute']);
1293 echo $display_attributes[$info[
'params'][
'attribute']];
1300 text_box($prefix.
'_current['.$id.
'][name]', $info[
'name']);
1302 echo array_get_index($info,
'name',
'');
1311 check_box($prefix.
'_current['.$id.
'][remove]',
'1');
1324 echo translate(
'cms_listing_sort_by_attribute_none');
1329 $o->openField(translate(
'new'));
1331 <table
class=
"sq-backend-table" style=
"width: 60ex">
1333 <th style=
"width: 20ex"><?php echo translate(
'asset_type'); ?></th>
1336 $types = $asset->attr(
'types');
1337 $type_info = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($types),
'name');
1338 combo_box($prefix.
'_new[type_code]', $type_info, FALSE);
1343 <th><?php echo translate(
'display_name'); ?></th>
1344 <td><?php text_box($prefix.
'_new[name]',
''); ?></td>
1366 $val = $asset->attr(
'sort_by');
1369 if (!empty($_POST[$prefix.
'_current'])) {
1370 foreach ($_POST[$prefix.
'_current'] as $i => $details) {
1371 if (!empty($details[
'remove'])) {
1374 $val[$i][
'name'] = $details[
'name'];
1375 $val[$i][
'params'][
'type_code'] = $details[
'type_code'];
1376 $attributes = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeAttributes($details[
'type_code']);
1377 if (isset($attributes[$details[
'attribute']])) {
1378 $val[$i][
'params'][
'attribute'] = $details[
'attribute'];
1379 $val[$i][
'params'][
'attr_type'] = $attributes[$val[$i][
'params'][
'attribute']];
1381 $val[$i][
'params'][
'attribute'] = reset(array_keys($attributes));
1388 if (!empty($_POST[$prefix.
'_new'][
'name'])) {
1389 $attributes = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypeAttributes($_POST[$prefix.
'_new'][
'type_code']);
1390 if (empty($attributes)) {
1391 trigger_localised_error(
'CMS0110', E_USER_WARNING);
1393 $default_attr = array_shift(array_keys($attributes));
1395 'type' =>
'asset_attrib',
1396 'name' => $_POST[$prefix.
'_new'][
'name'],
1398 'type_code' => $_POST[$prefix.
'_new'][
'type_code'],
1399 'attribute' => $default_attr,
1400 'attr_type' => $attributes[$default_attr],
1409 return $asset->setAttrValue(
'sort_by', $val);
1428 $wa = $asset->writeAccess(
'attributes');
1429 $o->openField($wa ? translate(
'current') :
'');
1430 $meta_datas = Array();
1431 foreach ($asset->attr(
'sort_by') as $id => $info) {
1432 if ($info[
'type'] ==
'metadata') {
1433 $meta_datas[$id] = $info;
1437 if (!empty($meta_datas)) {
1439 <table
class=
"sq-backend-table">
1441 <th style=
"width: 60ex"><?php echo translate(
'metadata_field'); ?></th>
1442 <th><?php echo translate(
'display_name') ?></th>
1446 <th style=
"width: 12ex"><?php echo translate(
'remove_question'); ?></th>
1452 foreach ($meta_datas as $id => $info) {
1458 asset_finder($prefix.
'_current['.$id.
'][field]',$info[
'field'],Array(
'metadata_field' =>
'D'));
1460 echo get_asset_tag_line($info[
'field']);
1467 text_box($prefix.
'_current['.$id.
'][name]', array_get_index($info,
'name',
''));
1469 echo array_get_index($info,
'name',
'');
1478 check_box($prefix.
'_current['.$id.
'][remove]',
'1');
1491 echo translate(
'cms_listing_sort_by_metadata_field_none');
1495 $o->openField(translate(
'new'));
1497 <table
class=
"sq-backend-table" style=
"width: 60ex">
1499 <th style=
"width: 20ex"><?php echo translate(
'metadata_field'); ?></th>
1500 <td><?php asset_finder($prefix.
'_new[field]',0,Array(
'metadata_field' =>
'D')); ;?></td>
1503 <th><?php echo translate(
'display_name'); ?></th>
1504 <td><?php text_box($prefix.
'_new[name]',
''); ?></td>
1526 $val = $asset->attr(
'sort_by');
1529 if (!empty($_POST[$prefix.
'_current'])) {
1530 foreach ($_POST[$prefix.
'_current'] as $i => $details) {
1531 if (!empty($details[
'remove'])) {
1534 $val[$i][
'name'] = $details[
'name'];
1535 if (!empty($details[
'field'][
'assetid'])) {
1536 $val[$i][
'field'] = $details[
'field'][
'assetid'];
1543 if (!empty($_POST[$prefix.
'_new'][
'name']) && !empty($_POST[$prefix.
'_new'][
'field'][
'assetid'])) {
1545 'type' =>
'metadata',
1546 'name' => $_POST[$prefix.
'_new'][
'name'],
1547 'field' => $_POST[$prefix.
'_new'][
'field'][
'assetid'],
1548 'params' => Array(),
1555 return $asset->setAttrValue(
'sort_by', $val);
1574 $wa = $asset->writeAccess(
'attributes');
1575 $o->openField($wa ? translate(
'current') :
'');
1576 $keyword_datas = Array();
1577 foreach ($asset->attr(
'sort_by') as $id => $info) {
1578 if ($info[
'type'] ==
'keyword') {
1579 $keyword_datas[$id] = $info;
1583 if (!empty($keyword_datas)) {
1585 <table
class=
"sq-backend-table">
1587 <th style=
"width: 60ex"><?php echo (
'Keyword'); ?></th>
1588 <th><?php echo translate(
'display_name') ?></th>
1592 <th style=
"width: 12ex"><?php echo translate(
'remove_question'); ?></th>
1598 foreach ($keyword_datas as $id => $info) {
1604 text_box($prefix.
'_current['.$id.
'][keyword]', array_get_index($info,
'keyword',
''));
1606 echo array_get_index($info,
'name',
'');
1613 text_box($prefix.
'_current['.$id.
'][name]', array_get_index($info,
'name',
''));
1615 echo array_get_index($info,
'name',
'');
1624 check_box($prefix.
'_current['.$id.
'][remove]',
'1');
1637 echo translate(
'cms_listing_sort_by_keyword_field_none');
1641 $o->openField(translate(
'new'));
1643 <table
class=
"sq-backend-table" style=
"width: 60ex">
1645 <th style=
"width: 20ex"><?php echo translate(
'keyword'); ?></th>
1646 <td><?php text_box($prefix.
'_new[keyword]',
''); ?></td>
1649 <th><?php echo translate(
'display_name'); ?></th>
1650 <td><?php text_box($prefix.
'_new[name]',
''); ?></td>
1672 $val = $asset->attr(
'sort_by');
1675 if (!empty($_POST[$prefix.
'_current'])) {
1676 foreach ($_POST[$prefix.
'_current'] as $i => $details) {
1677 if (!empty($details[
'remove'])) {
1680 $val[$i][
'name'] = $details[
'name'];
1681 if (!empty($details[
'keyword'])) {
1682 $val[$i][
'keyword'] = $details[
'keyword'];
1689 if (!empty($_POST[$prefix.
'_new'][
'name']) && !empty($_POST[$prefix.
'_new'][
'keyword'])) {
1691 'type' =>
'keyword',
1692 'name' => $_POST[$prefix.
'_new'][
'name'],
1693 'keyword' => $_POST[$prefix.
'_new'][
'keyword'],
1694 'params' => Array(),
1701 return $asset->setAttrValue(
'sort_by', $val);
1721 $wa = $asset->writeAccess(
'attributes');
1722 if ($wa) $o->addHiddenField($prefix.
'_submitted', 1);
1724 $o->openField(translate(
'cms_listing_random_sort'));
1725 $random_enabled = FALSE;
1726 foreach ($asset->attr(
'sort_by') as $v) {
1727 if ($v[
'name'] ==
'Random') {
1728 $random_enabled = TRUE;
1733 check_box($prefix.
'_enable_random',
'1', $random_enabled);
1734 label(translate(
'cms_listing_enable_random_sort'), $prefix.
'_enable_random');
1736 $filename = $random_enabled ?
'tick' :
'cross';
1737 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.$filename.
'.gif" /> ';
1738 echo translate(
'cms_listing_enable_random_sort');
1741 $o->openField(translate(
'cms_listing_no_sort'));
1742 $nosort_enabled = FALSE;
1743 foreach ($asset->attr(
'sort_by') as $v) {
1744 if ($v[
'name'] ==
'No Sorting') {
1745 $nosort_enabled = TRUE;
1750 check_box($prefix.
'_enable_nosort',
'1', $nosort_enabled);
1751 label(translate(
'cms_listing_enable_no_sort'), $prefix.
'_enable_nosort');
1753 $filename = $nosort_enabled ?
'tick' :
'cross';
1754 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.$filename.
'.gif" /> ';
1755 echo translate(
'cms_listing_enable_no_sort');
1774 $val = $asset->attr(
'sort_by');
1775 if (isset($_POST[$prefix.
'_submitted'])) {
1776 $want_random = !empty($_POST[$prefix.
'_enable_random']);
1777 $random_index = FALSE;
1778 foreach ($val as $i => $v) {
1779 if ($v[
'name'] ==
'Random') {
1784 if (($random_index !== FALSE) && !$want_random) {
1785 unset($val[$random_index]);
1786 }
else if (($random_index === FALSE) && $want_random) {
1795 $want_nosort = !empty($_POST[$prefix.
'_enable_nosort']);
1796 $nosort_index = FALSE;
1797 foreach ($val as $i => $v) {
1798 if ($v[
'name'] ==
'No Sorting') {
1803 if (($nosort_index !== FALSE) && !$want_nosort) {
1804 unset($val[$nosort_index]);
1805 }
else if (($nosort_index === FALSE) && $want_nosort) {
1807 'name' =>
'No Sorting',
1813 return $asset->setAttrValue(
'sort_by', $val);
1834 $last = end($options);
1836 while (($last[
'name'] ==
'Random') || ($last[
'name'] ==
'No Sorting')) {
1837 array_unshift($ending, $last);
1838 array_pop($options);
1839 $last = end($options);
1841 $options = array_merge($options, Array($new_option), $ending);
1858 $write_access = $asset->writeAccess(
'attributes');
1859 $sort_by = $asset->attr(
'metadata_sort_type');
1862 'raw' =>
'Raw Value',
1863 'presentation' =>
'Presentation Value',
1866 if ($write_access) {
1867 combo_box($prefix.
'_metadata_sort_type', $option, FALSE, $sort_by);
1869 echo ($sort_by ==
'raw') ?
'Raw Value' :
'Presentation Value';
1872 return $write_access;
1890 if (isset($_POST[$prefix.
'_metadata_sort_type'])) {
1891 return $asset->setAttrValue(
'metadata_sort_type', $_POST[$prefix.
'_metadata_sort_type']);
1910 $write_access = $asset->writeAccess(
'attributes');
1911 $sort_by_list = $asset->attr(
'sort_by');
1913 if (empty($sort_by_list)) {
1914 echo translate(
'cms_listing_no_sorting_applied');
1917 $last_index = count($sort_by_list) - 1;
1919 $default = $asset->attr(
'default_sort_by');
1921 foreach ($sort_by_list as $id => $info) {
1922 $names[$id] = $info[
'name'];
1925 if ($write_access) {
1926 combo_box($prefix.
'_default_sort', $names, FALSE, $default);
1928 if (isset($sort_by_list[$default][
'name'])) {
1929 echo $sort_by_list[$default][
'name'];
1933 return $write_access;
1951 if (isset($_POST[$prefix.
'_default_sort'])) {
1952 $new_default_index = $_POST[$prefix.
'_default_sort'];
1953 $new_sort_order = $asset->attr(
'sort_by');
1954 $old_sort_order = $this->_tmp[
'previous_sort_options'];
1955 $new_default_entry = array_get_index($new_sort_order, $new_default_index, -1);
1956 $old_default_entry = $old_sort_order[$new_default_index];
1957 unset($new_default_entry[
'name']);
1958 unset($old_default_entry[
'name']);
1959 if ($new_default_entry != $old_default_entry) {
1965 foreach ($new_sort_order as $i => $v) {
1967 if ($v == $old_default_entry) {
1969 $new_default_index = $i;
1974 return $asset->setAttrValue(
'default_sort_by', $new_default_index);
1993 $write_access = $asset->writeAccess(
'attributes');
1994 $sort_by_list = $asset->attr(
'sort_by');
1996 if (empty($sort_by_list)) {
1997 echo translate(
'cms_listing_no_sort_by_options');
2002 $types = $asset->attr(
'types');
2003 if (empty($types)) {
2004 echo translate(
'cms_listing_no_types_no_sort');
2009 <script type=
"text/javascript">
2010 function sortOrderMoveDown(currentOrder) {
2011 if (!document.getElementById) {
2012 alert(js_translate(
'brower_does_not_support_getelementbyid'));
2016 var currentElement = document.getElementById(
'<?php echo $prefix ?>_sort_order_' + currentOrder);
2017 var nextElement = document.getElementById(
'<?php echo $prefix ?>_sort_order_' + (currentOrder + 1));
2020 if (!nextElement)
return;
2022 if (!currentElement.innerHTML) {
2023 alert(js_translate(
'brower_does_not_support_innerhtml'));
2027 var table = currentElement.parentNode;
2028 while (table.tagName !=
'TABLE') {
2029 table = table.parentNode;
2031 table.style.border =
'2px dashed #7B9EBD';
2034 var temp = currentElement.innerHTML;
2035 currentElement.innerHTML = nextElement.innerHTML;
2036 nextElement.innerHTML = temp;
2038 var currOrder = document.getElementById(
'<?php echo $prefix; ?>_sort_order_list[' + currentOrder +
']');
2039 var prevOrder = document.getElementById(
'<?php echo $prefix; ?>_sort_order_list[' + (currentOrder + 1) +
']');
2041 var temp = prevOrder.value;
2042 prevOrder.value = currOrder.value;
2043 currOrder.value = temp;
2046 function sortOrderMoveUp(currentOrder) {
2047 if (!document.getElementById) {
2048 alert(js_translate(
'brower_does_not_support_getelementbyid'));
2052 if (currentOrder == 0)
return;
2054 var currentElement = document.getElementById(
'<?php echo $prefix ?>_sort_order_' + currentOrder);
2055 var prevElement = document.getElementById(
'<?php echo $prefix ?>_sort_order_' + (currentOrder - 1));
2057 if (!currentElement.innerHTML) {
2058 alert(js_translate(
'brower_does_not_support_innerhtml'));
2062 var table = currentElement.parentNode;
2063 while (table.tagName !=
'TABLE') {
2064 table = table.parentNode;
2066 table.style.border =
'2px dashed #7B9EBD';
2069 var temp = currentElement.innerHTML;
2070 currentElement.innerHTML = prevElement.innerHTML;
2071 prevElement.innerHTML = temp;
2073 var currOrder = document.getElementById(
'<?php echo $prefix; ?>_sort_order_list[' + currentOrder +
']');
2074 var prevOrder = document.getElementById(
'<?php echo $prefix; ?>_sort_order_list[' + (currentOrder - 1) +
']');
2076 var temp = prevOrder.value;
2077 prevOrder.value = currOrder.value;
2078 currOrder.value = temp;
2081 <table
class=
"sq-backend-table" style=
"width: 50%;">
2083 <th><?php echo translate(
'cms_listing_sort_option_name'); ?></th>
2085 if ($write_access) {
2086 ?><th colspan=
"2" style=
"width: 8ex"><?php echo translate(
'order'); ?></th><?php
2092 foreach ($sort_by_list as $id => $info) {
2097 hidden_field($prefix.
'_sort_order_list['.$id.
']', $id); ?>
2098 <span
id =
"<?php echo $prefix ?>_sort_order_<?php echo $id; ?>"><?php echo $info[
'name']; ?></span>
2101 if ($write_access) {
2106 sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/up_arrow.png', 16, 16, translate(
'move_up'), NULL,
'class="clickable" onclick="sortOrderMoveUp('.$id.
')"');
2112 if ($i != count($sort_by_list)-1) {
2113 sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/down_arrow.png', 16, 16, translate(
'move_down'), NULL,
'class="clickable" onclick="sortOrderMoveDown('.$id.
')"');
2128 return $write_access;
2145 $sort_by_list = $asset->attr(
'sort_by');
2146 if (isset($_POST[$prefix.
'_sort_order_list'])) {
2147 $sort_order = $_POST[$prefix.
'_sort_order_list'];
2148 $save_list = Array();
2150 foreach ($sort_order as $id => $order) {
2151 if (empty($sort_by_list[$order])) {
2152 unset($sort_by_list[$order]);
2154 if (isset($sort_by_list[$order])) {
2155 $save_list[$i++] = $sort_by_list[$order];
2156 unset($sort_by_list[$order]);
2160 return $asset->setAttrValue(
'sort_by', array_merge($save_list, $sort_by_list));
2179 $write_access = $asset->writeAccess(
'attributes');
2180 $sort_direction = $asset->attr(
'reverse_sort');
2181 $sort_asc_text = $asset->attr(
'sort_direction_asc_text');
2182 $sort_desc_text = $asset->attr(
'sort_direction_desc_text');
2185 '0' => $sort_asc_text,
2186 '1' => $sort_desc_text,
2189 if ($write_access) {
2190 combo_box($prefix.
'_default_sort_direction', $options, FALSE, $sort_direction);
2192 echo ($sort_direction) ? $sort_desc_text : $sort_asc_text;
2195 return $write_access;
2212 $direction = array_get_index($_POST, $prefix.
'_default_sort_direction');
2213 if (!is_null($direction)) {
2214 $direction = (int)(
bool)$direction;
2215 $asset->setAttrValue(
'reverse_sort', $direction);
2233 if ($asset->attr(
'group_by') ==
'letter') {
2235 'name' => translate(
'name'),
2236 'short_name' => translate(
'short_name'),
2239 return $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfoFields();
2258 $root_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major',
'root');
2259 $root_asset_ids = Array();
2260 foreach ($root_links as $root_link) {
2261 $root_asset_ids[$root_link[
'minorid']] = $root_link[
'minor_type_code'];
2264 if ($asset->writeAccess(
'links')) {
2265 multiple_asset_finder($prefix.
'_root_nodes', array_keys($root_asset_ids));
2267 $infos = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($root_asset_ids));
2268 ?><ul style=
"margin: 1px 15px;"><?php
2269 foreach ($infos as $assetid => $info) {
2270 echo
'<li>'.get_asset_tag_line($assetid).
'</li>';
2291 if (!isset($_POST[$prefix.
'_root_nodes']) || (isset($asset->_tmp[
'reverting_to_system_version']) && $asset->_tmp[
'reverting_to_system_version'])) {
2294 $new_root_nodes = $_POST[$prefix.
'_root_nodes'];
2295 foreach ($new_root_nodes as $new_root_node) {
2296 $new_root_node_ids[] = $new_root_node[
'assetid'];
2300 $root_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major',
'root');
2302 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
2303 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
2307 foreach ($root_links as $root_link) {
2308 if (!in_array($root_link[
'minorid'], $new_root_node_ids)) {
2309 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($root_link[
'linkid'])) {
2316 foreach ($new_root_nodes as $index => $node) {
2318 foreach ($root_links as $root_link) {
2319 if ($root_link[
'minorid'] == $node[
'assetid']) {
2324 if ($node[
'assetid'] != 0) {
2325 $new_root = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($node[
'assetid']);
2326 if (!$asset->createLink($new_root, SQ_LINK_NOTICE,
'root')) {
2328 trigger_localised_error(
'CMS0016', E_USER_WARNING, $new_root->name, $new_root->id);
2335 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
2337 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
2340 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
2358 $asset->reindexGroupFormats();
2360 $write_access = $asset->writeAccess(
'attributes');
2361 $group_by = $asset->attr(
'asset_grouping');
2362 $commit_button = FALSE;
2364 foreach ($group_by as $level => $group_by_option) {
2366 switch ($group_by_option[
'group_type']) {
2367 case 'parent_asset':
2368 $option_name =
'cms_listing_parent_asset';
2372 $option_name =
'asset_metadata';
2375 case 'standard_asset':
2376 $option_name =
'standard_asset_field';
2380 $option_name =
'asset_attribute';
2384 $option_name =
'keyword';
2392 $o->openSection(
'Group Level '.($level+1).
': '.translate($option_name));
2394 switch ($group_by_option[
'group_type']) {
2395 case 'parent_asset':
2400 $commit_button |= $this->
paintGroupByMetadata($asset, $o, $prefix.
'['.$level.
']', $group_by_option);
2403 case 'standard_asset':
2408 $commit_button |= $this->
paintGroupByKeyword($asset, $o, $prefix.
'['.$level.
']', $group_by_option);
2417 $o->openField(translate(
'cms_listing_sort_order'));
2420 'asc' => translate(
'cms_listing_ascending_order'),
2421 'desc' => translate(
'cms_listing_descending_order'),
2424 if ($write_access) {
2425 combo_box($prefix.
'['.$level.
'][sort_order]', $options, FALSE, array_get_index($group_by_option,
'sort_order',
'asc'));
2427 echo $options[array_get_index($group_by_option,
'sort_order',
'asc')];
2432 $o->openField(translate(
'cms_listing_max_children_per_group'));
2433 $max_children = array_get_index($group_by_option,
'max_children', NULL);
2434 if ($write_access) {
2435 text_box($prefix.
'['.$level.
'][max_children]', $max_children, 5);
2437 if (is_null($max_children)) {
2438 echo
'<em>'.translate(
'unlimited').
'</em>';
2447 if ($write_access) {
2449 $o->openField(translate(
'delete_question'));
2451 check_box($prefix.
'['.$level.
'][delete]',
'1', array_get_index($group_by_option,
'new_page', FALSE));
2452 label(translate(
'cms_listing_delete_group_format'), $prefix.
'['.$level.
'][delete]');
2458 $link = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref(Array($group_by_option[
'format_assetid'] =>
'contents'));
2459 ?><a href=
"<?php echo $link[$group_by_option['format_assetid']]; ?>"><?php echo translate(
'cms_listing_edit_group_format'); ?></a><?php
2468 return $commit_button;
2485 if (!$asset->writeAccess(
'attributes'))
return FALSE;
2487 $group_by_details = $asset->attr(
'asset_grouping');
2488 $posted_options = array_get_index($_POST, $prefix, Array());
2489 $folder = $asset->getFolder(
'group_formats');
2492 foreach ($posted_options as $key => $posted_option) {
2493 if (is_array($posted_option) && (array_get_index($posted_option,
'delete', 0) == 1)) {
2494 $format_assetid = $group_by_details[$key][
'format_assetid'];
2495 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkByAsset($folder->id, $format_assetid);
2497 if (empty($current_link)) {
2498 trigger_error(
'Group format does not seem to exist for group level '.($key+1), E_USER_WARNING);
2500 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($current_link[
'linkid'])) {
2501 trigger_error(
'Could not delete link between group level '.($key+1).
' and group formats folder', E_USER_WARNING);
2505 unset($group_by_details[$key]);
2509 foreach ($group_by_details as $group_by_key => $group_by_option) {
2510 switch ($group_by_option[
'group_type']) {
2511 case 'parent_asset':
2519 case 'standard_asset':
2536 $group_by_details = array_merge($group_by_details, Array());
2537 $asset->reindexGroupFormats();
2540 $asset->setAttrValue(
'asset_grouping', $group_by_details);
2541 return $asset->saveAttributes();
2559 $write_access = $asset->writeAccess(
'attributes');
2561 $o->openField(translate(
'metadata_field'));
2562 $field_assetid = array_get_index($group_by_option,
'metadata_field', 0);
2564 if ($write_access) {
2565 asset_finder($prefix.
'[metadata_field]', $field_assetid, Array(
'metadata_field' =>
'D'));
2567 if ($field_assetid) {
2568 echo get_asset_tag_line($field_assetid);
2572 $o->note(translate(
'cms_listing_group_metadata_field_note'));
2575 $o->openField(translate(
'cms_listing_default_metadata_sort_type'));
2577 $sort_by = array_get_index($group_by_option,
'metadata_sort_type',
'raw');
2579 'raw' => translate(
'cms_listing_raw_value'),
2580 'presentation' => translate(
'cms_listing_presentation_value'),
2583 if ($write_access) {
2584 combo_box($prefix.
'[metadata_sort_type]', $option, FALSE, $sort_by);
2586 echo ($sort_by ==
'raw') ? translate(
'cms_listing_raw_value') : translate(
'cms_listing_presentation_value');
2589 $o->note(translate(
'cms_listing_default_metadata_sort_type_note'));
2592 return $write_access;
2611 $posted_option = array_get_index($_POST[$prefix], $key, NULL);
2612 if (!is_array($posted_option))
return FALSE;
2614 if (isset($posted_option[
'metadata_field'])) {
2615 $group_by_option[
'metadata_field'] = $posted_option[
'metadata_field'][
'assetid'];
2617 $group_by_option[
'sort_order'] = $posted_option[
'sort_order'];
2619 if (empty($posted_option[
'max_children'])) {
2620 $group_by_option[
'max_children'] = NULL;
2622 $group_by_option[
'max_children'] = $posted_option[
'max_children'];
2625 if (isset($posted_option[
'metadata_sort_type'])) {
2626 $group_by_option[
'metadata_sort_type'] = $posted_option[
'metadata_sort_type'];
2647 $write_access = $asset->writeAccess(
'attributes');
2650 'assetid' => translate(
'asset_id'),
2651 'version' => translate(
'version'),
2652 'name' => translate(
'name'),
2653 'short_name' => translate(
'short_name'),
2654 'status' => translate(
'asset_status'),
2655 'created' => translate(
'created_date'),
2656 'updated' => translate(
'last_updated_date'),
2657 'published' => translate(
'last_published_date'),
2658 'status_changed' => translate(
'status_changed_date'),
2659 'type_code' => translate(
'type_code'),
2661 $field = array_get_index($group_by_option,
'field',
'');
2663 $o->openField(translate(
'standard_asset_field'));
2665 if ($write_access) {
2666 combo_box($prefix.
'[standard_asset_field]', $options, FALSE, $field);
2668 if (empty($field)) {
2669 echo
'<em>'.translate(
'cms_listing_no_field_selected').
'</em>';
2671 echo $options[$field];
2677 return $write_access;
2696 $posted_option = array_get_index($_POST[$prefix], $key, NULL);
2697 if (!is_array($posted_option))
return FALSE;
2699 if (isset($posted_option[
'standard_asset_field'])) {
2700 $group_by_option[
'field'] = $posted_option[
'standard_asset_field'];
2702 $group_by_option[
'sort_order'] = $posted_option[
'sort_order'];
2704 if (empty($posted_option[
'max_children'])) {
2705 $group_by_option[
'max_children'] = NULL;
2707 $group_by_option[
'max_children'] = $posted_option[
'max_children'];
2728 $write_access = $asset->writeAccess(
'attributes');
2730 $o->openField(translate(
'cms_listing_restrict_types'));
2732 if ($write_access) {
2733 asset_type_chooser($prefix.
'[restrict_types]', TRUE, array_get_index($group_by_option,
'restrict_types', Array()), NULL, FALSE, TRUE);
2735 if (empty($group_by_option[
'restrict_types'][
'type_code'])) {
2736 echo
'<i>'.translate(
'cms_listing_no_types_selected').
'</i>';
2738 ?><ul style=
"margin: 1px 15px"><?php
2739 $type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($group_by_option[
'restrict_types'][
'type_code'],
'name');
2741 foreach ($group_by_option[
'restrict_types'][
'type_code'] as $key => $type_code) {
2743 echo get_asset_type_icon($type_code);
2744 echo $type_names[$type_code];
2745 if ($group_by_option[
'restrict_types'][
'inherit'][$key]) {
2746 echo
' ('.strtolower(translate(
'cms_listing_inherits_child_types')).
')';
2754 $o->note(translate(
'cms_listing_group_asset_restriction_note'));
2758 $o->openField(
'Direct Parent Only ?');
2759 if ($write_access) {
2760 check_box($prefix.
'[direct_parent_only]',
'1', array_get_index($group_by_option,
'direct_parent_only', FALSE));
2761 label(
'Only list assets with direct parent that matches the Restricted Types', $prefix.
'[direct_parent_only]');
2764 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo array_get_index($group_by_option, 'direct_parent_only', FALSE) ? 'tick' : 'cross'; ?>.gif" width=
"15" height=
"15" />
2766 echo
'Only list assets with direct parent that matches the Restricted Types';
2770 $o->openField(translate(
'sort_by'));
2775 $sort_by_options[
'sorting_metadata_field'] =
'Metadata Field';
2776 $sort_by_options[
''] =
'-- '.translate(
'select').
' --';
2778 $current_option = array_get_index($group_by_option,
'sort_by',
'');
2780 if ($write_access) {
2781 combo_box($prefix.
'[sort_by]', $sort_by_options, FALSE, $current_option);
2782 if ($current_option ==
'sorting_metadata_field') {
2784 $field_assetid = array_get_index($group_by_option,
'sorting_metadata_field', 0);
2785 asset_finder($prefix.
'[sorting_metadata_field]',$field_assetid);
2787 $o->note(
'Select the order in which the parent assets should be displayed');
2790 if (empty($current_option)) {
2791 echo
'<i>'.translate(
'cms_listing_no_sorting_applied').
'</i>';
2793 echo $sort_by_options[$current_option];
2800 if (isset($group_by_option[
'sort_by']) && $group_by_option[
'sort_by'] ==
'sorting_metadata_field') {
2801 $o->openField(translate(
'cms_listing_default_metadata_sort_type'));
2803 $sort_by = array_get_index($group_by_option,
'metadata_sort_type',
'raw');
2805 'raw' => translate(
'cms_listing_raw_value'),
2806 'presentation' => translate(
'cms_listing_presentation_value'),
2809 if ($write_access) {
2810 combo_box($prefix.
'[metadata_sort_type]', $option, FALSE, $sort_by);
2812 echo ($sort_by ==
'raw') ? translate(
'cms_listing_raw_value') : translate(
'cms_listing_presentation_value');
2815 $o->note(translate(
'cms_listing_default_metadata_sort_type_note'));
2820 return $write_access;
2841 $posted_option = array_get_index($_POST[$prefix], $key, NULL);
2842 if (!is_array($posted_option))
return FALSE;
2844 if (isset($posted_option[
'restrict_types'])) {
2845 $group_by_option[
'restrict_types'] = $posted_option[
'restrict_types'];
2849 foreach ($group_by_option[
'restrict_types'][
'type_code'] as $key => $type_code) {
2850 if (empty($type_code)) {
2851 unset($group_by_option[
'restrict_types'][
'type_code'][$key]);
2852 unset($group_by_option[
'restrict_types'][
'inherit'][$key]);
2856 if (isset($posted_option[
'sorting_metadata_field'])) {
2857 $group_by_option[
'sorting_metadata_field'] = $posted_option[
'sorting_metadata_field'][
'assetid'];
2860 $group_by_option[
'direct_parent_only'] = array_get_index($posted_option,
'direct_parent_only', FALSE);
2861 $group_by_option[
'sort_by'] = $posted_option[
'sort_by'];
2862 $group_by_option[
'sort_order'] = $posted_option[
'sort_order'];
2864 if (isset($posted_option[
'metadata_sort_type'])) {
2865 $group_by_option[
'metadata_sort_type'] = $posted_option[
'metadata_sort_type'];
2868 if (empty($posted_option[
'max_children'])) {
2869 $group_by_option[
'max_children'] = NULL;
2871 $group_by_option[
'max_children'] = $posted_option[
'max_children'];
2893 $write_access = $asset->writeAccess(
'attributes');
2895 $o->openField(translate(
'keyword'));
2896 $keyword = array_get_index($group_by_option,
'keyword', NULL);
2897 if ($write_access) {
2898 text_box($prefix.
'[keyword]', $keyword, 10);
2900 if (is_null($keyword)) {
2901 echo
'<em>'.translate(
'cms_listing_no_keyword').
'</em>';
2908 return $write_access;
2927 $posted_option = array_get_index($_POST[$prefix], $key, NULL);
2928 if (!is_array($posted_option))
return FALSE;
2930 if (isset($posted_option[
'keyword'])) {
2931 $group_by_option[
'keyword'] = $posted_option[
'keyword'];
2933 $group_by_option[
'sort_order'] = $posted_option[
'sort_order'];
2935 if (empty($posted_option[
'max_children'])) {
2936 $group_by_option[
'max_children'] = NULL;
2938 $group_by_option[
'max_children'] = $posted_option[
'max_children'];
2958 if ($asset->writeAccess(
'attributes')) {
2959 $group_by = $asset->attr(
'asset_grouping');
2961 check_box($prefix.
'[new]');
2962 ?> Add a
new group level <?php
2963 $options = Array(0 =>
'at the top level');
2964 for ($i = 1; $i <= count($group_by); $i++) {
2965 $options[$i] =
'after group level '.$i;
2967 combo_box($prefix.
'[new_after]', $options, FALSE, count($group_by));
2971 '' =>
'-- '.translate(
'select').
' --',
2972 'parent_asset' => translate(
'cms_listing_parent_asset'),
2973 'metadata' => translate(
'asset_metadata'),
2974 'standard_asset' => translate(
'standard_asset_field'),
2975 'keyword' => translate(
'keyword'),
2978 combo_box($prefix.
'[new_type]', $options, FALSE,
'');
2982 return $asset->writeAccess(
'attributes');
2999 if ($asset->writeAccess(
'attributes')) {
3001 if (isset($_POST[$prefix][
'new'])) {
3003 $new_type = array_get_index($_POST[$prefix],
'new_type', NULL);
3004 $new_position = array_get_index($_POST[$prefix],
'new_after', NULL);
3006 if (!is_null($new_type) && !is_null($new_position)) {
3011 $posted_options = array_get_index($_POST, $prefix, Array());
3013 $group_by_options = $asset->attr(
'asset_grouping');
3015 foreach ($group_by_options as $key => $group_by_option) {
3016 if (isset($posted_options[$key][
'delete'])) {
3019 if ((
int)$key <= $new_position)$pos_adjust++;
3025 $new_position -= $pos_adjust;
3028 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
3029 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
3030 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
3031 $folder = $asset->getFolder(
'group_formats');
3034 $copy_link = Array(
'asset' => &$folder,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1,
'sort_order' => $new_position);
3037 $bodycopy->setAttrValue(
'name',
'Group Level '.($new_position+1).
' Format');
3038 $group_listing_data = Array(
'content' =>
'%group_listing%');
3040 if (!$bodycopy->create($copy_link, $group_listing_data)) {
3041 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
3042 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
3047 if (!$asset->writeAccess(
'attributes')) {
3048 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'attributes');
3052 $new_group = Array(Array(
'group_type' => $new_type,
'format_assetid' => $bodycopy->id));
3053 array_splice($group_by_options, $new_position, 0, $new_group);
3054 $asset->setAttrValue(
'asset_grouping', $group_by_options);
3057 $asset->reindexGroupFormats();
3058 if (!$asset->saveAttributes()) {
3059 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
3060 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
3065 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
3066 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
3091 $write_access = $asset->writeAccess(
'attributes');
3093 $selections = $asset->attr(
'asset_selections');
3094 $input_types = Array(
3095 'radio' => translate(
'cms_listing_radio_buttons'),
3096 'selection' => translate(
'cms_listing_drop_down_list'),
3097 'textbox' => translate(
'cms_listing_text_field'),
3099 $defaults = $asset->getAssetSelectionDefaults();
3102 foreach ($selections as $name => $settings) {
3104 <table
class=
"sq-backend-table">
3106 <th><?php echo $name; ?></th>
3107 <td
class=
"sq-backend-table-header" style=
"text-align: right;">
3109 hidden_field($prefix.
'_sel['.$name.
'][permanent]', array_get_index($settings,
'permanent', $defaults[
'permanent']));
3110 if ($write_access && !array_get_index($settings,
'permanent', $defaults[
'permanent'])) {
3111 check_box($prefix.
'_sel_delete['.$name.
']',
'1');
3112 label(translate(
'delete_question'), $prefix.
'_sel_delete['.$name.
']');
3118 <td><?php echo translate(
'cms_listing_input_style') ?></td>
3121 if ($write_access) {
3122 combo_box($prefix.
'_sel['.$name.
'][type]', $input_types, FALSE, array_get_index($settings,
'type', $defaults[
'type']));
3124 echo $input_types[array_get_index($settings,
'type', $defaults[
'type'])];
3130 <td><?php echo translate(
'options') ?></td>
3134 $options = array_get_index($settings,
'options', Array());
3137 <table style=
"width: 100%; border: 0;">
3141 if ($write_access) {
3142 check_box($prefix.
'_sel['.$name.
'][options][allow_multiple]',
'1', array_get_index($options,
'allow_multiple', $defaults[
'options'][
'allow_multiple']));
3143 label(translate(
'cms_listing_allow_multiple'), $prefix.
'_sel['.$name.
'][options][allow_multiple]');
3145 ?><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo (array_get_index($options, 'allow_multiple', $defaults['options']['allow_multiple']) ? 'tick' : 'cross'); ?>.gif" width=
"15" height=
"15" /><?php
3146 echo
' '.translate(
'cms_listing_allow_multiple');
3150 <td style=
"text-align: right;"><?php echo translate(
'cms_listing_radio_dd_only') ?></td>
3155 if ($write_access) {
3156 check_box($prefix.
'_sel['.$name.
'][options][allow_negative]',
'1', array_get_index($options,
'allow_negative', $defaults[
'options'][
'allow_negative']));
3157 label(translate(
'cms_listing_allow_negative_values'), $prefix.
'_sel['.$name.
'][options][allow_negative]');
3159 ?><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo (array_get_index($options, 'allow_negative', $defaults['options']['allow_negative']) ? 'tick' : 'cross'); ?>.gif" width=
"15" height=
"15" /><?php
3160 echo
' '.translate(
'cms_listing_allow_negative_values');
3164 <td style=
"text-align: right;"><?php echo translate(
'cms_listing_text_dd_only') ?></td>
3169 $restrict_range = array_get_index($options,
'restrict_range', Array());
3170 if ($write_access) {
3171 check_box($prefix.
'_sel['.$name.
'][options][restrict_range][enable]',
'1', array_get_index($restrict_range,
'enable', $defaults[
'options'][
'restrict_range'][
'enable']));
3172 label(translate(
'cms_listing_restrict_values_to_range').
':', $prefix.
'_sel['.$name.
'][options][restrict_range][enable]');
3174 ?><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo (array_get_index($restrict_range, 'enable', $defaults['options']['restrict_range']['enable']) ? 'tick' : 'cross'); ?>.gif" width=
"15" height=
"15" /><?php
3175 echo translate(
'cms_listing_restrict_values_to_range') ?>:<?php
3180 if ($write_access) {
3181 int_text_box($prefix.
'_sel['.$name.
'][options][restrict_range][min]', array_get_index($restrict_range,
'min', $defaults[
'options'][
'restrict_range'][
'min']), TRUE, 3);
3183 echo
'<strong>'.array_get_index($restrict_range,
'min', $defaults[
'options'][
'restrict_range'][
'min']).
'</strong>';
3185 $from_box = ob_get_contents();
3190 if ($write_access) {
3191 int_text_box($prefix.
'_sel['.$name.
'][options][restrict_range][max]', array_get_index($restrict_range,
'max', $defaults[
'options'][
'restrict_range'][
'max']), TRUE, 3);
3193 echo
'<strong>'.array_get_index($restrict_range,
'max', $defaults[
'options'][
'restrict_range'][
'max']).
'</strong>';
3195 $to_box = ob_get_contents();
3198 echo
' '.translate(
'cms_listing_from_to_range', $from_box, $to_box);
3201 <td style=
"text-align: right; vertical-align: top;">
3202 <?php echo translate(
'cms_listing_text_dd_only_dd_req') ?><br/>
3203 <?php echo translate(
'cms_listing_override_by_previous_options') ?>
3216 if ($write_access) {
3218 $o->openField(translate(
'cms_listing_add_new_selection_question'));
3220 text_box($prefix.
'_sel_new',
'');
3223 return $write_access;
3240 $write_access = $asset->writeAccess(
'attributes');
3242 if ($write_access) {
3243 $selections = $asset->attr(
'asset_selections');
3244 $defaults = $asset->getAssetSelectionDefaults();
3247 if (!empty($_POST[$prefix.
'_sel'])) {
3248 foreach ($_POST[$prefix.
'_sel'] as $name => $settings) {
3251 if (isset($selections[$name])) {
3253 $selections[$name] = array_merge_multi($defaults, $settings);
3255 $type = array_get_index($selections[$name],
'type', $defaults[
'type']);
3256 $options = array_get_index($selections[$name],
'options', $defaults[
'options']);
3257 $restrict_range = array_get_index($options,
'restrict_range', $defaults[
'options'][
'restrict_range']);
3261 if (array_get_index($options,
'allow_multiple', $defaults[
'options'][
'allow_multiple']) && ($type !=
'radio' && $type !=
'selection')) {
3262 $selections[$name][
'options'][
'allow_multiple'] = 0;
3266 if (array_get_index($options,
'allow_negative', $defaults[
'options'][
'allow_negative']) && $type !=
'textbox') {
3267 $selections[$name][
'options'][
'allow_negative'] = 0;
3271 if (array_get_index($restrict_range,
'enable', $defaults[
'options'][
'restrict_range'][
'enable']) && ($type !=
'textbox' && $type !=
'selection')) {
3272 $selections[$name][
'options'][
'restrict_range'][
'enable'] = 0;
3276 if ($type ==
'selection') {
3277 $selections[$name][
'options'][
'restrict_range'][
'enable'] = 1;
3281 if (array_get_index($restrict_range,
'min', $defaults[
'options'][
'restrict_range'][
'min']) < 0 && !array_get_index($options,
'allow_negative', $defaults[
'options'][
'allow_negative'])) {
3282 $selections[$name][
'options'][
'restrict_range'][
'min'] = 0;
3284 if (array_get_index($restrict_range,
'max', $defaults[
'options'][
'restrict_range'][
'max']) < 0 && !array_get_index($options,
'allow_negative', $defaults[
'options'][
'allow_negative'])) {
3285 $selections[$name][
'options'][
'restrict_range'][
'max'] = 0;
3289 if (array_get_index($restrict_range,
'min', $defaults[
'options'][
'restrict_range'][
'min']) > array_get_index($restrict_range,
'max', $defaults[
'options'][
'restrict_range'][
'max'])) {
3290 $selections[$name][
'options'][
'restrict_range'][
'min'] = array_get_index($restrict_range,
'max', $defaults[
'options'][
'restrict_range'][
'max']);
3299 if (!empty($_POST[$prefix.
'_sel_delete'])) {
3300 foreach ($_POST[$prefix.
'_sel_delete'] as $name => $value) {
3301 if (isset($selections[$name])) {
3302 unset($selections[$name]);
3307 if (!empty($_POST[$prefix.
'_sel_new'])) {
3309 $name = trim($_POST[$prefix.
'_sel_new']);
3310 $name = str_replace(
' ',
'_',$name);
3311 $name = str_replace(
'%',
'_',$name);
3313 $selections[$name] = $defaults;
3316 $asset->setAttrValue(
'asset_selections', $selections);
3320 return $write_access;
3337 $write_access = $asset->writeAccess(
'attributes');
3339 $targets = $asset->attr(
'asset_targets');
3340 $defaults = $asset->getAssetTargetDefaults();
3343 foreach ($targets as $name => $settings) {
3345 <table
class=
"sq-backend-table">
3347 <th><?php echo $name; ?></th>
3348 <td
class=
"sq-backend-table-header" style=
"text-align: right;">
3350 hidden_field($prefix.
'_target['.$name.
'][permanent]', array_get_index($settings,
'permanent', $defaults[
'permanent']));
3351 if ($write_access && !array_get_index($settings,
'permanent', $defaults[
'permanent'])) {
3352 check_box($prefix.
'_target_delete['.$name.
']',
'1');
3353 label(translate(
'delete_question'), $prefix.
'_target_delete['.$name.
']');
3359 <td><?php echo translate(
'cms_listing_button_label') ?>:</td>
3362 if ($write_access) {
3363 text_box($prefix.
'_target['.$name.
'][label]', array_get_index($settings,
'label', $defaults[
'label']));
3365 echo array_get_index($settings,
'label', $defaults[
'label']);
3371 <td><?php echo translate(
'cms_listing_target') ?>:</td>
3375 $assetid = array_get_index(array_get_index($settings,
'target_asset', $defaults[
'target_asset']),
'assetid', $defaults[
'target_asset'][
'assetid']);
3377 if ($write_access) {
3379 <table style=
"width: 100%; border: 0;">
3381 <td style=
"width: 100px"><?php echo translate(
'url') ?>:</td>
3382 <td><?php text_box($prefix.
'_target['.$name.
'][target_url]', array_get_index($settings,
'target_url', $defaults[
'target_url'])); ?></td>
3385 <td style=
"width: 100px"><?php echo translate(
'cms_listing_or_asset') ?>:</td>
3386 <td><?php asset_finder($prefix.
'_target['.$name.
'][target_asset]', $assetid); ?></td>
3393 if (!empty($settings[
'target_url'])) {
3396 <table style=
"width: 100%; border: 0;">
3398 <td style=
"width: 100px"><?php echo translate(
'url') ?>:</td>
3399 <td><?php echo array_get_index($settings,
'target_url', $defaults[
'target_url']); ?></td>
3404 }
else if (!empty($settings[
'target_asset'])) {
3407 <table style=
"width: 100%; border: 0;">
3409 <td style=
"width: 100px"><?php echo translate(
'asset') ?>:</td>
3412 echo get_asset_tag_line($assetid);
3431 if ($write_access) {
3433 $o->openField(translate(
'cms_listing_add_new_target_question'));
3435 text_box($prefix.
'_target_new',
'');
3438 return $write_access;
3455 $write_access = $asset->writeAccess(
'attributes');
3457 if ($write_access) {
3459 $targets = $asset->attr(
'asset_targets');
3460 $defaults = $asset->getAssetTargetDefaults();
3463 if (!empty($_POST[$prefix.
'_target'])) {
3464 foreach ($_POST[$prefix.
'_target'] as $name => $settings) {
3466 if (isset($targets[$name])) {
3467 $targets[$name] = array_merge_multi($defaults, $settings);
3470 if (!empty($targets[$name][
'target_url'])) {
3471 $targets[$name][
'target_asset'][
'assetid'] = 0;
3478 if (!empty($_POST[$prefix.
'_target_delete'])) {
3479 foreach ($_POST[$prefix.
'_target_delete'] as $name => $value) {
3480 if (isset($targets[$name])) unset($targets[$name]);
3485 if (!empty($_POST[$prefix.
'_target_new'])) {
3487 $name = trim($_POST[$prefix.
'_target_new']);
3488 $name = str_replace(
' ',
'_',$name);
3489 $name = str_replace(
'%',
'_',$name);
3491 $targets[$name] = $defaults;
3494 $asset->setAttrValue(
'asset_targets', $targets);
3497 return $write_access;
3514 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
3515 $write_access = $asset->writeAccess(
'attributes');
3517 $current = $asset->attr(
'statuses');
3519 if ($write_access) {
3520 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
3521 $statuses = get_constant_values(
'SQ_STATUS');
3523 foreach ($statuses as $constant => $value) {
3524 $options[$value] = get_status_description($value);
3527 combo_box($prefix.
'_statuses', $options, TRUE, $current);
3528 hidden_field($prefix.
'_statuses_submitted',
'1');
3530 if (empty($current)) {
3531 echo translate(
'cms_listing_no_status_selected');
3533 ?><ul style=
"margin: 1px 15px;"><?php
3534 foreach ($current as $status) {
3536 echo get_asset_status_icon($status);
3537 echo get_status_description($status);
3543 return $write_access;
3561 if (!$asset->writeAccess(
'attributes'))
return FALSE;
3564 if (!isset($_POST[$prefix.
'_statuses_submitted']))
return FALSE;
3566 $statuses = Array();
3569 if (isset($_POST[$prefix.
'_statuses'])) {
3570 foreach ($_POST[$prefix.
'_statuses'] as $status) {
3571 $statuses[] = $status;
3574 $statuses = array_unique($statuses);
3577 return $asset->setAttrValue(
'statuses', $statuses);
3594 $write_access = $asset->writeAccess(
'attributes');
3597 'read' => SQ_PERMISSION_READ,
3598 'write' => SQ_PERMISSION_WRITE,
3599 'admin' => SQ_PERMISSION_ADMIN,
3603 $perm_options = Array();
3604 foreach ($perms as $title => $perm) {
3605 $perm_options[$perm] = translate($title);
3607 $conf_perm = $asset->attr(
'list_permission');
3608 $conf_eff = $asset->attr(
'list_effective');
3610 if ($write_access) {
3611 combo_box($prefix.
'_permissions[list]', $perm_options, FALSE, $conf_perm);
3616 check_box($prefix.
'_permissions[effective]', 1, $conf_eff);
3617 label(translate(
'cms_listing_access_include_effective'), $prefix.
'_permissions[effective]');
3621 echo translate(
'cms_listing_access_effective_permission', $perm_options[$conf_perm]);
3623 echo $perm_options[$conf_perm];
3626 return $asset->writeAccess(
'attributes');
3644 if (!$asset->writeAccess(
'attributes'))
return FALSE;
3645 if (!isset($_POST[$prefix.
'_permissions']))
return FALSE;
3647 $permission = array_get_index($_POST[$prefix.
'_permissions'],
'list');
3648 $effective = array_get_index($_POST[$prefix.
'_permissions'],
'effective', 0);
3650 if (is_null($permission))
return FALSE;
3652 $asset->setAttrValue(
'list_permission', $permission);
3653 $asset->setAttrValue(
'list_effective', $effective);
3674 $types = $options[
'asset_types'];
3675 if ($asset->writeAccess(
'content')) {
3677 $display_values = Array(
'type_code' => Array(),
'inherit' => Array());
3678 foreach ($types as $type => $inherit) {
3679 $display_values[
'type_code'][] = $type;
3680 $display_values[
'inherit'][] = $inherit;
3682 asset_type_chooser($prefix.
'_structured_types', TRUE, $display_values, NULL, TRUE, TRUE);
3686 if (empty($types)) {
3687 echo
'<p class="sq-backend-warning">'.translate(
'cms_listing_no_asset_types_selected').
'</p>';
3689 $type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($types),
'name');
3691 <table
class=
"sq-backend-table">
3693 <th><?php echo translate(
'type') ?></th>
3694 <th><?php echo translate(
'inherit_question') ?></th>
3697 $inherit_image_path = sq_web_path(
'lib').
'/web/images/';
3698 foreach ($types as $type => $inherit) {
3699 $inherit_image = $inherit_image_path.($inherit ?
'tick' :
'cross').
'.gif';
3700 $inherit_alt = $inherit ? translate(
'yes') : translate(
'no');
3703 <td><?php echo $type_names[$type]; ?></td>
3704 <td><img src=
"<?php echo $inherit_image; ?>" alt=
"<?php echo $inherit_alt; ?>" /></td>
3734 if (!$asset->writeAccess(
'attributes'))
return FALSE;
3736 if (isset($_POST[$prefix.
'_structured_types'])) {
3737 $existing_types = $options[
'asset_types'];
3738 $submitted_types = Array();
3739 foreach ($_POST[$prefix.
'_structured_types'][
'type_code'] as $i => $type_code) {
3740 if (!empty($type_code)) {
3741 $submitted_types[$type_code] = $_POST[$prefix.
'_structured_types'][
'inherit'][$i];
3744 $options[
'asset_types'] = $submitted_types;
3745 $asset->setAttrValue(
'structured_dropdown_options', $options);
3766 $write_access = $asset->writeAccess(
'attributes');
3767 $options = $asset->attr(
'structured_dropdown_options');
3769 <table
class=
"sq-backend-table">
3771 <td
class=
"sq-backend-table-header">
3772 <?php echo translate(
'name') ?>:
3774 <td colspan=
"2" class=
"">
3776 if ($write_access) {
3777 text_box($prefix.
'_structured_name', $options[
'name']);
3779 echo $options[
'name'];
3782 <br /> *<?php echo translate(
'must_be_selected_dynamic_parameter'); ?>
3786 <td
class=
"sq-backend-table-header">
3787 <b><?php echo translate(
'root_node') ?>:</b>
3791 if ($write_access) {
3792 asset_finder($prefix.
'_structured_root', $options[
'root_node']);
3794 if ($options[
'root_node'] != 0) {
3795 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($options[
'root_node']));
3796 if (isset($asset_info[$options[
'root_node']][
'name'])) {
3797 echo get_asset_tag_line($options[
'root_node']);
3799 echo translate(
'core_no_selected_root_node');
3802 echo translate(
'core_no_selected_root_node');
3809 <td
class=
"sq-backend-table-header">
3810 <b><?php echo translate(
'depth') ?></b>
3813 <td
class=
"sq-backend-table-header">
3815 if ($write_access) {
3816 int_text_box($prefix.
'_structured_max_depth', $options[
'max_depth'], FALSE, 4, 0);
3818 echo ($options[
'max_depth'] ==
'0' ? translate(
'infinite').
' '.translate(
'depth') : $options[
'max_depth']);
3824 <td
class=
"sq-backend-table-header">
3825 <b><?php echo translate(
'asset_types') ?>:</b>
3827 <td colspan=
"2" class=
"">
3834 <td
class=
"sq-backend-table-header">
3835 <b><?php echo translate(
'style') ?></b>
3839 <?php
if ($write_access) {
3841 <select name=
"<?php echo $prefix.'_structured_input_style'; ?>">
3842 <option value=
"0" <?php echo $asset->attr(
'check_boxes')== 0 ?
'selected="selected"' :
''; ?> ><?php echo translate(
'dropdown_list'); ?></option>
3843 <option value=
"1" <?php echo $asset->attr(
'check_boxes')== 1 ?
'selected="selected"' :
''; ?> ><?php echo translate(
'radio_buttons'); ?></option>
3844 <option value=
"2" <?php echo $asset->attr(
'check_boxes')== 2 ?
'selected="selected"' :
''; ?> ><?php echo translate(
'check_boxes'); ?></option>
3847 echo $asset->attr(
'check_boxes') == 0 ? translate(
'dropdown_list') : $asset->attr(
'check_boxes') == 1 ? translate(
'radio_buttons') : translate(
'check_boxes');
3855 <td
class=
"sq-backend-table-header">
3856 <b><?php echo translate(
'width') ?></b>
3860 if ($write_access) {
3861 int_text_box($prefix.
'_structured_width', $options[
'width'], FALSE, 4, 0);
3863 echo $options[
'width'] == 0 ? translate(
'fit_to_contents') : $options[
'width'];
3869 <td
class=
"sq-backend-table-header">
3870 <b><?php echo translate(
'height') ?></b>
3874 if ($write_access) {
3875 int_text_box($prefix.
'_structured_height', $options[
'height'], FALSE, 4, 0);
3877 echo $options[
'height'] == 0 ? translate(
'not_specified') : $options[
'height'];
3883 <td
class=
"sq-backend-table-header">
3884 <b><?php echo translate(
'seperator') ?></b>
3889 if ($write_access) {
3890 text_box($prefix.
'_structured_seperator', $options[
'seperator'], FALSE, 10, 0);
3892 echo $options[
'seperator'];
3900 return $write_access;
3918 if (!$asset->writeAccess(
'attributes'))
return FALSE;
3921 $options = $asset->attr(
'structured_dropdown_options');
3925 if (isset($_REQUEST[$prefix.
'_structured_root'])) {
3926 $options[
'root_node'] = $_REQUEST[$prefix.
'_structured_root'][
'assetid'];
3931 if (isset($_REQUEST[$prefix.
'_structured_name'])) {
3932 $options[
'name'] = $_REQUEST[$prefix.
'_structured_name'];
3934 if (isset($_REQUEST[$prefix.
'_structured_width'])) {
3935 $options[
'width'] = $_REQUEST[$prefix.
'_structured_width'];
3937 if (isset($_REQUEST[$prefix.
'_structured_height'])) {
3938 $options[
'height'] = $_REQUEST[$prefix.
'_structured_height'];
3940 if (isset($_REQUEST[$prefix.
'_structured_max_depth'])) {
3941 $options[
'max_depth'] = $_REQUEST[$prefix.
'_structured_max_depth'];
3943 if (isset($_REQUEST[$prefix.
'_structured_seperator'])) {
3944 $options[
'seperator'] = $_REQUEST[$prefix.
'_structured_seperator'];
3946 if (isset($_REQUEST[$prefix.
'_structured_input_style'])) {
3947 $asset->setAttrValue(
'check_boxes', $_REQUEST[$prefix.
'_structured_input_style']);
3950 $asset->setAttrValue(
'structured_dropdown_options', $options);
3969 return ($asset->attr(
'group_by') ==
'letter');
3989 $write_access = $asset->writeAccess(
'links');
3990 $bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_TYPE_2,
'bodycopy', FALSE,
'no_results');
3991 $enabled = !empty($bodycopy_link);
3993 if ($write_access) {
3995 '1' => translate(
'yes'),
3996 '0' => translate(
'no'),
3999 combo_box($prefix.
'_use_bodycopy', $options, FALSE, Array($enabled));
4003 echo translate(
'yes').
' - '.get_asset_tag_line($bodycopy_link[
'minorid'],
'contents');
4005 echo translate(
'no');
4009 return $write_access;
4026 if (!$asset->writeAccess(
'links'))
return FALSE;
4027 $enabled = $_POST[$prefix.
'_use_bodycopy'];
4029 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
4030 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
4032 if (!$asset->setUseNoResultsBodycopy($enabled)) {
4033 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
4034 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
4038 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
4039 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
4060 $write_access = $asset->writeAccess(
'attributes');
4061 $current_types = $asset->attr(
'proxy_types');
4063 $am = $GLOBALS[
'SQ_SYSTEM']->am;
4065 $o->openField(translate(
'cms_listing_proxy_asset_types'));
4066 if (empty($current_types)) {
4067 echo translate(
'cms_listing_no_types_defined');
4070 <table
class=
"sq-backend-table">
4072 <td
class=
"sq-backend-table-header" style=
"width: 200px;"><?php echo translate(
'cms_listing_proxy_type_code') ?></td>
4073 <td
class=
"sq-backend-table-header"><?php echo translate(
'cms_listing_proxy_child_type_codes') ?></td>
4075 if ($write_access) {
4076 ?><td
class=
"sq-backend-table-header" style=
"width: 20px;"><?php echo translate(
'delete') ?></td><?php
4082 foreach ($current_types as $current_type => $type_settings) {
4085 <td
class=
"sq_backend-data"><?php
4086 echo get_asset_type_icon($current_type);
4087 echo $am->getTypeInfo($current_type,
'name');
4089 <td
class=
"sq_backend-data"><?php
4090 if ($write_access) {
4093 foreach ($type_settings as $type_code => $inherit) {
4094 $options[
'type_code'][$i] = $type_code;
4095 $options[
'inherit'][$i] = $inherit;
4098 asset_type_chooser($prefix.
'_'.$current_type.
'_children', TRUE, $options, NULL, TRUE, TRUE);
4100 $type_names = $am->getTypeInfo(array_keys($type_settings),
'name');
4101 ?><ul style=
"margin: 1px 15px"><?php
4102 foreach ($type_settings as $type_code => $inherits) {
4104 echo get_asset_type_icon($type_code);
4105 echo $type_names[$type_code];
4107 echo
' ('.strtolower(translate(
'cms_listing_inherits_child_types')).
')';
4115 if ($write_access) {
4116 ?><td
class=
"sq_backend-data"><?php check_box($prefix.
'_'.$current_type.
'_delete'); ?></td><?php
4128 $search_types = array_keys($asset->attr(
'types'));
4129 if ($write_access && !empty($search_types)) {
4130 $o->openField(translate(
'cms_listing_proxy_type_code_new'));
4131 $types = array_diff($search_types, array_keys($current_types));
4133 if (empty($types)) {
4134 echo translate(
'cms_listing_proxy_all_types_selected');
4137 $options = Array(
'' =>
'');
4138 $options += $am->getTypeInfo($types,
'name');
4139 combo_box($prefix.
'_new_type', $options, FALSE, count($types));
4144 return $write_access;
4161 $current_types = $asset->attr(
'proxy_types');
4163 foreach ($current_types as $current_type => $type_settings) {
4165 if (isset($_REQUEST[$prefix.
'_'.$current_type.
'_delete'])) {
4166 unset($current_types[$current_type]);
4171 if (!empty($_REQUEST[$prefix.
'_'.$current_type.
'_children'])) {
4172 $children = $_REQUEST[$prefix.
'_'.$current_type.
'_children'];
4174 $current_types[$current_type] = Array();
4175 foreach ($children[
'type_code'] as $index => $type_code) {
4176 if (empty($type_code))
continue;
4177 $current_types[$current_type][$type_code] = (empty($children[
'inherit'][$index])) ? FALSE : TRUE;
4181 $current_types[$current_type][
'children'] = Array();
4185 if (!empty($_REQUEST[$prefix.
'_new_type'])) {
4186 $current_types[$_REQUEST[$prefix.
'_new_type']] = Array();
4189 return $asset->setAttrValue(
'proxy_types', $current_types);
4206 $write_access = $asset->writeAccess(
'attributes');
4208 $exclude_assets = $asset->attr(
'exclude_assets');
4210 if ($write_access) {
4211 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
4213 multiple_asset_finder($prefix.
'_exclude_asset', $exclude_assets);
4216 foreach ($exclude_assets as $index => $assetid) {
4217 echo
'<li>'.get_asset_tag_line($assetid).
'</li>';
4222 return $write_access;
4242 if (!$asset->writeAccess(
'attributes'))
return FALSE;
4243 if (empty($_POST[$prefix.
'_exclude_asset']))
return FALSE;
4245 $exclude_assets = $_POST[$prefix.
'_exclude_asset'];
4246 $save_exclude_assets = Array();
4247 foreach ($exclude_assets as $index => $asset_info) {
4248 if (!empty($asset_info[
'assetid'])) {
4249 $save_exclude_assets[] = $asset_info[
'assetid'];
4253 return $asset->setAttrValue(
'exclude_assets', $save_exclude_assets);
4272 $write_access = $asset->writeAccess(
'attributes');
4274 $exclude_assets = $asset->attr(
'exclude_root_nodes');
4276 if ($write_access) {
4277 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
4279 multiple_asset_finder($prefix.
'_exclude_root_node', $exclude_assets);
4282 foreach ($exclude_assets as $index => $assetid) {
4283 echo
'<li>'.get_asset_tag_line($assetid).
'</li>';
4288 return $write_access;
4306 if (!$asset->writeAccess(
'attributes'))
return FALSE;
4307 if (empty($_POST[$prefix.
'_exclude_root_node']))
return FALSE;
4309 $exclude_assets = $_POST[$prefix.
'_exclude_root_node'];
4310 $save_exclude_assets = Array();
4311 foreach ($exclude_assets as $index => $asset_info) {
4312 if (!empty($asset_info[
'assetid'])) {
4313 $save_exclude_assets[] = $asset_info[
'assetid'];
4317 return $asset->setAttrValue(
'exclude_root_nodes', $save_exclude_assets);