18 require_once SQ_CORE_PACKAGE_PATH.
'/content_type/content_type_edit_fns.inc';
41 parent::__construct();
57 if ($asset->writeAccess(
'links') && $asset->writeAccess(
'attributes')) {
60 if (!is_null($nested_asset)) {
61 $paint_with = $asset->attr(
'paint_with');
63 $paint_layout_id = (is_null($arbitrary_paint_layout)) ? 0 : $arbitrary_paint_layout->id;
64 $asset_link = $GLOBALS[
'SQ_SYSTEM']->am->getAssetURL($nested_asset->id);
65 if (empty($asset_link)) {
66 $asset_link = strip_url(current_url(FALSE, TRUE)).
'/?a='.$nested_asset->id;
69 <table
class=
"sq-backend-table">
71 <td
class=
"sq-backend-table-cell-alt"><b><?php echo translate(
'cms_ct_nest_content_currently_nesting', $nested_asset->attr(
'name')) ?><?php require_once SQ_INCLUDE_PATH.
'/general.inc'; echo
' : '.get_asset_tag_line($nested_asset->id);?></b></td>
74 <td
class=
"sq-backend-table-cell"><?php asset_finder($prefix.
'_nested_assetid', $nested_asset->id, Array(
'asset' =>
'D')); ?></td>
77 <td
class=
"sq-backend-table-cell"><b><a href=
"<?php echo $asset_link; ?>" id=
"sq_preview_new_window" target=
"_blank"><?php echo translate(
'cms_ct_nest_content_click_to_preview') ?></a></b></td>
80 <td
class=
"sq-backend-table-cell-alt"><b>Dynamic Options:</b></td>
83 <td
class=
"sq-backend-table-cell">
92 <th>GET Variable Name</th>
97 <td>
Asset ID to nest the contents of:</td>
98 <td><?php text_box($prefix.
'_dynamic_nest_get', $asset->attr(
'dynamic_nest_get'), 30) ?></td>
105 <td
class=
"sq-backend-table-cell-alt"><b>Paint
this asset:</b></td>
108 <td
class=
"sq-backend-table-cell">
110 radio_button($prefix.
'_paint_with',
'raw', ($paint_with ==
'raw' ? 1 : 0));
111 label(
'Raw (no Paint Layout)', $prefix.
'_paint_with_raw');
114 radio_button($prefix.
'_paint_with',
'default', ($paint_with ==
'default' ? 1 : 0));
115 label(
'Using default Paint Layout (based on lookup rules)', $prefix.
'_paint_with_default');
118 radio_button($prefix.
'_paint_with',
'arbitrary', ($paint_with ==
'arbitrary' ? 1 : 0));
119 label(
'Using an arbitrary Paint Layout: ', $prefix.
'_paint_with_arbitrary');
120 asset_finder($prefix.
'_paint_with_layout', $paint_layout_id, Array(
'paint_layout_page' =>
'D'));
125 <td
class=
"sq-backend-table-cell-alt"><b>Send the following additional GET variables to the asset:</b></td>
128 <td
class=
"sq-backend-table-cell">
132 sq_print_icon(sq_web_path(
'data').
'/asset_types/bodycopy/images/icons/delete.png', 16, 16, translate(
'delete'), translate(
'delete'),
' style="border:none"');
133 $delete_icon = ob_get_clean();
134 $delete_icon = str_replace(
"\n",
' ', $delete_icon);
136 $additional_get_vars = $asset->attr(
'additional_get');
137 if (empty($additional_get_vars)) {
141 $last_key = max(array_keys($additional_get_vars));
144 <script type=
"text/javascript">
145 if (typeof <?php echo $asset->type() ?> ==
'undefined') {
146 <?php echo $asset->type() ?> = {
152 addGetRow:
function(prefix) {
153 node = document.getElementById(prefix +
'_additional_get_body');
154 index = this.nextIndex[prefix];
157 tr = document.createElement(
'tr');
158 tr.id = prefix +
'_additional_get_row_' + index;
161 td1 = document.createElement(
'td');
162 td1.innerHTML =
'<?php text_box("' + prefix +
'_additional_get[' + index +
'][name]", '', 20) ?>';
163 td2 = document.createElement(
'td');
164 td2.innerHTML =
'<?php text_box("' + prefix +
'_additional_get[' + index +
'][value]", '', 30) ?>'
165 td3 = document.createElement(
'td');
166 td3.innerHTML =
'<a href="" onclick="<?php echo $asset->type() ?>.removeGetRow(\'' + prefix +
'\', \
'' + index +
'\');
return false;
"><?php echo $delete_icon; ?></a>';
168 // Now put them all together
172 node.appendChild(tr);
175 this.nextIndex[prefix]++;
177 // Update display of "no variable
" status
178 this.updateNoVarStatus(prefix);
184 removeGetRow: function(prefix, index) {
185 node = document.getElementById(prefix + '_additional_get_row_' + index);
186 node.parentNode.removeChild(node);
187 this.updateNoVarStatus(prefix);
191 * Updates display of the "no variable
" body.
193 updateNoVarStatus: function(prefix) {
194 node = document.getElementById(prefix + '_additional_get_body');
195 var noVarBody = document.getElementById(prefix + '_additional_get_none');
196 noVarBody.style.display = (node.getElementsByTagName('tr').length > 0) ? 'none' : 'block';
201 // Set the first new index for newly created rows
202 <?php echo $asset->type(); ?>.nextIndex['<?php echo $prefix; ?>'] = <?php echo ($last_key + 1); ?>;
212 <th>Variable Name</th>
213 <th>Variable Value</th>
214 <th><span style="white-space: nowrap
"><?php echo translate('delete_question') ?></span></th>
219 <td colspan="3
"><a href="" onclick="<?php echo $asset->type() ?>.addGetRow(
'<?php echo $prefix ?>');
return false;
" id="<?php echo $prefix ?>_additional_get_new_row
"><?php echo translate('cms_ct_nest_content_additional_get_add'); ?></a></td>
222 <td colspan="3
">You can use keywords of the form <strong>%nested_asset_*%</strong> to refer to any of the keywords of the asset<br/>being nested. You can also use global keywords (<strong>%globals_*%</strong>). These will be evaluated upon asset load.</td>
225 <tbody id="<?php echo $prefix ?>_additional_get_none
" style="display: <?php echo empty($additional_get_vars) ?
'table-row-group' :
'none' ?>
">
227 <td colspan="3
"><em><?php echo translate('cms_ct_nest_content_additional_get_no_variables'); ?></em></td>
230 <tbody id="<?php echo $prefix ?>_additional_get_body
">
232 foreach ($additional_get_vars as $key => $var_info) {
234 <tr id="<?php echo $prefix; ?>_additional_get_row_<?php echo $key; ?>
">
235 <td><?php text_box($prefix.'_additional_get['.$key.'][name]', $var_info['name'], 20) ?></td>
236 <td><?php text_box($prefix.'_additional_get['.$key.'][value]', $var_info['value'], 30) ?></td>
237 <td><a href="" onclick="<?php echo $asset->type() ?>.removeGetRow(
'<?php echo $prefix; ?>',
'<?php echo $key; ?>');
return false;
"><?php echo $delete_icon; ?></a></td>
250 <table class="sq-backend-table
">
252 <td class="sq-backend-table-cell-alt
"><b><?php echo translate('cms_ct_nest_content_no_page_selected'); ?></b></td>
255 <td class="sq-backend-table-cell
"><?php asset_finder($prefix.'_nested_assetid', '', Array('asset' => 'D')); ?></td>
264 }//end paintBackend()
278 function paint(&$asset, $editing=FALSE, $generating=FALSE)
280 // get the asset - we can't pass the type in because it could be anything
281 // we also mute errors because we check later on
282 $nested_asset = $this->_getNestedAsset($asset);
283 if (is_null($nested_asset)) return FALSE;
286 $this->paintGenerated($asset, $nested_asset);
291 // We are in the edit interface, so just print a link
292 $asset_link = $GLOBALS['SQ_SYSTEM']->am->getAssetURL($nested_asset->id);
293 if (empty($asset_link)) {
294 $asset_link = strip_url(current_url(FALSE, TRUE)).'/?a='.$nested_asset->id;
296 $asset_contents = '<strong>'.translate('cms_ct_nest_content_nested_content').get_asset_tag_line($nested_asset->id).'</strong> <a href="'.$asset_link.'" id="sq_preview_new_window
" target="_blank
">'.translate('cms_ct_nest_content_click_to_preview').'</a>.';
298 $asset_contents = '';
299 // This is the real deal, so we want to actually print the asset
301 // Check for recursion
302 // We use the cache key where available to distinguish differently-behaving
303 // copies of the same asset (Bug Fix #1601)
304 $asset_cache_key = $nested_asset->id;
305 if (method_exists($nested_asset, '_getCacheKey')) {
306 $asset_cache_key .= $nested_asset->_getCacheKey();
309 // Add GET vars to the cache key, as these will
310 $additional_get_vars = $this->_processAdditionalGetVars($asset, $nested_asset);
311 $asset_cache_key .= '-'.md5(serialize($additional_get_vars));
313 if (isset($GLOBALS['SQ_NEST_CONTENT_PAINTED'][$asset_cache_key])) {
314 unset($GLOBALS['SQ_NEST_CONTENT_PAINTED'][$asset_cache_key]);
315 echo '<span class="sq-backend-warning
"><b>[ ** '.translate('cms_ct_nest_content_recursion_warning').' ** ]<br/>'.translate('cms_ct_nest_content_recursion_body').'</b></span>';
319 // Now do the additional GET vars stuff
321 $_GET = array_merge($_GET, $additional_get_vars);
323 // Record that we have printed this asset
324 // OKAY! so we havn't actually printed it yet, but we need to record that
325 // we have or we might just fall endlessly into printBody functions and
326 // never get back here again
327 $GLOBALS['SQ_NEST_CONTENT_PAINTED'][$asset_cache_key] = 1;
329 // Ask the asset to do its thing
331 switch ($asset->attr('paint_with')) {
333 // Raw - just paint it
334 $nested_asset->printBody();
338 // Default Rules - use the "normal
" method of determining
339 // which paint layout gets used
340 $nested_asset->printBodyWithPaintLayout();
344 // Get the arbitary paint layout; if there is none set,
345 // paint it raw, otherwise paint it with the arbitrary layout
346 $arbitrary_paint_layout = $this->_getArbitraryPaintLayout($asset);
347 if (empty($arbitrary_paint_layout)) {
348 $nested_asset->printBody();
350 $nested_asset->printBodyWithPaintLayout($arbitrary_paint_layout->id);
355 $asset_contents = ob_get_contents();
358 $keywords = extract_keywords($asset_contents);
359 $replacements = Array();
360 foreach ($keywords as $idx => $keyword) {
361 if (strpos($keyword, 'nested_get_') === 0) {
362 $sub_keyword = substr($keyword, 11);
363 $replacements[$keyword] = array_get_index($_GET, $sub_keyword, '');
367 replace_keywords($asset_contents, $replacements);
371 unset($GLOBALS['SQ_NEST_CONTENT_PAINTED'][$asset_cache_key]);
374 echo $asset_contents;
390 function paintGenerated(&$asset, &$nested_asset)
392 $additional_get_vars = $asset->attr('additional_get');
393 $get_var_cache_key = md5(serialize($additional_get_vars));
394 echo '<'.'?php'."\n
";
397 if (isset($_GET['<?php echo $asset->attr('dynamic_nest_get'); ?>'])) {
398 $nested_assetid = $_GET['<?php echo $asset->attr('dynamic_nest_get'); ?>'];
399 $nested_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($nested_assetid, '', TRUE);
400 if ($nested_asset == null) {
401 $nested_assetid = '<?php echo $nested_asset->id; ?>';
402 $nested_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($nested_assetid);
405 $nested_assetid = '<?php echo $nested_asset->id; ?>';
406 $nested_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($nested_assetid);
408 $nesting_assetid = '<?php echo $asset->id; ?>';
409 $temp_parent_array = $GLOBALS['SQ_SYSTEM']->am->getDependantParents($nesting_assetid, '' , TRUE, FALSE);
410 $parents_nesting_asset_id = $temp_parent_array[0];
411 $parents_nesting_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($parents_nesting_asset_id);
413 $asset_cache_key = $nested_assetid.'-<?php echo $get_var_cache_key; ?>';
414 if (method_exists($nested_asset, '_getCacheKey')) {
415 $asset_cache_key .= $nested_asset->_getCacheKey();
418 if (!isset($GLOBALS['SQ_NEST_CONTENT_PAINTED'])) $GLOBALS['SQ_NEST_CONTENT_PAINTED'] = Array();
419 if (!isset($GLOBALS['SQ_NEST_CONTENT_PAINTED'][$asset_cache_key])) {
421 $additional_get_vars = <?php
422 // keyword delimiters need to be replaced temporarily
423 echo str_replace('%', '%', var_export($additional_get_vars, TRUE)); ?>;
424 $processed_get_vars = Array();
425 foreach ($additional_get_vars as $get_var) {
426 $get_name = $get_var['name'];
427 $get_value = str_replace('%', '%', $get_var['value']);
428 $found = preg_match_all('/%(asset\_.*)%/U', $get_value, $set_matches, PREG_PATTERN_ORDER);
429 $asset_matches = $set_matches[1];
431 foreach ($asset_matches as $asset_keyword) {
432 $replacement = $parents_nesting_asset->getKeywordReplacement($asset_keyword);
433 if (!is_null($replacement)) {
434 $get_value = str_replace('%'.$asset_keyword.'%', $replacement, $get_value);
438 $found = preg_match_all('/%(nested\_asset\_.*)%/U', $get_value, $set_matches, PREG_PATTERN_ORDER);
439 $nested_asset_matches = $set_matches[1];
441 foreach ($nested_asset_matches as $nested_asset_keyword) {
442 if (0 === strpos($nested_asset_keyword, 'nested_')) {
443 $nested_asset_keyword = str_replace('nested_','',$nested_asset_keyword);
445 $replacement = $nested_asset->getKeywordReplacement($nested_asset_keyword);
446 if (!is_null($replacement)) {
447 $get_value = str_replace('nested_','',$get_value);
448 $get_value = str_replace('%'.$nested_asset_keyword.'%', $replacement, $get_value);
452 replace_global_keywords($get_value);
454 preg_match('/([^\[]*)(.*)/', $get_name, $base_name);
455 $array_bits = $base_name[2];
456 if (empty($array_bits)) {
457 $processed_get_vars[$base_name[1]] = $get_value;
459 $array_els = Array();
461 if (!isset($processed_get_vars[$base_name[1]])) {
462 $processed_get_vars[$base_name[1]] = Array();
466 while (!empty($array_bits)) {
467 $found = preg_match('/\[([^\]]*)\](.*)/', $array_bits, $base_name);
469 $array_bits = $base_name[2];
470 $array_els[] = addslashes($base_name[1]);
473 $eval_str = '$processed_get_vars[\''.addslashes($base_name[1]).'\'][\''.implode('\'][\'', $array_els).'\'] = '.addslashes($get_value);
477 $old_get[$asset_cache_key] = $_GET;
478 $_GET = array_merge($_GET, $processed_get_vars);
480 // $_REQUEST by default is supposed to contain the contnets of $_GET
481 $old_request[$asset_cache_key] = $_REQUEST;
482 $_REQUEST = array_merge($_REQUEST, $processed_get_vars);
484 $GLOBALS['SQ_NEST_CONTENT_PAINTED'][$asset_cache_key] = 1;
485 $nested_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($nested_assetid, '', TRUE);
486 $asset_contents = '';
487 if ($nested_asset->id && $nested_asset->readAccess()) {
490 switch ($asset->attr('paint_with')) {
493 $nested_asset->printBody();
499 $nested_asset->printBodyWithPaintLayout();
504 $arbitrary_paint_layout = $this->_getArbitraryPaintLayout($asset);
505 if (empty($arbitrary_paint_layout)) {
507 $nested_asset->printBody();
511 $arbitrary_paint_layout = $GLOBALS['SQ_SYSTEM']->am->getAsset(<?php echo $arbitrary_paint_layout->id ?>);
512 $nested_asset->printBodyWithPaintLayout($arbitrary_paint_layout->id);
518 $asset_contents = ob_get_contents();
521 $keywords = extract_keywords($asset_contents);
522 $replacements = Array();
523 foreach ($keywords as $idx => $keyword) {
524 if (strpos($keyword, 'nested_get_') === 0) {
525 $sub_keyword = substr($keyword, 11);
526 $replacements[$keyword] = array_get_index($_GET, $sub_keyword, '');
530 replace_keywords($asset_contents, $replacements);
533 echo $asset_contents;
534 unset($GLOBALS['SQ_NEST_CONTENT_PAINTED'][$asset_cache_key]);
536 $_GET = $old_get[$asset_cache_key];
537 $_REQUEST = $old_request[$asset_cache_key];
539 echo '<font color="red
"><b>[ ** '.translate('cms_ct_nest_content_recursion_warning').' ** ]<br />'.translate('cms_ct_nest_content_recursion_body').'</b></font>';
542 <?php echo "\n
".'?'.'>';
544 }//end paintGenerated()
556 function _processAdditionalGetVars(&$asset, &$nested_asset)
558 $processed_get_vars = Array();
559 $additional_get_vars = $asset->attr('additional_get');
560 if (!isset($additional_vars) || empty($additional_vars)) {
561 return $processed_get_vars;
563 $temp_parent_array = $GLOBALS['SQ_SYSTEM']->am->getDependantParents($asset->id, '' , TRUE, FALSE);
564 $parents_nesting_asset_id = $temp_parent_array[0];
565 $parents_nesting_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($parents_nesting_asset_id);
566 foreach ($additional_get_vars as $get_var) {
567 $get_name = $get_var['name'];
568 $get_value = $get_var['value'];
569 $found = preg_match_all('/%(asset\_.*)%/U', $get_value, $set_matches, PREG_PATTERN_ORDER);
570 $asset_matches = $set_matches[1];
571 foreach ($asset_matches as $asset_keyword) {
572 $replacement = $parents_nesting_asset->getKeywordReplacement($asset_keyword);
573 if (!is_null($replacement)) {
574 $get_value = str_replace('%'.$asset_keyword.'%', $replacement, $get_value);
578 $found = preg_match_all('/%(nested\_(asset\_.*))%/U', $get_value, $set_matches, PREG_PATTERN_ORDER);
579 $nested_asset_orig_matches = $set_matches[1];
580 $nested_asset_matches = $set_matches[2];
582 foreach ($nested_asset_matches as $na_id => $nested_asset_keyword) {
583 if (0 === strpos($nested_asset_keyword, 'nested_')) {
584 $nested_asset_keyword = str_replace('nested_','',$nested_asset_keyword);
586 $replacement = $nested_asset->getKeywordReplacement($nested_asset_keyword);
587 if (!is_null($replacement)) {
588 $get_value = str_replace('nested_','',$get_value);
589 $get_value = str_replace('%'.$nested_asset_orig_matches[$na_id].'%', $replacement, $get_value);
593 replace_global_keywords($get_value);
595 preg_match('/([^\[]*)(.*)/', $get_name, $base_name);
596 $array_bits = $base_name[2];
597 if (empty($array_bits)) {
598 $processed_get_vars[$base_name[1]] = $get_value;
600 $array_els = Array();
602 if (!isset($processed_get_vars[$base_name[1]])) {
603 $processed_get_vars[$base_name[1]] = Array();
607 while (!empty($array_bits)) {
608 $found = preg_match('/\[([^\]]*)\](.*)/', $array_bits, $base_name);
610 $array_bits = $base_name[2];
611 $array_els[] = addslashes($base_name[1]);
614 $eval_str = '$processed_get_vars[\''.addslashes($base_name[1]).'\'][\''.implode('\'][\'', $array_els).'\'] = '.addslashes($get_value);
619 return $processed_get_vars;
621 }//end _processAdditionalGetVars()
634 function processBackend($link, &$asset, $prefix)
638 $nested_asset = $this->_getNestedAsset($asset);
639 $current_assetid = (!is_null($nested_asset)) ? $nested_asset->id : 0;
641 $arbitrary_paint_layout = $this->_getArbitraryPaintLayout($asset);
642 $current_apl_assetid = (!is_null($arbitrary_paint_layout)) ? $arbitrary_paint_layout->id : 0;
644 $additional_get = array_get_index($_POST, $prefix.'_additional_get', Array());
645 foreach ($additional_get as $var_index => $var_value) {
646 $var_value['name'] = trim($var_value['name']);
647 if (empty($var_value['name'])) {
648 unset($additional_get[$var_index]);
652 $dynamic_nest_get = (isset($_POST[$prefix.'_dynamic_nest_get'])) ? $_POST[$prefix.'_dynamic_nest_get'] : '';
653 $assetid = (isset($_POST[$prefix.'_nested_assetid']['assetid'])) ? $_POST[$prefix.'_nested_assetid']['assetid'] : 0;
654 $paint_with = array_get_index($_POST, $prefix.'_paint_with', 'raw');
655 $paint_with_assetid = (isset($_POST[$prefix.'_paint_with_layout']['assetid'])) ? $_POST[$prefix.'_paint_with_layout']['assetid'] : 0;
657 if ($paint_with_assetid && ($paint_with == 'arbitrary')) {
658 if ($current_apl_assetid) {
659 $link = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE, '', TRUE, 'paint_with_layout');
660 if (!$asset->deleteLink($link['linkid'])) {
661 $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
666 // create a NOTICE link for delete notification
667 $arbitrary_paint_layout = $GLOBALS['SQ_SYSTEM']->am->getAsset($paint_with_assetid);
668 if (!$asset->createLink($arbitrary_paint_layout, SQ_LINK_NOTICE, 'paint_with_layout')) {
669 $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
673 $asset->linksUpdated();
677 if (($dynamic_nest_get != $asset->attr('dynamic_nest_get')) || ($paint_with != $asset->attr('paint_with')) || ($additional_get != $asset->attr('additional_get')) || ($paint_with_assetid != $current_apl_assetid)) {
678 $asset->setAttrValue('paint_with', $paint_with);
679 $asset->setAttrValue('additional_get', $additional_get);
680 $asset->setAttrValue('dynamic_nest_get', trim($dynamic_nest_get));
682 if (!$asset->saveAttributes()) {
683 $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
692 if ($assetid != $current_assetid) {
694 $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
695 $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
697 if ($current_assetid) {
698 $link = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE, '', TRUE, 'nested_asset');
699 if (!$asset->deleteLink($link['linkid'])) {
700 $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
701 $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
706 // create a NOTICE link for delete notification
707 $nested_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid);
708 if (!$asset->createLink($nested_asset, SQ_LINK_NOTICE, 'nested_asset')) {
709 $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
710 $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
714 // get the html contents of the nested asset so
715 // we change the type of the cell later - other content
716 // types can use the html
718 // if we dont have the frontend asset set just buffer nothing
719 if (SQ_IN_LIMBO && !isset($GLOBALS['SQ_SYSTEM']->frontend_asset)) {
723 $this->paint($asset, $prefix);
724 $html = ob_get_contents();
728 $asset->setAttrValue('html', $html);
731 if (!$current_assetid && $assetid) {
732 // Normally you are not supposed to call linksUpdated() directly, however,
733 // createAssetLink() does not call linksUpdated() to the major unless its dependant link.
734 // let's manually update the paint layout bodycopy if there is any
735 $asset->linksUpdated();
738 $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
739 $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
742 // Fix to Bug #5055 Nested content divs don't save properly across contexts
743 // refresh the content_file.php for all the context here. This content_type(_nest_asset)
744 // is different to any other content types. This is more so based on what asset is linked
745 // with the link_value of 'nested_asset'. And since the Links are not contextable
746 // we have to treat all the context w.r.t the changed asset
747 $bodycopy_div_id = array_keys($GLOBALS['SQ_SYSTEM']->am->getParents($asset->id, 'bodycopy_container', FALSE));
748 if (isset($bodycopy_div_id[0])) {
749 $bodycopy_div = $GLOBALS['SQ_SYSTEM']->am->getAsset($bodycopy_div_id[0]);
750 $bodycopy_div_edit_fns = $bodycopy_div->getEditFns();
751 $all_context = $GLOBALS['SQ_SYSTEM']->getAllContexts();
752 foreach ($all_context as $context_id => $info) {
753 $GLOBALS['SQ_SYSTEM']->changeContext($context_id);
754 $bodycopy_div_edit_fns->generateContentFile($bodycopy_div);
755 $GLOBALS['SQ_SYSTEM']->restoreContext();
761 } else if ($current_assetid) {
762 $link = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE, '', TRUE, 'nested_asset');
763 $ok = $asset->deleteLink($link['linkid']);
768 }//end processBackend()
779 function &_getNestedAsset(&$asset)
781 $nested_asset = NULL;
783 if (isset($_GET[$asset->attr('dynamic_nest_get')])){
784 $nested_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($_GET[$asset->attr('dynamic_nest_get')], '', TRUE);
786 $nested_link = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE, '', TRUE, 'nested_asset');
787 if (!empty($nested_link)) {
788 $nested_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($nested_link['minorid'], $nested_link['minor_type_code'], TRUE);
792 return $nested_asset;
794 }//end _getNestedAsset()
805 function &_getArbitraryPaintLayout(&$asset)
807 $paint_layout = NULL;
809 $paint_layout_link = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE, '', TRUE, 'paint_with_layout');
810 if (!empty($paint_layout_link)) {
811 $paint_layout = $GLOBALS['SQ_SYSTEM']->am->getAsset($paint_layout_link['minorid'], $paint_layout_link['minor_type_code'], TRUE);
814 return $paint_layout;
816 }//end _getArbitraryPaintLayout()