<?php
/**
 *	Generated by miceCMS
 *	Date: 2010-11-18 10:50:22
 */
class model_Menu {
	private $subsection="";
	private $setstr="";
	private $fields="";
	private $values="";
	private $nrows="";
	private $offset="";
	private $pages=10;
	private $pagenum=1;
	private $menuId=Null;		//	 field type: "int(11+int)"
	private $title=Null;		//	 field type: "varchar(50+varchar)"
	private $parentid=0;		//	 field type: "int(11+int)"
	private $path=Null;		//	 field type: "varchar(255+varchar)"
	private $orderid=0;		//	 field type: "int(11+int)"
	private $depth=0;		//	 field type: "int(11+int)"
	private $childcount=0;		//	 field type: "int(11+int)"
	private $summary=Null;		//	 field type: "varchar(255+varchar)"
	private $tags=Null;		//	 field type: "varchar(200+varchar)"
	private $img=Null;		//	 field type: "varchar(200+varchar)"
	private $isvisible=0;		//	 field type: "int(11+int)"
	private $url=Null;		//	 field type: "varchar(200+varchar)"

	public function getMenuId(){
		return $this->menuId;
	}
	public function setMenuId($menuId){
		$this->menuId=$menuId;
		if($this->setstr=="")
			$this->setstr="menu_id=".$menuId."";
		else
			$this->setstr.=",menu_id=".$menuId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="menu_id";
			$this->values="".$menuId."";
		}else{
			$this->fields.=",menu_id";
			$this->values.=",".$menuId."";
		}
	}
	public function getTitle(){
		return $this->title;
	}
	public function setTitle($title){
		$this->title=$title;
		if($this->setstr=="")
			$this->setstr="title='".$title."'";
		else
			$this->setstr.=",title='".$title."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="title";
			$this->values="'".$title."'";
		}else{
			$this->fields.=",title";
			$this->values.=",'".$title."'";
		}
	}
	public function getParentid(){
		return $this->parentid;
	}
	public function setParentid($parentid){
		$this->parentid=$parentid;
		if($this->setstr=="")
			$this->setstr="parentid=".$parentid."";
		else
			$this->setstr.=",parentid=".$parentid."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="parentid";
			$this->values="".$parentid."";
		}else{
			$this->fields.=",parentid";
			$this->values.=",".$parentid."";
		}
	}
	public function getPath(){
		return $this->path;
	}
	public function setPath($path){
		$this->path=$path;
		if($this->setstr=="")
			$this->setstr="path='".$path."'";
		else
			$this->setstr.=",path='".$path."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="path";
			$this->values="'".$path."'";
		}else{
			$this->fields.=",path";
			$this->values.=",'".$path."'";
		}
	}
	public function getOrderid(){
		return $this->orderid;
	}
	public function setOrderid($orderid){
		$this->orderid=$orderid;
		if($this->setstr=="")
			$this->setstr="orderid=".$orderid."";
		else
			$this->setstr.=",orderid=".$orderid."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="orderid";
			$this->values="".$orderid."";
		}else{
			$this->fields.=",orderid";
			$this->values.=",".$orderid."";
		}
	}
	public function getDepth(){
		return $this->depth;
	}
	public function setDepth($depth){
		$this->depth=$depth;
		if($this->setstr=="")
			$this->setstr="depth=".$depth."";
		else
			$this->setstr.=",depth=".$depth."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="depth";
			$this->values="".$depth."";
		}else{
			$this->fields.=",depth";
			$this->values.=",".$depth."";
		}
	}
	public function getChildcount(){
		return $this->childcount;
	}
	public function setChildcount($childcount){
		$this->childcount=$childcount;
		if($this->setstr=="")
			$this->setstr="childcount=".$childcount."";
		else
			$this->setstr.=",childcount=".$childcount."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="childcount";
			$this->values="".$childcount."";
		}else{
			$this->fields.=",childcount";
			$this->values.=",".$childcount."";
		}
	}
	public function getSummary(){
		return $this->summary;
	}
	public function setSummary($summary){
		$this->summary=$summary;
		if($this->setstr=="")
			$this->setstr="summary='".$summary."'";
		else
			$this->setstr.=",summary='".$summary."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="summary";
			$this->values="'".$summary."'";
		}else{
			$this->fields.=",summary";
			$this->values.=",'".$summary."'";
		}
	}
	public function getTags(){
		return $this->tags;
	}
	public function setTags($tags){
		$this->tags=$tags;
		if($this->setstr=="")
			$this->setstr="tags='".$tags."'";
		else
			$this->setstr.=",tags='".$tags."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="tags";
			$this->values="'".$tags."'";
		}else{
			$this->fields.=",tags";
			$this->values.=",'".$tags."'";
		}
	}
	public function getImg(){
		return $this->img;
	}
	public function setImg($img){
		$this->img=$img;
		if($this->setstr=="")
			$this->setstr="img='".$img."'";
		else
			$this->setstr.=",img='".$img."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="img";
			$this->values="'".$img."'";
		}else{
			$this->fields.=",img";
			$this->values.=",'".$img."'";
		}
	}
	public function getIsvisible(){
		return $this->isvisible;
	}
	public function setIsvisible($isvisible){
		$this->isvisible=$isvisible;
		if($this->setstr=="")
			$this->setstr="isvisible=".$isvisible."";
		else
			$this->setstr.=",isvisible=".$isvisible."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="isvisible";
			$this->values="".$isvisible."";
		}else{
			$this->fields.=",isvisible";
			$this->values.=",".$isvisible."";
		}
	}
	public function getUrl(){
		return $this->url;
	}
	public function setUrl($url){
		$this->url=$url;
		if($this->setstr=="")
			$this->setstr="url='".$url."'";
		else
			$this->setstr.=",url='".$url."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="url";
			$this->values="'".$url."'";
		}else{
			$this->fields.=",url";
			$this->values.=",'".$url."'";
		}
	}
	public function setSubsection($str){
		$this->subsection=" ".$str;
	}
	public function setNrows($str){
		$this->nrows=$str;
	}
	public function setOffset($str){
		$this->offset=$str;
	}
	public function setPages($str){
		$this->pages=$str;
	}
	public function setPagenum($str){
		$this->pagenum=$str;
	}
	public function doSelect() {
		global $conn;
		$result=$conn->SelectArray("#__menu ","*",$this->subsection);
		return $this->fetchResult($result);
	}
	public function doSelectLimit() {
		global $conn;
		$result=$conn->SelectArrayLimit("#__menu ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResult($result);
	}
	public function doSelectOne() {
		global $conn;
		$result=$conn->SelectRow("#__menu ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResultOne($result);
	}
	public function doCount() {
		global $conn;
		return $conn->SelectCount("#__menu ","*",$this->subsection);
	}
	public function doInsert() {
		global $conn;
		return $conn->Insert("#__menu ",$this->fields,$this->values);
	}
	public function doDelete() {
		global $conn;
		return $conn->Delete("#__menu ",$this->subsection);
	}
	public function doUpdate() {
		global $conn;
		return $conn->Update("#__menu ",$this->setstr,$this->subsection);
	}
	public function Pager() {
		$this->nrows=($this->pagenum-1)*$this->pages;
		$this->offset=$this->pages;
		return $this->doSelectLimit();
	}
	public function Page() {
		return $this->pagenum;
	}
	public function Totals() {
		return $this->doCount();
	}
	public function TotalPages() {
		if (!$this->doCount())	return 0;
		return (int)ceil($this->Totals()/$this->pages);
	}
	public function fetchResult($result){
		if(!$result){
			return $result;
		}
		$array=new ArrayObject();
		for($i=0;$i<count($result);$i++){
			$menu=new model_Menu();
			$menu->menuId=$result[$i]["menu_id"];
			$menu->title=$result[$i]["title"];
			$menu->parentid=$result[$i]["parentid"];
			$menu->path=$result[$i]["path"];
			$menu->orderid=$result[$i]["orderid"];
			$menu->depth=$result[$i]["depth"];
			$menu->childcount=$result[$i]["childcount"];
			$menu->summary=$result[$i]["summary"];
			$menu->tags=$result[$i]["tags"];
			$menu->img=$result[$i]["img"];
			$menu->isvisible=$result[$i]["isvisible"];
			$menu->url=$result[$i]["url"];
			$array->append($menu);
		}
		return $array;
	}
	public function fetchResultOne($result){
		if(!$result){
			return $result;
		}
		$menu=new model_Menu();
		$menu->menuId=$result["menu_id"];
		$menu->title=$result["title"];
		$menu->parentid=$result["parentid"];
		$menu->path=$result["path"];
		$menu->orderid=$result["orderid"];
		$menu->depth=$result["depth"];
		$menu->childcount=$result["childcount"];
		$menu->summary=$result["summary"];
		$menu->tags=$result["tags"];
		$menu->img=$result["img"];
		$menu->isvisible=$result["isvisible"];
		$menu->url=$result["url"];
		return $menu;
	}
}
?>