<?php

class ClearHtmlAction extends CommonAction {
	
	public function index() {

	}


	//一鍵更新靜態緩存html
	public function all() {

		if (IS_POST) {
			delCacheHtml('', true);
			$this->success('更新成功!', U(GROUP_NAME.'/ClearHtml/all'));
			exit();
		}

		$this->type = '一鍵更新|靜態緩存';
		$this->display();
	}


	//更新首頁靜態緩存html
	public function home() {

		if (IS_POST) {
			delCacheHtml('Index_index', false, 'index:index');
			$this->success('更新成功!', U(GROUP_NAME.'/ClearHtml/home'));
			exit();
		}

		$this->type = '更新首頁|靜態緩存';
		$this->display('all');
	}

	//更新欄目靜態緩存html
	public function lists() {

		if (IS_POST) {
			$isall = I('get.isall', 0, 'intval');
			if ($isall) {
				delCacheHtml('List', true, '');
			}else {
				$idArr = I('key', array(), '');
				$cate = M('category')->where(array('id' => array('IN', $idArr), 'type' => 0))->field(array('id', 'ename'))->select();
				foreach ($cate as $v) {
					//更新靜態緩存
					delCacheHtml('List/index_'.$v['id'].'_', false, 'list:index');
					delCacheHtml('List/index_'.$v['ename'], false, 'list:index');//還有只有名稱
				}

			}
			
			$this->success('更新成功!', U(GROUP_NAME.'/ClearHtml/lists'));
			exit();
		}

		$cate = D('CategoryView')->nofield('content')->where(array('category.type' => 0))->order('category.sort,category.id')->select();
		//$cate = getCategory();
		import('Class.Category', APP_PATH);
		$this->cate = Category::toLevel($cate, '&nbsp;&nbsp;&nbsp;&nbsp;', 0);

		$this->type = '更新欄目|靜態緩存';
		$this->display('all');
	}


	//更新內容頁靜態緩存html
	public function shows() {

		if (IS_POST) {
			$isall = I('get.isall', 0, 'intval');
			if ($isall) {
				delCacheHtml('Show', true, '');
			}else {
				$idArr = I('key', array(), '');
				$cate = D('CategoryView')->where(array('category.id' => array('IN', $idArr), 'type' => 0))->field(array('id', 'ename', 'tablename'))->select();
				foreach ($cate as $v) {
					//更新靜態緩存
					delCacheHtml('Show/index_'.$v['id'].'_', false, 'show:index');
					delCacheHtml('Show/index_'.$v['ename'], false, 'show:index');//還有只有名稱
				}

			}
			
			$this->success('更新成功!', U(GROUP_NAME.'/ClearHtml/shows'));
			exit();
		}

		$cate = D('CategoryView')->where(array('category.type' => 0))->order('category.sort,category.id')->select();
		//$cate = getCategory();
		import('Class.Category', APP_PATH);
		$this->cate = Category::toLevel($cate, '&nbsp;&nbsp;&nbsp;&nbsp;', 0);

		$this->type = '更新內容頁(文檔)|靜態緩存';
		$this->display('all');
	}

	//更新專題靜態緩存html
	public function special() {

		if (IS_POST) {
			$isall = I('get.isall', 0, 'intval');
			if ($isall) {
				delCacheHtml('Special', true, '');
			}else {				
					delCacheHtml('Special/index', false, 'special:index');
			}
			
			$this->success('更新成功!', U(GROUP_NAME.'/ClearHtml/special'));
			exit();
		}


		$this->type = '更新專題|靜態緩存';
		$this->display('all');
	}




}


?>