18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page_edit_fns.inc';
42 parent::__construct();
57 if ($asset->writeAccess(
'attributes')) {
58 multiple_asset_finder($prefix.
'_event_sources', array_keys($asset->attr(
'root_nodes')));
61 $infos = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($asset->attr(
'root_nodes')),
'', TRUE,
'name');
62 ?><ul style=
"margin: 1px 15px;"><?php
63 foreach ($infos as $id => $name) {
64 echo
'<li>'.get_asset_tag_line($id).
'</li>';
85 if (isset($_POST[$prefix.
'_event_sources'])) {
86 $root_nodes = Array();
87 foreach ($_POST[$prefix.
'_event_sources'] as $source) {
88 if (!empty($source[
'assetid'])) {
89 $root_nodes[$source[
'assetid']] = 1;
92 return $asset->setAttrValue(
'root_nodes', $root_nodes);
117 $write_access = $asset->writeAccess(
'attributes');
118 $success = $write_access;
120 $o->openField(translate(
'cal_rolling_time_frame_time_unit'));
121 $dt_select_contents = Array(
122 'days' => translate(
'days'),
123 'weeks' => translate(
'weeks'),
124 'months' => translate(
'months'),
128 <script type=
"text/javascript">
129 function changeTimeUnitTextfield(value)
131 document.getElementById(<?php echo
'"'.$prefix.
'_time_unit_select_duration_from"'; ?>).value=value;
132 document.getElementById(<?php echo
'"'.$prefix.
'_time_unit_select_duration_to"'; ?>).value=value;
137 combo_box($prefix.
'_time_unit_select', $dt_select_contents, FALSE, $asset->attr(
'time_unit'), 0,
'onchange="changeTimeUnitTextfield(this.value)"');
139 echo ucwords($dt_select_contents[$asset->attr(
'time_unit')]);
143 $o->openField(translate(
'cal_rolling_time_frame_from'));
144 $success = $this->
_paintDaySelect($asset, $prefix,
'duration_from') && $success;
146 $o->openField(translate(
'cal_rolling_time_frame_to'));
147 $success = $this->
_paintDaySelect($asset, $prefix,
'duration_to') && $success;
148 $o->note(translate(
'cal_rolling_duration_from_to_note'));
168 $time_unit_val = array_get_index($_REQUEST, $prefix.
'_time_unit_select');
169 return (($asset->setAttrValue(
'time_unit', $time_unit_val)) &&
259 $write_access = $asset->writeAccess(
'attributes');
261 $dt_select_contents = Array (
262 'days' => translate(
'days'),
263 'weeks' => translate(
'weeks'),
264 'months' => translate(
'months'),
267 $pf_select_contents = Array(
268 'duration_past' => translate(
'cal_rolling_duration_past_combo'),
269 'duration_future' => translate(
'cal_rolling_duration_future_combo'),
274 $attr_val = $asset->attr($attr);
275 $text_val = abs($attr_val);
276 $combo_val = ($attr_val < 0 ?
'duration_past' :
'duration_future');
279 int_text_box($prefix.
'_'.$attr, $text_val, FALSE, 2);
280 text_box($prefix.
'_time_unit_select_'.$attr, $asset->attr(
'time_unit'),
'5',
'', FALSE,
'disabled');
281 combo_box($prefix.
'_pastfuture_select_'.$attr, $pf_select_contents, FALSE, $combo_val);
283 echo translate(
'cal_rolling_'.$combo_val, $text_val, $asset->attr(
'time_unit'));
286 return $write_access;
303 if ($asset->writeAccess(
'attributes')) {
304 $text_val = abs(array_get_index($_REQUEST, $prefix.
'_'.$attr, 0));
305 $select_val = array_get_index($_REQUEST, $prefix.
'_pastfuture_select_'.$attr,
'duration_future');
307 $attr_val = ($select_val ==
'duration_past' ? ($text_val * -1) : $text_val);
308 return $asset->setAttrValue($attr, $attr_val);
329 <table
class=
"sq-backend-table">
331 <th><?php echo translate(
'edit_format') ?></th>
332 <th><?php echo translate(
'note') ?></th>
358 function _paintDefaultFormatLink($root_assetid, $bodycopy_name, $bodycopy_description, $type_code=
'bodycopy', $screen=
'contents')
360 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($root_assetid, SQ_LINK_TYPE_2, $type_code, TRUE, $bodycopy_name);
362 $info = Array($link[
'minorid'] =>
'contents');
363 $href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($info);
367 <?php echo get_asset_tag_line($link[
'minorid'], $screen); ?>
370 <?php echo $bodycopy_description; ?>
391 $write_access = $asset->writeAccess(
'links');
393 $formats = $asset->getFormats(
'type_formats');
394 if (count($formats) > 0) {
396 <table
class=
"sq-backend-table">
398 <th><?php echo translate(
'asset_type') ?></th>
399 <th><?php echo translate(
'edit_format') ?></th>
403 <th><?php echo translate(
'delete_question') ?></th>
409 foreach ($formats as $minorid => $value) {
410 if ($value ==
'default_format')
continue;
412 $info = Array($minorid =>
'contents');
413 $href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($info);
414 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($value,
'name');
417 <td style=
"width: 200px;">
419 echo get_asset_type_icon($value);
425 echo get_asset_tag_line($minorid,
'contents');
431 <td style=
"width: 100px;">
433 check_box($prefix.
'_delete_type['.$value.
']');
446 echo translate(
'calendar_rolling_no_type_formats');
450 $new_format_options = Array(
'' =>
'');
451 foreach ($types as $type => $inherit) {
452 if (in_array($type, $formats))
continue;
453 $new_format_options[$type] = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type,
'name');
455 if (count($new_format_options) > 0) {
456 echo
'<p><b>'.translate(
'calendar_rolling_new_type_format').
'</b> ';
457 combo_box($prefix.
'_new_type', $new_format_options, FALSE,
'');
462 return $write_access;
479 $folder = $asset->getFolder(
'type_formats');
482 $deleted_formats = array_get_index($_POST, $prefix.
'_delete_type', Array());
483 $new_type = array_get_index($_POST, $prefix.
'_new_type',
'');
484 if (isset($deleted_formats[$new_type])) {
485 trigger_localised_error(
'CMS0042', E_USER_WARNING, $new_type);
486 unset($deleted_formats[$new_type]);
490 foreach ($deleted_formats as $type => $on) {
491 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $type);
492 if (empty($current_link)) {
493 trigger_localised_error(
'CMS0043', E_USER_WARNING, $type);
495 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($current_link[
'linkid'])) {
496 trigger_localised_error(
'CMS0044', E_USER_WARNING, $type);
502 if ($new_type !=
'' && !isset($types[$new_type])) {
503 trigger_localised_error(
'CMS0045', E_USER_WARNING, $new_type);
507 if ($new_type !=
'') {
509 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $new_type);
510 if (empty($current_link)) {
512 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
513 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
514 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
516 $copy_link = Array(
'asset' => &$folder,
'value' => $new_type,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
519 $bodycopy->setAttrValue(
'name', $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($new_type,
'name').
' Format');
521 if (!$bodycopy->create($copy_link)) {
522 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
523 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
526 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
527 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
529 trigger_localised_error(
'CMS0046', E_USER_WARNING, $new_type);
532 if (isset($asset->_tmp[
'formats'][
'type_formats'])) {
533 unset($asset->_tmp[
'formats'][
'type_formats']);
556 $write_access = $asset->writeAccess(
'links');
557 $bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_TYPE_2,
'bodycopy', FALSE,
'no_results');
558 $enabled = !empty($bodycopy_link);
562 '1' => translate(
'yes'),
563 '0' => translate(
'no'),
566 combo_box($prefix.
'_use_bodycopy', $options, FALSE, Array($enabled));
570 echo translate(
'yes').
' - '.get_asset_tag_line($bodycopy_link[
'minorid'],
'contents');
572 echo translate(
'no');
576 return $write_access;
593 if (!$asset->writeAccess(
'links'))
return FALSE;
594 $enabled = $_POST[$prefix.
'_use_bodycopy'];
596 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
597 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
599 if (!$asset->setUseNoResultsBodycopy($enabled)) {
600 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
601 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
605 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
606 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
623 $types = $asset->attr(
'types');
626 foreach ($types as $base_asset_type => $inherit) {
627 $descendents = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($base_asset_type);
629 if (is_array($descendents) && (count($descendents) > 0)) {
630 foreach ($descendents as $descendent_type) {
631 $types[$descendent_type] = 0;