static string fetchFileErrorType(
int
$error
)
|
|
Tests the $_FILE error code and returns the corresponding atk error text token.
Parameters:
API Tags:
static success/failure mkdir(
string
$path
)
|
|
Recursive mkdir.
Parameters:
|
string |
$path: |
path to create |
API Tags:
static succes/failure rmdir(
string
$dir
)
|
|
Recursive rmdir.
Parameters:
|
string |
$dir: |
path to remove |
API Tags:
atkFileAttribute atkFileAttribute(
string
$name, array
$dir, [int
$flags = 0], [int
$size = 0]
)
|
|
Constructor
Parameters:
|
string |
$name: |
Name of the attribute |
|
array |
$dir: |
Can be a string with the Directory with images/files or an array with a Directory and a Display Url |
|
int |
$flags: |
Flags for this attribute |
|
int |
$size: |
Filename size |
string AddSlash(
string
$dir_url
)
|
|
returns a string with a / on the end
Parameters:
|
string |
$dir_url: |
String with the url/dir |
API Tags:
| Return: | with a / on the end |
| Access: | public |
array db2value(
array
$rec
)
|
|
Convert value to string
Parameters:
|
array |
$rec: |
Array with fields |
API Tags:
| Return: | Array with tmpfile, orgfilename,filesize |
Redefinition of:
- atkAttribute::db2value()
- Converts a database value to an internal value.
Redefined in descendants as:
Return the database field type of the attribute.
API Tags:
| Return: | which is the 'generic' type of the database field for this attribute. |
Redefinition of:
- atkAttribute::dbFieldType()
- Return the database field type of the attribute.
Redefined in descendants as:
boolean delete(
array
$record
)
|
|
Deletes file from HD
Parameters:
|
array |
$record: |
Array with fields |
API Tags:
| Return: | False if the delete went wrong |
Redefinition of:
- atkAttribute::delete()
- The delete method is called by the framework to inform the attribute that a record is deleted.
string display(
array
$record, [
$mode = ""]
)
|
|
Display values
Parameters:
|
array |
$record: |
Array with fields |
|
|
$mode: |
|
API Tags:
| Return: | Filename or Nothing |
Redefinition of:
- atkAttribute::display()
- Returns a displayable string for this value, to be used in HTML pages.
Redefined in descendants as:
string edit(
[array
$record = ""], [string
$fieldprefix = ""], [String
$mode = ""]
)
|
|
Returns a piece of html code that can be used in a form to edit this attribute's value.
Parameters:
|
array |
$record: |
Record |
|
string |
$fieldprefix: |
Field prefix |
|
String |
$mode: |
The mode we're in ('add' or 'edit') |
API Tags:
| Return: | piece of html code with a browsebox |
Redefinition of:
- atkAttribute::edit()
- Returns a piece of html code that can be used in a form to edit this attribute's value.
Redefined in descendants as:
array fetchValue(
array
$rec
)
|
|
Get filename out of Array
Parameters:
API Tags:
| Return: | Array with tmpfile,filename,filesize,orgfilename |
Redefinition of:
- atkAttribute::fetchValue()
- Convert values from an HTML form posting to an internal value for this attribute.
The filenameMangle(
array
$rec, string
$default
)
|
|
Determine the real filename of a file (based on m_filenameTpl).
Parameters:
|
array |
$rec: |
The record |
|
string |
$default: |
The default filename |
API Tags:
| Return: | real filename based on the filename template |
| Access: | public |
string getFileExtension(
string
$filename
)
|
|
Get the file extension
Parameters:
|
string |
$filename: |
Filename |
API Tags:
| Return: | The file extension |
array getFiles(
string
$dir
)
|
|
Returns an array containing files in specified directory optionally filtered by settings from setAllowedFileTypes method.
Parameters:
|
string |
$dir: |
Directory to read files from |
API Tags:
| Return: | Array with files in specified dir |
Redefined in descendants as:
Retrieve the list of searchmodes which are supported.
API Tags:
| Return: | List of supported searchmodes |
Redefinition of:
- atkAttribute::getSearchModes()
- Retrieve the list of searchmodes supported by the attribute.
string hide(
[array
$record = ""], [String
$fieldprefix = ""]
)
|
|
Returns a piece of html code that can be used in a form to display hidden values for this attribute.
Parameters:
|
array |
$record: |
Array with values |
|
String |
$fieldprefix: |
The fieldprefix to put in front of the name of any html form element for this attribute. |
API Tags:
| Return: | Piece of htmlcode |
Redefinition of:
- atkAttribute::hide()
- Returns a piece of html code for hiding this attribute in an HTML form, while still posting its value. (<input type="hidden">)
boolean isAllowedFileType(
&$rec, array
$rec
)
|
|
Check whether the filetype is is one of the allowed file formats. If the FileType array is empty this assumes that all formats are allowed!
Parameters:
Information Tags:
| Todo: | It turns out that handling mimetypes is not that easy the mime_content_type has been deprecated and there is no Os independend alternative! For now we only support a few image mime types. |
boolean isEmpty(
array
$record
)
|
|
Check if the attribute is empty..
Parameters:
|
array |
$record: |
the record |
API Tags:
Redefinition of:
- atkAttribute::isEmpty()
- Check if a record has an empty value for this attribute.
void processFile(
String
$filepath, String
$filename
)
|
|
Perform processing on an image right after it is uploaded.
If you need any resizing or other postprocessing to be done on a file after it is uploaded, you can create a derived attribute that implements the processFile($filepath) method. The default implementation does not do any processing.
Parameters:
|
String |
$filepath: |
The path of the uploaded file. |
|
String |
$filename: |
The name of the uploaded file. |
boolean setAllowedFileTypes(
array
$types
)
|
|
Set the allowed file types. This can either be mime types (detected by the / in the middle or file extensions (without the leading dot!).
Parameters:
void setAutonumbering(
[bool
$autonumbering = true]
)
|
|
Turn auto-numbering of filenames on/off.
When autonumbering is turned on, uploading a file with the same name as the file of another record, will result in the file getting a unique sequence number.
Parameters:
API Tags:
void setDir(
mixed
$dir
)
|
|
Sets the directory into which uploaded files are saved. (See setAutonumbering() and setFilenameTemplate() for some other ways of manipulating the names of uploaded files.)
Parameters:
|
mixed |
$dir: |
string with directory path or array with directory path and display url (see constructor) |
API Tags:
void setFilenameTemplate(
string
$template
)
|
|
Set filename template.
Parameters:
void validate(
&$record, String
$mode, array
$record
)
|
|
Checks if the file has a valid filetype.
Note that obligatory and unique fields are checked by the atkNodeValidator, and not by the validate() method itself.
Parameters:
|
array |
$record: |
The record that holds the value for this attribute. If an error occurs, the error will be stored in the 'atkerror' field of the record. |
|
String |
$mode: |
The mode for which should be validated ("add" or "update") |
|
|
&$record: |
|
Redefinition of:
- atkAttribute::validate()
- Checks if a value is valid.
string value2db(
array
$rec
)
|
|
Convert value to record for database
Parameters:
|
array |
$rec: |
Array with Fields |
API Tags:
| Return: | Nothing or Fieldname or Original filename |
Redefinition of:
- atkAttribute::value2db()
- Converts the internal attribute value to one that is understood by the database.
Redefined in descendants as:
The _filenameMangle(
array
$rec, string
$default
)
|
|
Determine the real filename of a file.
If a method <fieldname>_filename exists in the owner instance this method is called with the record and default filename to determine the filename. Else if a file template is set this is used instead and otherwise the default filename is returned.
Parameters:
|
array |
$rec: |
The record |
|
string |
$default: |
The default filename |
API Tags:
| Return: | real filename |
| Access: | private |
String _filenameUnique(
array
$rec, String
$filename
)
|
|
Give the file a uniquely numbered filename.
Parameters:
|
array |
$rec: |
The record for thish the file was uploaded |
|
String |
$filename: |
The name of the uploaded file |
API Tags:
| Return: | The name of the uploaded file, renumbered if necessary |
| Access: | private |