Store Locator Plus®

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

$active_columns  : array<string|int, mixed>
$data_table  : array<string|int, string>
$data_table  : mixed
$database  : SLP_Data
$database  : mixed
$metatable  : array<string|int, mixed>
$metatable  : mixed
$slplus  : SLPlus
$uses_slplus  : bool
$slplus  : mixed
$uses_slplus  : 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_cols()  : array<string|int, mixed>
Return an array of the meta data field properties.
get_data()  : mixed
Gets data for a store id, useful in cases when a join isn't required
get_instance()  : SLPlus_BaseClass_Object
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.
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()  : mixed
Update a data field, changing the metadata. Provide the slug and the options.
update_field_slug()  : mixed

Properties

$active_columns

public array<string|int, mixed> $active_columns

The active extended data columns (does not include inactive addon packs)

$data_table

public array<string|int, string> $data_table

Properties of the plugin data table 'name' => table name, 'fields' => key/value pair key is field name value is format.

$metatable

public array<string|int, mixed> $metatable

The properties of the meta table. metatable['name']

metatable['records'][][id|field_id|label|slug|type|options]

  • name = the name of the meta table.

  • records = a named array, keys are field slugs => values are named arrays of the properties

    • the field slug is the key

      • id = the unique id for this field
      • field_id = the unique id as a string field_###
      • label = the proper case label
      • slug = the "slugified" version of the label
      • type = the field type varchar(default)/text/int/boolean
      • options (serialized)

$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_cols()

Return an array of the meta data field properties.

public 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.

get_data()

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

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

int The id to lookup

$field_id : = 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() ]) : SLPlus_BaseClass_Object

TODO: PHP7.4 and PHP8.0 the static instance variable returns an object matching $class TODO: PHP8.1 the static instance continually returns the FIRST object (SLP_Admin_Helper) every time -- it is like PHP8.1 static instance is bound to base_class-object versus the calling class object

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
SLPlus_BaseClass_Object

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.

remove_field()

Removes a field from the data table

public remove_field( $label[,  $options = array() ][,  $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 :

string The label to remove

$options : = array()

mixed[] wpdb options

$mode : = '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.

set_options()

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

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

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( $sl_id,  $data) : false|int
Parameters
$sl_id :

int The id of the location

$data :

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

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

public update_field(bool|string $label, bool|string $type, array<string|int, mixed> $options_array) : mixed
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
mixed

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

update_field_slug()

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

        
On this page

Search results