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);
112 <table
class=
"sq-backend-table">
114 <th><?php echo translate(
'edit_format') ?></th>
115 <th><?php echo translate(
'note') ?></th>
118 $this->
_paintDefaultFormatLink($asset->id,
'page_contents', translate(
'calendar_upcoming_events_page_contents_desc'));
140 function _paintDefaultFormatLink($root_assetid, $bodycopy_name, $bodycopy_description, $type_code=
'bodycopy', $screen=
'contents')
142 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($root_assetid, SQ_LINK_TYPE_2, $type_code, TRUE, $bodycopy_name);
144 $info = Array($link[
'minorid'] =>
'contents');
145 $href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($info);
149 <?php echo get_asset_tag_line($link[
'minorid'], $screen); ?>
152 <?php echo $bodycopy_description; ?>
173 $write_access = $asset->writeAccess(
'links');
175 $formats = $asset->getFormats(
'type_formats');
176 if (count($formats) > 0) {
178 <table
class=
"sq-backend-table">
180 <th><?php echo translate(
'asset_type') ?></th>
181 <th><?php echo translate(
'edit_format') ?></th>
185 <th><?php echo translate(
'delete_question') ?></th>
191 foreach ($formats as $minorid => $value) {
192 if ($value ==
'default_format')
continue;
194 $info = Array($minorid =>
'contents');
195 $href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($info);
196 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($value,
'name');
199 <td style=
"width: 200px;">
201 echo get_asset_type_icon($value);
207 echo get_asset_tag_line($minorid,
'contents');
213 <td style=
"width: 100px;">
215 check_box($prefix.
'_delete_type['.$value.
']');
228 echo translate(
'calendar_upcoming_events_no_type_formats');
232 $new_format_options = Array(
'' =>
'');
233 foreach ($types as $type => $inherit) {
234 if (in_array($type, $formats))
continue;
235 $new_format_options[$type] = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type,
'name');
237 if (count($new_format_options) > 0) {
238 echo
'<p><b>'.translate(
'calendar_upcoming_events_new_type_format').
'</b> ';
239 combo_box($prefix.
'_new_type', $new_format_options, FALSE,
'');
244 return $write_access;
261 $folder = $asset->getFolder(
'type_formats');
264 $deleted_formats = array_get_index($_POST, $prefix.
'_delete_type', Array());
265 $new_type = array_get_index($_POST, $prefix.
'_new_type',
'');
266 if (isset($deleted_formats[$new_type])) {
267 trigger_localised_error(
'CMS0042', E_USER_WARNING, $new_type);
268 unset($deleted_formats[$new_type]);
272 foreach ($deleted_formats as $type => $on) {
273 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $type);
274 if (empty($current_link)) {
275 trigger_localised_error(
'CMS0043', E_USER_WARNING, $type);
277 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($current_link[
'linkid'])) {
278 trigger_localised_error(
'CMS0044', E_USER_WARNING, $type);
284 if ($new_type !=
'' && !isset($types[$new_type])) {
285 trigger_localised_error(
'CMS0045', E_USER_WARNING, $new_type);
289 if ($new_type !=
'') {
291 $current_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($folder->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE, $new_type);
292 if (empty($current_link)) {
294 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
295 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
296 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
298 $copy_link = Array(
'asset' => &$folder,
'value' => $new_type,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
301 $bodycopy->setAttrValue(
'name', $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($new_type,
'name').
' Format');
303 if (!$bodycopy->create($copy_link)) {
304 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
305 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
308 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
309 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
311 trigger_localised_error(
'CMS0046', E_USER_WARNING, $new_type);
314 if (isset($asset->_tmp[
'formats'][
'type_formats'])) {
315 unset($asset->_tmp[
'formats'][
'type_formats']);
336 $types = $asset->attr(
'types');
339 foreach ($types as $base_asset_type => $inherit) {
340 $descendents = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($base_asset_type);
342 if (is_array($descendents) && (count($descendents) > 0)) {
343 foreach ($descendents as $descendent_type) {
344 $types[$descendent_type] = 0;