<?php
class flinkAction extends CommonAction{
		private $flink;
		function __construct(){
			parent::__construct();
			$this->flink=new flinkModel();
		}

		function add(){
			$this->display("admin/flink/flink.html");

		}

		function mod(){
			$total = count( $this->flink->total());
			$this->page = new page($total,10,'');
			$val = $this->flink->findAll("",$this->page->getOffset(),10,"","ordering,id");
			$fpage =$this->page->fpage();
			$this->assign("fpage",$fpage);
			$this->assign("flink",$val);
			$this->display("admin/flink/flinkmod.html");

	    }

	    function edit(){
	    	$_POST=$this->flink->find($_REQUEST["id"]);
	    	$this->assign("post",$_POST);
			$this->display("admin/flink/flinkedit.html");


	    }

	    function del(){
	    	if($_REQUEST["id"]=="data"){
				$_REQUEST["id"]=$_REQUEST["xm"];
			}
			if($this->flink->del($_REQUEST["id"])){
				$this->showMsg("成功删除链接","admin.php?m=flink&a=mod");
			}else{
				$this->showMsg("删除链接失败","admin.php?m=flink&a=mod");
			}
	    }

		function flink_insert(){
			if($this->flink->chech_form()){
				if($this->flink->add($_POST)){
					$this->showMsg("成功添加友情链接","admin.php?m=flink&a=mod");
				}else{
					$this->showMsg("添加友情链接失败","admin.php?m=flink&a=add");;
				}

			}else{
				$this->showMsg($this->flink->getMessList(),"admin.php?m=flink&a=add");
			}
		}

		function flink_update(){
			if($this->flink->chech_form()){
				if($this->flink->mod($_POST)){
					$this->showMsg("成功修改友情链接","admin.php?m=flink&a=mod");
				}else{
					$this->showMsg("修改友情链接失败","admin.php?m=flink&a=mod");;
				}

			}else{
				$this->showMsg($this->flink->getMessList(),"admin.php?m=flink&a=mod");
			}

		}

		function ordering(){
			if(empty($_POST['order'])){
				$this->showMsg("没有需要排序的链接","admin.php?m=flink&a=mod");
			}
			if($this->flink->valorder()){
				if($this->flink->ordering()){
					$this->showMsg("排序修改成功","admin.php?m=flink&a=mod");
				}else{
					$this->showMsg("排序修改失败","admin.php?m=flink&a=mod");
				}

			}else{
				$this->showMsg($this->flink->getMessList(),"admin.php?m=flink&a=mod");
			}

		}




}
?>
