/** * returns list of terms that are related to object * @param {array} $object_UID array of type array("column_name"=>'DELIVERY_BASE_ID', "value"=>5) * @param {string} $database_name database name e.g. 'content', 'user' * @param {string} $tableName Table name of the relation which depends on object type, e.g. R_LD2T, R_LK2T. * @param {string} $lang The required language, if no language is selected all languages will be returned * @return {array:terms} array of terms */ public static function get_terms_of_object($object_UID, $database_name, $tableName, $lang = '') { // get database name $database_name = dbAPI::get_db_name($database_name); $dbObj = new dbAPI(); // get column name of object and its value (UID) to look for in table $object_column_name = $object_UID["column_name"]; $object_UID_value = $object_UID["value"]; if ($object_column_name == null || $object_column_name == '') { debugLog::log("<i>[relations.php:get_terms_of_object]</i> Column name was not specified."); return null; } // get all related terms to object $query = "SELECT * FROM " . $tableName . " where ENABLED = 1 AND (" . $object_column_name . " = " . $object_UID_value . ")"; $results = $dbObj->db_select_query($database_name, $query); // retrieve term's details from terms class into array $terms = array(); for ($i = 0; $i < count($results); $i++) { $curr_term = term::get_term_by_UID($results[$i]["TERM_ID"], $lang); // copy LINK_TYPE to term object $curr_term["LINK_TYPE"] = $results[$i]["LINK_TYPE"]; array_push($terms, $curr_term); } return $terms; }
public static function get_term_by_UID_with_relations($UID, $lang = '') { // check if term exists $term = term::get_term_by_UID($UID, $lang); if ($term == null) { return null; } // add related terms to term $term["RELATED_TERMS"] = term::get_relations_of_term($UID, $lang); // add term's scopes $term["SCOPES"] = term::get_scopes_of_term($UID, $lang); return $term; }