View source
<?php
function oa_export_comments_export($entity_id, &$results) {
foreach (oa_export_get_comments($entity_id) as $cid) {
if ($comment = reset(entity_load('comment', array(
$cid,
)))) {
oa_export_entity_export('comment', $comment, $results);
}
else {
$results['messages'][] = t("The comment with cid: !cid, couldn't be exported. It no longer exists", array(
'!cid' => $cid,
));
}
}
}
function oa_export_menus_export($entity, $entity_id, $entity_type, &$results) {
if ($mlid = og_menu_single_get_link_mlid($entity_type, $entity_id)) {
$menu = menu_link_load($mlid);
if (!empty($menu)) {
list(, , $bundle) = entity_extract_ids($entity_type, $entity);
$menu_name = str_replace('-', '_', $menu['menu_name']);
foreach (module_implements('oa_export_menus__' . $entity_type . '__' . $menu_name) as $module) {
$function = $module . '_oa_export_menus__' . $entity_type . '__' . $menu_name;
if (function_exists($function)) {
$function($menu, $entity_id, $entity_type, $bundle, $results);
}
}
}
}
}
function oa_export_oa_export_menus__node__og_menu_single($menu, $entity_id, $entity_type, $bundle, &$results) {
$items = array();
if (!isset($results['export']['menu' . ':' . $entity_type . ':' . $entity_id])) {
if (!oa_export_child_menu_exported($menu['plid'], $results)) {
if (isset($menu['plid']) && empty($menu['plid'])) {
$items[$entity_type . ':' . $entity_id . ':' . $menu['mlid']][$menu['plid']] = $menu;
oa_export_find_menu_children($items, $menu['mlid'], $entity_id, $entity_type);
}
else {
$parent = og_menu_single_menu_link_load($menu['plid']);
if (isset($parent['plid']) && empty($parent['plid'])) {
list($type, $id) = explode('/', $parent['link_path']);
if (!isset($results['export'][$type . ':' . $id])) {
$items[$entity_type . ':' . $entity_id . ':' . $parent['mlid']][$parent['plid']] = $parent;
list(, $entity_id) = explode('/', $parent['link_path']);
oa_export_find_menu_children($items, $parent['mlid'], $entity_id, $entity_type);
}
}
}
if (!empty($items)) {
$results['export']['menu' . ':' . $entity_type . ':' . $entity_id] = $items;
}
}
}
}
function oa_export_find_menu_children(&$items, $mlid, $entity_id, $entity_type) {
$children = og_menu_single_children_items($mlid);
foreach ($children as $description => $link) {
$items[$entity_type . ':' . $entity_id . ':' . $link['link']['plid']][$link['link']['mlid']] = $link['link'];
}
}
function oa_export_child_menu_exported($plid, &$results) {
if ($parent = og_menu_single_menu_link_load($plid)) {
list(, $entity_id) = explode('/', $parent['link_path']);
if (!isset($results['export']['menu' . ':' . $entity_id])) {
return FALSE;
}
else {
return TRUE;
}
}
}