'; showtableheader(); showsubtitle(array('order', 'blogcategory_name', 'blogcategory_num', 'operation')); foreach ($category as $key=>$value) { if($value['level'] == 0) { echo showcategoryrow($key, 0, ''); } } echo ' 
'.cplang('blogcategory_addcategory').'
'; showtablefooter(); echo ''; showtableheader('', 'notop'); showsubmit('editsubmit'); showtablefooter(); showformfooter(); $langs = array(); $keys = array('blogcategory_addcategory', 'blogcategory_addsubcategory', 'blogcategory_addthirdcategory'); foreach ($keys as $key) { $langs[$key] = cplang($key); } echo << SCRIPT; } else { if($_POST['name']) { foreach($_POST['name'] as $key=>$value) { $sets = array(); $value = trim($value); if($category[$key] && $category[$key]['catname'] != $value) { $sets['catname'] = $value; } if($category[$key] && $category[$key]['displayorder'] != $_POST['order'][$key]) { $sets['displayorder'] = $_POST['order'][$key] ? $_POST['order'][$key] : '0'; } if($sets) { C::t('home_blog_category')->update($key, $sets); } } } if($_POST['newname']) { foreach ($_POST['newname'] as $upid=>$names) { foreach ($names as $nameid=>$name) { C::t('home_blog_category')->insert(array('upid' => $upid, 'catname' => trim($name), 'displayorder'=>intval($_POST['neworder'][$upid][$nameid]))); } } } if($_POST['settingnew']) { $_POST['settingnew'] = array_map('intval', $_POST['settingnew']); C::t('common_setting')->update_batch($_POST['settingnew']); updatecache('setting'); } include_once libfile('function/cache'); updatecache('blogcategory'); cpmsg('blogcategory_update_succeed', 'action=blogcategory', 'succeed'); } } elseif($operation == 'delete') { if(!$_GET['catid'] || !$category[$_GET['catid']]) { cpmsg('blogcategory_catgory_not_found', '', 'error'); } if(!submitcheck('deletesubmit')) { $blog_count = C::t('home_blog')->count_by_catid($_GET['catid']); if(!$blog_count && empty($category[$_GET[catid]]['children'])) { C::t('home_blog_category')->delete($_GET['catid']); include_once libfile('function/cache'); updatecache('blogcategory'); cpmsg('blogcategory_delete_succeed', 'action=blogcategory', 'succeed'); } shownav('portal', 'blogcategory'); showsubmenu('blogcategory', array( array('list', 'blogcategory', 0), array('delete', 'blogcategory&operation=delete&catid='.$_GET['catid'], 1) )); showformheader('blogcategory&operation=delete&catid='.$_GET['catid']); showtableheader(); if($category[$_GET[catid]]['children']) { showsetting('blogcategory_subcategory_moveto', '', '', ''. ''. ''. '' ); } include_once libfile('function/portalcp'); showsetting('blogcategory_blog_moveto', '', '', category_showselect('blog', 'tocatid', false, $category[$_GET['catid']]['upid'])); showsubmit('deletesubmit'); showtablefooter(); showformfooter(); } else { if($_POST['tocatid'] == $_GET['catid']) { cpmsg('blogcategory_move_category_failed', 'action=blogcategory', 'error'); } $delids = array($_GET['catid']); if($category[$_GET['catid']]['children']) { if($_POST['subcat_op'] == 'parent') { $upid = intval($category[$_GET['catid']]['upid']); C::t('home_blog_category')->update($category[$_GET['catid']]['children'], array('upid' => $upid)); } else { $delids = array_merge($delids, $category[$_GET['catid']]['children']); foreach ($category[$_GET['catid']]['children'] as $id) { $value = $category[$id]; if($value['children']) { $delids = array_merge($delids, $value['children']); } } if(!$category[$_POST['tocatid']] || in_array($_POST['tocatid'], $delids)) { cpmsg('blogcategory_move_category_failed', 'action=blogcategory', 'error'); } } } if($delids) { C::t('home_blog_category')->delete($delids); C::t('home_blog')->update_by_catid($delids, array('catid'=>$_POST['tocatid'])); $num = C::t('home_blog')->count_by_catid($_POST['tocatid']); C::t('home_blog_category')->update_num_by_catid($num, $_POST['tocatid'], false); } include_once libfile('function/cache'); updatecache('blogcategory'); cpmsg('blogcategory_delete_succeed', 'action=blogcategory', 'succeed'); } } function showcategoryrow($key, $level = 0, $last = '') { global $_G; loadcache('blogcategory'); $value = $_G['cache']['blogcategory'][$key]; $return = ''; include_once libfile('function/portalcp'); $value['num'] = category_get_num('blog', $key); if($level == 2) { $class = $last ? 'lastchildboard' : 'childboard'; $return = '
'. ''. '
'. ''.$value[num].''.cplang('delete').''; } elseif($level == 1) { $return = '
'. ''. ''.cplang('blogcategory_addthirdcategory').'
'. ''.$value[num].''.cplang('delete').''; for($i=0,$L=count($value['children']); $i<$L; $i++) { $return .= showcategoryrow($value['children'][$i], 2, $i==$L-1); } } else { $return = '
'. ''. '
'. ''.$value[num].''.cplang('delete').''; for($i=0,$L=count($value['children']); $i<$L; $i++) { $return .= showcategoryrow($value['children'][$i], 1, ''); } $return .= '
'.cplang('blogcategory_addsubcategory').'
'; } return $return; } ?>