private function getRelationshipTypesForParentAsDOM($pn_parent_id) { $t_list = new ca_lists(); $vo_types = $this->opo_dom->createElement("types"); $qr_types = $this->opo_db->query("SELECT * FROM ca_relationship_types WHERE parent_id=?", $pn_parent_id); if (!$qr_types->numRows()) { return false; } while ($qr_types->nextRow()) { $vo_type = $this->opo_dom->createElement("type"); if (preg_match("/root\\_for\\_[0-9]{1,3}/", $qr_types->get("type_code"))) { // ignore legacy root records continue; } $vo_type->setAttribute("code", $this->makeIDNO($qr_types->get("type_code"))); $vo_type->setAttribute("default", $qr_types->get("is_default")); $vo_labels = $this->opo_dom->createElement("labels"); $qr_type_labels = $this->opo_db->query("SELECT * FROM ca_relationship_type_labels WHERE type_id=?", $qr_types->get("type_id")); while ($qr_type_labels->nextRow()) { $vo_label = $this->opo_dom->createElement("label"); $vo_label->setAttribute("locale", $this->opt_locale->localeIDToCode($qr_type_labels->get("locale_id"))); $vo_label->appendChild($this->opo_dom->createElement("typename", caEscapeForXML($qr_type_labels->get("typename")))); $vo_label->appendChild($this->opo_dom->createElement("typename_reverse", caEscapeForXML($qr_type_labels->get("typename_reverse")))); $vo_labels->appendChild($vo_label); } $vo_type->appendChild($vo_labels); // restrictions (left side) /** @var BaseRelationshipModel $t_instance */ $t_instance = $this->opo_dm->getInstanceByTableNum($qr_types->get("table_num")); if ($qr_types->get("sub_type_left_id")) { /** @var BaseModelWithAttributes $t_left_instance */ $vs_left_table = $t_instance->getLeftTableName(); $t_left_instance = $this->opo_dm->getInstanceByTableNum($vs_left_table); $vs_type_code = $t_left_instance->getTypeListCode(); $va_item = $t_list->getItemFromListByItemID($vs_type_code, $qr_types->get("sub_type_left_id")); $vo_type->appendChild($this->opo_dom->createElement("subTypeLeft", $va_item["idno"])); } // restrictions (right side) if ($qr_types->get("sub_type_right_id")) { /** @var BaseModelWithAttributes $t_right_instance */ $vs_right_table = $t_instance->getRightTableName(); $t_right_instance = $this->opo_dm->getInstanceByTableNum($vs_right_table); $vs_type_code = $t_right_instance->getTypeListCode(); $va_item = $t_list->getItemFromListByItemID($vs_type_code, $qr_types->get("sub_type_right_id")); $vo_type->appendChild($this->opo_dom->createElement("subTypeRight", $va_item["idno"])); } // subtypes if ($vo_subtypes = $this->getRelationshipTypesForParentAsDOM($qr_types->get("type_id"))) { $vo_types->appendChild($vo_subtypes); } $vo_types->appendChild($vo_type); } return $vo_types; }