SLP® phpDocs

SLP_Data_Extension extends SLPlus_BaseClass_Object
in package

The extended data interface helper. Managed the extended data columns when needed.

Table of Contents

Properties

$addon  : object
$data_table  : mixed
$database  : mixed
$metatable  : mixed
$myslp  : MySLP
$slplus  : SLPlus
$uses_myslp  : bool
$uses_slplus  : bool
$slug  : mixed
$active_columns  : mixed

Methods

__construct()  : mixed
__get()  : SLPlus_BaseClass_Object
__isset()  : bool
add_field()  : string
Adds a field to the data table, if already exits then update it.
filter_ExtendedDataQueries()  : string
Extend the SQL query set for extended data queries.
filter_ExtendSelectAll()  : string
Add the join clause to the base plugin select all clause.
filter_SanitizeTitleForMySQLField()  : string
Replace hyphens with underscore to make "titles" MySQL field name appropriate.
get_active_cols()  : array<string|int, stdClass>
Get the active columns (those for active add-on packs.
get_data()  : mixed
Gets data for a store id, useful in cases when a join isn't required
get_instance()  : static
Return an instance of the object which is also registered to the slplus global less the SLP_ part.
get_option()  : mixed
Get the options set for an extended data field.
has_field()  : bool
Tell people if the extended data contains a field identified by slug.
initialize()  : mixed
Things we do when be build this called from SLPlus_BaseClass_Object __contruct
remove_field()  : string
Removes a field from the data table
set_cols()  : mixed
Reads the metadata from the slp_extendo_meta table as OBJECTS and stores it in metatable['records'][<slug>]
set_options()  : mixed
Set the option-values for a field by breaking apart the serialized options part of the meta.
set_properties()  : mixed
Set our properties.
update_data()  : false|int
Update an sl_id's data
update_data_table()  : mixed
Updates the meta data table used to control the field info in the extension data table.
update_field_slug()  : mixed
get_cols()  : array<string|int, mixed>
Return an array of the meta data field properties.
update_field()  : bool|int|mysqli_result|null
Update a data field, changing the metadata. Provide the slug and the options.

Properties

$uses_myslp

public bool $uses_myslp

Set to true to add a $myslp property pointing to global $myslp

$uses_slplus

public bool $uses_slplus

Set to true (default) if the object needs access to the SLPlus plugin object.

Methods

__construct()

public __construct([array<string|int, mixed> $options = array() ]) : mixed
Parameters
$options : array<string|int, mixed> = array()

__isset()

public __isset(string $property) : bool
Parameters
$property : string
Return values
bool

add_field()

Adds a field to the data table, if already exits then update it.

public add_field(string $label[, string $type = 'text' ][, array<string|int, mixed> $options = array() ][, string $mode = 'wait' ]) : string

mode parameter

  • 'immediate' = default, run create table command when adding the field
  • 'wait' = do not run the create table command when adding this field
Parameters
$label : string

Plain text field label for this field.

$type : string = 'text'

The data type for this field.

$options : array<string|int, mixed> = array()

Options field contains serialized data for this field.

$mode : string = 'wait'

'wait' or 'immediate' determines if we call the update table structure as soon as this is called.

Tags
key

string 'slug' Unique field slug

key

string 'addon' Slug for the add-on object (short slug i.e. 'slp-experience')

key

string 'display_type' Display helper used to help with admin and UI rendering. 'checkbox' 'icon' the icon picker, with a text input box set to the field value 'input'|'text' for a single line input 'none' do not render this field 'subheader' a h3 label 'textarea' for a multiline textarea input 'submit' A submit button with value set to the field value

key

string 'help_text' The help text to display next to the field.

Return values
string

the slug of the field that was added.

filter_ExtendedDataQueries()

Extend the SQL query set for extended data queries.

public filter_ExtendedDataQueries(string $command) : string
Parameters
$command : string
Return values
string

filter_ExtendSelectAll()

Add the join clause to the base plugin select all clause.

public filter_ExtendSelectAll(string $sqlStatement) : string
Parameters
$sqlStatement : string

the existing SQL command for Select All

Return values
string

filter_SanitizeTitleForMySQLField()

Replace hyphens with underscore to make "titles" MySQL field name appropriate.

public filter_SanitizeTitleForMySQLField(string $title, string $raw_title, string $context) : string
Parameters
$title : string

party cleaned up title

$raw_title : string

original title

$context : string

mode that sanitize_title was called with such as 'query' or 'save'

Return values
string

sanitized title string with no hyphens in it

get_active_cols()

Get the active columns (those for active add-on packs.

public get_active_cols() : array<string|int, stdClass>
Return values
array<string|int, stdClass>

columns for active plugins.

get_data()

Gets data for a store id, useful in cases when a join isn't required

public get_data(mixed $sl_id[, mixed $field_id = null ]) : mixed
Parameters
$sl_id : mixed

int The id to lookup

$field_id : mixed = null

string (optional) The field id to return when only one field is needed

Return values
mixed

The column (string) or an array of all the columns

get_instance()

Return an instance of the object which is also registered to the slplus global less the SLP_ part.

public static get_instance([bool $no_global = false ][, mixed $params = array() ]) : static
Parameters
$no_global : bool = false

set to true to skip assigning object to SLP global as a property.

$params : mixed = array()

object init params

Return values
static

get_option()

Get the options set for an extended data field.

public get_option(string $slug, string $option_name) : mixed
Parameters
$slug : string

the field slug

$option_name : string

the option name

Return values
mixed

the value of that option

has_field()

Tell people if the extended data contains a field identified by slug.

public has_field(string $slug) : bool
Parameters
$slug : string

the field slug

Return values
bool

true if the field exists, false if not.

initialize()

Things we do when be build this called from SLPlus_BaseClass_Object __contruct

public initialize() : mixed

remove_field()

Removes a field from the data table

public remove_field(mixed $label[, mixed $options = array() ][, mixed $mode = 'immediate' ]) : string

mode parameter

  • 'immediate' = default, run update table command when removing the field
  • 'wait' = do not run the update table command when removing this field
Parameters
$label : mixed

string The label to remove

$options : mixed = array()

mixed[] wpdb options

$mode : mixed = 'immediate'

string operating mode

Return values
string

slug of the removed field.

set_cols()

Reads the metadata from the slp_extendo_meta table as OBJECTS and stores it in metatable['records'][<slug>]

public set_cols([bool $force = false ]) : mixed
Parameters
$force : bool = false

= set true to force reloading of data.

Tags
used-by

\SLPlus_Location::valid_location_property

used-by

\SLP_Data_Extension::get_cols

used-by

\SLP_Data_Extension::get_active_cols

used-by

\SLP_Admin_Locations_Actions::save_edited_location

set_options()

Set the option-values for a field by breaking apart the serialized options part of the meta.

public set_options(mixed $slug) : mixed
Parameters
$slug : mixed

set_properties()

Set our properties.

public set_properties([array<string|int, mixed> $options = array() ]) : mixed
Parameters
$options : array<string|int, mixed> = array()

update_data()

Update an sl_id's data

public update_data(mixed $sl_id, mixed $data) : false|int
Parameters
$sl_id : mixed

int The id of the location

$data : mixed

mixed The col => value pairs to update

Return values
false|int

false if update/insert failed or number of records inserted/updated if OK.

update_data_table()

Updates the meta data table used to control the field info in the extension data table.

public update_data_table([array<string|int, mixed> $params = array() ]) : mixed

Table is created or modified whenever a new data field is added.

Accepted $params values

  • 'mode' determines which mode to operate in:

  • 'force' = force re-read of metadata

  • null = default, use in-memory cache of metadata to build create SQL string

Parameters
$params : array<string|int, mixed> = array()
Tags
global

array $EZSQL_ERROR

update_field_slug()

public update_field_slug(mixed $slug, mixed $label, mixed $type) : mixed
Parameters
$slug : mixed
$label : mixed
$type : mixed

get_cols()

Return an array of the meta data field properties.

private get_cols([bool $force = false ]) : array<string|int, mixed>
Parameters
$force : bool = false

force a re-read of the meta data from disk.

Return values
array<string|int, mixed>

an array of arrays containing the meta data field values.

update_field()

Update a data field, changing the metadata. Provide the slug and the options.

private update_field(bool|string $label, bool|string $type, array<string|int, mixed> $options_array) : bool|int|mysqli_result|null
Parameters
$label : bool|string

The new value for the label, set to false to skip.

$type : bool|string

The new value for the type, set to false to skip

$options_array : array<string|int, mixed>

The options array stored in the metadata options field.

Return values
bool|int|mysqli_result|null

returns false if failed, 1 if update made, slug if field added.


        
On this page

Search results