getInt("NumColumnsPerBrowsePage"); $MinEntriesPerColumn = 3; # determine the number of entries to put in each column $EntriesPerColumn = max( round(count($Classifications) / $NumberOfColumns), $MinEntriesPerColumn ); reset($Classifications); for ($ColumnNo = 0; $ColumnNo < $NumberOfColumns; $ColumnNo++) { $ClassificationsHTML[$CellNumber] = ""; for ($EntryNo = 0; $EntryNo < $EntriesPerColumn; $EntryNo++) { # reached the end of results before reaching th end of a column if (($Classification = current($Classifications)) === false) { break 2; } $ClassificationsHTML[$CellNumber] .= getHtmlForClassification($Classification, $Field, $Parent, $StartLetter, $Search); next($Classifications); } $CellNumber++; } return $ClassificationsHTML; } /** * Return string of HTML with link for a single classification entry. * @param Classification $Classification The classification to print. * @param MetadataField|null $Field currently in use. * @param Classification|null $Parent The main classification's parent. * @param string|null $StartLetter currently selected for pagination. * @param string|null $Search applied to these results. * @return string The HTML for a single classification. * @see getHtmlForClassifications() */ function getHtmlForClassification( Classification $Classification, ?MetadataField $Field, ?Classification $Parent, ?string $StartLetter, ?string $Search ): string { $SafeId = defaulthtmlentities($Classification->id()); $SafeName = ($Search !== null) ? defaulthtmlentities($Classification->fullName()) : defaulthtmlentities($Classification->segmentName()); $SafeResourceCount = defaulthtmlentities($Classification->fullResourceCount()); $TgtParams = ( ($Search !== null) ? ("&SQ=".urlencode($Search)) : "") . ( ($StartLetter !== null) ? ("&SL=".urlencode($StartLetter)) : "") . ( ($Field !== null) ? ("&FieldId=".$Field->id()) : ""); $ParentParams = ( ($Parent !== null) ? ("&ParentId=".$Parent->id()) : ""); $EditButton = new HtmlButton("Edit"); $EditButton->setIcon("Pencil.svg"); $EditButton->setSize(HtmlButton::SIZE_SMALL); $EditButton->setLink("index.php?P=EditClassification&ClassificationId=" . $SafeId . $TgtParams . $ParentParams); $ClassificationLink = "index.php?P=EditClassifications&ParentId=" . $SafeId . $TgtParams; return "

" . $SafeName . " (" . $SafeResourceCount . ") " . $EditButton->getHtml() . "

"; } /** * Print an option list containing metadata schemas used to select the metadata * schema. * @param MetadataSchema $SchemaInUse The metadata schema in use. */ function printSchemaOptionList(MetadataSchema $SchemaInUse): void { $Options = []; # get the metadata schema options foreach (MetadataSchema::getAllSchemas() as $Schema) { $Options[$Schema->Id()] = $Schema->Name() . " Schema"; } $OptList = new HtmlOptionList("SC", $Options, $SchemaInUse->id()); $OptList->submitOnChange(true); $OptList->printHtml(); } /** * Print an option list containing the tree fields for the schema in use. * @param MetadataSchema $SchemaInUse Metadata schema in use. * @param ?MetadataField $FieldInUse The metadata field to select. */ function printTreeFieldOptionList( MetadataSchema $SchemaInUse, ?MetadataField $FieldInUse = null ): void { $OptList = new HtmlOptionList( "FieldId", $SchemaInUse->getFieldNames(MetadataSchema::MDFTYPE_TREE), is_null($FieldInUse) ? null : $FieldInUse->id() ); $OptList->submitOnChange(true); $OptList->printIfEmpty(false); $OptList->printHtml(); } /** * Print the classification breadcrumb links for the given parent classification. * @param Classification|null $Parent The parent classification to print the links for. * @param string|null $SearchQuery. * @param MetadataField $Field involved in the breadcrumbs. */ function printClassificationBreadcrumb( ?Classification $Parent, ?string $SearchQuery, MetadataField $Field ): void { # don't print anything if there isn't a parent selected if (is_null($Parent)) { return; } # get the hiearchy up to the parent classification $Hierarchy = getClassificationHierarchy($Parent); $HierarchyStrings = []; # transform the hiearchy into an array of classification names foreach ($Hierarchy as $Classification) { $SafeId = defaulthtmlentities($Classification->Id()); $Link = "index.php?P=EditClassifications&ParentId=".$SafeId .($SearchQuery !== null ? "&SQ=".urlencode($SearchQuery) : ''); $HierarchyStrings[] = '' .$Classification->SegmentName().""; } # separate each link by "--" and print them $Link = "index.php?P=EditClassifications" .($SearchQuery !== null ? "&SQ=".urlencode($SearchQuery) : ''); print '(x) ' ."".defaulthtmlentities($Field->name()).": " .implode(" -- ", $HierarchyStrings); } /** * Get the classification hierarchy ending at the given classification. * @param Classification $Classification The classification to end at. * @return array Returns an array of classifications for the hierarchy. */ function getClassificationHierarchy(Classification $Classification) : array { $Hierarchy = array($Classification); # add the classifications in reverse order while ($Classification->parentId() > 0) { $Classification = new Classification($Classification->parentId()); $Hierarchy[] = $Classification; } # reverse the hierarchy so that it is in the correct order $Hierarchy = array_reverse($Hierarchy); return $Hierarchy; } /** * Return the URL to the page to add a classification for the given field * underneath the given parent classification. * @param MetadataField $Field The metadata field to use. * @param Classification|null $Parent The optional parent to use. * @return string The URL to the page to add a classification for. */ function getAddClassificationLink(MetadataField $Field, ?Classification $Parent = null): string { # -1 needs to be used to signify that the classification should be added at # the top level return "index.php?" . http_build_query([ "P" => "AddClassification", "FieldId" => $Field->id(), "ParentId" => is_null($Parent) ? -1 : $Parent->id() ]); } /** * Print pagination for the classification list split by starting letter. * @param string|null $SearchQuery applied to these results. * @param Classification|null $Parent currently selected. * @param MetadataField|null $Field currently in use. * @param ?string $StartLetter currently selected for pagination. */ function printPagination( ?string $SearchQuery, ?Classification $Parent, ?MetadataField $Field, ?string $StartLetter ): void { global $H_ClassificationCount; global $H_ClassificationsAll; # construct parameters for jump page $Params = ( ($Parent !== null) ? ("&ParentId=".$Parent->id()) : "" ) .( ($Field !== null) ? ( "&FieldId=".$Field->id()) : "" ) .( ($SearchQuery !== null) ? ("&SQ=".urlencode($SearchQuery)) : "" ); print("Classifications starting with: "); foreach (range('A', 'Z') as $Letter) { if ($StartLetter == strtolower($Letter)) { print("".$Letter." "); } elseif (array_key_exists(strtolower($Letter), $H_ClassificationsAll)) { print("".$Letter." "); } else { print ("".$Letter.""); } } if ($StartLetter == "XX") { print ("(Other)"); } elseif (array_key_exists('XX', $H_ClassificationsAll)) { print("(Other)"); } else { print ("(Other)"); } } # ----- SETUP ---------------------------------------------------------------- if (!isset($H_Errors)) { throw new Exception("H_Errors not defined."); } if (!isset($H_Field)) { $H_Field = null; } if (!isset($H_Parent)) { $H_Parent = null; } if (!isset($H_Schema)) { throw new Exception("H_Schema not defined."); } if (!isset($H_SearchQuery)) { $H_SearchQuery = null; } if (!isset($H_StartLetter)) { $H_StartLetter = null; } $ErrorsExist = count($H_Errors); if (!$ErrorsExist) { if (!isset($H_ClassificationCount)) { throw new Exception("H_ClassificationCount not defined."); } if (!isset($H_Classifications)) { throw new Exception("H_Classifications not defined."); } } $SafeSchemaId = defaulthtmlentities($H_Schema->Id()); $SafeSchemaName = defaulthtmlentities($H_Schema->Name()); $IntConfig = InterfaceConfiguration::getInstance(); $SearchButton = new HtmlButton("Search"); $SearchButton->setIcon("MagnifyingGlass.svg"); $SearchButton->setSize(HtmlButton::SIZE_SMALL); $ExportVocabButton = new HtmlButton("Export Vocabulary"); $ExportVocabButton->setIcon("FileExport.svg"); $AddClassificationButton = new HtmlButton("Add Classification Here"); $AddClassificationButton->setIcon("Plus.svg"); if (!$ErrorsExist) { $ClassificationsTable = new HtmlTable(); $ClassificationsTable->setTableClass("table"); $ClassificationsTable->addRow(getHtmlForClassifications( $H_Classifications, $H_Field, $H_Parent, $H_StartLetter, $H_SearchQuery )); } # ----- DISPLAY -------------------------------------------------------------- if ($ErrorsExist) { print '

# Add/Edit Classifications

'; print 'Errors encountered'; print '

'; foreach ($H_Errors as $Error) { print '
- '.$Error.'
'; } print '

'; return; } ?>

# Add/Edit Classifications

Id()) : "") .($H_Field !== null ? ("&FieldId=".$H_Field->Id()) : "") ."\">X)" ." ".$H_SearchQuery.""; } ?>
Search: "/> getHtml(); ?>

There are no tree fields in the metadata schema. Tree fields can be created on the Metadata Field Editor page.

setLink("index.php?P=DBExportField&Id=" . $H_Field->id()); $AddClassificationButton->setLink(getAddClassificationLink($H_Field, $H_Parent)); if ($H_ClassificationCount > $IntConfig->getInt("NumClassesPerBrowsePage")) { print("

"); printPagination($H_SearchQuery, $H_Parent, $H_Field, $H_StartLetter); print("

"); } ?>

( )

getHtml(); ?>

getHtml(); ?>

(browse hierarchy to add or edit classifications at other levels)

There are currently no classifications in this field at this level.

$IntConfig->getInt("NumClassesPerBrowsePage")) { print("

"); print("
"); printPagination($H_SearchQuery, $H_Parent, $H_Field, $H_StartLetter); print("
"); } ?>

getHtml(); ?>