<?php
defined('PHP168_PATH') or die();

$this_controller->check_admin_action($ACTION) or message('no_privilege');

if(REQUEST_METHOD == 'GET'){
	$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
	$page = max(1, $page);

	$page_url = $this_router .'-'. $ACTION .'?page=?page?';
	$count = 0;
	$select = select();
	$select -> from($this_module->table,'*');
	$select -> order('id DESC');
	$list = $core->list_item(
		$select,
		array(
			'page' => &$page,
			'count' => &$count,
			'page_size' => 20
		)
	);

	$pages = list_page(array(
		'count' => $count,
		'page' => $page,
		'page_size' => 20,
		'url' => $page_url
	));
	
	include template($this_module, 'item', 'admin');
}else if(REQUEST_METHOD == 'POST'){
	//include $this_module->path .'call/import_list.call.php';
	//修复栏目内容数
	$DB_master->update($this_module->table, array('post' => 0), '');
	
	$query = $DB_master->query("SELECT iid, COUNT(*) AS `count` FROM $this_module->data_table GROUP BY iid");
	while($arr = $DB_master->fetch_array($query)){
		$this_module->update_count($arr['iid'], $arr['count'],true);
	}
	message('done');
}
