<?php
/**
 *	Generated by miceCMS
 *	http://www.miceCMS.com/
 */
class config_indexAction extends security_login {
	function action(){
		//接收参数并放入Session
		ModuleLimit(__CLASS__);
		$miceSession = new session();
		if($_POST['isuse']=='0'){
			$miceSession->set('ci_isuse','0');
		}elseif($_POST['isuse']=='1'){
			$miceSession->set('ci_isuse','1');
		}elseif($miceSession->get('ci_isuse')!='0' and $miceSession->get('ci_isuse')!='1'){
			$miceSession->set('ci_isuse','2');
		}

		if($_POST['keywords']){
			$miceSession->set('ci_keywords',$_POST['keywords']);
		}elseif($miceSession->get('ci_keywords')<='0'){
			$miceSession->set('ci_keywords','标记');
		}

		if($_POST['pages']){
			$miceSession->set('ci_pages',$_POST['pages']);
		}elseif($miceSession->get('ci_pages')<=0 or $_POST['pages']=='20'){
			$miceSession->set('ci_pages',20);
		}

		if($this->_getParam('page')){
			$miceSession->set('ci_page',$this->_getParam('page'));
		}else{
			$miceSession->set('ci_page',1);
		}

		//组合sql
		$subsql=' WHERE 1=1';
		if($miceSession->get('ci_isuse')!='' and $miceSession->get('ci_isuse')!='2'){
			$subsql.=' AND isuse = '.$miceSession->get('ci_isuse');
		}
		if($miceSession->get('ci_keywords')!='标记'){
			$subsql.=' AND (tag LIKE \'%'.$miceSession->get('ci_keywords').'%\')';
		}
		$subsql.=' ORDER BY config_id ASC';

		//查找
		global $conn;
		$config=new model_Config();
		$config->setSubsection($subsql);
		$config->setPagenum($miceSession->get('ci_page'));
		$config->setPages($miceSession->get('ci_pages'));
		$configs=$config->Pager();
		$pager=MicePager($config->TotalPages(),$config->Totals(),$config->Page(),5,MICE_URL.'admin.php/config/config/page/');

		$smarty = new Smarty();
		$smarty->load_filter('pre','micePreCompileAdmin');

		$smarty->assign('index',MICE_URL.'admin.php/config/index');
		$smarty->assign('create',MICE_URL.'admin.php/config/edit');
		$smarty->assign('edit',MICE_URL.'admin.php/config/edit/config_id/');
		$smarty->assign('delete',MICE_URL.'admin.php/config/delete/config_id/');

		$smarty->assign('keywords',$miceSession->get('ci_keywords'));
		$smarty->assign('isuse',$miceSession->get('ci_isuse'));
		$smarty->assign('pages',$miceSession->get('ci_pages'));

		$smarty->assign('results',$configs);
		$smarty->assign('pager',$pager);
		$filename = new getTPLFileName(__CLASS__);
		$smarty->display($filename->TPLFileName);
	}
}
?>