Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezmediatype.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezmediatype.php 8138 2001-11-01 08:31:40Z ce $
5 //
6 // Definition of eZMediaType class
7 //
8 // Created on: <29-Jun-2001 11:13:12 jhe>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
29 // include_once( "classes/ezdb.php" );
30 // include_once( "ezmediacatalogue/classes/ezmediaattribute.php" );
31
32 class eZMediaType
33 {
38 function __construct( $id=-1 )
39 {
40 if ( $id != -1 )
41 {
42 $this->ID = $id;
43 $this->get( $this->ID );
44 }
45 }
46
50 function store()
51 {
52 $db =& eZDB::globalDatabase();
53 $res = false;
54
55 if ( !isset( $this->ID ) )
56 {
57 $db->lock( "eZMediaCatalogue_Type" );
58
59 $this->ID = $db->nextID( "eZMediaCatalogue_Type", "ID" );
60
61 $res = $db->query( "INSERT INTO eZMediaCatalogue_Type (ID,Name) VALUES
62 ('$this->ID','$this->Name')" );
63 $db->unlock();
64 }
65 else
66 {
67 $db->query( "UPDATE eZMediaCatalogue_Type SET
68 Name='$this->Name' WHERE ID='$this->ID'" );
69 }
70
71
72 if ( $res == false )
73 $db->rollback( );
74 else
75 $db->commit();
76
77 return true;
78 }
79
83 function get( $id=-1 )
84 {
85 $db =& eZDB::globalDatabase();
86
87 $ret = false;
88 if ( $id != -1 )
89 {
90 $db->array_query( $type_array, "SELECT * FROM eZMediaCatalogue_Type WHERE ID='$id'" );
91
92 if ( count( $type_array ) > 1 )
93 {
94 die( "Error: Media types with the same ID was found in the database. This shouldent happen." );
95 }
96 else if( count( $type_array ) == 1 )
97 {
98 $this->ID =& $type_array[0][$db->fieldName("ID")];
99 $this->Name =& $type_array[0][$db->fieldName("Name")];
100 $ret = true;
101 }
102 }
103
104 return $ret;
105 }
106
110 function &getAll()
111 {
112 $db =& eZDB::globalDatabase();
113
114 $return_array = array();
115 $type_array = array();
116
117 $db->array_query( $type_array, "SELECT ID FROM eZMediaCatalogue_Type ORDER BY Name" );
118
119 for ( $i=0; $i<count($type_array); $i++ )
120 {
121 $return_array[$i] = new eZMediaType( $type_array[$i][$db->fieldName("ID")], 0 );
122 }
123
124 return $return_array;
125 }
126
130 function delete()
131 {
132 $db =& eZDB::globalDatabase();
133
134 // delete all attributes and values
135 $attributes = $this->attributes();
136 foreach ( $attributes as $attribute )
137 {
138 $attribute->delete();
139 }
140
141 $db->query( "DELETE FROM eZMediaCatalogue_TypeLink WHERE TypeID='$this->ID'" );
142 $db->query( "DELETE FROM eZMediaCatalogue_Type WHERE ID='$this->ID'" );
143 }
144
148 function id()
149 {
150 return $this->ID;
151 }
152
156 function name()
157 {
158 $this->Name = stripslashes($this->Name);
159 return $this->Name;
160 }
161
165 function description()
166 {
167 $this->Description = stripslashes($this->Description);
168 return $this->Description;
169 }
170
174 function setName( $value )
175 {
176 $this->Name = $value;
177 }
178
182 function setDescription( $value )
183 {
184 $this->Description = $value;
185 }
186
191 function attributes( )
192 {
193 $db =& eZDB::globalDatabase();
194
195 $return_array = array();
196 $attribute_array = array();
197
198 $db->array_query( $attribute_array, "SELECT ID
199 FROM eZMediaCatalogue_Attribute
200 WHERE TypeID='$this->ID' ORDER BY Placement" );
201
202 for ( $i=0; $i<count($attribute_array); $i++ )
203 {
204 $return_array[$i] = new eZMediaAttribute( $attribute_array[$i][$db->fieldName("ID")], false );
205 }
206
207 return $return_array;
208 }
209
210 var $ID;
211 var $Name;
212
213 }
214
215 ?>
$i
$i
Definition: admin/adlist.php:91
$Description
$Description
Definition: articlelistrss.php:38
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZMediaAttribute
Definition: ezmediaattribute.php:49
eZMediaType
Definition: ezmediatype.php:33
eZMediaType\id
id()
Definition: ezmediatype.php:148
eZMediaType\$ID
$ID
Definition: ezmediatype.php:210
eZMediaType\name
name()
Definition: ezmediatype.php:156
eZMediaType\__construct
__construct( $id=-1)
Definition: ezmediatype.php:38
eZMediaType\setName
setName( $value)
Definition: ezmediatype.php:174
eZMediaType\description
description()
Definition: ezmediatype.php:165
eZMediaType\store
store()
Definition: ezmediatype.php:50
eZMediaType\$Name
$Name
Definition: ezmediatype.php:211
eZMediaType\setDescription
setDescription( $value)
Definition: ezmediatype.php:182
eZMediaType\attributes
attributes()
Definition: ezmediatype.php:191
eZMediaType\getAll
& getAll()
Definition: ezmediatype.php:110
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.