Subversion-Projekte lars-tiefland.medien

Revision

Revision 82 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
68 lars 1
<?
9 lars 2
	Class Album
3
	{
4
		var $id;
5
		var $name;
13 lars 6
		var $sampler;
17 lars 7
		var $genre;
9 lars 8
		var $pic;
9
		var $year;
26 lars 10
		var $p_del;
34 lars 11
		var $artist;
9 lars 12
 
13
		function __construct($id=0)
14
		{
15
			global $db, $prefix;
16
			if ($id)
17
			{
18
				$sql="SELECT * FROM $prefix"."albums WHERE a_id=$id";
19
				$res=$db->query($sql);
20
				$row=$res->fetchRow();
10 lars 21
				$this->id=$id;
52 lars 22
				$this->name=stripslashes($row["a_name"]);
13 lars 23
				$this->sampler=$row["a_sampler"];
17 lars 24
				$this->genre=$row["a_genre"];
9 lars 25
				$this->year=$row["a_year"];
52 lars 26
				$this->pic =stripslashes(($row["a_pic"])?$row["a_pic"]:"nopic.jpg");
34 lars 27
				$this->artist=$row["a_artist"];
9 lars 28
			}
29
			else
30
			{
10 lars 31
				$this->id=0;
9 lars 32
				$this->name="";
13 lars 33
				$this->sampler=0;
20 lars 34
				$this->genre=-1;
9 lars 35
				$this->pic="";
36
				$this->year=0;
34 lars 37
				$this->artist=0;
9 lars 38
			}
39
			return $this;
40
		}
13 lars 41
		function Album($id=0)
9 lars 42
		{
43
			$this->__construct($id);
44
		}
45
 
34 lars 46
		function update($a_name, $a_pic, $a_year, $a_sampler=0, $a_genre=0, $p_del=0, $a_artist=0)
10 lars 47
		{
48
			$this->name=$a_name;
13 lars 49
			$this->sampler=$a_sampler;
10 lars 50
			$this->year=$a_year;
51
			$this->pic=$a_pic;
17 lars 52
			$this->genre=$a_genre;
26 lars 53
			$this->p_del=$p_del;
34 lars 54
			$this->artist=$a_artist;
10 lars 55
		}
56
 
57
		function save($mode="save")
58
		{
59
			global $db, $prefix;
60
			switch ($mode)
61
			{
62
				case "save":
61 lars 63
					$sql="INSERT INTO $prefix"."albums (a_name, a_sampler, a_pic, a_year, a_genre, a_artist) VALUES ('$this->name', $this->sampler, '$this->pic', $this->year, $this->genre, $this->artist)";
10 lars 64
					break;
65
				case "update":
66
					$pic_sql="";
26 lars 67
					if ($this->pic || $this->p_del)
10 lars 68
					{
69
						$pic_sql="a_pic='$this->pic',";
70
					}
34 lars 71
					$sql="UPDATE $prefix"."albums SET a_name='$this->name', a_sampler=$this->sampler, ".$pic_sql." a_year=$this->year, a_genre=$this->genre, a_artist=$this->artist WHERE a_id=$this->id";
10 lars 72
					break;
73
				case "del":
74
					break;
75
			}
76
			return $db->query($sql);
77
		}
16 lars 78
 
79
		function Liste($start=0,$anz=0)
80
		{
81
			global $db, $prefix, $common;
82
			$sql="SELECT * FROM $prefix"."albums";
83
			if ($anz > 0)
84
			{
85
				$res=$db->limitquery($sql,$start,$anz);
86
				$id=0;
67 lars 87
				$ret=array(array());
16 lars 88
				while ($row=$res->fetchRow())
89
				{
90
					$ret[$id]["link_id"]=$row["a_id"];
52 lars 91
					$ret[$id]["a_name"]=stripslashes($row["a_name"]);
16 lars 92
					$ret[$id]["a_year"]=($row["a_year"])?$row["a_year"]:$common["unknown"];
52 lars 93
					$ret[$id]["a_pic"]=stripslashes(($row["a_pic"])?$row["a_pic"]:"nopic.jpg");
39 lars 94
					$ret[$id]["a_type"]=($row["a_sampler"])?$common["yes"]:$common["no"];
34 lars 95
					$artist=new Artist($row["a_artist"]);
96
					if($row["a_artist"]==1)
97
					{
98
						$ret[$id]["a_artist"]=$common["$artist->name"];
99
					}
100
					else
101
					{
102
						$ret[$id]["a_artist"]=($artist->fname)?"$artist->fname $artist->name":"$artist->name";
103
					}
17 lars 104
					$g=new Genre($row["a_genre"]);
105
					$ret[$id]["a_genre"]=$g->name;
16 lars 106
					$id++;
107
				}
108
				return $ret;
109
			}
110
			else
111
			{
112
				$res=$db->query($sql);
113
				return $res->numRows();
114
			}
115
		}
23 lars 116
 
117
		function getAlbums()
118
		{
119
			global $db, $prefix, $common;
63 lars 120
			$sql="SELECT * FROM $prefix"."albums ORDER BY a_name";
23 lars 121
			$res=$db->query($sql);
122
			$ret["-1"]=$common["please_select"];
123
			while ($row=$res->fetchRow())
124
			{
125
				$id=$row["a_id"];
52 lars 126
				$ret[$id]=stripslashes($row["a_name"]);
23 lars 127
			}
128
			return $ret;
129
		}
9 lars 130
	}
131
?>