function getframehtml($data = array()) { global $_G; $html = $style = ''; foreach ((array) $data as $id => $content) { list($flag, $name) = explode('`', $id); if ($flag == 'frame') { $fattr = $content['attr']; $moveable = $fattr['moveable'] == 'true' ? ' move-span' : ''; $html .= '<div id="' . $fattr['name'] . '" class="' . $fattr['className'] . '">'; if (checkhastitle($fattr['titles'])) { $style = gettitlestyle($fattr['titles']); $html .= '<div class="' . implode(' ', $fattr['titles']['className']) . '"' . $style . '>' . gettitlehtml($fattr['titles'], 'frame') . '</div>'; } foreach ((array) $content as $colid => $coldata) { list($colflag, $colname) = explode('`', $colid); if ($colflag == 'column') { $html .= '<div id="' . $colname . '" class="' . $coldata['attr']['className'] . '">'; $html .= '<div id="' . $colname . '_temp" class="move-span temp"></div>'; $html .= getframehtml($coldata); $html .= '</div>'; } } $html .= '</div>'; } elseif ($flag == 'tab') { $fattr = $content['attr']; $moveable = $fattr['moveable'] == 'true' ? ' move-span' : ''; $html .= '<div id="' . $fattr['name'] . '" class="' . $fattr['className'] . '">'; $switchtype = 'click'; foreach ((array) $content as $colid => $coldata) { list($colflag, $colname) = explode('`', $colid); if ($colflag == 'column') { if (checkhastitle($fattr['titles'])) { $style = gettitlestyle($fattr['titles']); $title = gettitlehtml($fattr['titles'], 'tab'); } $switchtype = is_array($fattr['titles']['switchType']) && !empty($fattr['titles']['switchType'][0]) ? $fattr['titles']['switchType'][0] : 'click'; $html .= '<div id="' . $colname . '" class="' . $coldata['attr']['className'] . '"' . $style . ' switchtype="' . $switchtype . '">' . $title; $html .= getframehtml($coldata); $html .= '</div>'; } } $html .= '<div id="' . $fattr['name'] . '_content" class="tb-c"></div>'; $html .= '<script type="text/javascript">initTab("' . $fattr['name'] . '","' . $switchtype . '");</script>'; $html .= '</div>'; } elseif ($flag == 'block') { $battr = $content['attr']; $bid = intval(str_replace('portal_block_', '', $battr['name'])); if (!empty($bid)) { $html .= "<!--{block/{$bid}}-->"; $_G['curtplbid'][$bid] = $bid; } } } return $html; }
function import_diy($file) { global $_G; $css = ''; $html = array(); $arr = array(); $content = file_get_contents($file); require_once libfile('class/xml'); if (empty($content)) { return $arr; } $content = preg_replace("/\\<\\!\\-\\-\\[name\\](.+?)\\[\\/name\\]\\-\\-\\>\\s+/i", '', $content); $diycontent = xml2array($content); if ($diycontent) { foreach ($diycontent['layoutdata'] as $key => $value) { if (!empty($value)) { getframeblock($value); } } $newframe = array(); foreach ($_G['curtplframe'] as $value) { $newframe[] = $value['type'] . random(6); } $mapping = array(); if (!empty($diycontent['blockdata'])) { $mapping = block_import($diycontent['blockdata']); unset($diycontent['blockdata']); } $oldbids = $newbids = array(); if (!empty($mapping)) { foreach ($mapping as $obid => $nbid) { $oldbids[] = '#portal_block_' . $obid . ' '; $newbids[] = '#portal_block_' . $nbid . ' '; $oldbids[] = '[portal_block_' . $obid . ']'; $newbids[] = '[portal_block_' . $nbid . ']'; $oldbids[] = '~portal_block_' . $obid . '"'; $newbids[] = '~portal_block_' . $nbid . '"'; } } require_once libfile('class/xml'); $xml = array2xml($diycontent['layoutdata'], true); $xml = str_replace($oldbids, $newbids, $xml); $xml = str_replace((array) array_keys($_G['curtplframe']), $newframe, $xml); $diycontent['layoutdata'] = xml2array($xml); $css = str_replace($oldbids, $newbids, $diycontent['spacecss']); $css = str_replace((array) array_keys($_G['curtplframe']), $newframe, $css); foreach ($diycontent['layoutdata'] as $key => $value) { $html[$key] = getframehtml($value); } } if (!empty($html)) { $xml = array2xml($html, true); require_once libfile('function/block'); block_get_batch(implode(',', $mapping)); foreach ($mapping as $bid) { $blocktag[] = '<!--{block/' . $bid . '}-->'; $blockcontent[] = block_fetch_content($bid); } $xml = str_replace($blocktag, $blockcontent, $xml); $html = xml2array($xml); $arr = array('html' => $html, 'css' => $css, 'mapping' => $mapping); } return $arr; }