$MDFieldInfo) { $LocalFieldOptions[$MDFieldId] = $MDFieldInfo["Name"]; # preparing array indexed by option value for use as a parameter # to classForOptions $LocalFieldTypes[$MDFieldId] = "option-type-".$MDFieldInfo["Type"]; } # if no index is specified, this row is the template row at the bottom # of the table for each schema, used to add a new mapping to those # configured for the schema $IndexForDropdown = $Index ?? "N"; $LocalFieldOptions[0] = "--"; # placeholder value used when an EXIF tag is selected that can not be mapped # to the metadata field already selected for this mapping $FieldOptionList = new HtmlOptionList( "F_LocalField-".$Schema->Id().'-'.$Index, $LocalFieldOptions, [$CurrentValue] ); $FieldOptionList->classForOptions($LocalFieldTypes); $FieldOptionList->classForList("mv-localfields"); $FieldOptionsHtml = $FieldOptionList->getHtml(); return $FieldOptionsHtml; } /* * Create HTML for an EXIF tag drop down for a mapping from an EXIF tag to one * of a schema's metadata fields. * @param MetadataSchema $Schema The drop down allows an EXIF tag to be * selected to create a mapping to a metataa field in this schema. * @param int|null $Index Index number of mapping of an EXIF tag to a metadata * field within a given schema, NULL if this dropdown is for the * template row for new mappings. * @param string|null $Tag EXIF tag that is mapped for this mapping when the * page loads if this dropdown is for an already-configurd mapping, NULL * if this dropdown is for the template row for new mappings. * @return string HTML for a drop down with a list of options of EXIF tags * this mapping can be set to use, with the $Tag already selected. */ function getOptionListHtmlForMappedTag( MetadataSchema $Schema, ?int $Index, ?string $Tag ): string { # retrieve the list EXIF tags that can have their values assigned to # schemas' metadata fields based on configured mappings from the plugin # configuration $AvailableTags = setupTagsForHtmlOptionList(); # the row index will be N if this dropdown will be on the template (bottom) # row, otherwise is numeric and indicates which row in the table $RowIndex = $Index ?? "N"; $StartingValue = []; if (!is_null($Tag)) { $StartingValue [] = $Tag; } else { # if this dropdown is for the template row, there will be am empty initial # selection indicated by a placeholder "--" $AvailableTags = array_merge(["-1" => "--"], $AvailableTags); } $TagOptionList = new HtmlOptionList( 'F_ExifPicker-'.$Schema->Id().'-'.$RowIndex, $AvailableTags, $StartingValue ); $TagOptionList->classForList("mv-tags"); return $TagOptionList->getHtml(); } /** * Set up an array of EXIF tags and their display labels for use as a * parameter for HtmlOptionList. * Pull the "ExifTags" plugin configuration setting, an array of all of the * EXIF tags the plugin can import data from to apply to a record's metadata * fields. The array is indexed by EXIF tag, the value for each tag is an * array with the index "Label" for the tag's label. * @return Array indexed on EXIF tags, (eg: "EXIF.ImageUniqueID"), the value * for each tag is the tag's label. */ function setupTagsForHtmlOptionList(): array { $Plugin = ExifTags::getInstance(); $ExifTags = $Plugin->getConfigSetting("ExifTags"); $TagsWithLabel = []; foreach ($ExifTags as $Tag => $TagInfo) { $AvailableTags[$Tag] = $TagInfo["Label"]; } return $AvailableTags ?? []; } /** * Output table rows that show mappings configured for a schema from EXIF tags * to the schema's metadata fields. The EXIF tags and metadata fields are both * shown in editable drop-downs. * @param MetadataSchema $Schema Metadata schema the table rows show configured * mappings for. * @param array $MappableFieldsForSchema Metadata fields in a schema which have * types which are able to have values assigned from EXIF tags, indexed * on metadata field ID. Values have the metadata field's type and name. * @param int $Index Number indicates where a mapping from an EXIF tag to a * schema's metadata field sits in the ordered list of mappings for the * schema. * @param array $Mapping Array represents a mapping from an EXIF tag to one of * the schema's metadata fields with the ID of the metadata field * the tag is mapped to and the EXIF tag that is mapped to the field * under the keys "FieldId" and "Tag". */ function printTableRowsForSchemaMappings( MetadataSchema $Schema, array $MappableFieldsForSchema, int $Index, array $Mapping ): void { $Tag = $Mapping["Tag"]; $CurrentValue = $Mapping["FieldId"]; $FieldOptionsHtml = getOptionListHtmlForMappedField( $Schema, $MappableFieldsForSchema, $Index, $CurrentValue ); $TagListHtml = getOptionListHtmlForMappedTag( $Schema, $Index, $Tag ); $DeletedFlagFieldName = implode("-", ["F_Deleted", $Schema->Id(), $Index]); ?> requireUIFile("ExifTags.js"); # verify that required incoming variables are set if (!isset($H_PotentialFields)) { throw new Exception("Variable \$H_PotentialFields not set."); } $Plugin = ExifTags::getInstance(); $FieldMappings = $Plugin->getConfigSetting("FieldMappings"); $ExifTags = $Plugin->getConfigSetting("ExifTags"); # ----- DISPLAY ----------------------------------------------------------------- PageTitle("EXIF Tags - Configure Mappings"); ?>

EXIF Tags - Configure Mappings

Id()] ?? []; $MappableFieldsForSchema = $H_PotentialFields[$Schema->Id()]; foreach ($MappingsForSchema as $Index => $Mapping) { printTableRowsForSchemaMappings( $Schema, $MappableFieldsForSchema, $Index, $Mapping ); } # blank row to add mappings, below existing mappings for each schema $FieldOptionsHtml = getOptionListHtmlForMappedField($Schema, $MappableFieldsForSchema, null, 0); $TagListHtml = getOptionListHtmlForMappedTag($Schema, null, null); ?>
EXIF Tags Metadata Fields

Schema: Name() ?>