Store Locator Plus®

SLP_Power_Locations_Import extends SLPlus_BaseClass_Object
in package

CSV Import handler for locations.

Table of Contents

Constants

csv_import_hook  = 'cron_csv_import'
hook  = 'slp_import_locations'

Properties

$addon  : SLPPower
$addon  : mixed
$adle_setting  : bool
$attachment_id  : int
$data  : array<string|int, string>
$fieldnames  : array<string|int, string>
$file_meta  : mixed
$filehandle  : mixed
$filehandle  : mixed
$load_data  : bool
$maxcols  : int
$messages  : SLP_Message_Manager
$messages  : mixed
$mode_for_current_record  : string
$output  : string
$output  : mixed
$processing_report  : array<string|int, string>
$processing_report  : mixed
$reported_too_many_fields  : bool
$skip_geocoding  : bool
$slplus  : SLPlus
$update_codes  : mixed
$uses_slplus  : bool
$slplus  : mixed
$uses_slplus  : mixed
$adle_setting  : mixed
$attachment_id  : mixed
$base_fieldnames  : mixed
$csv_clear_messages_on_import  : mixed
$data  : mixed
$default_mode  : mixed
$fieldnames  : mixed
$load_data  : mixed
$maxcols  : mixed
$mode_for_current_record  : mixed
$reported_too_many_fields  : mixed
$skip_geocoding  : mixed

Methods

__construct()  : mixed
__get()  : SLPlus_BaseClass_Object
__isset()  : bool
add_sl_to_base_fieldnames()  : array<string|int, mixed>
Add sl_ to any base data fields (id, store, address, address2, etc.) that are in the location data.
add_upload_meta()  : mixed
Add upload meta.
get_active_list()  : array<string|int, mixed>
Return a list of active location imports by attachment ID.
get_instance()  : SLPlus_BaseClass_Object
Return an instance of the object which is also registered to the slplus global less the SLP_ part.
get_scheduled_list()  : array<string|int, mixed>
Get a list of scheduled (cron/recurring) imports.
import()  : mixed
Process the locations csv file.
initialize()  : mixed
Things we do at startup.
match_identifier_field_on_import()  : array<string|int, mixed>
Look to see if incoming Identifier data is already in the extended data set.
prepare_for_import()  : mixed
Things we do to prepare for an import.
process_each_csv_line()  : mixed
Process the lines of the CSV file.
return_base_fields_only()  : bool
Only use the base table fields.
set_properties()  : mixed
Set our properties.
sql_match_identifier()  : string
Add the identifier filter to the SQL where clause.
start_detached_import()  : false|int
Start a detached import.
start_remote_file_import()  : int|void
Remote File Importer
stop_processing()  : mixed
Stop file processing, update meta.
strip_extra_spaces_from_csv_location_data()  : array<string|int, string>
Strip extra spaces from location data.
update_category_and_page_id()  : mixed
Attach our category data to the update string.
filter_SetMessages()  : array<string|int, mixed>
Set the process count output strings the users sees after an upload.
get_attachment_details()  : array<string|int, mixed>
Get attachment details
get_remote_file()  : mixed
Get a remote file and store it locally.
is_valid_csv_file()  : bool
Is this a valid CSV File?
load_directly_into_mysql()  : mixed
Load basic CSV files directly into MYSQL with LOAD DATA.
map_fields()  : array<string|int, mixed>
Map field name "aliases" to location data fields for import.
move_csv_to_slpdir()  : string
Move the CSV File to a local directory.
ok_to_process_file()  : bool
Override this to add special processing that skips the data processing of the file.
open_csv_file()  : bool
Open the CSV File and set the filehandle.
open_file_and_start_importing()  : mixed
Load the CSV file and start importing it into memory.
process_File()  : mixed
Process a CSV File.
report_malformed_csv_record()  : mixed
Report a malformed CSV record.
respawn()  : false|int
Respawn a single me, if I am not already in the spawning pool.
set_field_names()  : mixed
Set the field names array for the fields being processed.
set_FileMeta()  : mixed
Set file meta for the import.
set_options_from_meta()  : mixed
Set options for CSV Import from meta
set_uploads_meta()  : mixed
Set uploads meta for upload directory parsing.
strip_utf8_control_chars()  : string
Strip UTF-8 control characters
update_position_meta()  : mixed
Update the position meta data.

Constants

Properties

$mode_for_current_record read-only

public string $mode_for_current_record

What mode is the current record in 'add' || 'update' || 'skip' - set by internal processes

$reported_too_many_fields read-only

public bool $reported_too_many_fields

Did we already report a too many fields problem?

$update_codes

public mixed $update_codes = array('added', 'exists', 'not_updated', 'skipped', 'malformed', 'updated')

$uses_slplus

public bool $uses_slplus

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

$base_fieldnames

private mixed $base_fieldnames = array('id' => 'sl_id', 'store' => 'sl_store', 'address' => 'sl_address', 'address2' => 'sl_address2', 'city' => 'sl_city', 'state' => 'sl_state', 'zip' => 'sl_zip', 'country' => 'sl_country', 'latitude' => 'sl_latitude', 'longitude' => 'sl_longitude')

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

Add sl_ to any base data fields (id, store, address, address2, etc.) that are in the location data.

public add_sl_to_base_fieldnames(array<string|int, mixed> $location_data) : array<string|int, mixed>
Parameters
$location_data : array<string|int, mixed>
Return values
array<string|int, mixed>

location data with 'sl_' attached to the keys that are base fields.

add_upload_meta()

Add upload meta.

public add_upload_meta(array<string|int, mixed>|bool $data, int $attachment_id) : mixed
Parameters
$data : array<string|int, mixed>|bool

Array of meta data for the given attachment, or false if the object does not exist.

$attachment_id : int

Attachment post ID.

get_active_list()

Return a list of active location imports by attachment ID.

public get_active_list() : array<string|int, mixed>
Tags
used-by

\SLP_Power_REST_Handler::get_imports

Return values
array<string|int, mixed>

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

Get a list of scheduled (cron/recurring) imports.

public get_scheduled_list() : array<string|int, mixed>
Return values
array<string|int, mixed>

import()

Process the locations csv file.

public import(int $attachment_id) : mixed
Parameters
$attachment_id : int
Tags
used-by

\SLP_Power_Cron::import_locations

initialize()

Things we do at startup.

public initialize() : mixed
Tags
uses
SLP_Power_Locations_Import::add_csv_mime_type

match_identifier_field_on_import()

Look to see if incoming Identifier data is already in the extended data set.

public match_identifier_field_on_import(array<string|int, mixed> $location_data) : array<string|int, mixed>
Parameters
$location_data : array<string|int, mixed>
Tags
used-by

\SLP_Power_Locations_Import::prepare_for_import via slp_csv_locationdata filter

Return values
array<string|int, mixed>

$location_data

process_each_csv_line()

Process the lines of the CSV file.

public process_each_csv_line() : mixed
Tags
uses
SLP_Power_Locations_Import::add_sl_to_base_fieldnames

via FILTER: slp_csv_locationdata Priority 8

uses
SLP_Power_Locations_Import::strip_extra_spaces_from_csv_location_data

via FILTER: slp_csv_locationdata

uses
SLP_Power_Locations_Import::match_identifier_field_on_import

via FILTER: slp_csv_locationdata

uses
SLP_Power_Category_Manager::create_categories_from_location_data

via FILTER: slp_csv_locationdata

uses
SLP_Premier_Admin_Locations::strip_sl_from_territory_fields

via FILTER: slp_csv_locationdata

return_base_fields_only()

Only use the base table fields.

public return_base_fields_only( $var) : bool
Parameters
$var :
Tags
used-by

\SLP_Power_Locations_Import::load_directly_into_mysql

Return values
bool

set_properties()

Set our properties.

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

sql_match_identifier()

Add the identifier filter to the SQL where clause.

public sql_match_identifier(string $sql_slug) : string
Parameters
$sql_slug : string

The SQL command slug

Return values
string

The SQL string snippet

start_detached_import()

Start a detached import.

public start_detached_import(int|object $attachment) : false|int
Parameters
$attachment : int|object

Attachment ID or object.

Return values
false|int

int of the time import will run if ok , false if not

start_remote_file_import()

Remote File Importer

public start_remote_file_import( $params) : int|void
Parameters
$params :
Return values
int|void

stop_processing()

Stop file processing, update meta.

public stop_processing(mixed $args[, string $hook = self::hook ]) : mixed
Parameters
$args : mixed
$hook : string = self::hook

strip_extra_spaces_from_csv_location_data()

Strip extra spaces from location data.

public strip_extra_spaces_from_csv_location_data( $location_data) : array<string|int, string>
Parameters
$location_data :
Return values
array<string|int, string>

$location_data

update_category_and_page_id()

Attach our category data to the update string.

public update_category_and_page_id() : mixed

Put it in the sl_option_value field as a serialized string.

Assumes currentLocation is set.

filter_SetMessages()

Set the process count output strings the users sees after an upload.

private filter_SetMessages() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_attachment_details()

Get attachment details

private get_attachment_details(int $id) : array<string|int, mixed>
Parameters
$id : int
Return values
array<string|int, mixed>

get_remote_file()

Get a remote file and store it locally.

private get_remote_file(mixed $params) : mixed
Parameters
$params : mixed

is_valid_csv_file()

Is this a valid CSV File?

private is_valid_csv_file() : bool

TODO: old-import but should use some of this for new CSV type checking

Called for scheduled imports only.

Return values
bool

load_directly_into_mysql()

Load basic CSV files directly into MYSQL with LOAD DATA.

private load_directly_into_mysql() : mixed

This is MUCH faster than CSV parsing but requires the CSV has no extended data such as categories, etc.

map_fields()

Map field name "aliases" to location data fields for import.

private map_fields(array<string|int, mixed> $location_data) : array<string|int, mixed>
Parameters
$location_data : array<string|int, mixed>
Return values
array<string|int, mixed>

move_csv_to_slpdir()

Move the CSV File to a local directory.

private move_csv_to_slpdir() : string
Return values
string

ok_to_process_file()

Override this to add special processing that skips the data processing of the file.

private ok_to_process_file() : bool
Return values
bool

open_csv_file()

Open the CSV File and set the filehandle.

private open_csv_file(mixed $filename) : bool
Parameters
$filename : mixed
Return values
bool

open_file_and_start_importing()

Load the CSV file and start importing it into memory.

private open_file_and_start_importing() : mixed

report_malformed_csv_record()

Report a malformed CSV record.

private report_malformed_csv_record(int $field_count) : mixed
Parameters
$field_count : int

set_FileMeta()

Set file meta for the import.

private set_FileMeta() : mixed

Use the standard browser file upload objects $_FILES if set.

If not set check for a remote file URL and use that.

Tags
used-by

\SLP_Power_Locations_Import::prepare_for_import

used-by

\SLP_Power_Locations_Import::schedule_remote_import

strip_utf8_control_chars()

Strip UTF-8 control characters

private strip_utf8_control_chars(string $string) : string
Parameters
$string : string
Return values
string

        
On this page

Search results