Manager FieldManager

public class FieldManager extends Manager

class.fieldmanager.php #14

The FieldManager class is responsible for managing all fields types in Symphony. Fields are stored on the file system either in the /fields folder of toolkit or in a fields folder in an extension path.

Methods

string __getClassName()

Given a type, returns the full class name of a Field. Fields use a 'field' prefix

Parameters
  • $type A field handle

string __getClassPath()

Finds a Field by type by searching the TOOLKIT . /fields folder and then any fields folders in the installed extensions. The function returns the path to the folder where the field class resides.

Parameters
  • $name The field handle, that is, field.{$handle}.php

string __getDriverPath()

Given a field type, return the path to it's class

Parameters
  • $type The handle of the field to load (it's type)

See Also
string __getHandleFromFilename()

Given the filename of a Field, return it's handle. This will remove the Symphony conventions of field.*.php

Parameters
  • $filename The filename of the Field

integer|boolean add()

Given an associative array of fields, insert them into the database returning the resulting Field ID if successful, or false if there was an error. As fields are saved in order on a section, a query is made to determine the sort order of this field to be current sort order +1.

Parameters
  • $fields Associative array of field names => values for the Field object

Returns

Returns a Field ID of the created Field on success, false otherwise.

Field create()

Creates an instance of a given class and returns it. Adds the instance to the $_pool array with the key being the handle.

Parameters
  • $type The handle of the Field to create (which is it's handle)

boolean delete()

Given a Field ID, delete a Field from Symphony. This will remove the field from the fields table, all of the data stored in the entries for this field and any section associations if they exist.

Parameters
  • $id The ID of the Field that should be deleted

boolean edit()

Given a Author ID and associative array of fields, update an existing Author row in the Database's authors table. Returns boolean for success/failure

Parameters
  • $id The ID of the Field that should be updated

  • $fields Associative array of field names => values for the Field object This array does need to contain every value for the field object, it can just be the changed values.

array fetch()

The fetch method returns a instance of a Field from tbl_fields. The most common use of this function is to retrieve a Field by ID, but it can be used to retrieve Fields from a Section also. There are several parameters that can be used to fetch fields by their Type, Location, by a Field Constant or with a custom WHERE query.

Parameters
  • $id The ID of the field to retrieve. Defaults to null which will return multiple field objects

  • $section_id The ID of the section to look for the fields in. Defaults to null which will allow all fields in the Symphony installation to be searched on.

  • $order Available values of ASC (Ascending) or DESC (Descending), which refer to the sort order for the query. Defaults to ASC (Ascending)

  • $sortfield The field to sort the query by. Can be any from the tbl_fields schema. Defaults to 'sortorder'

  • $type Filter fields by their type, ie. input, select. Defaults to null

  • $location Filter fields by their location in the entry form. There are two possible values, 'main' or 'sidebar'. Defaults to null

  • $where Allows a custom where query to be included. Must be valid SQL. The tbl_fields alias is t1

  • $restrict Only return fields if they match one of the Field Constants. Available values are __TOGGLEABLE_ONLY__, __UNTOGGLEABLE_ONLY__, __FILTERABLE_ONLY__, __UNFILTERABLE_ONLY__ or __FIELD_ALL__. Defaults to __FIELD_ALL__

Returns

An array of Field objects. If no Field are found, null is returned.

int fetchFieldIDFromElementName()

Given an element name and it's section, return it's ID. Symphony enforces a uniqueness constraint on a section where every field must have a unique label (and therefore handle) so whilst it is impossible to have two fields from the same section, it would be possible to have two fields with the same name from different sections. Passing the $section_id allows you to specify which section should be searched.

Parameters
  • $element_name The handle of the Field label

  • $section_id The section that this field belongs too

Returns

The field ID

string fetchFieldTypeFromID()

Given a field ID, return the type of the field by querying tbl_fields

void fetchHandleFromElementName()
Deprecated

This function will be removed in the next major release. The FieldManager::fetchHandleFromID is the preferred way to get a field's handle

string fetchHandleFromID()

Given a field ID, return the handle of the field by querying tbl_fields

array fetchTypes()

Returns an array of all available field handles discovered in the TOOLKIT . /fields or EXTENSIONS . /{}/fields.

Returns

A single dimensional array of field handles.

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