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++) { for ($EntryNo = 0; $EntryNo < $EntriesPerColumn; $EntryNo++) { # reached the end of results before reacing th end of a column if (($Classification = current($Classifications)) === false) { break 2; } PrintClassification($Classification, $Field, $Parent, $StartLetter, $Search); next($Classifications); } print(""); } reset($Classifications); } /** * Print 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. * @see PrintClassifications() */ function PrintClassification( Classification $Classification, ?MetadataField $Field, ?Classification $Parent, ?string $StartLetter, ?string $Search ): void { $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); ?>

() getHtml(); ?>

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"); # ----- DISPLAY -------------------------------------------------------------- if ($ErrorsExist) { print '

Add/Edit Classifications

'; print 'Errors encountered'; 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("
"); } ?>