Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticle/user/fileedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: fileedit.php 7497 2001-09-27 08:00:49Z jhe $
5 //
6 // Created on: <21-Dec-2000 18:01:48 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/ezfile.php" );
32
33 // include_once( "ezfilemanager/classes/ezvirtualfile.php" );
34
35 $ini =& eZINI::instance( 'site.ini' );
36 $Language = $ini->variable( "eZArticleMain", "Language" );
37
38 // include_once( "ezarticle/classes/ezarticlecategory.php" );
39 // include_once( "ezarticle/classes/ezarticle.php" );
40
41 if ( isset( $DeleteSelected ) )
42 $Action = "Delete";
43
44 if ( $Action == "Insert" )
45 {
46 $file = new eZFile();
47
48 if ( $file->getUploadedFile( "userfile" ) )
49 {
50 $article = new eZArticle( $ArticleID );
51
52 $uploadedFile = new eZVirtualFile();
53 $uploadedFile->setName( $Name );
54 $uploadedFile->setDescription( $Description );
55
56 $uploadedFile->setFile( $file );
57
58 $uploadedFile->store();
59
60 $article->addFile( $uploadedFile );
61
62 eZPBLog::writeNotice( "File added to article $ArticleID from IP: $REMOTE_ADDR" );
63 }
64 else
65 {
66 print( $file->name() . " not uploaded successfully" );
67 }
68
69 // include_once( "classes/ezhttptool.php" );
70 eZHTTPTool::header( "Location: /article/articleedit/filelist/" . $ArticleID . "/" );
71 exit();
72 }
73
74 if ( $Action == "Update" )
75 {
76 $file = new eZFile();
77
78 if ( $file->getUploadedFile( "userfile" ) )
79 {
80 $article = new eZArticle( $ArticleID );
81
82 $oldFile = new eZFile( $FileID );
83 $article->deleteFile( $oldFile );
84
85 $uploadedFile = new eZVirtualFile();
86 $uploadedFile->setName( $Name );
87 $uploadedFile->setDescription( $Description );
88
89 $uploadedFile->setFile( $file );
90
91 $uploadedFile->store();
92
93 $article->addFile( $uploadedFile );
94 }
95 else
96 {
97 $uploadedFile = new eZVirtualFile( $FileID );
98 $uploadedFile->setName( $Name );
99 $uploadedFile->setDescription( $Description );
100 $uploadedFile->store();
101 }
102
103 // include_once( "classes/ezhttptool.php" );
104 eZHTTPTool::header( "Location: /article/articleedit/filelist/" . $ArticleID . "/" );
105 exit();
106 }
107
108
109 if ( $Action == "Delete" )
110 {
111 $article = new eZArticle( $ArticleID );
112
113 if ( count( $FileArrayID ) != 0 )
114 {
115 foreach ( $FileArrayID as $FileID )
116 {
117 $file = new eZVirtualFile( $FileID );
118 $article->deleteFile( $file );
119 }
120 }
121
122 // include_once( "classes/ezhttptool.php" );
123 eZHTTPTool::header( "Location: /article/articleedit/filelist/" . $ArticleID . "/" );
124 exit();
125 }
126
127 $t = new eZTemplate( "kernel/ezarticle/user/" . $ini->variable( "eZArticleMain", "TemplateDir" ),
128 "kernel/ezarticle/user/intl/", $Language, "fileedit.php" );
129
130 $t->setAllStrings();
131
132 $t->set_file( "file_edit_page", "fileedit.tpl" );
133
134
135 //default values
136 $t->set_var( "name_value", "" );
137 $t->set_var( "description_value", "" );
138 $t->set_var( "action_value", "Insert" );
139 $t->set_var( "option_id", "" );
140 $t->set_var( "file", "" );
141
142 if ( $Action == "Edit" )
143 {
144 $article = new eZArticle( $ArticleID );
145 $file = new eZVirtualFile( $FileID );
146
147 $t->set_var( "article_name", $article->name() );
148
149 $t->set_var( "file_id", $file->id() );
150 $t->set_var( "name_value", $file->name() );
151 $t->set_var( "description_value", $file->description() );
152 $t->set_var( "action_value", "Update" );
153 }
154
155 $article = new eZArticle( $ArticleID );
156
157 $t->set_var( "article_name", $article->name() );
158 $t->set_var( "article_id", $article->id() );
159
160 $t->pparse( "output", "file_edit_page" );
161
162 ?>
$Description
$Description
Definition: articlelistrss.php:38
eZArticle
Definition: ezarticle.php:82
eZFile
Tool class which has convencience functions for files and directories.
Definition: ezfile.php:19
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZPBLog\writeNotice
static writeNotice( $notice)
Definition: ezpblog.php:166
eZTemplate
Definition: eztemplate.php:107
eZVirtualFile
Definition: ezvirtualfile.php:42
$Action
$Action
Definition: companysearch.php:80
$ArticleID
$ArticleID
Definition: export.php:48
$Language
$Language
Definition: ezarticle/user/fileedit.php:36
$ini
$ini
Definition: ezarticle/user/fileedit.php:35
$t
if( $Action=="Insert") if( $Action=="Update") if( $Action=="Delete") $t
Definition: ezarticle/user/fileedit.php:127
$article
if( $Action=="Edit") $article
Definition: ezarticle/user/fileedit.php:155
$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+.