<?php
/**
 *	Generated by miceCMS
 *	Date: 2010-11-18 10:50:22
 */
class model_Category {
	private $subsection="";
	private $setstr="";
	private $fields="";
	private $values="";
	private $nrows="";
	private $offset="";
	private $pages=10;
	private $pagenum=1;
	private $categoryId=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 $type=Null;		//	 field type: "varchar(25+varchar)"
	private $tpl=Null;		//	 field type: "varchar(200+varchar)"
	private $indextpl=Null;		//	 field type: "varchar(200+varchar)"
	private $subtpl=Null;		//	 field type: "varchar(200+varchar)"
	private $url=Null;		//	 field type: "varchar(200+varchar)"
	private $target=Null;		//	 field type: "varchar(20+varchar)"
	private $filename=Null;		//	 field type: "varchar(255+varchar)"
	private $listrule=Null;		//	 field type: "varchar(200+varchar)"
	private $articlerule=Null;		//	 field type: "varchar(200+varchar)"
	private $ishtml=0;		//	 field type: "int(11+int)"
	private $usergroupId=-1;		//	 field type: "int(11+int)"

	public function getCategoryId(){
		return $this->categoryId;
	}
	public function setCategoryId($categoryId){
		$this->categoryId=$categoryId;
		if($this->setstr=="")
			$this->setstr="category_id=".$categoryId."";
		else
			$this->setstr.=",category_id=".$categoryId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="category_id";
			$this->values="".$categoryId."";
		}else{
			$this->fields.=",category_id";
			$this->values.=",".$categoryId."";
		}
	}
	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 getType(){
		return $this->type;
	}
	public function setType($type){
		$this->type=$type;
		if($this->setstr=="")
			$this->setstr="type='".$type."'";
		else
			$this->setstr.=",type='".$type."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="type";
			$this->values="'".$type."'";
		}else{
			$this->fields.=",type";
			$this->values.=",'".$type."'";
		}
	}
	public function getTpl(){
		return $this->tpl;
	}
	public function setTpl($tpl){
		$this->tpl=$tpl;
		if($this->setstr=="")
			$this->setstr="tpl='".$tpl."'";
		else
			$this->setstr.=",tpl='".$tpl."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="tpl";
			$this->values="'".$tpl."'";
		}else{
			$this->fields.=",tpl";
			$this->values.=",'".$tpl."'";
		}
	}
	public function getIndextpl(){
		return $this->indextpl;
	}
	public function setIndextpl($indextpl){
		$this->indextpl=$indextpl;
		if($this->setstr=="")
			$this->setstr="indextpl='".$indextpl."'";
		else
			$this->setstr.=",indextpl='".$indextpl."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="indextpl";
			$this->values="'".$indextpl."'";
		}else{
			$this->fields.=",indextpl";
			$this->values.=",'".$indextpl."'";
		}
	}
	public function getSubtpl(){
		return $this->subtpl;
	}
	public function setSubtpl($subtpl){
		$this->subtpl=$subtpl;
		if($this->setstr=="")
			$this->setstr="subtpl='".$subtpl."'";
		else
			$this->setstr.=",subtpl='".$subtpl."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="subtpl";
			$this->values="'".$subtpl."'";
		}else{
			$this->fields.=",subtpl";
			$this->values.=",'".$subtpl."'";
		}
	}
	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 getTarget(){
		return $this->target;
	}
	public function setTarget($target){
		$this->target=$target;
		if($this->setstr=="")
			$this->setstr="target='".$target."'";
		else
			$this->setstr.=",target='".$target."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="target";
			$this->values="'".$target."'";
		}else{
			$this->fields.=",target";
			$this->values.=",'".$target."'";
		}
	}
	public function getFilename(){
		return $this->filename;
	}
	public function setFilename($filename){
		$this->filename=$filename;
		if($this->setstr=="")
			$this->setstr="filename='".$filename."'";
		else
			$this->setstr.=",filename='".$filename."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="filename";
			$this->values="'".$filename."'";
		}else{
			$this->fields.=",filename";
			$this->values.=",'".$filename."'";
		}
	}
	public function getListrule(){
		return $this->listrule;
	}
	public function setListrule($listrule){
		$this->listrule=$listrule;
		if($this->setstr=="")
			$this->setstr="listrule='".$listrule."'";
		else
			$this->setstr.=",listrule='".$listrule."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="listrule";
			$this->values="'".$listrule."'";
		}else{
			$this->fields.=",listrule";
			$this->values.=",'".$listrule."'";
		}
	}
	public function getArticlerule(){
		return $this->articlerule;
	}
	public function setArticlerule($articlerule){
		$this->articlerule=$articlerule;
		if($this->setstr=="")
			$this->setstr="articlerule='".$articlerule."'";
		else
			$this->setstr.=",articlerule='".$articlerule."'";
		if($this->fields=="" AND $this->values==""){
			$this->fields="articlerule";
			$this->values="'".$articlerule."'";
		}else{
			$this->fields.=",articlerule";
			$this->values.=",'".$articlerule."'";
		}
	}
	public function getIshtml(){
		return $this->ishtml;
	}
	public function setIshtml($ishtml){
		$this->ishtml=$ishtml;
		if($this->setstr=="")
			$this->setstr="ishtml=".$ishtml."";
		else
			$this->setstr.=",ishtml=".$ishtml."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="ishtml";
			$this->values="".$ishtml."";
		}else{
			$this->fields.=",ishtml";
			$this->values.=",".$ishtml."";
		}
	}
	public function getUsergroupId(){
		return $this->usergroupId;
	}
	public function setUsergroupId($usergroupId){
		$this->usergroupId=$usergroupId;
		if($this->setstr=="")
			$this->setstr="usergroup_id=".$usergroupId."";
		else
			$this->setstr.=",usergroup_id=".$usergroupId."";
		if($this->fields=="" AND $this->values==""){
			$this->fields="usergroup_id";
			$this->values="".$usergroupId."";
		}else{
			$this->fields.=",usergroup_id";
			$this->values.=",".$usergroupId."";
		}
	}
	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("#__category ","*",$this->subsection);
		return $this->fetchResult($result);
	}
	public function doSelectLimit() {
		global $conn;
		$result=$conn->SelectArrayLimit("#__category ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResult($result);
	}
	public function doSelectOne() {
		global $conn;
		$result=$conn->SelectRow("#__category ","*",$this->subsection,$this->nrows,$this->offset);
		return $this->fetchResultOne($result);
	}
	public function doCount() {
		global $conn;
		return $conn->SelectCount("#__category ","*",$this->subsection);
	}
	public function doInsert() {
		global $conn;
		return $conn->Insert("#__category ",$this->fields,$this->values);
	}
	public function doDelete() {
		global $conn;
		return $conn->Delete("#__category ",$this->subsection);
	}
	public function doUpdate() {
		global $conn;
		return $conn->Update("#__category ",$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++){
			$category=new model_Category();
			$category->categoryId=$result[$i]["category_id"];
			$category->title=$result[$i]["title"];
			$category->parentid=$result[$i]["parentid"];
			$category->path=$result[$i]["path"];
			$category->orderid=$result[$i]["orderid"];
			$category->depth=$result[$i]["depth"];
			$category->childcount=$result[$i]["childcount"];
			$category->summary=$result[$i]["summary"];
			$category->tags=$result[$i]["tags"];
			$category->img=$result[$i]["img"];
			$category->isvisible=$result[$i]["isvisible"];
			$category->type=$result[$i]["type"];
			$category->tpl=$result[$i]["tpl"];
			$category->indextpl=$result[$i]["indextpl"];
			$category->subtpl=$result[$i]["subtpl"];
			$category->url=$result[$i]["url"];
			$category->target=$result[$i]["target"];
			$category->filename=$result[$i]["filename"];
			$category->listrule=$result[$i]["listrule"];
			$category->articlerule=$result[$i]["articlerule"];
			$category->ishtml=$result[$i]["ishtml"];
			$category->usergroupId=$result[$i]["usergroup_id"];
			$array->append($category);
		}
		return $array;
	}
	public function fetchResultOne($result){
		if(!$result){
			return $result;
		}
		$category=new model_Category();
		$category->categoryId=$result["category_id"];
		$category->title=$result["title"];
		$category->parentid=$result["parentid"];
		$category->path=$result["path"];
		$category->orderid=$result["orderid"];
		$category->depth=$result["depth"];
		$category->childcount=$result["childcount"];
		$category->summary=$result["summary"];
		$category->tags=$result["tags"];
		$category->img=$result["img"];
		$category->isvisible=$result["isvisible"];
		$category->type=$result["type"];
		$category->tpl=$result["tpl"];
		$category->indextpl=$result["indextpl"];
		$category->subtpl=$result["subtpl"];
		$category->url=$result["url"];
		$category->target=$result["target"];
		$category->filename=$result["filename"];
		$category->listrule=$result["listrule"];
		$category->articlerule=$result["articlerule"];
		$category->ishtml=$result["ishtml"];
		$category->usergroupId=$result["usergroup_id"];
		return $category;
	}
}
?>