Sitellite Application Framework
Class Tree         Index         All Elements

Class: MF_Widget_file

Source Location: Program_Root/MailForm/Widget/File.php

Class Overview

MF_Widget
   |
   --MF_Widget_file

File widget. Displays an HTML <input type="file" /> form field.


Author(s)

Version

  • 1.8, 2002-08-05, $Id: File.php,v 1.5 2006/12/04 10:08:31 lux Exp $

Copyright

  • Copyright (C) 2001-2003, Simian Systems Inc.

Variables

Methods


Inherited Variables

Inherited Methods

Class: MF_Widget

MF_Widget::MF_Widget()
Constructor Method.
MF_Widget::addRule()
Adds a validation rule to the list of $rules.
MF_Widget::attr()
This is the accessor method for setting and getting the value of
MF_Widget::changeType()
MF_Widget::display()
Returns the display HTML for this widget. The optional parameter determines whether or not to automatically display the widget nicely, or whether to simply return the widget (for use in a template).
MF_Widget::getAttrs()
Returns a list of all of the attributes of this object's HTML tag in a string ready to be concatenated into the actual rendered tag output.
MF_Widget::getValue()
Fetches the actual value for this widget.
MF_Widget::invalid()
Returns a ' class="invalid"' string if the widget's $invalid property is set to true, or an empty string otherwise.
MF_Widget::setDefault()
Sets the default value for the widget.
MF_Widget::setValue()
Sets the *ACTUAL* value for this widget. An optional second parameter can be passed, which is unused here, but can be used in complex widget types to assign parts of a value and piece it together from multiple physical form fields.
MF_Widget::setValues()
Sets the *POSSIBLE* values for this widget. If $value is given, sets $this->value as a hash, otherwise, as a string.
MF_Widget::unsetAttr()
Use this method to remove an attribute from the tag
MF_Widget::validate()
Validates the widget against its set of $rules. Returns false on failure to pass any rule.
MF_Widget::validation()
Sets the validation $rule for this widget. Note: This method is deprecated and only wraps around the addRule() method anyway. Please use addRule() instead, since this method will be removed in a near-future release.

Class Details

[line 66]
File widget. Displays an HTML <input type="file" /> form field.

New in 1.2:

  • Added a move() method, to move the temp file to a more permanent location. move() also calls is_uploaded_file for you, but since the $cgi object does also it's duplicate code. We do need it though to make sure we don't try talking to an object under $cgi that doesn't exist. Calls is_uploaded_file() internally, so there's no need to do it again.
  • Added a $path property, so that the path to save files to can be pre-specified.
New in 1.4:
  • Added a $web_path property, to distinguish between the filesystem path and the web folder path.
New in 1.6:
  • Added a constructor method to set the $passover_isset value to true, which is inherited from MF_Widget.
New in 1.8:
  • Added $mode, $user, and $group properties, which set the mode, user, and group information for newly uploaded files during the move() method.

1 <?php
2
3 $widget = new MF_Widget_file ('name');
4 $widget->validation ('is "foo"');
5 $widget->setValue ('foo');
6 $widget->error_message = 'Oops! This widget is being unruly!';
7
8 ? >




Tags:

access:  public
version:  1.8, 2002-08-05, $Id: File.php,v 1.5 2006/12/04 10:08:31 lux Exp $
license:  http://www.sitellite.org/index/license
copyright:  Copyright (C) 2001-2003, Simian Systems Inc.
author:  John Luxford <mailto:lux@simian.ca>


[ Top ]


Class Variables

$extra =  ''

[line 74]

A way to pass extra parameters to the HTML form tag, for example 'enctype="multipart/form-data"'.



Tags:

access:  public

Type:   mixed


[ Top ]

$group =  false

[line 125]

Specifies a group to chgrp() the newly uploaded file to during the move() method. Can only be changed to any group that the PHP user belongs to. See the PHP documentation for the chgrp() function for more information.



Tags:

access:  public

Type:   mixed


[ Top ]

$mode =  false

[line 102]

Specifies a mode to chmod() the newly uploaded file to during

the move() method. The mode is also known as the permissions of the file. Must be set as a 4-digit octal value with the first digit on the left being a zero (0), for example 0755. See the PHP documentation for the chmod() function for more information.




Tags:

access:  public

Type:   mixed


[ Top ]

$path =  ''

[line 82]

The directory in which to place the uploaded file.



Tags:

access:  public

Type:   mixed


[ Top ]

$type =  'file'

[line 134]

This is the short name for this widget. The short name is the class name minus the 'MF_Widget_' prefix.



Tags:

access:  public

Type:   mixed
Overrides:   Array


[ Top ]

$user =  false

[line 114]

Specifies a user to chown() the newly uploaded file to during

the move() method. This is not likely to work on most systems, but it exists for the few strange (and highly suspect) configurations where it will. See the PHP documentation for the chown() function for more information.




Tags:

access:  public

Type:   mixed


[ Top ]

$web_path =  ''

[line 90]

The web path to the directory in which to place the uploaded file.



Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


constructor MF_Widget_file [line 144]

MF_Widget_file MF_Widget_file( string $name)

Constructor Method. Also sets the $passover_isset property to false.



Tags:

access:  public


Parameters:

string   $name  

[ Top ]

method display [line 159]

string display( [boolean $generate_html = 0])

Returns the display HTML for this widget. The optional parameter determines whether or not to automatically display the widget nicely, or whether to simply return the widget (for use in a template).



Tags:

access:  public


Overrides MF_Widget::display() (Returns the display HTML for this widget. The optional parameter determines whether or not to automatically display the widget nicely, or whether to simply return the widget (for use in a template).)

Parameters:

boolean   $generate_html  

[ Top ]

method move [line 213]

boolean move( [string $path = ''], [string $fname = ''], [object $cgi = ''])

Calls the move() method of the corresponding UploadedFile

object in the provided $cgi object's properties. If no $cgi object is provided, it assumes a global one. Returns empty on failure or on 'no file uploaded', and returns the web path to the newly placed file upon success.




Tags:

access:  public


Parameters:

string   $path  
string   $fname  
object   $cgi  

[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:17:33 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2