<?php
class AdminView
{
	public $mkstr;
	public $wapid;
	public $cid;
	
	function __construct($mkstr,$cid)
	{
		$this -> mkstr = $mkstr;
		$this -> wapid = WAPID;
		$this -> cid   = $cid;
	}
	
	function showClass(){
		if($_GET['del'] == NULL){
		$result = mysql_query("SELECT cid,cn,xuhao FROM class WHERE url='".get_mkid($this->mkstr)."' AND siteid ='{$this->wapid}' ORDER BY xuhao DESC");
		$dnum = 0;
		while(list($cid,$cn,$number) = mysql_fetch_row($result))
		{
			$div = $dnum++%2 == 0 ? 'line1' : 'line2';
			$show .= '<div class="'.$div.'">';
			$show .= '<a href="?cid='.$cid.'">'.$cn.'</a>';
			$show .= '[<a href="?del='.$cid.'">删除</a>]';
			$show .= '</div>';
		}
		return $show;
		}else{
			return $this->delClass();
		}
	}
	
	function delClass(){
		if($_GET['q'] != 'y'){
			return '<div class="tip">确定删除此栏目?删除后不可恢复！<br><a href="del='.$_GET['del'].'&q=y">[确定删除此栏目(栏目内的数据不会清空)]</a></div>';
		}else{
			if(mysql_query('DELETE FROM class WHERE siteid= \''.$this->wapid.'\' AND cid=\''.$_GET['del'].'\'')){
				return '<div class="tip">命令执行成功</div>';
			}else{
				return '<div class="tip">命令执行失败</div>';
			}
		}
	}
}