fieldExtender
in package
This is the root class for use by plugins to extend the Zenphoto database table fields. The administrative tabs for the objects will have input items for these new fields. They will be placed in the proximate location of the "custom data" field on the page.
Fields added to searchable objects will be included in the list of selectable search fields. They will be enabled in the list by default. The standard search form allows a visitor to choose to disable the field for a particular search.
Since the Zenphoto objects are not directly aware of these new fields, themes
must use the "get()" methods to retrieve the content for display. E.g.
echo $_zp_current_album->get('new_field');
Fields are defined in the child class and passed as the fields array parameter which consists of a multi-dimensional array, one row per object/field. The elements of each row are:
"table" is the database table name (without prefix) of the object to which the field is to be added. "name" is the MySQL field name for the new field "desc" is the "display name" of the field "type" is the database field type: int, varchar, tinytext, text, mediumtext, and longtext. "size" is the byte size of the varchar or int field (it is not needed for other types)
Database fields names must conform to MySQL field naming rules.
The constructor($fields) method establishes the fields in the database. It is recommended that the plugin invoke this method from its class __constructor method and that the the class be instantiated when the plugin is loaded from the setup plugin options processing (e.g. when OFFSET_PATH==2. The constructor method will check if the plugin is enabled. If so it adds the fields, if not it removes any previously added fields.
Tags
Table of Contents
Methods
- _addToSearch() : array<string|int, mixed>
- Updates the list of search fields to include the new fields
- _adminEdit() : string
- Displays the edit fields for user type objects
- _adminNotice() : type
- Notification of need to run setup
- _adminSave() : bool
- Process the save of user object type elements
- _getCustomData() : array<string|int, mixed>
- Returns an array with the content of the custom fields for the object
- _mediaItemEdit() : string
- Displays the edit fields for image and album objects
- _mediaItemSave() : mixed
- Processes the save of image and album objects
- _register() : mixed
- registers filters for handling display and edit of objects as appropriate
- _setCustomData() : mixed
- _zenpageItemEdit() : string
- Displays the edit fields for zenpage objects
- _zenpageItemSave() : string
- Processes the save of zenpage objects
- constructor() : mixed
- This method establishes the current set of database fields. It will add the fields to the database if they are not already present. Fields from previous constructor calls that are no longer in the list will be removed from the database (along with any data associated with them.)
Methods
_addToSearch()
Updates the list of search fields to include the new fields
public
static _addToSearch(array<string|int, mixed> $list, mixed $fields) : array<string|int, mixed>
Parameters
- $list : array<string|int, mixed>
-
the list of fields as known to the search engine
- $fields : mixed
Return values
array<string|int, mixed>_adminEdit()
Displays the edit fields for user type objects
public
static _adminEdit(string $html, object $userobj, int $i, string $background, bool $current, mixed $fields) : string
Parameters
- $html : string
- $userobj : object
- $i : int
- $background : string
- $current : bool
- $fields : mixed
Return values
string_adminNotice()
Notification of need to run setup
public
static _adminNotice(type $tab, type $subtab, type $me) : type
Parameters
- $tab : type
- $subtab : type
- $me : type
Return values
type_adminSave()
Process the save of user object type elements
public
static _adminSave(bool $updated, object $userobj, int $i, bool $alter, mixed $fields) : bool
Parameters
- $updated : bool
- $userobj : object
- $i : int
- $alter : bool
- $fields : mixed
Return values
bool_getCustomData()
Returns an array with the content of the custom fields for the object
public
static _getCustomData(object $obj, array<string|int, mixed> $fields) : array<string|int, mixed>
Parameters
- $obj : object
- $fields : array<string|int, mixed>
Return values
array<string|int, mixed>_mediaItemEdit()
Displays the edit fields for image and album objects
public
static _mediaItemEdit(string $html, object $object, int $i, mixed $fields) : string
Parameters
- $html : string
- $object : object
- $i : int
- $fields : mixed
Return values
string_mediaItemSave()
Processes the save of image and album objects
public
static _mediaItemSave(object $object, int $i, mixed $fields) : mixed
Parameters
- $object : object
- $i : int
- $fields : mixed
_register()
registers filters for handling display and edit of objects as appropriate
public
static _register(mixed $me, mixed $fields) : mixed
Parameters
- $me : mixed
- $fields : mixed
_setCustomData()
public
static _setCustomData(mixed $obj, mixed $values) : mixed
Parameters
- $obj : mixed
- $values : mixed
_zenpageItemEdit()
Displays the edit fields for zenpage objects
public
static _zenpageItemEdit(string $html, object $object, mixed $fields) : string
Parameters
- $html : string
- $object : object
- $fields : mixed
Return values
string_zenpageItemSave()
Processes the save of zenpage objects
public
static _zenpageItemSave(string $custom, object $object, mixed $fields) : string
Parameters
- $custom : string
- $object : object
- $fields : mixed
Return values
stringconstructor()
This method establishes the current set of database fields. It will add the fields to the database if they are not already present. Fields from previous constructor calls that are no longer in the list will be removed from the database (along with any data associated with them.)
public
constructor(mixed $me, array<string|int, mixed> $newfields) : mixed
Parameters
- $me : mixed
- $newfields : array<string|int, mixed>