Documentation

ImportUtilities

Shared utility methods used by both simple and complete import modes.

Provides language data retrieval, file handling, delimiter parsing, column mapping, and post-import operations (multiword handling, linking).

Tags
category

Lwt

author

HugoFara hugo.farajallah@protonmail.com

license

Unlicense http://unlicense.org/

link
https://hugofara.github.io/lwt/developer/api
since
3.0.0

Table of Contents

Constants

BATCH_SIZE  = 500
Maximum number of rows to insert in a single batch.

Methods

countImportedTerms()  : int
Count imported terms.
createTempFile()  : string
Create a temporary file from text input.
getDelimiter()  : string
Get delimiter character from tab type.
getImportedTerms()  : array<string|int, mixed>
Get imported terms for display.
getLanguageData()  : array<string|int, mixed>|null
Get language data for a specific language.
getLastWordUpdate()  : string|null
Get the last word status change timestamp.
getSqlDelimiter()  : string
Get delimiter for SQL LOAD DATA statement.
handleMultiwords()  : void
Handle multi-word expressions after import.
isLocalInfileEnabled()  : bool
Check if local infile is enabled in MySQL and PHP.
isRightToLeft()  : bool
Get right-to-left setting for a language.
linkWordsToTextItems()  : void
Link imported words to text items.
parseColumnMapping()  : array{columns: array, fields: array{txt: int, tr: int, ro: int, se: int, tl: int}}
Parse column mapping from request.

Constants

BATCH_SIZE

Maximum number of rows to insert in a single batch.

public mixed BATCH_SIZE = 500

Keeps memory usage reasonable for large imports.

Methods

countImportedTerms()

Count imported terms.

public countImportedTerms(string $lastUpdate) : int
Parameters
$lastUpdate : string

Last update timestamp

Return values
int

Number of imported terms

createTempFile()

Create a temporary file from text input.

public createTempFile(string $content) : string
Parameters
$content : string

Text content to write

Return values
string

Path to temporary file

getDelimiter()

Get delimiter character from tab type.

public getDelimiter(string $tabType) : string
Parameters
$tabType : string

Tab type (c, t, h)

Return values
string

Delimiter character

getImportedTerms()

Get imported terms for display.

public getImportedTerms(string $lastUpdate, int $offset, int $limit) : array<string|int, mixed>
Parameters
$lastUpdate : string

Last update timestamp

$offset : int

Offset for pagination

$limit : int

Limit for pagination

Return values
array<string|int, mixed>

Imported terms data

getLanguageData()

Get language data for a specific language.

public getLanguageData(int $langId) : array<string|int, mixed>|null
Parameters
$langId : int

Language ID

Return values
array<string|int, mixed>|null

Language data or null if not found

getLastWordUpdate()

Get the last word status change timestamp.

public getLastWordUpdate() : string|null
Return values
string|null

Last update timestamp

getSqlDelimiter()

Get delimiter for SQL LOAD DATA statement.

public getSqlDelimiter(string $tabType) : string
Parameters
$tabType : string

Tab type (c, t, h)

Return values
string

SQL delimiter string

handleMultiwords()

Handle multi-word expressions after import.

public handleMultiwords(int $langId, string $lastUpdate) : void
Parameters
$langId : int

Language ID

$lastUpdate : string

Last update timestamp

isLocalInfileEnabled()

Check if local infile is enabled in MySQL and PHP.

public isLocalInfileEnabled() : bool

Note: Even if MySQL server has local_infile enabled, PHP might not allow it. We check both the server setting and the PHP mysqli setting.

Return values
bool

True if local_infile is enabled on both server and client

isRightToLeft()

Get right-to-left setting for a language.

public isRightToLeft(int $langId) : bool
Parameters
$langId : int

Language ID

Return values
bool

True if language is RTL

linkWordsToTextItems()

Link imported words to text items.

public linkWordsToTextItems() : void

parseColumnMapping()

Parse column mapping from request.

public parseColumnMapping(array<string|int, mixed> $columns, bool $removeSpaces) : array{columns: array, fields: array{txt: int, tr: int, ro: int, se: int, tl: int}}
Parameters
$columns : array<string|int, mixed>

Column assignments from form (Col1-Col5)

$removeSpaces : bool

Whether language removes spaces

Return values
array{columns: array, fields: array{txt: int, tr: int, ro: int, se: int, tl: int}}

        
On this page

Search results