<?php
/*
转换文章分类
portal_category
*/

if($start <= 1){
	truncatetable('portal_category');
}

$maxfid = $xc->db['source']->result($xc->db['source']->query("SELECT max(column_id) FROM {$source_tablepre}cms_column"), 0);
if($start < $maxfid){
	$converted = 1;
}


$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}cms_column WHERE column_id >= $start AND column_id < $start + $rpp") or dexit();
while ($pwcmsclass = $xc->db['source']->fetch_array($query)) {
	$pwcmsclass			=	daddslashes($pwcmsclass);

	//portal_category
	$catid				=	$pwcmsclass['column_id'];
	$upid				=	$pwcmsclass['parent_id'];
	$catname			=	$pwcmsclass['name'];
	$articles			=	$xc->db['source']->result($xc->db['source']->query("SELECT count(article_id) FROM {$source_tablepre}cms_article WHERE column_id='$catid'"),0);
	$displayorder		=	$pwcmsclass['order'];
	$closed				=	$pwcmsclass['allowoffer'];
	$description		=	$pwcmsclass['seodesc'];
	$keyword			=	$pwcmsclass['seokeywords'];

	$field1		=	array('catid', 'upid', 'catname', 'articles', 'displayorder', 'closed', 'description', 'keyword');
	$query1		=	getinsertsql("{$discuz_tablepre}portal_category", $field1);


	if ($xc->db['discuz']->query($query1)) {
		$convertedrows ++;
	} else {
		reportlog("无法转换栏目 catid = $catid catname = '$catname'，SQL 语句如下 ：<br><textarea rows=\"3\" style=\"width: 100%;\">".$sql."</textarea>");
	}

	$totalrows ++;
}
?>
