fsMeta
by Rasmus Schultz
Provides classes for storage, manipulation and editing of metadata
Files
FileComments
class/fsmeta.php

This is the main include file of fsMeta - all required classes will be loaded by this include.

You can safely include this file several times - it will only load once.

XoopsForm element classes are automatically loaded, if the XoopsForm class has already been loaded.

class/fsmeta_meta.php
-
class/fsmeta_factory.php
-
class/fsmeta_form.php
-
class/fsmeta_table.php
-
class/fsmeta_field.php
-
class/fsmeta_field_factory.php
-
class/fsmeta_choice.php
-
class/fsmeta_choice_factory.php
-
class/fsmeta_types.php
-
Classes
ClassComments
fsMetaException

This is the exception-class used throughout the fsMeta system.

fsMeta

This is the main class used for reading, writing, rendering form inputs and parsing posted form input. (more...)

fsMetaFactory

This factory class can be used to query metadata, or as a helper to create JOIN statements in foreign factory classes.

XoopsFormMetaData

This XoopsFormElement can be used to render groups of metadata editors. (more...)

fsMetaTable

A table represents a single physical table containing metadata, and provides access to fields. (more...)

fsMetaField

Field-type determines the kind of type-handler class used to manage the field, refer to the fsMetaType classes for more information. (more...)

fsMetaFieldFactory
-
fsMetaChoice

This class implements a choice for a field (e.g. fields of type Select or Multi) (more...)

fsMetaChoiceFactory
-
fsMetaTypeHandler

This class provides utility functions related to field-type handlers. (more...)

fsMetaType

This abstract class defines abstract and default methods for all field-type handlers.

fsMetaType_String

This handler implements a simple string, stored in a VARCHAR(255) column

fsMetaType_Text

This handler implements a large string, stored in a TEXT column

fsMetaType_Int

This handler implements a signed integer number, stored in an INT column

fsMetaType_Time

This handler implements a date and time field, stored in a DATETIME column

fsMetaType_Select

This handler implements single selection from a collection of choices, stored as a single INT column. (more...)

fsMetaType_Multi

This class implements multiple selections from a collection of choices, stored as one TINYINT column per choice. (more...)

fsMetaException in file class/fsmeta.php
Extends: Exception

This is the exception-class used throughout the fsMeta system.

Member Methods
MethodComments
Public__construct Has parameters
-
public __construct ( $message )
ArgumentDefaultComments
$message-
-
fsMeta in file class/fsmeta_meta.php
Member Methods
MethodComments
~ fs Meta Has comments Has parameters

If the provided tablename does not exist, a table with that name is automatically created. (more...)

public static fsMeta ( $tablename, $id )

If the provided tablename does not exist, a table with that name is automatically created.

The constructor will throw an fsMetaException, if the provided id is not a positive integer value.

ArgumentDefaultComments
$tablename-

the name of the physical table, NOT including the 'xoops_' prefix.

$idnull

primary id, optional - if omitted (or null), a "dummy" fsMeta object is created. You can use a "dummy" fsMeta object to render forms for new objects, when you do not yet know what the primary id is going to be.

Misc. accessors
Publicget Table Name
-
public getTableName ( )
Publicget Id
-
public getId ( )
Metadata accessors
Publicget Value Has comments Has parameters

Retrieves the value of the given metadata field.

public getValue ( $fieldname )

Retrieves the value of the given metadata field.

ArgumentDefaultComments
$fieldname-
-
Publicset Value Has comments Has parameters

Set the given field to the given value. (more...)

public setValue ( $fieldname, $value )

Set the given field to the given value.

Note that you have to call the save() method to physically save the new data.

ArgumentDefaultComments
$fieldname-
-
$value-
-
Publicget Values Has comments

Returns an associative array containing all metadata values. (more...)

public getValues ( )

Returns an associative array containing all metadata values.

Useful for quickly passing metadata to templates and other read-only applications.

Publicsave Has comments

Save changed values permanently in the database.

public save ( )

Save changed values permanently in the database.

Form input/output methods
Publicadd Elements Has comments Has hints Has parameters

Creates and configured a XoopsFormMetaData element for every group, and adds them to the given XoopsForm. (more...)

public addElements ( &$form, $extra, $prefix )

Creates and configured a XoopsFormMetaData element for every group, and adds them to the given XoopsForm.

Hint: This is the simplest method for adding metadata-inputs to your XoopsForm.

ArgumentDefaultComments
&$form-
-
$extra''
-
$prefix''

optional - prefix for form input names, rarely needed. (only if you have multiple metadata-editors for different objects on the same page)

Publicget Element Has comments Has parameters

Creates and configures a XoopsFormMetaData element, that you can add to your form with [XoopsForm::addElement()].

public getElement ( $groupname, $prefix )

Creates and configures a XoopsFormMetaData element, that you can add to your form with [XoopsForm::addElement()].

ArgumentDefaultComments
$groupnamenull

optional - if specified, only fields with the given group-name are added to the created form-element.

$prefix''

optional - prefix for form input names, rarely needed. (only if you have multiple metadata-editors for different objects on the same page)

Publicrender Has comments Has parameters

Renders the field with the given fieldname as a form INPUT element.

public render ( $fieldname, $prefix, $extra, $options )

Renders the field with the given fieldname as a form INPUT element.

ArgumentDefaultComments
$fieldname-
-
$prefix''

optional - if supplied, this string is prefixed on the form INPUT NAME.

$extra''

optional - use this if you need to inject (for example) a class or style attribute in the INPUT element.

$optionsnull

optional, an array with additional options. The available options differ for every field type - please refer to the fsMetaType classes.

Publicparse Has comments Has parameters

Parses a value from a POST or GET request, from an INPUT element rendered using the render() method, and returns a PHP-value (suitable for use with setValue).

public parse ( $fieldname, $prefix, $post )

Parses a value from a POST or GET request, from an INPUT element rendered using the render() method, and returns a PHP-value (suitable for use with setValue).

ArgumentDefaultComments
$fieldname-
-
$prefix''

optional - if supplied, must match the prefix you specified when you used render().

$posttrue

optional, defaults to true - if false, $_GET[] will be used instead of $_POST[].

Publicpickup Has comments Has hints Has parameters

Automatically pick up, parse and set values from a POST or GET request, from INPUT elements rendered using calls to render(). (more...)

public pickup ( $prefix, $groupname, $post )

Automatically pick up, parse and set values from a POST or GET request, from INPUT elements rendered using calls to render().

You still have to manually call save() after calling this method.

Hint: Use the XoopsFormMetaData class to easily add a group of fields to a XoopsForm.

ArgumentDefaultComments
$prefix''

optional - if supplied, must match the prefix used with previous render() calls.

$groupname-1

optional - if supplied, picks up only fields with the given group-name. Use a null-argument to pick up only ungrouped fields.

$posttrue

optional, defaults to true - if false, $_GET[] will be used instead of $_POST[].

Object removal
Publicremove Has comments

Remove this metadata object.

public remove ( )

Remove this metadata object.

Utility methods
Publicget Table Has comments

Returns the fsMetaTable object associated with the table of this object.

public getTable ( )

Returns the fsMetaTable object associated with the table of this object.

Publicget Fields Has comments Has parameters

Returns an array containing fsMetaField objects.

public getFields ( $groupname )

Returns an array containing fsMetaField objects.

ArgumentDefaultComments
$groupname-1

optional - if specified, returns only fields with the given group-name. Use a null-argument to retrieve ungrouped fields.

Internal helper functions
Protectedinit Values
-
protected initValues ( )
fsMetaFactory in file class/fsmeta_factory.php
Member Methods
MethodComments
~ fs Meta Factory Has parameters
-
public fsMetaFactory ( $tablename, $logic )
ArgumentDefaultComments
$tablename-
-
$logic"AND"

the logic to use when combining subsequent added criteria, e.g. "AND" or "OR".

Logic control methods

These methods enable you to build queries with complex logic.

Publicbegin Logic Has comments Has parameters

Start a new logic block. (more...)

public beginLogic ( $logic )

Start a new logic block.

Any subsequent calls to criteria building methods, will add criteria to the new logic block.

Once you have added all your criteria, you must call endLogic() to end the logic block.

$logic: the logic to use when combining subsequent added criteria, e.g. "AND" or "OR".

ArgumentDefaultComments
$logic-
-
Publicend Logic Has comments

End the current logic block. (more...)

public endLogic ( )

End the current logic block.

Any subsequent calls to criteria building methods, will add criteria to the parent logic block.

Criteria building methods
Publicadd Criteria Has comments Has parameters

Most comparisons can be done with this method, for example: (more...)

public addCriteria ( $fieldname, $value, $operator )

Most comparisons can be done with this method, for example:

$myfactory->addCriteria("email", "%@fyens.dk", "LIKE"); // "email" fields must end in "fyens.dk"

$myfactory->addCriteria("interest", array("sport", "art"), "IN"); // "interest" fields must contain either "sport" or "art"

$myfactory->addCriteria("age", 18, ">="); // "age" fields must contain values greater or equal to 18

ArgumentDefaultComments
$fieldname-
-
$value-
-
$operator-
-
Publicadd Null Has comments Has parameters

Adds a null-comparison criteria: $fieldname must contain a NULL value ($null = true), or field value must NOT contain a NULL value ($null = false).

public addNull ( $fieldname, $null )

Adds a null-comparison criteria: $fieldname must contain a NULL value ($null = true), or field value must NOT contain a NULL value ($null = false).

ArgumentDefaultComments
$fieldname-
-
$nulltrue
-
Query methods
Publicget Meta Has comments

Executes the query and returns an associative array of fsMeta objects, using record ids as array-keys. (more...)

public getMeta ( )

Executes the query and returns an associative array of fsMeta objects, using record ids as array-keys.

May return an empty array.

Publiccount Has comments

Counts the number of records matching the criteria of this factory instance.

public count ( )

Counts the number of records matching the criteria of this factory instance.

Publictouch Has comments

Touches all records matching the criteria of this factory instance. (more...)

public touch ( )

Touches all records matching the criteria of this factory instance.

Use this after an UPDATE query on metadata-tables, to ensure that cached values are refreshed by fsMeta.

Helper functions

The following helper functions are used internally, but are also useful to foreign factory classes.

Publicget Expression Has comments

Builds an expression you can use in the WHERE clause of an SQL statement.

public getExpression ( )

Builds an expression you can use in the WHERE clause of an SQL statement.

Publicget Source Has comments

Returns the source tablename, backtick-quoted, suitable for use in an SQL statement.

public getSource ( )

Returns the source tablename, backtick-quoted, suitable for use in an SQL statement.

Publicget Key Has comments

Returns the source table's primary key, fully qualified and backtick-quoted, suitable for use in an SQL statement.

public getKey ( )

Returns the source table's primary key, fully qualified and backtick-quoted, suitable for use in an SQL statement.

Publicget Column Has comments Has warnings Has parameters

Determines the column-name of the given field and value, returns a backtick-quoted, fully qualified column-name, suitable for use in a SQL statement - e.g. "`mytable`.`mycolumn`". (more...)

public getColumn ( $fieldname, $value )

Determines the column-name of the given field and value, returns a backtick-quoted, fully qualified column-name, suitable for use in a SQL statement - e.g. "`mytable`.`mycolumn`".

If used with a multi-column field (such as fieldtype Multi) the value argument must be used.

Note: this method returns null, if the given fieldname and value could not be resolved to a column-name.

ArgumentDefaultComments
$fieldname-
-
$valuenull
-
Publicget Value Has comments Has warnings Has parameters

Returns an SQL-value, suitable for use in a comparison expression in a WHERE clause. (more...)

public getValue ( $fieldname, &$value )

Returns an SQL-value, suitable for use in a comparison expression in a WHERE clause.

Note: this method returns null, if the given fieldname and value could not be resolved to a column-name.

ArgumentDefaultComments
$fieldname-
-
&$value-
-
Private helper functions
Private_get S Q L Has parameters
-
private _getSQL ( &$node )
ArgumentDefaultComments
&$node-
-
XoopsFormMetaData in file class/fsmeta_form.php
Extends: XoopsFormElement

This XoopsFormElement can be used to render groups of metadata editors.

Use the standard method setExtra() to inject additional attributes into the <table> tag, e.g. class="myclass", etc.

You can use the fsMeta::pickup method to easily pick up groups of posted metadata values.

Member Methods
MethodComments
~ Xoops Form Meta Data Has parameters
-
public XoopsFormMetaData ( $caption, $name, $tablename, $id, $groupname )
ArgumentDefaultComments
$caption-
-
$name-
-
$tablename-
-
$idnull
-
$groupnamenull
-
Publicrender
-
public render ( )
fsMetaTable in file class/fsmeta_table.php
Extends: fsObject

A table represents a single physical table containing metadata, and provides access to fields.

A field is often the same as a physical column in the underlying table, but not as a rule - the fieldtype Multi, for example, uses multiple columns to store selections.

Member Methods
MethodComments
~ fs Meta Table Has comments Has parameters

You should not call the constructor directly - instead, please use the static getTable() method.

public static fsMetaTable ( $tablename, $values )

You should not call the constructor directly - instead, please use the static getTable() method.

ArgumentDefaultComments
$tablename-
-
$valuesarray()
-
Instanciation
Publicget Table Has comments Has warnings Has parameters

Returns an instance of fsMetaTable. (more...)

public static getTable ( $tablename )

Returns an instance of fsMetaTable.

Warning: If no table with the given tablename exists, an empty table is created. Therefore you can NOT use this method simply to check if a table exists!

ArgumentDefaultComments
$tablename-
-
Accessors
Publicget Table Name
-
public getTableName ( )
Publicget Title
-
public getTitle ( )
Publicset Title Has parameters
-
public setTitle ( $value )
ArgumentDefaultComments
$value-
-
Publicget Description
-
public getDescription ( )
Publicset Description Has parameters
-
public setDescription ( $value )
ArgumentDefaultComments
$value-
-
Field management methods
Publicget Fields Has comments Has parameters

Returns an array containing all the fsMetaField objects of this fsMetaTable. (more...)

public getFields ( $groupname )

Returns an array containing all the fsMetaField objects of this fsMetaTable.

The returned associative array is indexed using fieldnames.

ArgumentDefaultComments
$groupname-1

optional - if specified, returns only fsMetaField objects with the given group-name. Use a null-argument to retrieve ungrouped fields.

Publicget Field Has comments Has parameters

Returns the fsMetaField object with the given fieldname. (more...)

public getField ( $fieldname )

Returns the fsMetaField object with the given fieldname.

Returns null if no field with the given fieldname exists in this table.

ArgumentDefaultComments
$fieldname-
-
Publiccreate Field Has comments Has parameters

Creates and returns a new fsMetaField object with the given fieldname and fieldtype. (more...)

public createField ( $fieldname, $fieldtype )

Creates and returns a new fsMetaField object with the given fieldname and fieldtype.

Throws an fsMetaException on failure, which could be due to duplicate fieldname, or invalid fieldtype.

ArgumentDefaultComments
$fieldname-
-
$fieldtype-
-
Utility methods
Publicget Schema Has comments

Returns the Schema object for this table.

public getSchema ( )

Returns the Schema object for this table.

Publicget Groups Has comments

Returns an array containing all fsMetaGroup objects associated with this table. (more...)

public getGroups ( )

Returns an array containing all fsMetaGroup objects associated with this table.

The returned associative array is indexed using group-names.

Object creation
Publiccreate Has comments Has parameters

Creates and returns a new fsMetaTable with the given tablename. (more...)

public static create ( $tablename )

Creates and returns a new fsMetaTable with the given tablename.

May throw an fsMetaException, and returns false, if a table with the given name already exists.

ArgumentDefaultComments
$tablename-
-
Object removal
Publicremove
-
public remove ( )
Object retrieval
Publicget All Has comments Has parameters

Returns an array containing all fsMetaTable objects.

public static getAll ( $prefix )

Returns an array containing all fsMetaTable objects.

ArgumentDefaultComments
$prefixnull

optional - if supplied, returns only tables with names beginning with the given prefix.

fsMetaField in file class/fsmeta_field.php
Extends: fsObject

Field-type determines the kind of type-handler class used to manage the field, refer to the fsMetaType classes for more information.

Fields are always ordered, ascending, first by group number, then by priority.

Group name is optional, and can be used to group fields together - the fsMeta class, for example, has a render() method which takes a $groupname argument, which can be used to render only a certain group of fields.

Field-options refer to a small collection of special options for the type-handler's render() method, and so is typically used to change the behavior or layout of the rendered html inputs. Each type-handler has a disctinct set of available options - most don't have any. The fsMetaType_Select handler, for example, has a "mode" option that can be used to render the field as a dropdown or group of radio buttons.

A field is often the same as a physical column in the underlying table, but not as a rule - the fieldtype Multi, for example, uses multiple columns to store selections. Such fields also always have choices associated with them.

Generally, you can use getHandler() to get the handler of a field, then use the handlers isMultiColumn() method to check if the field uses one or more columns to store it's value.

For single-column fields, the physical column-name in the field's table is simply the fieldname, e.g. getFieldName().

For multi-column fields, each associated choice is related to a physical column in the underlying table. Column-names are composed of the fieldname, followed by two underscores "__", followed by the choice-index.

Member Methods
MethodComments
~ fs Meta Field Has parameters
-
public static fsMetaField ( $tablename, $fieldname, $values )
ArgumentDefaultComments
$tablename-
-
$fieldname-
-
$valuesarray()
-
Accessors
Publicget Table Name
-
public getTableName ( )
Publicget Field Name
-
public getFieldName ( )
Publicget Field Type
-
public getFieldType ( )
Publicget Priority
-
public getPriority ( )
Publicset Priority Has parameters
-
public setPriority ( $value )
ArgumentDefaultComments
$value-
-
Publicget Title
-
public getTitle ( )
Publicset Title Has parameters
-
public setTitle ( $value )
ArgumentDefaultComments
$value-
-
Publicget Hint
-
public getHint ( )
Publicset Hint Has parameters
-
public setHint ( $value )
ArgumentDefaultComments
$value-
-
Publicget Description
-
public getDescription ( )
Publicset Description Has parameters
-
public setDescription ( $value )
ArgumentDefaultComments
$value-
-
Publicget Group Name
-
public getGroupName ( )
Publicset Group Name Has parameters
-
public setGroupName ( $groupname )
ArgumentDefaultComments
$groupname-
-
Publicget Field Options Has comments

An associative array containing options for this field's handler.

public getFieldOptions ( )

An associative array containing options for this field's handler.

Publicset Field Options Has parameters
-
public setFieldOptions ( $options )
ArgumentDefaultComments
$options-
-
Utility methods
Publicget Handler
-
public getHandler ( )
Publicget Table
-
public getTable ( )
Form input/output methods
Publicrender Has comments Has parameters

Renders this field as HTML code, using $value as the current value. (more...)

public render ( $value, $prefix, $extra, $options )

Renders this field as HTML code, using $value as the current value.

(if you're looking for a way to render your metadata as HTML code, you most likely want the [fsMeta::render] method.)

ArgumentDefaultComments
$valuenull
-
$prefix''
-
$extra''
-
$optionsnull
-
Publicparse Has comments Has parameters

Parses a value submitted from a FORM built using calls to render(). (more...)

public parse ( $prefix, $post )

Parses a value submitted from a FORM built using calls to render().

(if you're looking for a way to parse your metadata forms, you most likely want the [fsMeta::parse] method.)

ArgumentDefaultComments
$prefix''
-
$posttrue
-
Choice management methods
Publicget Choices Has comments Has parameters

Returns all fsMetaChoice objects associated with this field. (more...)

public getChoices ( $index_by, $use_cache )

Returns all fsMetaChoice objects associated with this field.

The result is an associative array where the keys, by default, are the choice-indexes.

May return an empty array.

ArgumentDefaultComments
$index_by'index'

optional, defaults to 'index' - specifies which field to use as key in the the returned associative array. Also useful is 'value', to quickly look up a choice by its user-value.

$use_cachetrue

used internally for optimization - do not use.

Publicadd Choice Has comments Has parameters

Creates and returns a new fsMetaChoice object for this field. (more...)

public static addChoice ( $title, $value )

Creates and returns a new fsMetaChoice object for this field.

Throws an fsMetaException on error.

ArgumentDefaultComments
$title-
-
$value-
-
Object creation
Publiccreate Has comments Has parameters

Creates and returns a new fsMetaField, and associates it with the fsMetaTable with the given tablename. (more...)

public static create ( $tablename, $fieldname, $fieldtype )

Creates and returns a new fsMetaField, and associates it with the fsMetaTable with the given tablename.

May throw an fsMetaException if a field with the given fieldname already exists in the given table, or if the requested fieldtype is invalid.

ArgumentDefaultComments
$tablename-
-
$fieldname-
-
$fieldtype-
-
Object removal
Publicremove
-
public remove ( )
Object retrieval
Publicget Field Has comments Has parameters

Returns an instance of a fsMetaField object - you should use this to acquire field objects, rather than the constructor. (more...)

public static getField ( $tablename, $fieldname, &$cache_inject )

Returns an instance of a fsMetaField object - you should use this to acquire field objects, rather than the constructor.

If the specified field can not be found, this method throws an fsMetaException.

$cache_inject: this parameter is used internally for caching - you should not use it.

ArgumentDefaultComments
$tablename-
-
$fieldname-
-
&$cache_injectarray()
-
Publicget By Table Name Has comments Has parameters

Returns an associative array containing all fields for the given table. (more...)

public static getByTableName ( $tablename, $groupname )

Returns an associative array containing all fields for the given table.

The returned array is indexed using fieldnames.

ArgumentDefaultComments
$tablename-
-
$groupname-1

optional - if specified, returns only fields with the given group-name. Use a null-argument to retrieve ungrouped fields.

Helper methods
Publicis Valid Field Name Has parameters
-
public static isValidFieldName ( $fieldname )
ArgumentDefaultComments
$fieldname-
-
fsMetaFieldFactory in file class/fsmeta_field_factory.php
Member Methods
MethodComments
Publicset Table Name Has parameters
-
public setTableName ( $tablename )
ArgumentDefaultComments
$tablename-
-
Publicset Field Name Has parameters
-
public setFieldName ( $fieldname )
ArgumentDefaultComments
$fieldname-
-
Publicset Group Name Has parameters
-
public setGroupName ( $groupname )
ArgumentDefaultComments
$groupname-
-
Publicget Fields Has parameters
-
public getFields ( $index_by )
ArgumentDefaultComments
$index_bynull

which field to index the returned array by, for example 'fieldname' (optional, defaults to a plain numeric array)

fsMetaChoice in file class/fsmeta_choice.php
Extends: fsObject

This class implements a choice for a field (e.g. fields of type Select or Multi)

Choice-value refers to the underlying value of a choice - for example, when you get the value of a Select, this is the value that is returned.

Choices are idenitified by a triple-key: tablename, fieldname and index - the value of a Select or Multi is thus identified by the value's index, which means you can change the underlying choice-value of a choice without problems.

Member Methods
MethodComments
~ fs Meta Choice Has parameters
-
public fsMetaChoice ( $tablename, $fieldname, $index, $values )
ArgumentDefaultComments
$tablename-
-
$fieldname-
-
$index-
-
$valuesarray()
-
Accessors
Publicget Table Name
-
public getTableName ( )
Publicget Field Name
-
public getFieldName ( )
Publicget Index
-
public getIndex ( )
Publicget Title
-
public getTitle ( )
Publicset Title Has parameters
-
public setTitle ( $value )
ArgumentDefaultComments
$value-
-
Publicget Choice Value
-
public getChoiceValue ( )
Publicset Choice Value Has parameters
-
public setChoiceValue ( $value )
ArgumentDefaultComments
$value-
-
Publicget Priority
-
public getPriority ( )
Publicset Priority Has parameters
-
public setPriority ( $value )
ArgumentDefaultComments
$value-
-
Utility methods
Publicget Field
-
public getField ( )
Publicget Column Name
-
public getColumnName ( )
Object creation
Publiccreate Has comments Has parameters

Creates and returns a new fsMetaChoice object. (more...)

public static create ( $tablename, $fieldname, $title, $value )

Creates and returns a new fsMetaChoice object.

Throws an fsMetaException if the provided title or value are invalid or missing, or if the provided tablename/fieldname does not exist.

ArgumentDefaultComments
$tablename-
-
$fieldname-
-
$title-
-
$value-
-
Object removal
Publicremove
-
public remove ( )
fsMetaChoiceFactory in file class/fsmeta_choice_factory.php
Member Methods
MethodComments
Publicset Table Name Has parameters
-
public setTableName ( $tablename )
ArgumentDefaultComments
$tablename-
-
Publicset Field Name Has parameters
-
public setFieldName ( $fieldname )
ArgumentDefaultComments
$fieldname-
-
Publicset Choice Value Has parameters
-
public setChoiceValue ( $value )
ArgumentDefaultComments
$value-
-
Publicget Choices Has parameters
-
public getChoices ( $index_by )
ArgumentDefaultComments
$index_bynull

which field to index the returned array by, for example 'index' (optional, defaults to a plain numeric array)

fsMetaTypeHandler in file class/fsmeta_types.php
Member Methods
MethodComments
Publicis Valid Type Has comments Has parameters

Use this function to check if the given typename is a valid typename.

public static isValidType ( $typename )

Use this function to check if the given typename is a valid typename.

ArgumentDefaultComments
$typename-
-
Publicget Valid Types Has comments

Returns an array of valid metatypenames.

public static getValidTypes ( )

Returns an array of valid metatypenames.

Publicget Handler Has comments Has parameters

Returns a global instance of the given metatype handler.

public static getHandler ( $typename )

Returns a global instance of the given metatype handler.

ArgumentDefaultComments
$typename-
-
fsMetaType in file class/fsmeta_types.php
Derived classes: fsMetaType_String, fsMetaType_Int, fsMetaType_Time, fsMetaType_Select, fsMetaType_Multi

This abstract class defines abstract and default methods for all field-type handlers.

Member Methods
MethodComments
Publicis Multi Column Has comments

Returns true if this field uses multiple columns to store its value. (more...)

public static isMultiColumn ( )

Returns true if this field uses multiple columns to store its value.

By default, all metatypes are single-column - multi-column types need to override this default method.

Publichas Choices Has comments

Returns true if this field-type can have choices. (more...)

public hasChoices ( )

Returns true if this field-type can have choices.

By default, metatypes can not have choices - types that need choices must override this default method.

Publicrender Options Has comments Has parameters

Returns an array of form-elements specific to a field-type. (more...)

public renderOptions ( $prefix, &$options )

Returns an array of form-elements specific to a field-type.

The generated form-elements are prefixed with the given string.

Use parseOptions() with the same prefix to parse the posted options.

(admin/meta_field.php uses this method to display a field's options)

ArgumentDefaultComments
$prefix-
-
&$options-
-
Publicparse Options Has comments Has parameters

Parses posted options, returns an associative array. (more...)

public parseOptions ( $prefix )

Parses posted options, returns an associative array.

Use renderOptions() to render form-elements

(admin/meta_field_save.php uses this method to save a field's options)

ArgumentDefaultComments
$prefix-
-
Abstractinit Column Has comments

Initializes type and length (etc.) for the given SchemaColumn object, according to a type's specific requirements

public abstract initColumn ( )

Initializes type and length (etc.) for the given SchemaColumn object, according to a type's specific requirements

Abstractencode Has comments

Encode (and quote) a given PHP-value as an SQL-value

public abstract encode ( )

Encode (and quote) a given PHP-value as an SQL-value

Abstractdecode Has comments

Decode a given SQL-value to a PHP-value

public abstract decode ( )

Decode a given SQL-value to a PHP-value

Abstractrender Has comments

Renders a given field as an HTML input with the given current value.

public abstract render ( )

Renders a given field as an HTML input with the given current value.

Publicparse Has comments Has parameters

This returns a value from a FORM, via POST or GET request, and translates it to a PHP-value (e.g. compatible with [fsMeta::setValue])

public parse ( &$field, $prefix, $post )

This returns a value from a FORM, via POST or GET request, and translates it to a PHP-value (e.g. compatible with [fsMeta::setValue])

ArgumentDefaultComments
&$field-
-
$prefix''

this must match the prefix you specified if you used a prefix to render() the form input.

$posttrue

optional, defaults to true - if false, will pick up values from $_GET[] instead of $_POST[].

fsMetaType_String in file class/fsmeta_types.php
Derived classes: fsMetaType_Text Extends: fsMetaType

This handler implements a simple string, stored in a VARCHAR(255) column

Member Methods
MethodComments
Publicencode Has parameters
-
public encode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicdecode Has parameters
-
public decode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicinit Column Has parameters
-
public initColumn ( &$column )
ArgumentDefaultComments
&$column-
-
Publicrender Has parameters
-
public render ( &$field, $value, $prefix, $extra, $options )
ArgumentDefaultComments
&$field-
-
$valuenull
-
$prefix''
-
$extra''
-
$optionsnull
-
[fsMetaType]
Publicis Multi Column Has comments

Returns true if this field uses multiple columns to store its value. (more...)

public static isMultiColumn ( )

Returns true if this field uses multiple columns to store its value.

By default, all metatypes are single-column - multi-column types need to override this default method.

Publichas Choices Has comments

Returns true if this field-type can have choices. (more...)

public hasChoices ( )

Returns true if this field-type can have choices.

By default, metatypes can not have choices - types that need choices must override this default method.

Publicrender Options Has comments Has parameters

Returns an array of form-elements specific to a field-type. (more...)

public renderOptions ( $prefix, &$options )

Returns an array of form-elements specific to a field-type.

The generated form-elements are prefixed with the given string.

Use parseOptions() with the same prefix to parse the posted options.

(admin/meta_field.php uses this method to display a field's options)

ArgumentDefaultComments
$prefix-
-
&$options-
-
Publicparse Options Has comments Has parameters

Parses posted options, returns an associative array. (more...)

public parseOptions ( $prefix )

Parses posted options, returns an associative array.

Use renderOptions() to render form-elements

(admin/meta_field_save.php uses this method to save a field's options)

ArgumentDefaultComments
$prefix-
-
Publicparse Has comments Has parameters

This returns a value from a FORM, via POST or GET request, and translates it to a PHP-value (e.g. compatible with [fsMeta::setValue])

public parse ( &$field, $prefix, $post )

This returns a value from a FORM, via POST or GET request, and translates it to a PHP-value (e.g. compatible with [fsMeta::setValue])

ArgumentDefaultComments
&$field-
-
$prefix''

this must match the prefix you specified if you used a prefix to render() the form input.

$posttrue

optional, defaults to true - if false, will pick up values from $_GET[] instead of $_POST[].

fsMetaType_Text in file class/fsmeta_types.php
Extends: fsMetaType_String

This handler implements a large string, stored in a TEXT column

Member Methods
MethodComments
Publicinit Column Has parameters
-
public initColumn ( &$column )
ArgumentDefaultComments
&$column-
-
Publicrender Has parameters
-
public render ( &$field, $value, $prefix, $extra, $options )
ArgumentDefaultComments
&$field-
-
$valuenull
-
$prefix''
-
$extra''
-
$optionsnull
-
[fsMetaType_String]
Publicencode Has parameters
-
public encode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicdecode Has parameters
-
public decode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
[fsMetaType_String] :: [fsMetaType]
Publicis Multi Column Has comments

Returns true if this field uses multiple columns to store its value. (more...)

public static isMultiColumn ( )

Returns true if this field uses multiple columns to store its value.

By default, all metatypes are single-column - multi-column types need to override this default method.

Publichas Choices Has comments

Returns true if this field-type can have choices. (more...)

public hasChoices ( )

Returns true if this field-type can have choices.

By default, metatypes can not have choices - types that need choices must override this default method.

Publicrender Options Has comments Has parameters

Returns an array of form-elements specific to a field-type. (more...)

public renderOptions ( $prefix, &$options )

Returns an array of form-elements specific to a field-type.

The generated form-elements are prefixed with the given string.

Use parseOptions() with the same prefix to parse the posted options.

(admin/meta_field.php uses this method to display a field's options)

ArgumentDefaultComments
$prefix-
-
&$options-
-
Publicparse Options Has comments Has parameters

Parses posted options, returns an associative array. (more...)

public parseOptions ( $prefix )

Parses posted options, returns an associative array.

Use renderOptions() to render form-elements

(admin/meta_field_save.php uses this method to save a field's options)

ArgumentDefaultComments
$prefix-
-
Publicparse Has comments Has parameters

This returns a value from a FORM, via POST or GET request, and translates it to a PHP-value (e.g. compatible with [fsMeta::setValue])

public parse ( &$field, $prefix, $post )

This returns a value from a FORM, via POST or GET request, and translates it to a PHP-value (e.g. compatible with [fsMeta::setValue])

ArgumentDefaultComments
&$field-
-
$prefix''

this must match the prefix you specified if you used a prefix to render() the form input.

$posttrue

optional, defaults to true - if false, will pick up values from $_GET[] instead of $_POST[].

fsMetaType_Int in file class/fsmeta_types.php
Extends: fsMetaType

This handler implements a signed integer number, stored in an INT column

Member Methods
MethodComments
Publicencode Has parameters
-
public encode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicdecode Has parameters
-
public decode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicinit Column Has parameters
-
public initColumn ( &$column )
ArgumentDefaultComments
&$column-
-
Publicrender Has parameters
-
public render ( &$field, $value, $prefix, $extra, $options )
ArgumentDefaultComments
&$field-
-
$valuenull
-
$prefix''
-
$extra''
-
$optionsnull
-
Publicparse Has parameters
-
public parse ( &$field, $prefix, $post )
ArgumentDefaultComments
&$field-
-
$prefix''
-
$posttrue
-
[fsMetaType]
Publicis Multi Column Has comments

Returns true if this field uses multiple columns to store its value. (more...)

public static isMultiColumn ( )

Returns true if this field uses multiple columns to store its value.

By default, all metatypes are single-column - multi-column types need to override this default method.

Publichas Choices Has comments

Returns true if this field-type can have choices. (more...)

public hasChoices ( )

Returns true if this field-type can have choices.

By default, metatypes can not have choices - types that need choices must override this default method.

Publicrender Options Has comments Has parameters

Returns an array of form-elements specific to a field-type. (more...)

public renderOptions ( $prefix, &$options )

Returns an array of form-elements specific to a field-type.

The generated form-elements are prefixed with the given string.

Use parseOptions() with the same prefix to parse the posted options.

(admin/meta_field.php uses this method to display a field's options)

ArgumentDefaultComments
$prefix-
-
&$options-
-
Publicparse Options Has comments Has parameters

Parses posted options, returns an associative array. (more...)

public parseOptions ( $prefix )

Parses posted options, returns an associative array.

Use renderOptions() to render form-elements

(admin/meta_field_save.php uses this method to save a field's options)

ArgumentDefaultComments
$prefix-
-
fsMetaType_Time in file class/fsmeta_types.php
Extends: fsMetaType

This handler implements a date and time field, stored in a DATETIME column

Member Methods
MethodComments
Publicencode Has parameters
-
public encode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicdecode Has parameters
-
public decode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicinit Column Has parameters
-
public initColumn ( &$column )
ArgumentDefaultComments
&$column-
-
Publicrender Has parameters
-
public render ( &$field, $value, $prefix, $extra, $options )
ArgumentDefaultComments
&$field-
-
$valuenull
-
$prefix''
-
$extra''
-
$optionsnull
-
Publicparse Has parameters
-
public parse ( &$field, $prefix, $post )
ArgumentDefaultComments
&$field-
-
$prefix''
-
$posttrue
-
[fsMetaType]
Publicis Multi Column Has comments

Returns true if this field uses multiple columns to store its value. (more...)

public static isMultiColumn ( )

Returns true if this field uses multiple columns to store its value.

By default, all metatypes are single-column - multi-column types need to override this default method.

Publichas Choices Has comments

Returns true if this field-type can have choices. (more...)

public hasChoices ( )

Returns true if this field-type can have choices.

By default, metatypes can not have choices - types that need choices must override this default method.

Publicrender Options Has comments Has parameters

Returns an array of form-elements specific to a field-type. (more...)

public renderOptions ( $prefix, &$options )

Returns an array of form-elements specific to a field-type.

The generated form-elements are prefixed with the given string.

Use parseOptions() with the same prefix to parse the posted options.

(admin/meta_field.php uses this method to display a field's options)

ArgumentDefaultComments
$prefix-
-
&$options-
-
Publicparse Options Has comments Has parameters

Parses posted options, returns an associative array. (more...)

public parseOptions ( $prefix )

Parses posted options, returns an associative array.

Use renderOptions() to render form-elements

(admin/meta_field_save.php uses this method to save a field's options)

ArgumentDefaultComments
$prefix-
-
fsMetaType_Select in file class/fsmeta_types.php
Extends: fsMetaType

This handler implements single selection from a collection of choices, stored as a single INT column.

The stored value is the choice-index of the selected choice.

Member Methods
MethodComments
Publicencode Has parameters
-
public encode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicdecode Has parameters
-
public decode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicinit Column Has parameters
-
public initColumn ( &$column )
ArgumentDefaultComments
&$column-
-
Publichas Choices
-
public hasChoices ( )
Publicrender Options Has parameters
-
public renderOptions ( $prefix, &$options )
ArgumentDefaultComments
$prefix-
-
&$options-
-
Publicparse Options Has parameters
-
public parseOptions ( $prefix )
ArgumentDefaultComments
$prefix-
-
Publicrender Has parameters
-
public render ( &$field, $value, $prefix, $extra, $options )
ArgumentDefaultComments
&$field-
-
$valuenull
-
$prefix''
-
$extra''
-
$optionsnull

use array("mode" => "radios") to render as a group of radio buttons, and/or array("separator" => "...") to change the code inserted between each radio input (defaults to "<br />").

[fsMetaType]
Publicis Multi Column Has comments

Returns true if this field uses multiple columns to store its value. (more...)

public static isMultiColumn ( )

Returns true if this field uses multiple columns to store its value.

By default, all metatypes are single-column - multi-column types need to override this default method.

Publicparse Has comments Has parameters

This returns a value from a FORM, via POST or GET request, and translates it to a PHP-value (e.g. compatible with [fsMeta::setValue])

public parse ( &$field, $prefix, $post )

This returns a value from a FORM, via POST or GET request, and translates it to a PHP-value (e.g. compatible with [fsMeta::setValue])

ArgumentDefaultComments
&$field-
-
$prefix''

this must match the prefix you specified if you used a prefix to render() the form input.

$posttrue

optional, defaults to true - if false, will pick up values from $_GET[] instead of $_POST[].

fsMetaType_Multi in file class/fsmeta_types.php
Extends: fsMetaType

This class implements multiple selections from a collection of choices, stored as one TINYINT column per choice.

On the PHP-side, the selections are read/written as associative arrays, containing one element per available choice. The keys of this array, are choice-values, and the value of each element is a boolean true/false.

Member Methods
MethodComments
Publicencode Has parameters
-
public encode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicdecode Has parameters
-
public decode ( &$field, $value )
ArgumentDefaultComments
&$field-
-
$value-
-
Publicinit Column Has parameters
-
public initColumn ( &$column )
ArgumentDefaultComments
&$column-
-
Publicis Multi Column
-
public isMultiColumn ( )
Publichas Choices
-
public hasChoices ( )
Publicrender Options Has parameters
-
public renderOptions ( $prefix, &$options )
ArgumentDefaultComments
$prefix-
-
&$options-
-
Publicparse Options Has parameters
-
public parseOptions ( $prefix )
ArgumentDefaultComments
$prefix-
-
Publicrender Has parameters
-
public render ( &$field, $value, $prefix, $extra, $options )
ArgumentDefaultComments
&$field-
-
$valuenull
-
$prefix''
-
$extra''
-
$optionsnull

use array("mode" => "checkboxes") to render as a group of checkboxes, and/or array("separator" => "...") to change the code inserted between each checkbox input (defaults to "<br />").

Publicparse Has parameters
-
public parse ( &$field, $prefix, $post )
ArgumentDefaultComments
&$field-
-
$prefix''
-
$posttrue
-