Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticle/admin/mediaedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: mediaedit.php 8206 2001-11-01 18:13:26Z ce $
5 //
6 // Created on: <21-Sep-2000 10:32:36 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezlog.php" );
30
31 // include_once( "classes/ezmediafile.php" );
32
33 // include_once( "ezmediacatalogue/classes/ezmedia.php" );
34 // include_once( "ezmediacatalogue/classes/ezmediatype.php" );
35 // include_once( "ezuser/classes/ezauthor.php" );
36
37 $ini =& eZINI::instance( 'site.ini' );
38 $Language = $ini->variable( "eZArticleMain", "Language" );
39
40 // include_once( "ezarticle/classes/ezarticlecategory.php" );
41 // include_once( "ezarticle/classes/ezarticle.php" );
42
43 if ( isset ( $OK ) )
44 {
45 $file = new eZMediaFile();
46
47 $article = new eZArticle( $ArticleID );
48 if ( is_numeric( $MediaID ) )
49 $media = new eZMedia( $MediaID );
50 else
51 $media = new eZMedia( );
52
53 if ( trim( $NewCreatorName ) != "" &&
54 trim( $NewCreatorEmail ) != ""
55 )
56 {
57 $author = new eZAuthor( );
58 $author->setName( $NewCreatorName );
59 $author->setEmail( $NewCreatorEmail );
60 $author->store();
61 $media->setPhotographer( $author );
62 }
63 else
64 {
65 $media->setPhotographer( $PhotoID );
66 }
67
68 $media->setName( $Name );
69 $media->setCaption( $Caption );
70 $media->setDescription( $Description );
71 if ( $file->getUploadedFile( "userfile" ) )
72 {
73 $media->setMedia( $file );
74 }
75
76 $media->store();
77
78 $objectPermission = new eZObjectPermission();
79 eZObjectPermission::setPermission( -1, $media->id(), "mediacatalogue_media", "r" );
80 eZObjectPermission::setPermission( 1, $media->id(), "mediacatalogue_media", "w" );
81
82 if ( $TypeID == -1 )
83 {
84 $media->removeType();
85 }
86 else
87 {
88 $media->removeType();
89
90 $media->setType( new eZMediaType( $TypeID ) );
91
92 $i = 0;
93 if ( count( $AttributeValue ) > 0 )
94 {
95 foreach ( $AttributeValue as $attribute )
96 {
97 $att = new eZMediaAttribute( $AttributeID[$i] );
98
99 $att->setValue( $media, $attribute );
100
101 $i++;
102 }
103 }
104 }
105
106 if ( !is_numeric( $MediaID ) )
107 $article->addMedia( $media );
108
109 // include_once( "classes/ezhttptool.php" );
110 eZHTTPTool::header( "Location: /article/articleedit/medialist/" . $ArticleID . "/" );
111 exit();
112 }
113
114 if ( isset ( $DeleteSelected ) )
115 {
116 $article = new eZArticle( $ArticleID );
117
118 if ( count ( $MediaArrayID ) != 0 )
119 {
120 foreach( $MediaArrayID as $MediaID )
121 {
122 $media = new eZMedia( $MediaID );
123 $article->deleteMedia( $media );
124 }
125 }
126
127 // include_once( "classes/ezhttptool.php" );
128 if ( !isset( $Update ) )
129 {
130 eZHTTPTool::header( "Location: /article/articleedit/medialist/" . $ArticleID . "/" );
131 exit();
132 }
133 }
134
135 $t = new eZTemplate( "kernel/ezarticle/admin/" . $ini->variable( "eZArticleMain", "AdminTemplateDir" ),
136 "kernel/ezarticle/admin/intl/", $Language, "mediaedit.php" );
137
138 $t->setAllStrings();
139
140 $t->set_file( array(
141 "media_edit_page" => "mediaedit.tpl",
142 ) );
143
144
145 $t->set_block( "media_edit_page", "media_tpl", "media" );
146 $t->set_block( "media_edit_page", "type_tpl", "type" );
147 $t->set_block( "media_edit_page", "file_name_tpl", "file_name" );
148 $t->set_block( "media_edit_page", "no_file_name_tpl", "no_file_name" );
149 $t->set_block( "media_edit_page", "attribute_list_tpl", "attribute_list" );
150 $t->set_block( "media_edit_page", "photographer_item_tpl", "photographer_item" );
151 $t->set_block( "attribute_list_tpl", "attribute_tpl", "attribute" );
152
153 $t->set_var( "media_unit", "" );
154 $t->set_var( "no_file_name", "" );
155 $t->set_var( "file_name", "" );
156 $t->set_var( "media_size", "" );
157 $t->set_var( "media_id", "" );
158
159 //default values
160 if ( is_numeric( $MediaID ) )
161 {
162 $article = new eZArticle( $ArticleID );
163 $media = new eZMedia( $MediaID );
164
165 $t->set_var( "media_id", $media->id() );
166 $t->set_var( "name_value", $media->name() );
167 $t->set_var( "caption_value", $media->caption() );
168 $t->set_var( "decription_value", $media->description() );
169 $t->set_var( "action_value", "Update" );
170 $mediaType = $media->type();
171
172 $photographer = $media->photographer();
173 $PhotographerID = $photographer->id();
174
175 if ( $media->fileExists( true ) )
176 {
177 $mediaPath =& $media->filePath( true );
178 $size = eZPBFile::filesize( $mediaPath );
179 }
180 else
181 {
182 $size = 0;
183 }
184
185 $size = eZPBFile::siFileSize( $size );
186
187 $t->set_var( "media_size", $size["size-string"] );
188 $t->set_var( "media_unit", $size["unit"] );
189 if ( $media->originalFileName() )
190 {
191 $t->set_var( "no_file_name", "" );
192 $t->set_var( "media_file", $media->originalFileName() );
193 $t->parse( "file_name", "file_name_tpl" );
194 }
195 else
196 {
197 $t->set_var( "file_name", "" );
198 $t->parse( "no_file_name", "no_file_name_tpl" );
199 }
200
201 }
202 else
203 {
204 $t->set_var( "name_value", "$Name" );
205 $t->set_var( "caption_value", "$Caption" );
206 $t->set_var( "description_value", "$Description" );
207 $t->set_var( "action_value", "Insert" );
208 $t->set_var( "option_id", "" );
209 $t->set_var( "media", "" );
210 }
211
212
213 $author = new eZAuthor();
214 $authorArray = $author->getAll();
215 foreach ( $authorArray as $author )
216 {
217 if ( $PhotographerID == $author->id() )
218 {
219 $t->set_var( "selected", "selected" );
220 }
221 else
222 {
223 $t->set_var( "selected", "" );
224 }
225 $t->set_var( "photo_id", $author->id() );
226 $t->set_var( "photo_name", $author->name() );
227 $t->parse( "photographer_item", "photographer_item_tpl", true );
228 }
229
230
231 // Print out all the types.
232 $type = new eZMediaType();
233 $types = $type->getAll();
234
235 if ( isset( $TypeID ) )
236 $mediaType = new eZMediaType( $TypeID );
237
238 foreach ( $types as $typeItem )
239 {
240 if ( is_a( $mediaType, "eZMediaType" ) )
241 {
242 if ( $mediaType->id() == $typeItem->id() )
243 {
244 $t->set_var( "selected", "selected" );
245 }
246 else
247 {
248 $t->set_var( "selected", "" );
249 }
250 }
251 else
252 {
253 $t->set_var( "selected", "" );
254 }
255
256 $t->set_var( "type_id", $typeItem->id( ) );
257 $t->set_var( "type_name", $typeItem->name( ) );
258
259 $t->parse( "type", "type_tpl", true );
260 }
261
262 if ( is_a( $mediaType, "eZMediaType") )
263 {
264 $attributes = $mediaType->attributes();
265
266 foreach ( $attributes as $attribute )
267 {
268 $t->set_var( "attribute_id", $attribute->id( ) );
269 $t->set_var( "attribute_name", $attribute->name( ) );
270
271 if ( !$attribute->value( $media ) )
272 $t->set_var( "attribute_value", $attribute->defaultValue() );
273 else
274 $t->set_var( "attribute_value", $attribute->value( $media ) );
275
276 $t->parse( "attribute", "attribute_tpl", true );
277 }
278 }
279
280 if ( count( $attributes ) > 0 || !isset( $type ) )
281 {
282 $t->parse( "attribute_list", "attribute_list_tpl" );
283 }
284 else
285 {
286 $t->set_var( "attribute_list", "" );
287 }
288
289
290 $article = new eZArticle( $ArticleID );
291
292 $t->set_var( "article_name", $article->name() );
293 $t->set_var( "article_id", $article->id() );
294
295 $t->pparse( "output", "media_edit_page" );
296
297 ?>
$i
$i
Definition: admin/adlist.php:91
$Description
$Description
Definition: articlelistrss.php:38
eZArticle
Definition: ezarticle.php:82
eZAuthor
Definition: ezauthor.php:40
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZMediaAttribute
Definition: ezmediaattribute.php:49
eZMediaFile
Definition: ezmediafile.php:68
eZMediaType
Definition: ezmediatype.php:33
eZMedia
Definition: ezmedia.php:65
eZObjectPermission
Definition: ezobjectpermission.php:55
eZObjectPermission\setPermission
static setPermission( $group, $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:236
eZPBFile\siFileSize
static & siFileSize( $size)
Definition: ezpbfile.php:220
eZPBFile\filesize
static filesize( $filename)
Definition: ezpbfile.php:339
eZTemplate
Definition: eztemplate.php:107
$ArticleID
$ArticleID
Definition: export.php:48
$article
$article
Definition: ezarticle/admin/mediaedit.php:290
$authorArray
$authorArray
Definition: ezarticle/admin/mediaedit.php:214
$t
if(isset( $OK)) if(isset( $DeleteSelected)) $t
Definition: ezarticle/admin/mediaedit.php:135
$Language
$Language
Definition: ezarticle/admin/mediaedit.php:38
$ini
$ini
Definition: ezarticle/admin/mediaedit.php:37
$types
$types
Definition: ezarticle/admin/mediaedit.php:233
$author
$author
Definition: ezarticle/admin/mediaedit.php:213
$type
foreach( $authorArray as $author) $type
Definition: ezarticle/admin/mediaedit.php:232
$media
if(isset( $AddMedia)) $media
Definition: ezarticle/admin/medialist.php:76
$size
if($file_debug) $size
Definition: ezfilemanager/user/filedownload.php:165
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
exit
exit
Definition: folder.php:81
$Name
$Name
Definition: polledit.php:250
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.