Field FieldDate

public class FieldDate extends Field

field.date.php #13

A simple Date field that stores a full ISO date. Symphony will attempt to localize the date on a per Author basis. The field essentially maps to PHP's strtotime, so it is very flexible in terms of what an Author can input into it.

Constants

public static
field.date.php #18
static int ERROR = 4
public static
field.date.php #17
static int RANGE = 3
public static
field.date.php #16
static int REGEXP = 1
public static
field.date.php #15
static int $SIMPLE

Methods

void __construct()

Construct a new instance of this field.

boolean allowDatasourceOutputGrouping()

Test whether this field supports data source output grouping. This default implementation prohibits grouping. Data-source grouping allows clients of this field to group the XML output according to this field. Subclasses should override this if grouping is supported.

Returns

true if this field does support data source grouping, false otherwise.

boolean allowDatasourceParamOutput()

Test whether this field supports data source parameter output. This default implementation prohibits parameter output. Data-source parameter output allows this field to be provided as a parameter to other data sources or XSLT. Subclasses should override this if parameter output is supported.

Returns

true if this supports data source parameter output, false otherwise.

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 buildRangeFilterSQL(mixed $data, mixed $joins, mixed $where, bool $andOperation)
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.

Extension developers should always implement both buildSortingSQL() and buildSortingSelectSQL().

Uses
  • Field::isRandomOrder()
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.

See Also
string buildSortingSelectSQL(string $sort, str $order)

Build the needed SQL clause command to make buildSortingSQL() work on MySQL 5.7 in strict mode, which requires all columns in the ORDER BY clause to be included in the SELECT's projection.

If no new projection is needed (like if the order is made via a sub-query), simply return null.

For backward compatibility, this method checks if the sort expression contains ed.value. This check will be removed in Symphony 3.0.0.

Extension developers should make their Fields implement buildSortingSelectSQL() when overriding buildSortingSQL().

Uses
  • Field::isRandomOrder()
Parameters
  • $sort stringthe existing sort component of the sql query, after it has been passed to buildSortingSQL()

  • $order str(optional) an optional sorting direction. this defaults to ascending. Should be the same value that was passed to buildSortingSQL()

Returns

an optional select clause to append to the generated SQL query. This is needed when sorting on a column that is not part of the projection.

See Also
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 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.

public static
field.date.php #336
static void cleanFilterString(mixed $string)
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.

See Also
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)

Display the default settings panel, calls the buildSummaryBlock function after basic field settings are added to the wrapper.

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
array fetchFilterableOperators()

Returns the keywords that this field supports for filtering. Note that no filter will do a simple 'straight' match on the value.

array fetchSuggestionTypes()

Returns the types of filter suggestion this field supports. The array may contain the following values:

  • entry for searching entries in the current section
  • association for searching entries in associated sections
  • static for searching static values
  • date for searching in a calendar
  • parameters for searching in parameters

    If the date type is set, only the calendar will be shown in the suggestion dropdown.

void findDefaults(array $settings)

Allows a field to set default settings.

Parameters
  • $settings arraythe array of settings to populate with their defaults.

string formatDate(array $date)

Format the $data parameter according to this field's settings.

Parameters
  • $date arrayThe date to format

array getExportModes()

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

void getImportModes()
string|array getParameterPoolValue(array $data, integer $entry_id)

Function to format this field if it chosen in a data source to be output as a parameter in the XML.

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

Parameters
  • $data arrayThe data for this field from it's tbl_entry_data_{id} table

  • $entry_id integerThe optional id of this field entry instance

Returns

The formatted value to be used as the parameter. Note that this can be an array or a string. When returning multiple values use array, otherwise use string.

void groupRecords(array $records)

Default implementation of record grouping. This default implementation will throw an Exception. Thus, clients must overload this method for grouping to be successful.

Parameters
  • $records arraythe records to group.

public static
field.date.php #236
static array isEqualTo(array $parts, string $direction, boolean $equal_to)

Builds the correct date array depending if the filter should include the filter as well, ie. later than 2011, is effectively the same as equal to or later than 2012.

Parameters
  • $parts arrayAn associative array containing a date in ISO8601 format (or natural) with two keys, start and end.

  • $direction stringEither later or earlier, defaults to null.

  • $equal_to booleanIf the filter is equal_to or not, defaults to false.

boolean isSortable()

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

Returns

true if this field is sortable, false otherwise.

public static
field.date.php #162
static array parseDate(array $string, string $direction, boolean $equal_to)

Given a string, this function builds the range of dates that match it. The strings should be in ISO8601 style format, or a natural date, such as 'last week' etc.

Parameters
  • $string arrayThe date string to be parsed

  • $direction stringEither later or earlier, defaults to null.

  • $equal_to booleanIf the filter is equal_to or not, defaults to false.

Returns

An associative array containing a date in ISO8601 format (or natural) with two keys, start and end.

public static
field.date.php #251
static void parseFilter(mixed $string)
DateTime|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 prepareTextValue(array $data, integer $entry_id)

Format this field value for complete display as text (string). By default, it looks for the 'value' key in the $data array and strip tags from it.

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

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

Returns

the complete text representation of the values of this field instance.

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

Process the raw field data.

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.

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