Location: PHPKode > projects > COWeb (Common Objects for Web) > coweb-0.4.1/include/buttons.inc.php
<?
// Module de gestion des boutons
// Ecrit par Sébastien DIAZ
// Distribue sous license GPL


include "coweb.inc.php";

if (! defined("BUTTONS"))
{
	define("BUTTONS",1);

	class buttons extends images
	{
		var $image2;			// Adresse physique de l'image de survol

		function buttons($id, $table)
		// Constructeur
		{

			if (isset($id))
			{
			 	$dbl=new db(server, port, database, login, password, type);
				$dbl->connect();
				$dbl->query("	SELECT id, label, url, description, flag, follow, param, image, image2
						FROM $table
						WHERE id=$id"
						);
				$dbl->fetch();
				$this->id=stripslashes($dbl->row["id"]);
				$this->label=stripslashes($dbl->row["label"]);
				$this->url=stripslashes($dbl->row["url"]);				
				$this->description=stripslashes($dbl->row["description"]);				
				$this->flag=stripslashes($dbl->row["flag"]);
				$this->follow=stripslashes($dbl->row["follow"]);
				$this->param=stripslashes($dbl->row["param"]);
				$this->image=stripslashes($dbl->row["image"]);
				$this->image=stripslashes($dbl->row["image2"]);
			}
			else 
			{
				$this->id="";
				$this->label="";
				$this->url="";
				$this->description="";
				$this->flag="1";
				$this->follow="";
				$this->param="";
				$this->image="";
				$this->image2="";
			}
			$this->table=$table;
		}
	
	function Add()
	// Insertion d'un nouveau boutton
	{
		$dbl=new db(server, port, database, login, password, type);
		$dbl->connect();
		$dbl->query("	INSERT $this->table
				VALUES ('', '$this->label', '$this->url', '$this->description', '1', '0', '', '$this->image', '$this->image2')
				");
		$this->id=mysql_insert_id($dbl->id);
	}

	function Update()
	// Modification d'un boutton
	{
		$dbl=new db(server, port, database, login, password, type);
		$dbl->connect();
		$dbl->query("	UPDATE $this->table
				SET label='$this->label',
				url='$this->url',
				description='$this->description',
				flag='$this->flag',
				follow='$this->follow',
				param='$this->param',
				image='$this->image',
				image2='$this->image2'
				WHERE id=$this->id
			");
		$dbl->fetch();
	}

	
	
	function Generate()
	// Creation d'une table de bouttons
	{
		$dbl=new db(server, port, database, login, password, type);
		$dbl->Connect();
		$sql="	CREATE TABLE $this->table
			(
			id int(11) NOT NULL auto_increment,
			label varchar(64) default NULL,
			url tinytext,
			description tinytext,
			flag char(1) NOT NULL default '1',
			follow tinyint(4) NOT NULL default '0',
			param varchar(16) NOT NULL default '',
			image varchar(64) default NULL,
			image2 varchar(64) default NULL,
			UNIQUE KEY id (id)
			)";
		$dbl->Query($sql);
	}

}
}

?>
Return current item: COWeb (Common Objects for Web)