• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List

system/controls/formcontrolfile.php

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         // TODO
00068         // Get silo by path $location
00069         // Create a MediaAsset based on $_FILES[$this->name]['tmp_name']
00070         break;
00071       case 'path':
00072         move_uploaded_file( $_FILES[$this->field]['tmp_name'], $location . '/' . basename( $_FILES[$this->field]['name'] ) );
00073         break;
00074       /* TODO is there any use for any of these ?
00075     case 'user':
00076       User::identify()->info->{$location} = $this->value;
00077       break;
00078     case 'option':
00079       Options::set( $location, $this->value );
00080       break;
00081     case 'action':
00082       Plugins::filter($location, $this->value, $this->name, true);
00083       break;
00084     case 'formstorage':
00085       $storage->field_save( $this->name, $this->value );
00086       break;
00087       */
00088       case 'null':
00089         break;
00090     }
00091   }
00092 }
00093 
00094 ?>

Generated on Sun Aug 4 2013 12:51:43 for Habari by  doxygen 1.7.1