Core class used to implement the projects.

since 1.0.0
package GlotPress
inherited_from \GP_Thing

 Methods

__construct()

__construct($fields = array()
Inherited

Parameters

$fields

_compare_set_item()

_compare_set_item($set, $this_set) 

Parameters

$set

$this_set

Executes after creating a project.

after_create() : boolean

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

since 1.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 project.

after_delete() : boolean

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

since 2.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 project.

after_save(\GP_Project $project_before) : boolean

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

since 1.0.0
since 2.4.0 Added the `$project_before` parameter.
inherited_from \GP_Thing::after_save()

Parameters

$project_before

\GP_Project

Project 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

apply_default_conditions()

apply_default_conditions($conditions_str) 
Inherited

Parameters

$conditions_str

by_path()

by_path($path) 

Parameters

$path

coerce()

coerce($thing) 
Inherited

Parameters

$thing

copy_originals_from()

copy_originals_from($source_project_id) 

Parameters

$source_project_id

copy_sets_and_translations_from()

copy_sets_and_translations_from($source_project_id) 

Parameters

$source_project_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

Deletes a project and all of sub projects, translations, translation sets, originals 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 = null
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.

duplicate_project_contents_from()

duplicate_project_contents_from($source_project) 

Parameters

$source_project

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

Fetches the project by id or object.

get(integer|object $thing_or_id) : \GP_Project
since 2.3.0
inherited_from \GP_Thing::get()

Parameters

$thing_or_id

integerobject

A project or the id.

Returns

\GP_ProjectThe project

get()

get($thing_or_id) 
Inherited

Parameters

$thing_or_id

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

Gives an array of project objects starting from the current project children then its grand children etc

inclusive_sub_projects() : array

Returns

array

like_escape_printf()

like_escape_printf($s) 
Inherited

Parameters

$s

Retrieves multiple rows from this table

many() : mixed
Inherited

For parameters description see $wpdb->prepare().

since 1.0.0

Returns

mixedAn object, containing the selected row or false on error.

[many_no_map description]

many_no_map() : mixed
Inherited
since 1.0.0

Returns

mixed

[map description]

map(mixed $results) : mixed
Inherited
since 1.0.0

Parameters

$results

mixed

The results, mapped.

Returns

mixed

[map_no_map description]

map_no_map(mixed $results) : mixed
Inherited
since 1.0.0

Parameters

$results

mixed

The results, unmapped.

Returns

mixed

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

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

Parameters

$args

array

Arguments for a GP_Project object.

Returns

arrayNormalized arguments for a GP_Project 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

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 a single row from this table

one() : mixed
Inherited

For parameters description see BPDB::prepare()

Returns

mixedan object, containing the selected row or false on error

Gives an array of project objects starting from the current project then its parent, its parent and up to the root

path_to_root() : array
todo Cache the results. Invalidation is tricky, because on each project update we need to invalidate the cache for all of its children.

Returns

array

prepare()

prepare($args) 
Inherited

Parameters

$args

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() : mixed
Inherited
since 1.0.0

Returns

mixed

Regenrate the paths of all projects from its parents slugs

regenerate_paths($parent_project_id = null

Parameters

$parent_project_id

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

reload() 
Inherited

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

set_difference_from()

set_difference_from($other_project) 

Parameters

$other_project

set_fields()

set_fields($db_object) 
Inherited

Parameters

$db_object

set_memory_limit()

set_memory_limit($new_limit) 
Inherited

Parameters

$new_limit

set_static()

set_static($name, $value) 
Inherited

Parameters

$name

$value

source_url()

source_url($file, $line) 

Parameters

$file

$line

source_url_template()

source_url_template() 

sql_condition_from_php_value()

sql_condition_from_php_value($php_value) 
Inherited

Parameters

$php_value

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 sub projects

sub_projects() : array

Returns

arrayArray of GP_Project

top_level()

top_level() 

Updates a single row

update($data, $where = null
Inherited

Parameters

$data

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

$where

Updates this project's and its chidlren's paths, according to its current slug.

update_path() 

validate()

validate() 
Inherited

Retrieves a single value from this table

value() : scalar
Inherited

For parameters description see BPDB::prepare()

Returns

scalarthe result of the query or false on error

[_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

 

$active

$active 

Default

 

$class

$class 

Default

 

$default_conditions

$default_conditions 

Default

 

$description

$description 

Default

 

$errors

$errors 

Default

array()
 

$field_names

$field_names 

Default

array('id', 'name', 'slug', 'path', 'description', 'parent_project_id', 'source_url_template', 'active')
inherited_from \GP_Thing::field_names
 

$field_names

$field_names 

Default

array()
 

$id

$id 

Default

inherited_from \GP_Thing::id
 

$id

$id 

Default

 

$int_fields

$int_fields 

Default

array('id', 'parent_project_id', 'active')
inherited_from \GP_Thing::int_fields
 

$int_fields

$int_fields 

Default

array()
 

$map_results

$map_results 

Default

true
 

$name

$name 

Default

 

$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

 

$parent_project_id

$parent_project_id 

Default

 

$path

$path 

Default

 

$per_page

$per_page 

Default

30
 

$slug

$slug 

Default

 

$source_url_template

$source_url_template 

Default

 

$static

$static 

Default

array()
 

$static_by_class

$static_by_class 

Default

array()
Static
 

$table

$table 

Default

null
 

$table_basename

$table_basename 

Default

'gp_projects'
inherited_from \GP_Thing::table_basename
 

$table_basename

$table_basename 

Default

 

$user_source_url_template

$user_source_url_template 

Default

 

$validation_rules

$validation_rules 

Default

null
 

$validation_rules_by_class

$validation_rules_by_class 

Default

array()
Static