Core class used to implement the translation sets.

since 1.0.0
package GlotPress
inherited_from \GP_Thing

 Methods

__construct()

__construct($fields = array()
Inherited

Parameters

$fields

Executes after creating a translation set.

after_create() : boolean

This is a placeholder function which should be implemented in the child classes.

since 3.0.0
inherited_from \GP_Thing::after_create()

Returns

boolean

Is called after an object is created in the database.

after_create() : boolean
Inherited

This is a placeholder function which should be implemented in the child classes.

Returns

boolean

Executes after deleting a translation set.

after_delete() : boolean

This is a placeholder function which should be implemented in the child classes.

since 3.0.0
inherited_from \GP_Thing::after_delete()

Returns

boolean

Is called after an object is deleted from the database.

after_delete() : boolean
Inherited

This is a placeholder function which should be implemented in the child classes.

Returns

boolean

Executes after saving a translation set.

after_save(\GP_Translation_Set $translation_set_before) : boolean

This is a placeholder function which should be implemented in the child classes.

since 3.0.0
inherited_from \GP_Thing::after_save()

Parameters

$translation_set_before

\GP_Translation_Set

Translation set before the update.

Returns

boolean

Is called after an object is saved to the database.

after_save(\GP_Thing $thing_before) : boolean
Inherited

This is a placeholder function which should be implemented in the child classes.

Parameters

$thing_before

\GP_Thing

Object before the update.

Returns

boolean

Retrieves all rows from this table

all($order = null
Inherited

Parameters

$order

Retrieves the number of all originals.

all_count() : integer

Returns

integerNumber of all originals.

apply_default_conditions()

apply_default_conditions($conditions_str) 
Inherited

Parameters

$conditions_str

by_locale()

by_locale($locale_slug) 

Parameters

$locale_slug

by_project_id()

by_project_id($project_id) 

Parameters

$project_id

by_project_id_slug_and_locale()

by_project_id_slug_and_locale($project_id, $slug, $locale_slug) 

Parameters

$project_id

$slug

$locale_slug

Retrieves the number of "changes requested" translations.

changesrequested_count() : integer

Returns

integerNumber of "changes requested" translations.

Coerces data to being a thing object.

coerce(array|object $thing) : \GP_Thing | false
Inherited
since 1.0.0

Parameters

$thing

arrayobject

Data about the thing retrieved from the database.

Returns

\GP_ThingfalseThing object on success, false on failure.

Copies translations from a translation set to the current one

copy_translations_from($source_translation_set_id) 

This function doesn't merge then, just copies unconditionally. If a translation already exists, it will be duplicated. When copying translations from another project, it will search to find the original first.

Parameters

$source_translation_set_id

Inserts a new row

create($args) : mixed
Inherited

Parameters

$args

array associative array with fields as keys and values as values

Returns

mixedthe object corresponding to the inserted row or false on error

Inserts a record and then selects it back based on the id

create_and_select($args) : mixed
Inherited

Parameters

$args

array see create()

Returns

mixedthe selected object or false on error

Retrieves the number of current translations.

current_count() : integer

Returns

integerNumber of current translations.

Deletes a translation set and all of its translations and glossaries.

delete() : boolean
since 2.0.0
inherited_from \GP_Thing::delete()

Returns

boolean

Deletes a single row

delete() 
Inherited
since 1.0.0

Deletes all or multiple rows

delete_all(array $where = null
Inherited
since 1.0.0

Parameters

$where

array

An array of conditions to use to for a SQL "where" clause, if null, not used and all matching rows will be deleted.

Deletes multiple rows

delete_many(array $where) 
Inherited
since 2.0.0

Parameters

$where

array

An array of conditions to use to for a SQL "where" clause, if not passed, no rows will be deleted.

existing_locales()

existing_locales() 

existing_slugs()

existing_slugs() 

fields()

fields() 
Inherited

[find description]

find(string|array $conditions, string|array $order = null) : mixed
Inherited
since 1.0.0

Parameters

$conditions

stringarray

$order

stringarray

Optional.

Returns

mixed

[find_many description]

find_many(string|array $conditions, string|array $order = null) : mixed
Inherited
since 1.0.0

Parameters

$conditions

stringarray

$order

stringarray

Optional.

Returns

mixed

[find_many_no_map description]

find_many_no_map(string|array $conditions, string|array $order = null) : mixed
Inherited
since 1.0.0

Parameters

$conditions

stringarray

$order

stringarray

Optional.

Returns

mixed

[find_no_map description]

find_no_map(string|array $conditions, string|array $order = null) : mixed
Inherited
since 1.0.0

Parameters

$conditions

stringarray

$order

stringarray

Optional.

Returns

mixed

[find_one description]

find_one(string|array $conditions, string|array $order = null) : mixed
Inherited
since 1.0.0

Parameters

$conditions

stringarray

$order

stringarray

Optional.

Returns

mixed

force_false_to_null()

force_false_to_null($value) 
Inherited

Parameters

$value

found_rows()

found_rows() 
Inherited

Retrieves the number of fuzzy translations.

fuzzy_count() : integer

Returns

integerNumber of fuzzy translations.

Retrieves an existing thing.

get(\GP_Thing|integer $thing_or_id) : \GP_Thing | false
Inherited
since 1.0.0

Parameters

$thing_or_id

\GP_Thinginteger

ID of a thing or GP_Thing object.

Returns

\GP_ThingfalseThing object on success, false on failure.

get_db_field_formats()

get_db_field_formats($args) 
Inherited

Parameters

$args

get_static()

get_static($name, $default = null
Inherited

Parameters

$name

$default

has_static()

has_static($name) 
Inherited

Parameters

$name

Import translations from a Translations object.

import(\Translations $translations, string $desired_status = 'current') : boolean

Parameters

$translations

\Translations

the translations to be imported to this translation-set.

$desired_status

string

'current', 'waiting' or 'fuzzy'.

Returns

booleanor void

Retrieves the last modified date of a translation in this translation set.

last_modified() : string | false
since 1.0.0

Returns

stringfalseThe last modified date on success, false on failure.

like_escape_printf()

like_escape_printf($s) 
Inherited

Parameters

$s

Retrieves an entire result set from the database, mapped to GP_Thing.

many(string $query, mixed $args) : array<mixed,\GP_Thing>
Inherited
since 1.0.0
since 3.0.0 Added spread operator and require `$query` argument to be set.
see
see

Parameters

$query

string

Query statement with optional sprintf()-like placeholders.

$args

mixed

Optional arguments to pass to the GP_Thing::prepare() function.

Returns

array<mixed,\GP_Thing>A list of GP_Thing objects.

Retrieves an entire result set from the database.

many_no_map(string $query, mixed $args) : array<mixed,object>
Inherited
since 1.0.0
since 3.0.0 Added spread operator and require `$query` argument to be set.
see
see

Parameters

$query

string

Query statement with optional sprintf()-like placeholders.

$args

mixed

Optional arguments to pass to the GP_Thing::prepare() function.

Returns

array<mixed,object>Database query results.

Maps database results to their GP_Thing presentations.

map(mixed $results) : array<mixed,\GP_Thing> | array<mixed,object>
Inherited
since 1.0.0

Parameters

$results

mixed

The results from the database.

Returns

array<mixed,\GP_Thing>array<mixed,object>If enabled, a list of objects mapped to GP_Thing.

[map_no_map description]

map_no_map(mixed $results) : mixed
Inherited
since 1.0.0

Parameters

$results

mixed

The results, unmapped.

Returns

mixed

Returns the English name of a locale.

name_with_locale(string $separator = '&rarr;') : string

If the slug of the locale is not 'default' then the name of the current translation sets gets added as a suffix.

since 1.0.0

Parameters

$separator

string

Separator, in case the slug is not 'default'. Default: '→'.

Returns

stringThe English name of a locale.

Normalizes an array with key-value pairs representing a GP_Translation_Set object.

normalize_fields(array $args) : array
since 1.0.0
inherited_from \GP_Thing::normalize_fields()

Parameters

$args

array

Arguments for a GP_Translation_Set object.

Returns

arrayNormalized arguments for a GP_Translation_Set object.

Normalizes an array with key-value pairs representing a GP_Thing object.

normalize_fields(array $args) : array
Inherited
todo Include default type handling. For example dates 0000-00-00 should be set to null
since 1.0.0
since 3.0.0 Normalizes int fields to be integers.

Parameters

$args

array

Arguments for a GP_Thing object.

Returns

arrayNormalized arguments for a GP_Thing object.

now_in_mysql_format()

now_in_mysql_format() 
Inherited

Retrieves one row from the database.

one(string $query, mixed $args) : \GP_Thing | false
Inherited
since 1.0.0
since 3.0.0 Added spread operator and require `$query` argument to be set.
see
see

Parameters

$query

string

Query statement with optional sprintf()-like placeholders.

$args

mixed

Optional arguments to pass to the GP_Thing::prepare() function.

Returns

\GP_ThingfalseThing object on success, false on failure.

percent_translated()

percent_translated() 

Prepares a SQL query for safe execution. Uses sprintf()-like syntax.

prepare(string $query, mixed $args) : string
Inherited
since 1.0.0
since 3.0.0 Added spread operator and require `$query` argument to be set.
see

Parameters

$query

string

Query statement with optional sprintf()-like placeholders.

$args

mixed

Optional arguments to pass to the GP_Thing::prepare() function.

Returns

stringSanitized query string, if there is a query to prepare.

prepare_fields_for_create()

prepare_fields_for_create($args) 
Inherited

Parameters

$args

Prepares for enetering the database an array with key-value pairs, preresenting a GP_Thing object.

prepare_fields_for_save($args) 
Inherited

Parameters

$args

Performs a database query.

query(string $query, mixed $args) : integer | boolean
Inherited
since 1.0.0
since 3.0.0 Added spread operator and require `$query` argument to be set.
see
see

Parameters

$query

string

Database query.

$args

mixed

Optional arguments to pass to the prepare method.

Returns

integerbooleanNumber of rows affected/selected or false on error.

Reloads the object data from the database, based on its id

reload() : \GP_Thing
Inherited

Returns

\GP_ThingThing object.

Sets restriction rules for fields.

restrict_fields(\GP_Validation_Rules $rules) 
since 1.0.0
inherited_from \GP_Thing::restrict_fields()

Parameters

$rules

\GP_Validation_Rules

The validation rules instance.

Sets restriction rules for fields.

restrict_fields(\GP_Validation_Rules $rules) 
Inherited
since 1.0.0

Parameters

$rules

\GP_Validation_Rules

The validation rules instance.

Saves an existing thing.

save(mixed $args = null) : boolean | null
Inherited
since 1.0.0

Parameters

$args

mixed

Values to update.

Returns

booleannullNull and false on failure, true on success.

select_all_from_conditions_and_order()

select_all_from_conditions_and_order($conditions, $order = null
Inherited

Parameters

$conditions

$order

Sets fields of the current GP_Thing object.

set_fields(array $fields) 
Inherited

Parameters

$fields

array

Fields for a GP_Thing object.

set_static()

set_static($name, $value) 
Inherited

Parameters

$name

$value

Builds SQL conditions from a PHP value.

sql_condition_from_php_value(mixed $php_value) : string
Inherited

Examples: Input: null Output: IS NULL

Input: 'foo' Output: = 'foo'

Input: 1 or '1' Output: = 1

since 1.0.0

Parameters

$php_value

mixed

The PHP value to convert to conditions.

Returns

stringSQL conditions.

sql_from_conditions()

sql_from_conditions($conditions) 
Inherited

Parameters

$conditions

sql_from_order()

sql_from_order($order_by, $order_how = ''
Inherited

Parameters

$order_by

$order_how

sql_limit_for_paging()

sql_limit_for_paging($page, $per_page = null
Inherited

Parameters

$page

$per_page

Retrieves the number of untranslated originals.

untranslated_count() : integer

Returns

integerNumber of untranslated originals.

Updates a single row

update($data, $where = null
Inherited

Parameters

$data

array associative array with fields as keys and updated values as values

$where

Populates the count properties.

update_status_breakdown() 

validate()

validate() 
Inherited

Retrieves one variable from the database.

value(string $query, mixed $args) : string | null
Inherited
since 1.0.0
since 3.0.0 Added spread operator and require `$query` argument to be set.
see
see

Parameters

$query

string

Query statement with optional sprintf()-like placeholders.

$args

mixed

Optional arguments to pass to the GP_Thing::prepare() function.

Returns

stringnullDatabase query result (as string), or false on failure.

Retrieves the number of waiting translations.

waiting_count() : integer

Returns

integerNumber of waiting translations.

Retrieves the number of translations with warnings.

warnings_count() : integer

Returns

integerNumber of translations with warnings.

[_no_map description]

_no_map(string $name, mixed $args) : mixed
Inherited
since 1.0.0

Parameters

$name

string

Method name.

$args

mixed

Method-dependent arguments.

Returns

mixed

 Properties

 

Number of all originals.

$all_count : integer

Default

 

Number of changed requested translations.

$changesrequested_count : integer

Default

 

$class

$class 

Default

 

Number of current translations.

$current_count : integer

Default

 

$default_conditions

$default_conditions 

Default

 

$errors

$errors 

Default

array()
 

$field_names

$field_names 

Default

array('id', 'name', 'slug', 'project_id', 'locale')
inherited_from \GP_Thing::field_names
 

$field_names

$field_names 

Default

array()
 

Number of fuzzy translations.

$fuzzy_count : integer

Default

 

ID of the translation set.

$id : integer

Default

inherited_from \GP_Thing::id
 

$id

$id 

Default

 

$int_fields

$int_fields 

Default

array('id', 'project_id')
inherited_from \GP_Thing::int_fields
 

$int_fields

$int_fields 

Default

array()
 

Locale of the translation set.

$locale : string

Default

 

$map_results

$map_results 

Default

true
 

Name of the translation set.

$name : string

Default

 

The English name of the locale.

$name_with_locale : string

Default

 

$non_db_field_names

$non_db_field_names 

Default

array('current_count', 'untranslated_count', 'waiting_count', 'fuzzy_count', 'all_count', 'warnings_count', 'percent_translated', 'wp_locale', 'last_modified')
inherited_from \GP_Thing::non_db_field_names
 

$non_db_field_names

$non_db_field_names 

Default

array()
 

$non_updatable_attributes

$non_updatable_attributes 

Default

array('id')
inherited_from \GP_Thing::non_updatable_attributes
 

$non_updatable_attributes

$non_updatable_attributes 

Default

 

Number of old translations.

$old_count : integer

Default

 

$per_page

$per_page 

Default

30
 

The percent translated.

$percent_translated : integer

Default

 

GP project of the translation set.

$project : \GP_Project

Default

 

Project ID of the translation set.

$project_id : integer

Default

 

Number of rejected translations.

$rejected_count : integer

Default

 

Slug of the translation set.

$slug : string

Default

 

$static

$static 

Default

array()
 

$static_by_class

$static_by_class 

Default

array()
Static
 

$table

$table 

Default

null
 

$table_basename

$table_basename 

Default

'gp_translation_sets'
inherited_from \GP_Thing::table_basename
 

$table_basename

$table_basename 

Default

 

Number of untranslated originals.

$untranslated_count : integer

Default

 

$validation_rules

$validation_rules 

Default

null
 

$validation_rules_by_class

$validation_rules_by_class 

Default

array()
Static
 

Number of waiting translations.

$waiting_count : integer

Default

 

Number of translations with warnings.

$warnings_count : integer

Default

 

The WP locale.

$wp_locale : string

Default