ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

file_input_view.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class file_input_view_1_0_0{
27
38 var $PageCSS = false;
39 var $PageJS = false;
40 var $Security = false;
41
56 function __construct()
57 {
58 try
59 {
60 $this->PageCSS = get_package( 'page::page_css' , 'last' , __FILE__ );
61 $this->PageJS = get_package( 'page::page_js' , 'last' , __FILE__ );
62 $this->Security = get_package( 'security' , 'last' , __FILE__ );
63 }
64 catch( Exception $e )
65 {
66 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
67 }
68 }
69
88 private function upload_plugins( $Path )
89 {
90 try
91 {
92 $this->PageJS->add_javascript( $Path.'/include/plugins/swfupload.cookies.js' );
93 $this->PageJS->add_javascript( $Path.'/include/plugins/swfupload.queue.js' );
94 $this->PageJS->add_javascript( $Path.'/include/plugins/swfupload.speed.js' );
95 $this->PageJS->add_javascript( $Path.'/include/plugins/fileprogress.js' );
96 $this->PageJS->add_javascript( $Path.'/include/plugins/handlers.js' );
97 }
98 catch( Exception $e )
99 {
100 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
101 }
102 }
103
122 function pre_generation( $Options )
123 {
124 try
125 {
126 $Path = '{http_host}/'._get_package_relative_path_ex( 'file_input::file_input_view' , '1.0.0' );
127 $this->PageJS->add_javascript( $Path.'/include/swfupload.js' );
128 $this->upload_plugins( $Path );
129 $this->PageJS->add_javascript( $Path.'/include/js/file_input_view.js' );
130
131 $this->PageCSS->add_stylesheet( $Path.'/res/css/default.css' );
132
133 $Lang = get_package( 'lang' , 'last' , __FILE__ );
134 $Lang->include_strings_js( 'file_input::file_input_view' );
135 }
136 catch( Exception $e )
137 {
138 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
139 }
140 }
141
164 private function file_headers( $FileSize , $FileName )
165 {
166 try
167 {
168 header( 'HTTP/1.0 200 OK' );
169 header( 'Content-type: application/octet-stream' );
170 header( "Content-Length: $FileSize" );
171 header( "Content-Disposition: attachment; filename=\"$FileName\"" );
172 header( 'Connection: close' );
173 }
174 catch( Exception $e )
175 {
176 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
177 }
178 }
179
198 function download( $Options )
199 {
200 try
201 {
202 $Fid = $this->Security->get_gp( 'fid' , 'integer' , false );
203
204 if( $Fid !== false )
205 {
206 $FileInputAlgorithms = get_package( 'file_input::file_input_algorithms' , 'last' , __FILE__ );
207 $File = $FileInputAlgorithms->get_by_id( );
208
209 $FileSize = filesize( get_field( $File , 'file_path' ) );
210 $FileName = get_field( $File , 'original_file_name' );
211
212 $this->file_headers( $FileSize , $FileName );
213
214 readfile( get_field( $File , 'file_path' ) );
215 }
216 }
217 catch( Exception $e )
218 {
219 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
220 }
221 }
222
241 function view( $Options )
242 {
243 try
244 {
245 if( $Options->get_setting( 'download' , false ) )
246 {
247 $this->download( $Options );
248 }
249
250 return( '' );
251 }
252 catch( Exception $e )
253 {
254 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
255 }
256 }
257 }
258
259 ?>