示例#1
0
 /**
  *
  * @param string $type can be one of: ["ca_objects", "ca_entities", "ca_places", "ca_occurrences", "ca_collections", "ca_list_items", "ca_object_representations", "ca_storage_locations", "ca_movements", "ca_loans", "ca_tours", "ca_tour_stops"]
  * @param int $item_id primary key
  * @param string $attribute_code_or_id
  * @return array
  * @throws SoapFault
  */
 public function getAttributesByElement($type, $item_id, $attribute_code_or_id)
 {
     if (!($t_subject_instance = $this->getTableInstance($type, $item_id, true))) {
         throw new SoapFault("Server", "Invalid type or item_id");
     }
     $t_locale = new ca_locales();
     $t_element = new ca_metadata_elements();
     $va_attrs = $t_subject_instance->getAttributesByElement($attribute_code_or_id);
     $va_return = array();
     $va_element_type_cfg = ca_metadata_elements::getAttributeTypes();
     foreach ($va_attrs as $vo_attr) {
         $va_attr = array();
         foreach ($vo_attr->getValues() as $vo_value) {
             $t_element->load($vo_value->getElementID());
             $va_attr[] = array("value_id" => $vo_value->getValueID(), "display_value" => $vo_value->getDisplayValue(), "element_code" => $vo_value->getElementCode(), "element_id" => $vo_value->getElementID(), "attribute_info" => $t_subject_instance->getAttributeLabelAndDescription($vo_value->getElementCode()), "datatype" => $va_element_type_cfg[$t_element->get("datatype")], "locale" => $t_locale->localeIDToCode($vo_attr->getLocaleID()));
         }
         $va_return[$vo_attr->getAttributeID()] = $va_attr;
     }
     return $va_return;
 }
 /**
  * Returns data type name for numeric code
  *
  * @param $pn_type_code numeric type code
  * @return string Name of data type (eg. 'Text') or null if code is not defined
  */
 public static function getAttributeNameForTypeCode($pn_type_code)
 {
     $va_types = ca_metadata_elements::getAttributeTypes();
     return isset($va_types[$pn_type_code]) ? $va_types[$pn_type_code] : null;
 }