17 require_once SQ_CORE_PACKAGE_PATH.
'/bodycopy/bodycopy_container/bodycopy_container_edit_fns.inc';
40 parent::__construct();
56 $div_attributes = $asset->
attr(
'attributes');
57 $div_attributes[
'identifier'] = $asset->name;
60 case <?php echo $asset->id?> :
62 retVal[
"attributes"] =
'<?php echo var_serialise($div_attributes, TRUE)?>';
86 $containers = Array(Array(
'minorid'=>$bodycopy->id,
'minor_type_code'=>get_class_lower($bodycopy)));
88 $containers = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($bodycopy->id, SQ_LINK_TYPE_2,
'bodycopy_container', FALSE);
92 <script language=
"JavaScript" src=
"<?php echo sq_web_path('data').'/asset_types/bodycopy/js/bodycopy_edit_divs.js'?>"></script>
94 <script language=
"JavaScript" type=
"text/javascript">
95 function serialise_div(bodycopy_name, bodycopy_data, divid) {
96 var form = document.main_form;
97 if (!bodycopy_saved[bodycopy_name] && bodycopy_name != null) bodycopy_saved[bodycopy_name] =
new Object();
100 if (!bodycopy_saved[bodycopy_name][divid]) {
101 bodycopy_saved[bodycopy_name][divid] =
new Object();
104 bodycopy_saved[bodycopy_name][divid][
'attributes'] = bodycopy_data[
'attributes'];
107 form.elements[
'bodycopy_saved[' + bodycopy_name +
'][' + divid +
']'].value = var_serialise(bodycopy_saved[bodycopy_name][divid]);
111 function get_bodycopy_current_div_data(bodycopy_name, divid) {
112 if (divid == null) divid = -1;
113 return bodycopy_current_data[bodycopy_name].get_div_data(divid);
118 function get_bodycopy_current_div_count(bodycopy_name, asset_linked) {
119 return bodycopy_current_data[bodycopy_name].get_div_data(linked);
122 function get_bodycopy_div_available_classes() {
125 if (isset($GLOBALS[
'sq_preview_url']) && !empty($GLOBALS[
'sq_preview_url'])) {
126 $url = $GLOBALS[
'sq_preview_url'];
127 $url = preg_replace(
'|^http[s]?://|',
'', $url);
129 $designid = $GLOBALS[
'SQ_SYSTEM']->am->getValueFromURL($url,
'design::%frontend%', TRUE);
132 $design = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($designid);
133 $classes_list = $design->attr(
'div_classes');
134 if (!empty($classes_list)) {
136 foreach ($classes_list as $key => $value) {
137 $classes[$key] = $value;
143 return var_unserialise(
'<?php echo empty($classes) ? NULL : var_serialise($classes, TRUE); ?>');
146 function get_bodycopy_<?php echo $prefix?>_current_div_data(divid) {
148 retVal =
new Object();
154 if (count($containers)) {
155 foreach ($containers as $container_data) {
156 if ($container_data[
'minor_type_code'] !=
'bodycopy_div') {
160 $div = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($container_data[
'minorid'], $container_data[
'minor_type_code']);
161 $div_edit = $div->getEditFns();
162 $div_edit->paintBackendJsData($div, $prefix, $i);
168 retVal[
"num_containers"] = <?php echo count($containers); ?>;
176 if (bodycopy_data_exists(
new Array(
'<?php echo $prefix?>', divid,
'attributes'))) {
177 retVal [
"attributes"] = var_serialise(bodycopy_saved[
"<?php echo $prefix?>"][divid][
"attributes"]);
186 bodycopy_current_data[
"<?php echo $prefix?>"].get_div_data = get_bodycopy_<?php echo $prefix?>_current_div_data;
206 $div_attributes = $asset->
attr(
'attributes');
207 if (!isset($div_attributes[
'layout_type'])) {
208 $div_attributes[
'layout_type'] =
'div';
211 $attribute_list =
'';
213 for (reset($div_attributes); $name = key($div_attributes); next($div_attributes)) {
214 $val = $div_attributes[$name];
215 if ($val ==
'')
continue;
217 $skip_attribute = FALSE;
222 case 'disable_keywords':
223 case 'css_class_list':
224 $skip_attribute = TRUE;
231 if ($skip_attribute)
continue;
232 $attribute_list .=
' '.$name.
'="'.str_replace(
'"',
'"', $val).
'"';
236 $val = clean_div_attribute($asset->
attr(
'name'));
238 $attribute_list .=
' '.
'id="'.$val.
'"';
242 if ($div_attributes[
'layout_type'] !=
'none') {
243 echo
"\n<".strtolower($div_attributes[
'layout_type']).$attribute_list.
">\n";
248 if (!is_null($content_type)) {
249 $content_edit = $content_type->getEditFns();
250 $content_edit->paint($content_type, $editing, $generating);
254 if ($div_attributes[
'layout_type'] !=
'none') {
255 echo
"\n</".strtolower($div_attributes[
'layout_type']).
">\n";
275 if (!parent::paintContainer($asset, $o, $prefix)) {
279 $div_attributes = $asset->
attr(
'attributes');
281 $attribute_list =
'';
282 $popup_attribute_list =
'';
285 if (!empty($div_attributes)) {
286 for (reset($div_attributes); $name = key($div_attributes); next($div_attributes)) {
287 $val = $div_attributes[$name];
288 if ($val ==
'')
continue;
289 if ($name ==
'css_class_list')
continue;
290 if ($name ==
'dir') $dir_attribute = $div_attributes[$name];
291 $popup_attribute_list .=
' '.$name.
'="'.str_replace(
'"',
'"', $val).
'"';
292 $attribute_list .=
' '.$name.
'="'.str_replace(
'"',
'"', $val).
'"';
296 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_TYPE_2,
'content_type', FALSE,
'div_contents',
'major', TRUE);
298 $content_type = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
299 $content_prefix = $prefix.
'_'.get_class_lower($content_type).
'_'.$link[
'linkid'];
301 $content_type = NULL;
302 $content_prefix =
'';
306 $type_info = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(
'bodycopy');
309 <table<?php echo $attribute_list?> style=
"width:100%;">
311 <td align=
"left" background=
"" id=
"<?php echo $prefix.'_div_'.$asset->id;?>" width=
"4%" style=
"border: 1px dashed #C0C0C0;">
312 <span style=
"float: left;">
315 $public_userid = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAssetid(
'public_user');
317 $public_read = FALSE;
318 if ($asset->status == SQ_STATUS_LIVE && $asset->
readAccess(Array($public_userid))) {
321 $status_name = get_status_description($asset->status);
322 $status_img = get_asset_status_icon($asset->status);
323 $desc = translate(
'content_type_tooltip_status').
': '.$status_img.
'<b>'.get_status_description($asset->status).
'</b><br />';
324 $desc .= translate(
'content_type_tooltip_public').
': <b>'.($public_read ? translate(
'yes') : translate(
'no')).
'</b><br />';
325 $desc .= (($popup_attribute_list) ? translate(
'current_properties').
':<br> '.$popup_attribute_list :
'');
326 Bodycopy_Edit_Fns::printBodycopyIcon(
'bodycopy_edit_div_properties(\''.$prefix.
'\',
'.$asset->id.',
'.(($asset->status & SQ_SC_STATUS_SAFE_EDITING) ? 'false' : 'true').');
', 'Edit
'.$asset->attr('name
').'\
's Properties', $desc,
'table_properties',
'[Edit Properties]');
328 if (!is_null($content_type)) {
329 $content_edit = $content_type->getEditFns();
330 $content_edit->paintBackendIcons($content_type, $content_prefix);
333 $asset_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_SC_LINK_ALL,
'', TRUE,
'minor');
334 $count_linked_to = count($asset_links);
335 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($asset->id));
337 $lineages = $GLOBALS[
'SQ_SYSTEM']->am->getLinkLineages($asset->id, 5);
341 <div
id=
"asset-tag-line-<?php echo $asset->id ?>-lineages-linked" style=
"display:none">
344 echo
'This DIV is linked to <strong><i>'.$count_linked_to.
'</i></strong> assets'; ?></td></tr><?php
345 foreach ($lineages as $lineage_key => $lineage) {
346 if ($lineage[
'link_type'] & SQ_SC_LINK_BACKEND_NAV) {
347 $lineage_assetids = array_keys($lineage[
'lineage']);
348 $lineage_assetids[] = $asset->id;
349 $lineage_names = $lineage[
'lineage'];
351 if (count($lineage[
'lineage']) > 3) {
352 $lineage_names = $lineage[
'lineage'];
353 array_splice($lineage_names, 2, -1, Array(
'...'));
355 foreach ($lineage_names as $id => $name){
356 $lineage_names[$id] = htmlspecialchars($name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET);
358 $lineage_names[$asset->id] = htmlspecialchars($asset_info[$asset->id][
'name'], ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET);
359 require_once SQ_INCLUDE_PATH.
'/general.inc';
360 ?><tr><td
class=
"sq-backend-table-cell" ><a href=
"#" onclick=
"if (self.name == 'sq_wysiwyg_popup_main') {am = self;} else if (self.name == 'hipo_job') {am = opener;} else if ((typeof sq_wysiwyg_dialog != 'undefined') && (sq_wysiwyg_dialog != null) && !sq_wysiwyg_dialog.closed) { am = sq_wysiwyg_dialog; am.focus(); } else { am = parent.top.frames['sq_sidenav']; } am.asset_locator_start('<?php echo get_asset_lineage_sort_order($lineage_assetids) ?>'); tooltip.hide(); return false;"><?php echo implode(
' > ', $lineage_names) ?></a></td>
364 unset($lineages[$lineage_key]);
370 <span style=
"float: right;">
372 if (count($lineages) > 1) {
373 ?><div
id=
"asset-tag-line-<?php echo $asset->id ?>-cancel-icon" style=
"display:none"><?php
374 sq_print_icon(sq_web_path(
'data').
'/asset_types/bodycopy/images/icons/delete.png', 16, 16, translate(
'cancel'), translate(
'cancel'),
' style="border:none"');
376 $lineages_onclick =
'tooltip.show(this, document.getElementById(\'asset-tag-line-'.$asset->id.
'-lineages-linked\').innerHTML, \''.translate(
'linked_to_assets').
'\', document.getElementById(\
'asset-tag-line-'.$asset->id.
'-cancel-icon\').innerHTML)';
377 $lineages_name = translate(
'linked_to_assets');
378 require_once SQ_INCLUDE_PATH.
'/general.inc';
379 echo sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/asset_locator.png', 16, 16, $lineages_name, $lineages_name,
' class="clickable" align="absmiddle" onclick="'.$lineages_onclick.
'"');
381 if (!is_null($content_type)) {
382 $content_edit = $content_type->getEditFns();
383 $content_edit->paintBackendStatusIcons($content_type, $content_prefix);
390 <td style=
"border-left: 1px dashed #C0C0C0; border-right: 1px dashed #C0C0C0; border-bottom: 1px dashed #C0C0C0;" id=
"<?php echo $content_prefix; ?>_cell">
392 if (!is_null($content_type)) {
393 $content_edit = $content_type->getEditFns();
394 if (method_exists($content_edit,
'setDirAttr')) {
395 $content_edit->setDirAttr($dir_attribute);
397 $content_edit->paintBackend($content_type, $content_prefix);
426 $updated = parent::processContainer($asset, $o, $prefix, $bc_action, $bc_name, $bc_data, $bc_saved);
428 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_TYPE_2,
'content_type', FALSE,
'div_contents',
'major', TRUE);
431 $content_type = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
432 if (!is_null($content_type)) {
433 $content_prefix = $prefix.
'_'.get_class_lower($content_type).
'_'.$link[
'linkid'];
434 $content_edit = $content_type->getEditFns();
435 if ($content_edit->processBackend(Array(), $content_type, $content_prefix)) {
436 if ($content_type->saveAttributes()) $updated = TRUE;
441 if (isset($bc_saved[$prefix][$asset->id][
'attributes'][
'content_type'])) {
442 if ($this->
_updateCellType($asset, $bc_saved[$prefix][$asset->id][
'attributes'][
'content_type'])) {
466 $new_type = trim($new_type);
467 if (empty($new_type))
return FALSE;
470 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_TYPE_2,
'content_type', FALSE,
'div_contents',
'major', TRUE);
471 if (empty($link))
return FALSE;
472 $content_type = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
475 $current_type = get_class_lower($content_type);
476 if ($current_type == $new_type)
return FALSE;
480 $morphed = $content_type->morph(
'content_type');
481 if (!$morphed)
return FALSE;
484 $content_type = $morphed->morph($new_type);
485 if (!$content_type)
return FALSE;