GRIS_SHOW
in package
Class to manage the visibility of attributes and form fields
With this the class the visibility of attributes and form fields can be configured individually
PHP version 7
Copyright (c) 2021, Holger Heuser, GESIS Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8 50667 Cologne, Germany
Tags
Table of Contents
- dbtable = "gris_show"
- The constant for the database table
- settings_group = "show"
- The constant for the settings group
- $classname : object
- The name of the class
- $dbconnection : object
- The database object for managing the connection
- $i18n : object
- The object for translations
- $settings : object
- The object for settings
- $state : object
- The object for state
- $base_path : string
- The base path of the object (for file operations)
- $logger : object
- The object for logs
- __construct() : mixed
- The class constructor
- check_attribute() : array<string|int, mixed>
- Check if an attribute class is available for an object (and optional its ID)
- check_attribute_by_id() : array<string|int, mixed>
- Check if an attribute ID is available for an object (and optional its ID)
- check_attribute_entries() : mixed
- Compares the current attribute entries with the default list and adds missing entries or deletes false entries
- delete_show_entry() : array<string|int, mixed>
- Deletes an entry in the table gris_show (NOT in gris_attribute!)
- delete_show_object_type() : array<string|int, mixed>
- Deletes all entries of a given object type in the table gris_show
- get_all_attributes() : array<string|int, mixed>
- Get a full list of all attributes (from table gris_attributes)
- get_attribute_id_by_class() : int
- Get the name of an attribute by its ID
- get_attribute_list() : array<string|int, mixed>
- Get a list of filtered attributes (from table gris_attributes)
- get_attribute_name() : string
- Get the (readable) name of an attributes (not the variable name)
- get_attribute_search_list() : array<string|int, mixed>
- Get a list of all search_lists (from table gris_vocabulary!)
- get_attributes() : array<string|int, mixed>
- Get a list of all attributes for a given object and ID (optional with all attribute data (when $list is submitted) or just a list of IDs)
- get_id() : int
- Returns the show ID for a given attibute ID, object type and object ID
- get_mandatory_attribute_list() : array<string|int, mixed>
- Get a list with gris_attribute_class of all mandatory attributes and hidden items are filtered (from table gris_attributes)
- get_objects_by_attribute() : array<string|int, mixed>
- Get a list of all object IDs of a type for a given attribute
- get_search_attributes() : array<string|int, mixed>
- Get a list of all attributes for a given object and ID (optional with all attribute data (when $list is submitted) or just a list of IDs)
- set_attribute() : array<string|int, mixed>
- Sets a new attribute entry
- set_search_attribute() : array<string|int, mixed>
- Sets a new entry with attribute, object type and object ID
- set_show_entry() : array<string|int, mixed>
- Sets a new entry with attribute, object type and object ID in the table gris_show
- delete_attribute_entry() : array<string|int, mixed>
- Deletes an entry in the table gris_attribute
- search_json() : Returns
- Checks if an entry is in the given JSON array and removes it if found
Constants
dbtable
The constant for the database table
public
mixed
dbtable
= "gris_show"
settings_group
The constant for the settings group
public
mixed
settings_group
= "show"
Properties
$classname
The name of the class
protected
object
$classname
= NULL
Tags
$dbconnection
The database object for managing the connection
protected
object
$dbconnection
= NULL
Tags
$i18n
The object for translations
protected
object
$i18n
Tags
$settings
The object for settings
protected
object
$settings
= null
Tags
$state
The object for state
protected
object
$state
Tags
$base_path
The base path of the object (for file operations)
private
string
$base_path
Tags
$logger
The object for logs
private
object
$logger
Tags
Methods
__construct()
The class constructor
public
__construct() : mixed
Initializes the objects
Return values
mixed —check_attribute()
Check if an attribute class is available for an object (and optional its ID)
public
check_attribute(string $attribute_class, string $object_type[, string $object_id = NULL ]) : array<string|int, mixed>
Parameters
- $attribute_class : string
-
The class of the attribute
- $object_type : string
-
The type of the object (e.g. gris_project, gris_resource)
- $object_id : string = NULL
-
The ID of the object (optional)
Return values
array<string|int, mixed> —Returns an array of IDs
check_attribute_by_id()
Check if an attribute ID is available for an object (and optional its ID)
public
check_attribute_by_id(string $attribute_id, string $object_type[, string $object_id = NULL ]) : array<string|int, mixed>
Parameters
- $attribute_id : string
-
The ID of the attribute
- $object_type : string
-
The type of the object (e.g. gris_project, gris_resource)
- $object_id : string = NULL
-
The ID of the object (optional)
Return values
array<string|int, mixed> —Returns an array of IDs (Primary key of table gris_show) or 0 (int) if not found or -1 (int) on error
check_attribute_entries()
Compares the current attribute entries with the default list and adds missing entries or deletes false entries
public
check_attribute_entries([bool $change = true ]) : mixed
Parameters
- $change : bool = true
-
Whether changes should be made (default: true) or only returned as a list
Return values
mixed —Returns false if file is missing, an array string with false or missing entries or the current attribute list
delete_show_entry()
Deletes an entry in the table gris_show (NOT in gris_attribute!)
public
delete_show_entry(string $show_id) : array<string|int, mixed>
Parameters
- $show_id : string
-
The ID (Primary key of table gris_show) of the entry
Return values
array<string|int, mixed> —Returns true on success and false on error
delete_show_object_type()
Deletes all entries of a given object type in the table gris_show
public
delete_show_object_type(string $object_type) : array<string|int, mixed>
Parameters
- $object_type : string
-
The name of the group
Return values
array<string|int, mixed> —Returns true on success and false on error
get_all_attributes()
Get a full list of all attributes (from table gris_attributes)
public
get_all_attributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns an array with all attributes
get_attribute_id_by_class()
Get the name of an attribute by its ID
public
get_attribute_id_by_class(string $attribute_class, string $object_type) : int
Parameters
- $attribute_class : string
-
The class of the attribute
- $object_type : string
-
The type of the object (e.g. gris_project, gris_resource)
Return values
int —Returns the ID of the attribute or 0 (int) if not found
get_attribute_list()
Get a list of filtered attributes (from table gris_attributes)
public
get_attribute_list(mixed $objects[, string $group = NULL ][, bool $hidden = true ][, bool $import = false ]) : array<string|int, mixed>
Parameters
- $objects : mixed
- $group : string = NULL
-
The group (optional)
- $hidden : bool = true
-
Filter hidden entries
- $import : bool = false
-
Use this attribute for import
Return values
array<string|int, mixed> —Returns an array with attributes
get_attribute_name()
Get the (readable) name of an attributes (not the variable name)
public
get_attribute_name(string $variable_name, string $object_name) : string
Parameters
- $variable_name : string
-
The name of the variable
- $object_name : string
-
The name of the object (an array is optional, to search multiple objects)
Return values
string —Returns the readable name of the attributes
get_attribute_search_list()
Get a list of all search_lists (from table gris_vocabulary!)
public
get_attribute_search_list() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns an array with all attributes
get_attributes()
Get a list of all attributes for a given object and ID (optional with all attribute data (when $list is submitted) or just a list of IDs)
public
get_attributes(string $object_type, int $object_id[, string $list = NULL ]) : array<string|int, mixed>
Parameters
- $object_type : string
-
The type of the object (e.g. gris_project, gris_resource)
- $object_id : int
-
The ID of the object
- $list : string = NULL
-
The list of attributes (from $this->get_attribute_list)
Return values
array<string|int, mixed> —Returns an array with the IDs or the complete attribute data if $list is given
get_id()
Returns the show ID for a given attibute ID, object type and object ID
public
get_id(string $attribute_id, string $object_type, string $object_id) : int
Parameters
- $attribute_id : string
-
The ID of the attribute
- $object_type : string
-
The type of the object (e.g. gris_project, gris_resource)
- $object_id : string
-
The ID of the object (optional)
Return values
int —Returns the show ID
get_mandatory_attribute_list()
Get a list with gris_attribute_class of all mandatory attributes and hidden items are filtered (from table gris_attributes)
public
get_mandatory_attribute_list(string $object) : array<string|int, mixed>
Parameters
- $object : string
-
The type of the object (e.g. gris_project, gris_resource)
Return values
array<string|int, mixed> —Returns an array with all mandatory attributes
get_objects_by_attribute()
Get a list of all object IDs of a type for a given attribute
public
get_objects_by_attribute(string $object_type, string $attribute_id) : array<string|int, mixed>
Parameters
- $object_type : string
-
The type of the object (e.g. gris_project, gris_resource)
- $attribute_id : string
-
The ID of the attribute
Return values
array<string|int, mixed> —Returns an array of object IDs or an empty array if not found
get_search_attributes()
Get a list of all attributes for a given object and ID (optional with all attribute data (when $list is submitted) or just a list of IDs)
public
get_search_attributes(mixed $resourcetype_id) : array<string|int, mixed>
Parameters
- $resourcetype_id : mixed
Return values
array<string|int, mixed> —Returns an array with the IDs or the complete attribute data if $list is given
set_attribute()
Sets a new attribute entry
public
set_attribute(string $attribute_name, string $attribute_class, string $attribute_object[, string $attribute_group = NULL ], bool $attribute_mandatory[, bool $attribute_hide = NULL ][, bool $gris_attribute_import = NULL ]) : array<string|int, mixed>
Parameters
- $attribute_name : string
-
The name of the attribute
- $attribute_class : string
-
The class of the attribute (e.g. gris_show_title, gris_show_description)
- $attribute_object : string
-
The type of the object (e.g. gris_project, gris_resource)
- $attribute_group : string = NULL
-
The group of the attribute (optional)
- $attribute_mandatory : bool
-
Whether the attribute is mandatory (optional)
- $attribute_hide : bool = NULL
-
Whether the attribute is hidden (optional)
- $gris_attribute_import : bool = NULL
-
Whether the attribute is used for import (optional)
Return values
array<string|int, mixed> —Returns true on success and false on error
set_search_attribute()
Sets a new entry with attribute, object type and object ID
public
set_search_attribute(string $attribute_id, mixed $typ_id, mixed $what) : array<string|int, mixed>
Parameters
- $attribute_id : string
-
The ID of the attribute
- $typ_id : mixed
- $what : mixed
Return values
array<string|int, mixed> —Returns true on success and false on error
set_show_entry()
Sets a new entry with attribute, object type and object ID in the table gris_show
public
set_show_entry(string $attribute_id, string $object_type, string $object_id) : array<string|int, mixed>
Parameters
- $attribute_id : string
-
The ID of the attribute
- $object_type : string
-
The type of the object (e.g. gris_project, gris_resource)
- $object_id : string
-
The ID of the object (optional)
Return values
array<string|int, mixed> —Returns true on success and false on error
delete_attribute_entry()
Deletes an entry in the table gris_attribute
private
delete_attribute_entry(string $attribute_id) : array<string|int, mixed>
Parameters
- $attribute_id : string
-
The ID (Primary key of table gris_attribute) of the entry
Return values
array<string|int, mixed> —Returns true on success and false on error
search_json()
Checks if an entry is in the given JSON array and removes it if found
private
search_json(array<string|int, mixed> &$json, array<string|int, mixed> $entry) : Returns
Parameters
- $json : array<string|int, mixed>
- $entry : array<string|int, mixed>
Return values
Returns —true if found and false if not found