Yioop_V9.5_Source_Code_Documentation

LocaleModel extends Model
in package

Used to encapsulate information about a locale (data about a language in a given region).

Tags
author

Chris Pollett

Table of Contents

DEFAULT_DESCRIPTION_LENGTH  = 150
Default maximum character length of a search summary
MAX_SNIPPET_TITLE_LENGTH  = 20
MIN_SNIPPET_LENGTH  = 100
SNIPPET_LENGTH_LEFT  = 20
SNIPPET_LENGTH_RIGHT  = 40
SNIPPET_TITLE_LENGTH  = 20
$any_fields  : array<string|int, mixed>
These fields if present in $search_array (used by @see getRows() ), but with value "-1", will be skipped as part of the where clause but will be used for order by clause
$cache  : object
Cache object to be used if we are doing caching
$configure  : array<string|int, mixed>
Used to store ini file data of the current locale
$current_locale  : object
Holds global locale object currently in use for the session
$db  : object
Reference to a DatasourceManager
$db_name  : string
Name of the search engine database
$default_configure  : array<string|int, mixed>
Used to store ini file data of the default locale (will use if no translation current locale)
$edited_page_summaries  : array<string|int, mixed>
Associative array of page summaries which might be used to override default page summaries if set.
$extensions  : array<string|int, mixed>
File extensions of files to try to extract translatable strings from
$extract_dirs  : array<string|int, mixed>
Directories to try to extract translatable identifier strings from
$locale_name  : string
Locale name as a string it locale name's language
$locale_tag  : string
IANA tag name of current locale
$private_db  : object
Reference to a private DatasourceManager
$private_db_name  : string
Name of the private search engine database
$search_table_column_map  : array<string|int, mixed>
Associations of the form name of field for web forms => database column names/abbreviations In this case, things will in general map to the LOCALES tables in the Yioop database
$web_site  : object
Reference to a WebSite object in use to serve pages (if any)
$writing_mode  : string
Combination of text direction and block progression as a string. Has one of four values: lr-tb, rl-tb, tb-lr, tb-rl. Other possible values for things like Arabic block quoted in Mongolian not supported
__construct()  : mixed
Sets up the database manager that will be used and name of the search engine database
addLocale()  : mixed
Adds information concerning a new locale to the database
boldKeywords()  : string
Given a string, wraps in bold html tags a set of key words it contains.
checkLocaleExists()  : bool
Check if there is a locale with tag equal to $locale_tag
createIfNecessaryDirectory()  : int
Creates a directory and sets it to world permission if it doesn't already exist
deleteLocale()  : mixed
Remove a locale from the database
extractMergeLocales()  : array<string|int, mixed>
Used to extract identifier strings from files with correct extensions, then these strings are merged with existing extracted strings for each locale as well as their translations (if an extract string has a translation the translation is untouched by this process).
fileGetContents()  : string
Either a wrapper for file_get_contents, or if a WebSite object is being used to serve pages, it reads it in using blocking I/O file_get_contents() and caches it before return its string contents.
filePutContents()  : mixed
Either a wrapper for file_put_contents, or if a WebSite object is being used to serve pages, writes $data to the persistent file with name $filename. Saves a copy in the RAM cache if there is a copy already there.
formatSinglePageResult()  : array<string|int, mixed>
Given a page summary, extracts snippets which are related to a set of search words. For each snippet, bold faces the search terms, and then creates a new summary array.
fromCallback()  : string
Controls which tables and the names of tables underlie the given model and should be used in a getRows call This defaults to the single table whose name is whatever is before Model in the name of the model. For example, by default on FooModel this method would return "FOO". If a different behavior, this can be overridden in subclasses of Model
getDbmsList()  : array<string|int, mixed>
Gets a list of all DBMS that work with the search engine
getLocaleDirection()  : string
The text direction of the current locale being used by the text engine
getLocaleInfo()  : string
Returns the locale name, tag, and writing mode for tag $locale_tag
getLocaleList()  : array<string|int, mixed>
Returns information about available locales
getLocaleName()  : string
Returns the name of the locale for tag $locale_tag
getLocaleTag()  : string
Get the current IANA language tag being used by the search engine
getRows()  : array<string|int, mixed>
Gets a range of rows which match the provided search criteria from $th provided table
getSnippets()  : string
Given a string, extracts a snippets of text related to a given set of key words. For a given word a snippet is a window of characters to its left and right that is less than a maximum total number of characters.
getStringData()  : array<string|int, mixed>
For each translatable identifier string (either static from a configure ini file, or dynamic from the db) return its name together with its translation into the given locale if such a translation exists.
getTranslateStrings()  : array<string|int, mixed>
Searches the directories provided looking for files matching the extensions provided. When such a file is found it is loaded and scanned for tl() function calls. The identifier string in this function call is then extracted and added to a line array of strings to be translated.
getUserId()  : string
Get the user_id associated with a given username (In base class as used as an internal method in both signin and user models)
getWritingMode()  : string
Get the writing mode of the current locale (text and block directions)
initialize()  : mixed
Loads the provided locale's configure file (containing translation) and calls setlocale to set up locale specific string formatting (to format numbers, etc.)
isSingleLocalhost()  : bool
Used to determine if an action involves just one yioop instance on the current local machine or not
isTranslated()  : bool
Checks if the given string_id has a translation in translations
loginDbms()  : bool
Returns whether the provided dbms needs a login and password or not (sqlite or sqlite3)
lookupTranslation()  : string
Translates a string_id from among translation array data in $new_configure (most preferred, probably come from recent web form data), $old_configure (probably from work dir), and $fallback_configure (probably from base dir of Yioop instance, least preferred).
postQueryCallback()  : array<string|int, mixed>
Called after getRows has retrieved all the rows that it would retrieve but before they are returned to give one last place where they could be further manipulated. For example, in MachineModel this callback is used to make parallel network calls to get the status of each machine returned by getRows. The default for this method is to leave the rows that would be returned unchanged
rowCallback()  : array<string|int, mixed>
This is called after each row is retrieved by getRows. This method Then reads in the corresponding statistics.txt file (or rebuilds it from the Configure.ini file if it is out of date) to add to the row percent translated info.
searchArrayToWhereOrderClauses()  : array<string|int, mixed>
Creates the WHERE and ORDER BY clauses for a query of a Yioop table such as USERS, ROLE, GROUP, which have associated search web forms. Searches are case insensitive
selectCallback()  : string
Controls which columns and the names of those columns from the tables underlying the given model should be return from a getRows call.
translate()  : mixed
Translate an array consisting of an identifier string together with additional variable parameters into the current locale.
translateDb()  : mixed
Used to get the translation of a string_id stored in the database to the given locale.
traverseExtractRecursive()  : array<string|int, mixed>
Traverses a directory and its subdirectories looking for files whose extensions come from the extensions array. As the traversal is done a strings array is created. Each time a file is found of any identifiers of strings that need to be translated are added to the strings array. In addition, ini style comments are added givne the line file and line number of the item to be translated
updateLocale()  : mixed
Updates the Configure.ini file and static pages for a particular locale.
updateLocaleInfo()  : mixed
Used to update the fields stored in a LOCALE row according to an array holding new values
updateLocales()  : mixed
Cycles through locale subdirectories in LOCALE_DIR, for each locale it merges out the current general_ini and strings data.
updateLocaleSubFolder()  : mixed
Copies over subfolder items of the correct file extensions which exists in a fallback directory, but not in the actual directory of a locale.
updateStringData()  : mixed
Updates the identifier_string-translation pairs (both static and dynamic) for a given locale
updateTranslation()  : string
Computes a string of the form string_id = 'translation' for a string_id from among translation array data in $new_configure (most preferred, probably come from recent web form data), $old_configure (probably from work dir), and $fallback_configure (probably from base dir of Yioop instance, least preferred).
whereCallback()  : string
Controls the WHERE clause of the SQL query that underlies the given model and should be used in a getRows call.

Constants

DEFAULT_DESCRIPTION_LENGTH

Default maximum character length of a search summary

public mixed DEFAULT_DESCRIPTION_LENGTH = 150

MAX_SNIPPET_TITLE_LENGTH

public mixed MAX_SNIPPET_TITLE_LENGTH = 20

MIN_SNIPPET_LENGTH

public mixed MIN_SNIPPET_LENGTH = 100

SNIPPET_LENGTH_LEFT

public mixed SNIPPET_LENGTH_LEFT = 20

SNIPPET_LENGTH_RIGHT

public mixed SNIPPET_LENGTH_RIGHT = 40

SNIPPET_TITLE_LENGTH

public mixed SNIPPET_TITLE_LENGTH = 20

Properties

$any_fields

These fields if present in $search_array (used by @see getRows() ), but with value "-1", will be skipped as part of the where clause but will be used for order by clause

public array<string|int, mixed> $any_fields = ["mode", "active"]

$cache

Cache object to be used if we are doing caching

public static object $cache

$configure

Used to store ini file data of the current locale

public array<string|int, mixed> $configure = []

$current_locale

Holds global locale object currently in use for the session

public static object $current_locale = null

$db

Reference to a DatasourceManager

public object $db

$db_name

Name of the search engine database

public string $db_name

$default_configure

Used to store ini file data of the default locale (will use if no translation current locale)

public array<string|int, mixed> $default_configure = []

$edited_page_summaries

Associative array of page summaries which might be used to override default page summaries if set.

public array<string|int, mixed> $edited_page_summaries = null

$extensions

File extensions of files to try to extract translatable strings from

public array<string|int, mixed> $extensions = ["php"]

$extract_dirs

Directories to try to extract translatable identifier strings from

public array<string|int, mixed> $extract_dirs = ["controllers", "views", "library/indexing_plugins"]

$locale_name

Locale name as a string it locale name's language

public string $locale_name

$locale_tag

IANA tag name of current locale

public string $locale_tag

$private_db

Reference to a private DatasourceManager

public object $private_db

$private_db_name

Name of the private search engine database

public string $private_db_name

$search_table_column_map

Associations of the form name of field for web forms => database column names/abbreviations In this case, things will in general map to the LOCALES tables in the Yioop database

public array<string|int, mixed> $search_table_column_map = ["name" => "LOCALE_NAME", "tag" => "LOCALE_TAG", "mode" => "WRITING_MODE", "active" => "ACTIVE"]

$web_site

Reference to a WebSite object in use to serve pages (if any)

public object $web_site

$writing_mode

Combination of text direction and block progression as a string. Has one of four values: lr-tb, rl-tb, tb-lr, tb-rl. Other possible values for things like Arabic block quoted in Mongolian not supported

public string $writing_mode

Methods

__construct()

Sets up the database manager that will be used and name of the search engine database

public __construct([string $db_name = CDB_NAME ][, bool $connect = true ][, mixed $web_site = null ]) : mixed
Parameters
$db_name : string = CDB_NAME

the name of the database for the search engine

$connect : bool = true

whether to connect to the database by default after making the datasource class

$web_site : mixed = null
Return values
mixed

addLocale()

Adds information concerning a new locale to the database

public addLocale(string $locale_name, string $locale_tag, string $writing_mode[, int $active = 1 ]) : mixed
Parameters
$locale_name : string

the name of the locale in the locale's language

$locale_tag : string

the IANA language tag for the locale

$writing_mode : string

a combination of the horizontal and vertical text direction used for writing in the locale

$active : int = 1

whether the locale is current active (>0) or not used (== 0)

Return values
mixed

boldKeywords()

Given a string, wraps in bold html tags a set of key words it contains.

public boldKeywords(string $text, array<string|int, mixed> $words) : string
Parameters
$text : string

haystack string to look for the key words

$words : array<string|int, mixed>

an array of words to bold face

Return values
string

the resulting string after boldfacing has been applied

checkLocaleExists()

Check if there is a locale with tag equal to $locale_tag

public checkLocaleExists(string $locale_tag) : bool
Parameters
$locale_tag : string

to check for

Return values
bool

whether or not has exists

createIfNecessaryDirectory()

Creates a directory and sets it to world permission if it doesn't already exist

public createIfNecessaryDirectory(string $directory) : int
Parameters
$directory : string

name of directory to create

Return values
int

-1 on failure, 0 if already existed, 1 if created

deleteLocale()

Remove a locale from the database

public deleteLocale(string $locale_tag) : mixed
Parameters
$locale_tag : string

the IANA language tag for the locale to remove

Return values
mixed

extractMergeLocales()

Used to extract identifier strings from files with correct extensions, then these strings are merged with existing extracted strings for each locale as well as their translations (if an extract string has a translation the translation is untouched by this process).

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

which locale subfolders should be forced updated to the fallback dir's version

Return values
array<string|int, mixed>

a pair consisting of the data from the General.ini file together with an array of msg_ids msg_strings.

fileGetContents()

Either a wrapper for file_get_contents, or if a WebSite object is being used to serve pages, it reads it in using blocking I/O file_get_contents() and caches it before return its string contents.

public fileGetContents(string $filename[, bool $force_read = false ]) : string

Note this function assumes that only the web server is performing I/O with this file. filemtime() can be used to see if a file on disk has been changed and then you can use $force_read = true below to force re- reading the file into the cache

Parameters
$filename : string

name of file to get contents of

$force_read : bool = false

whether to force the file to be read from persistent storage rather than the cache

Return values
string

contents of the file given by $filename

filePutContents()

Either a wrapper for file_put_contents, or if a WebSite object is being used to serve pages, writes $data to the persistent file with name $filename. Saves a copy in the RAM cache if there is a copy already there.

public filePutContents(string $filename, string $data) : mixed
Parameters
$filename : string

name of file to write to persistent storages

$data : string

string of data to store in file

Return values
mixed

formatSinglePageResult()

Given a page summary, extracts snippets which are related to a set of search words. For each snippet, bold faces the search terms, and then creates a new summary array.

public formatSinglePageResult(array<string|int, mixed> $page[, array<string|int, mixed> $words = null ][, int $description_length = self::DEFAULT_DESCRIPTION_LENGTH ]) : array<string|int, mixed>
Parameters
$page : array<string|int, mixed>

a single search result summary

$words : array<string|int, mixed> = null

keywords (typically what was searched on)

$description_length : int = self::DEFAULT_DESCRIPTION_LENGTH

length of the description

Return values
array<string|int, mixed>

$page which has been snippified and bold faced

fromCallback()

Controls which tables and the names of tables underlie the given model and should be used in a getRows call This defaults to the single table whose name is whatever is before Model in the name of the model. For example, by default on FooModel this method would return "FOO". If a different behavior, this can be overridden in subclasses of Model

public fromCallback([mixed $args = null ]) : string
Parameters
$args : mixed = null

any additional arguments which should be used to determine these tables

Return values
string

a comma separated list of tables suitable for a SQL query

getDbmsList()

Gets a list of all DBMS that work with the search engine

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

Names of available data sources

getLocaleDirection()

The text direction of the current locale being used by the text engine

public getLocaleDirection() : string
Return values
string

either ltr (left-to-right) or rtl (right-to-left)

getLocaleInfo()

Returns the locale name, tag, and writing mode for tag $locale_tag

public getLocaleInfo(string $locale_tag) : string
Parameters
$locale_tag : string

to get name for

Return values
string

name of locale

getLocaleList()

Returns information about available locales

public getLocaleList([bool $only_active = true ][, bool $only_db_info = true ]) : array<string|int, mixed>
Parameters
$only_active : bool = true

says whether to return info only about active locales (true) or about all locales (false);

$only_db_info : bool = true

only get database information about the locale, skip calculating percent translated

Return values
array<string|int, mixed>

rows of locale information

getLocaleName()

Returns the name of the locale for tag $locale_tag

public getLocaleName(string $locale_tag) : string
Parameters
$locale_tag : string

to get name for

Return values
string

name of locale

getLocaleTag()

Get the current IANA language tag being used by the search engine

public getLocaleTag() : string
Return values
string

an IANA language tag

getRows()

Gets a range of rows which match the provided search criteria from $th provided table

public getRows(int $limit, int $num, int &$total[, array<string|int, mixed> $search_array = [] ][, array<string|int, mixed> $args = null ]) : array<string|int, mixed>
Parameters
$limit : int

starting row from the potential results to return

$num : int

number of rows after start row to return

$total : int

gets set with the total number of rows that can be returned by the given database query

$search_array : array<string|int, mixed> = []

each element of this is a quadruple name of a field, what comparison to perform, a value to check, and an order (ascending/descending) to sort by

$args : array<string|int, mixed> = null

additional values which may be used to get rows (what these are will typically depend on the subclass implementation)

Return values
array<string|int, mixed>

getSnippets()

Given a string, extracts a snippets of text related to a given set of key words. For a given word a snippet is a window of characters to its left and right that is less than a maximum total number of characters.

public getSnippets(string $text, array<string|int, mixed> $words, string $description_length) : string

There is also a rule that a snippet should avoid ending in the middle of a word

Parameters
$text : string

haystack to extract snippet from

$words : array<string|int, mixed>

keywords used to make look in haystack

$description_length : string

length of the description desired

Return values
string

a concatenation of the extracted snippets of each word

getStringData()

For each translatable identifier string (either static from a configure ini file, or dynamic from the db) return its name together with its translation into the given locale if such a translation exists.

public getStringData(string $locale_tag) : array<string|int, mixed>
Parameters
$locale_tag : string

the IANA language tag to translate string into

Return values
array<string|int, mixed>

rows of identifier string - translation pairs

getTranslateStrings()

Searches the directories provided looking for files matching the extensions provided. When such a file is found it is loaded and scanned for tl() function calls. The identifier string in this function call is then extracted and added to a line array of strings to be translated.

public getTranslateStrings(array<string|int, mixed> $extract_dirs, array<string|int, mixed> $extensions) : array<string|int, mixed>

This line array is formatted so that each line looks like a line that might occur in an PHP ini file. To understand this format one can look at the parse_ini_string function in the PHP manual or look at the Configure.ini files in the locale directory

Parameters
$extract_dirs : array<string|int, mixed>

directories to start looking for files with strings to be translated

$extensions : array<string|int, mixed>

file extensions of files which might contain such strings

Return values
array<string|int, mixed>

of lines for any ini file of msg_id msg_string pairs

getUserId()

Get the user_id associated with a given username (In base class as used as an internal method in both signin and user models)

public getUserId(string $username) : string
Parameters
$username : string

the username to look up

Return values
string

the corresponding userid

getWritingMode()

Get the writing mode of the current locale (text and block directions)

public getWritingMode() : string
Return values
string

the current writing mode

initialize()

Loads the provided locale's configure file (containing translation) and calls setlocale to set up locale specific string formatting (to format numbers, etc.)

public initialize(string $locale_tag) : mixed
Parameters
$locale_tag : string

the tag of the locale to use as the current locale

Return values
mixed

isSingleLocalhost()

Used to determine if an action involves just one yioop instance on the current local machine or not

public isSingleLocalhost(array<string|int, mixed> $machine_urls[, string $index_timestamp = -1 ]) : bool
Parameters
$machine_urls : array<string|int, mixed>

urls of yioop instances to which the action applies

$index_timestamp : string = -1

if timestamp exists checks if the index has declared itself to be a no network index.

Return values
bool

whether it involves a single local yioop instance (true) or not (false)

isTranslated()

Checks if the given string_id has a translation in translations

public isTranslated(string $string_id[, array<string|int, mixed> $translations = false ]) : bool
Parameters
$string_id : string

what to check if translated

$translations : array<string|int, mixed> = false

of form string_id => translation defaults to current configuration

Return values
bool

whether a translation of nonzero length exists

loginDbms()

Returns whether the provided dbms needs a login and password or not (sqlite or sqlite3)

public loginDbms(string $dbms) : bool
Parameters
$dbms : string

the name of a database management system

Return values
bool

true if needs a login and password; false otherwise

lookupTranslation()

Translates a string_id from among translation array data in $new_configure (most preferred, probably come from recent web form data), $old_configure (probably from work dir), and $fallback_configure (probably from base dir of Yioop instance, least preferred).

public lookupTranslation(array<string|int, mixed> $new_configure, array<string|int, mixed> $old_configure, array<string|int, mixed> $fallback_configure, string $string_id[, string $default_value = "" ]) : string
Parameters
$new_configure : array<string|int, mixed>

string_id => translation pairs

$old_configure : array<string|int, mixed>

string_id => translation pairs

$fallback_configure : array<string|int, mixed>

string_id => translation pairs

$string_id : string

an id to translate

$default_value : string = ""

value to use if no configuration has a translation for a string_id

Return values
string

translation of string id

postQueryCallback()

Called after getRows has retrieved all the rows that it would retrieve but before they are returned to give one last place where they could be further manipulated. For example, in MachineModel this callback is used to make parallel network calls to get the status of each machine returned by getRows. The default for this method is to leave the rows that would be returned unchanged

public postQueryCallback(array<string|int, mixed> $rows) : array<string|int, mixed>
Parameters
$rows : array<string|int, mixed>

that have been calculated so far by getRows

Return values
array<string|int, mixed>

$rows after this final manipulation

rowCallback()

This is called after each row is retrieved by getRows. This method Then reads in the corresponding statistics.txt file (or rebuilds it from the Configure.ini file if it is out of date) to add to the row percent translated info.

public rowCallback(string $locale, mixed $args) : array<string|int, mixed>
Parameters
$locale : string

one getRows row corresponding to a given locale

$args : mixed

additional arguments that might be used for this method (none used for this sub-class)

Return values
array<string|int, mixed>

$locale row with PERCENT_WITH_STRINGS field added

searchArrayToWhereOrderClauses()

Creates the WHERE and ORDER BY clauses for a query of a Yioop table such as USERS, ROLE, GROUP, which have associated search web forms. Searches are case insensitive

public searchArrayToWhereOrderClauses(array<string|int, mixed> $search_array[, array<string|int, mixed> $any_fields = ['status'] ]) : array<string|int, mixed>
Parameters
$search_array : array<string|int, mixed>

each element of this is a quadruple name of a field, what comparison to perform, a value to check, and an order (ascending/descending) to sort by

$any_fields : array<string|int, mixed> = ['status']

these fields if present in search array but with value "-1" will be skipped as part of the where clause but will be used for order by clause

Return values
array<string|int, mixed>

string for where clause, string for order by clause

selectCallback()

Controls which columns and the names of those columns from the tables underlying the given model should be return from a getRows call.

public selectCallback([mixed $args = null ]) : string
Parameters
$args : mixed = null

any additional arguments which should be used to determine the columns

Return values
string

a comma separated list of columns suitable for a SQL query

translate()

Translate an array consisting of an identifier string together with additional variable parameters into the current locale.

public translate(array<string|int, mixed> $arr) : mixed

Suppose the identifier string was some_view_fraction_received and two additional arguments 5 and 10 were given. Suppose further that its translation into the current locale (say en_US) was "%s out of %s". Then the string returned by translate would be "5 out of 10".

Parameters
$arr : array<string|int, mixed>

an array consisting of an identifier string followed optionally by parameter values.

Return values
mixed

the translation of the identifier string into the current locale where all %s have been replaced by the corresponding parameter values. Returns false if no translation

translateDb()

Used to get the translation of a string_id stored in the database to the given locale.

public translateDb(string $string_id, string $locale_tag) : mixed
Parameters
$string_id : string

id to translate

$locale_tag : string

to translate to

Return values
mixed

translation if found, $string_id, otherwise

traverseExtractRecursive()

Traverses a directory and its subdirectories looking for files whose extensions come from the extensions array. As the traversal is done a strings array is created. Each time a file is found of any identifiers of strings that need to be translated are added to the strings array. In addition, ini style comments are added givne the line file and line number of the item to be translated

public traverseExtractRecursive(string $dir, array<string|int, mixed> $extensions) : array<string|int, mixed>
Parameters
$dir : string

current directory to start looking for files with strings to be translated

$extensions : array<string|int, mixed>

file extensions of files which might contain such strings

Return values
array<string|int, mixed>

of lines for any ini file of msg_id msg_string pairs

updateLocale()

Updates the Configure.ini file and static pages for a particular locale.

public updateLocale(array<string|int, mixed> $general_ini, array<string|int, mixed> $strings, string $dir, string $locale[, array<string|int, mixed> $new_configure = null ][, array<string|int, mixed> $force_folders = [] ]) : mixed

The Configure.ini has general information (at this point not really being used) about all locales together with specific msg_id (identifiers to be translated) and msg_string (translation) data. updateLocale takes line data coming from the General.ini file, strings extracted from documents that might need to be translation, the old Configure.ini file (this might have existing translations), as well as new translation data that might come from a localizer via a web form and combines these to produce a new Configure.ini file

Parameters
$general_ini : array<string|int, mixed>

data from the General.ini file

$strings : array<string|int, mixed>

line array data extracted from files in directories that have strings in need of translation

$dir : string

the directory of all the locales

$locale : string

the particular locale in $dir to update

$new_configure : array<string|int, mixed> = null

translations of identifier strings from another source such as a localizer using a web form

$force_folders : array<string|int, mixed> = []

which locale subfolders should be forced updated to the fallback dir's version

Return values
mixed

updateLocaleInfo()

Used to update the fields stored in a LOCALE row according to an array holding new values

public updateLocaleInfo(array<string|int, mixed> $locale_info) : mixed
Parameters
$locale_info : array<string|int, mixed>

updated values for a LOCALE row

Return values
mixed

updateLocales()

Cycles through locale subdirectories in LOCALE_DIR, for each locale it merges out the current general_ini and strings data.

public updateLocales(array<string|int, mixed> $general_ini, array<string|int, mixed> $strings[, array<string|int, mixed> $force_folders = [] ]) : mixed

It deletes identifiers that are not in strings, it adds new identifiers and it leaves existing identifier translation pairs untouched.

Parameters
$general_ini : array<string|int, mixed>

data that would typically come from the General.ini file

$strings : array<string|int, mixed>

lines from what is equivalent to an ini file of msg_id msg_string pairs these lines also have comments on the file that strings were extracted from

$force_folders : array<string|int, mixed> = []

which locale subfolders should be forced updated to the fallback dir's version

Return values
mixed

updateLocaleSubFolder()

Copies over subfolder items of the correct file extensions which exists in a fallback directory, but not in the actual directory of a locale.

public updateLocaleSubFolder(string $locale_pages_path, string $fallback_pages_path, array<string|int, mixed> $file_extensions) : mixed
Parameters
$locale_pages_path : string

static page directory to which will copy

$fallback_pages_path : string

static page directory from which will copy

$file_extensions : array<string|int, mixed>

an array of strings names of file extensions for example: .txt.gz .thtml .php ,etc

Return values
mixed

updateStringData()

Updates the identifier_string-translation pairs (both static and dynamic) for a given locale

public updateStringData(string $locale_tag, array<string|int, mixed> $new_strings) : mixed
Parameters
$locale_tag : string

the IANA language tag to update the strings of

$new_strings : array<string|int, mixed>

rows of identifier string - translation pairs

Return values
mixed

updateTranslation()

Computes a string of the form string_id = 'translation' for a string_id from among translation array data in $new_configure (most preferred, probably come from recent web form data), $old_configure (probably from work dir), and $fallback_configure (probably from base dir of Yioop instance, least preferred).

public updateTranslation(array<string|int, mixed> $new_configure, array<string|int, mixed> $old_configure, array<string|int, mixed> $fallback_configure, string $string_id[, string $default_value = "" ]) : string
Parameters
$new_configure : array<string|int, mixed>

string_id => translation pairs

$old_configure : array<string|int, mixed>

string_id => translation pairs

$fallback_configure : array<string|int, mixed>

string_id => translation pairs

$string_id : string

an id to translate

$default_value : string = ""

value to use if no configuration has a translation for a string_id

Return values
string

translation in format describe above

whereCallback()

Controls the WHERE clause of the SQL query that underlies the given model and should be used in a getRows call.

public whereCallback([mixed $args = null ]) : string

This defaults to an empty WHERE clause.

Parameters
$args : mixed = null

additional arguments that might be used to construct the WHERE clause.

Return values
string

a SQL WHERE clause


        

Search results