00001 <?php
00002
00003 namespace Habari;
00004
00008 class FormControlFile extends FormControl
00009 {
00019 public function __get( $name )
00020 {
00021 switch ( $name ) {
00022 case 'tmp_file':
00023 return $_FILES[$this->field]['tmp_name'];
00024
00025 default:
00026 return parent::__get( $name );
00027 }
00028 }
00029
00035 public function get( $forvalidation = true )
00036 {
00037 $form = $this->get_form();
00038 $form->properties['enctype'] = 'multipart/form-data';
00039
00040 return parent::get( $forvalidation );
00041 }
00042
00048 public function save( $storage = null )
00049 {
00050 if ( $storage == null ) {
00051 $storage = $this->storage;
00052 }
00053
00054 if ( is_string( $storage ) ) {
00055 $storage = explode( ':', $storage, 2 );
00056 switch ( count( $storage ) ) {
00057 case 2:
00058 list( $type, $location ) = $storage;
00059 break;
00060 default:
00061 return;
00062 }
00063 }
00064
00065 switch ( $type ) {
00066 case 'silo':
00067
00068
00069
00070 break;
00071 case 'path':
00072 move_uploaded_file( $_FILES[$this->field]['tmp_name'], $location . '/' . basename( $_FILES[$this->field]['name'] ) );
00073 break;
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 case 'null':
00089 break;
00090 }
00091 }
00092 }
00093
00094 ?>