Field FieldUpload

public class FieldUpload extends Field

field.upload.php #13

A simple Upload field that essentially maps to HTML's <input type='file '/>.

Methods

void __construct()

Construct a new instance of this field.

void appendFormattedElement(XMLElement $wrapper, array $data, bool $encode, string $mode, integer $entry_id)

Append the formatted XML output of this field as utilized as a data source.

Since Symphony 2.5.0, it will defaults to prepareReadableValue return value.

Parameters
  • $wrapper XMLElementthe XML element to append the XML representation of this to.

  • $data arraythe current set of values for this field. the values are structured as for displayPublishPanel.

  • $encode bool(optional) flag as to whether this should be html encoded prior to output. this defaults to false.

  • $mode stringA field can provide ways to output this field's data. For instance a mode could be 'items' or 'full' and then the function would display the data in a different way depending on what was selected in the datasource included elements.

  • $entry_id integer(optional) the identifier of this field entry instance. defaults to null.

boolean buildDSRetrievalSQL(array $data, string $joins, string $where, bool $andOperation)

Construct the SQL statement fragments to use to retrieve the data of this field when utilized as a data source.

Parameters
  • $data arrayAn array of the data that contains the values for the filter as specified in the datasource editor. The value that is entered in the datasource editor is made into an array by using + or , to separate the filter.

  • $joins stringA string containing any table joins for the current SQL fragment. By default Datasources will always join to the tbl_entries table, which has an alias of e. This parameter is passed by reference.

  • $where stringA string containing the WHERE conditions for the current SQL fragment. This is passed by reference and is expected to be used to add additional conditions specific to this field

  • $andOperation bool(optional) This parameter defines whether the $data provided should be treated as AND or OR conditions. This parameter will be set to true if $data used a + to separate the values, otherwise it will be false. It is false by default.

Returns

True if the construction of the SQL was successful, false otherwise.

See Also
void buildSortingSQL(string $joins, string $where, string $sort, str $order)

Build the SQL command to append to the default query to enable sorting of this field. By default this will sort the results by the entry id in ascending order.

Parameters
  • $joins stringthe join element of the query to append the custom join sql to.

  • $where stringthe where condition of the query to append to the existing where clause.

  • $sort stringthe existing sort component of the sql query to append the custom sort sql code to.

  • $order str(optional) an optional sorting direction. this defaults to ascending. if this is declared either 'random' or 'rand' then a random sort is applied.

boolean canFilter()

Test whether this field can be filtered. This default implementation prohibits filtering. Filtering allows the XML output results to be limited according to an input parameter. Subclasses should override this if filtering is supported.

Returns

true if this can be filtered, false otherwise.

boolean canPrePopulate()

Test whether this field can be prepopulated with data. This default implementation does not support pre-population and, thus, returns false.

Returns

true if this can be pre-populated, false otherwise.

integer checkFields(array $errors, bool $checkForDuplicates)

Check the field's settings to ensure they are valid on the section editor

Parameters
  • $errors arraythe array to populate with the errors found.

  • $checkForDuplicates bool(optional) if set to true, duplicate Field name's in the same section will be flagged as errors. Defaults to true.

Returns

returns the status of the checking. if errors has been populated with any errors self::__ERROR__, self::__OK__ otherwise.

integer checkPostFieldData(array $data, string $message, integer $entry_id)

Check the field data that has been posted from a form. This will set the input message to the error message or to null if there is none. Any existing message value will be overwritten.

Parameters
  • $data arraythe input data to check.

  • $message stringthe place to set any generated error message. any previous value for this variable will be overwritten.

  • $entry_id integer(optional) the optional id of this field entry instance. this defaults to null.

Returns

self::__MISSING_FIELDS__ if there are any missing required fields, self::__OK__ otherwise.

boolean commit()

Commit the settings of this field from the section editor to create an instance of this field in a section.

Returns

true if the commit was successful, false otherwise.

boolean createTable()

The default field table construction method. This constructs the bare minimum set of columns for a valid field table. Subclasses are expected to overload this method to create a table structure that contains additional columns to store the specific data created by the field.

void displayPublishPanel(XMLElement $wrapper, array $data, mixed $flagWithError, string $fieldnamePrefix, string $fieldnamePostfix, integer $entry_id)

Display the publish panel for this field. The display panel is the interface shown to Authors that allow them to input data into this field for an Entry.

Parameters
  • $wrapper XMLElementthe XML element to append the html defined user interface to this field.

  • $data array(optional) any existing data that has been supplied for this field instance. this is encoded as an array of columns, each column maps to an array of row indexes to the contents of that column. this defaults to null.

  • $flagWithError mixed(optional) flag with error defaults to null.

  • $fieldnamePrefix string(optional) the string to be prepended to the display of the name of this field. this defaults to null.

  • $fieldnamePostfix string(optional) the string to be appended to the display of the name of this field. this defaults to null.

  • $entry_id integer(optional) the entry id of this field. this defaults to null.

void displaySettingsPanel(XMLElement $wrapper, mixed $errors)

Ensure the file exists in the WORKSPACE directory

Parameters
  • $wrapper XMLElementthe input XMLElement to which the display of this will be appended.

  • $errors mixedthe input error collection. this defaults to null.

See Also
boolean entryDataCleanup(integer|array $entry_id, array $data)

Remove the entry data of this field from the database.

Parameters
  • $entry_id integer|arraythe ID of the entry, or an array of entry ID's to delete.

  • $data array(optional) The entry data provided for fields to do additional cleanup This is an optional argument and defaults to null.

Returns

Returns true after the cleanup has been completed

XMLElement getExampleFormMarkup()

The default method for constructing the example form markup containing this field when utilized as part of an event. This displays in the event documentation and serves as a basic guide for how markup should be constructed on the Frontend to save this field

Returns

a label widget containing the formatted field element name of this.

array getExportModes()

Return a list of supported export modes for use with prepareExportValue.

void getFilePath(mixed $filename)
void getImportModes()
static void getMetaInfo(mixed $file, mixed $type)
boolean isSortable()

Test whether this field can be sorted. This default implementation returns false.

Returns

true if this field is sortable, false otherwise.

XMLElement prepareAssociationsDrawerXMLElement(Entry $e, array $parent_association, str $prepopulate)

Format this field value for display in the Associations Drawer publish index. By default, Symphony will use the return value of the prepareReadableValue function.

Parameters
  • $e EntryThe associated entry

  • $parent_association arrayAn array containing information about the association

  • $prepopulate strA string containing prepopulate parameter to append to the association url

Returns

The XMLElement must be a li node, since it will be added an ul node.

array|string|null prepareExportValue(mixed $data, integer $mode, integer $entry_id)

Give the field some data and ask it to return a value using one of many possible modes.

void prepareImportValue(mixed $data, mixed $mode, mixed $entry_id)
string prepareTableValue(array $data, XMLElement $link, integer $entry_id)

Format this field value for display in the publish index tables.

Since Symphony 2.5.0, this function will call Field::prepareReadableValue in order to get the field's human readable value.

Parameters
  • $data arrayan associative array of data for this string. At minimum this requires a key of 'value'.

  • $link XMLElement(optional) an XML link structure to append the content of this to provided it is not null. it defaults to null.

  • $entry_id integer(optional) An option entry ID for more intelligent processing. defaults to null

Returns

the formatted string summary of the values of this field instance.

void prepareTextValue(mixed $data, mixed $entry_id)
array processRawFieldData(mixed $data, integer $status, string $message, bool $simulate, mixed $entry_id)

For information about PHPs upload error constants see:

Parameters
  • $data mixedpost data from the entry form

  • $status integerthe status code resultant from processing the data.

  • $message stringthe place to set any generated error message. any previous value for this variable will be overwritten.

  • $simulate bool(optional) true if this will tell the CF's to simulate data creation, false otherwise. this defaults to false. this is important if clients will be deleting or adding data outside of the main entry object commit function.

  • $entry_id mixed(optional) the current entry. defaults to null.

Returns

the processed field data.

See Also

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details