<?php
/*
######################      CWB\     #######################
############################################################
CWB PRO			$Name: release_version1_0_03112006 $
Revision		$Revision: 1.1 $
Author			$Author: zelteto $
Created 03/01/03        $Date: 2006/10/18 11:53:33 $
Writed by               GraFX (webmaster@grafxsoftware.com)
Scripts Home:           http://www.grafxsoftware.com
############################################################
*/
class Pages
{
	var $id;
	var $title;
	var $description;
	var $keyword;
	var $first;
    var $data;
	
	function Pages($id="")
	{

	   $mf=new MiniFile("bd.php");
	   $this->data=$mf->getArray();	
	   
	   $this->id=$id;
       if(!empty($this->id)){
	   $this->title=$this->data[$this->id]["title"];
	   $this->description=$this->data[$this->id]["description"];
	   $this->keyword=$this->data[$this->id]["keyword"];
   
	   }
	        
	}//end constructor Pages

	function getId()
	{
		return $this->id;
	}//end getId
	
	function getTitle()
	{
		return $this->title;
	}//end getEnTitle

	function getDescription()
	{
		return $this->description;
	}//end getEnPages
	

	function getKeyword()
	{
		return $this->keyword;
	}//end getKeyword
	
	function setId($s)
	{
		$this->id = $s;
	}//end setId
	
	function setTitle($s)
	{
		$this->title = $s;
	}//end setEnTitle
	
	
	function setDescription($s)
	{
		$this->description = $s;
	}//end setEnPages
	
	
	function setKeyword($keyword)
	{
		$this->keyword = $keyword;
	}//end setKeyword
		
	function setFirst($id)
	{
		$new=$this->data;
		foreach( $new as $key =>$value)
		       if($key==$id)
			         $this->data[$key]["first"]=1;
				else
				     $this->data[$key]["first"]=0; 	  
		
	}//end setKeyword		
	
	function getFirstElement()
	{
		$new=$this->data;
		foreach( $new as $key =>$value)
		       if($this->data[$key]["first"]==1)
			         return $key;
		return "";		
		
	}//end setKeyword		
	
		
	function save()
	{
		if(!is_array($this->data))
		       $data=array();
		 
		if(!empty($this->id)){
				$this->data[$this->id]["title"]=$this->title;
				$this->data[$this->id]["description"]=$this->description;
				$this->data[$this->id]["keyword"]=$this->keyword;
				$this->data[$this->id]["time"]=time();
				if(empty($this->data[$this->id]["first"]))
					$this->data[$this->id]["first"]=0;
		}
		

		$mf=new MiniFile("bd.php");
		$mf->setArray($this->data);
		$mf->save();
	}//end save()
	function delete($values)
	{
		if(is_array($values)){
		 foreach ($values as $value)
			 unset($this->data[$value]);
		
		}
		else
		 unset($this->data[$this->id]);
		 
		$mf=new MiniFile("bd.php");
		$mf->setArray($this->data);
		$mf->save();
		
	}//end delete
	
	
}//end class Pages
?>