function cn_htmldir($cnstr, $sid = 0) { //返回 子站目录/顶级首序分类(/本首序分类)/次序分类/三序分类/ 的格式 global $cnhtmldir, $subsites; $dirstr = $sid ? $subsites[$sid]['dirname'] . '/' : ($cnhtmldir ? $cnhtmldir . '/' : ''); if ($cnstr) { parse_str($cnstr, $idsarr); $topid = $i = 0; foreach ($idsarr as $k => $v) { $k = $k == 'caid' ? 0 : str_replace('ccid', '', $k); $item = !$k ? read_cache('catalog', $v, '', $sid) : read_cache('coclass', $k, $v); if (!$i) { $items = $k == 'caid' ? read_cache('catalogs', '', '', $sid) : read_cache('coclasses', $k, $v); $topid = cn_upid($v, $items); $dirstr .= $items[$topid]['dirname'] . '/'; } if ($i || $topid != $v) { $dirstr .= $item['dirname'] . '/'; } $i = 1; } } return $dirstr; }
function cn_upid($id, &$arr, $level = 0) { if (empty($arr[$id])) { return 0; } return $arr[$id]['level'] < $level ? 0 : (!$arr[$id]['pid'] || $arr[$id]['level'] == $level ? $id : cn_upid($arr[$id]['pid'], $arr, $level)); }
function arc_topdir(&$item) { global $cnhtmldir, $subsites, $acatalogs; load_cache('acatalogs'); $topid = cn_upid($item['caid'], $acatalogs); return ($item['sid'] ? $subsites[$item['sid']]['dirname'] . '/' : ($cnhtmldir ? $cnhtmldir . '/' : '')) . $acatalogs[$topid]['dirname'] . '/'; }