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 $Field currently in use.
* @param string $StartLetter currently selected for pagination.
* @param string $Search applied to these results.
* @see PrintClassifications()
*/
function PrintClassification(Classification $Classification, $Field, $Parent, $StartLetter, $Search)
{
$AF = ApplicationFramework::getInstance();
$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()) : "");
?>
=
$SafeName; ?>
(= $SafeResourceCount; ?>)
Edit
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)
{
$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 $Parent The parent classification to print the links for.
* @param string $SearchQuery.
* @param MetadataField $Field involved in the breadcrumbs.
*/
function PrintClassificationBreadcrumb($Parent, $SearchQuery, $Field)
{
# 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);
}
/**
* Print 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 $Parent The optional parent to use.
*/
function PrintAddClassificationLink(MetadataField $Field, Classification $Parent = null)
{
# -1 needs to be used to signify that the classification should be added at
# the top level
print "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 $SearchQuery applied to these results.
* @param Classification $Parent currently selected.
* @param MetadataField $Field currently in use.
* @param string $StartLetter currently selected for pagination.
*/
function PrintPagination($SearchQuery, $Parent, $Field, $StartLetter)
{
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(" ");
} elseif (array_key_exists(strtolower($Letter), $H_ClassificationsAll)) {
print("".$Letter." ");
} else {
print ("");
}
}
if ($StartLetter == "XX") {
print ("");
} elseif (array_key_exists('XX', $H_ClassificationsAll)) {
print("(Other)");
} else {
print ("");
}
}
# ----- MAIN -----------------------------------------------------------------
global $H_Errors;
if (count($H_Errors)) {
print 'Add/Edit Classifications';
print 'Errors encountered';
print '';
return;
}
$SafeSchemaId = defaulthtmlentities($H_Schema->Id());
$SafeSchemaName = defaulthtmlentities($H_Schema->Name());
$IntConfig = InterfaceConfiguration::getInstance();
?>
Add/Edit Classifications
Id()) : "")
.($H_Field !== null ? ("&FieldId=".$H_Field->Id()) : "")
."\">X)"
." ".$H_SearchQuery."";
}
?>
There are no tree fields in the = $SafeSchemaName; ?>
metadata schema. Tree fields can be created on the
Metadata
Field Editor page.
$IntConfig->getInt("NumClassesPerBrowsePage")) {
print("
");
}
?>
(= $H_ClassificationCount; ?>
= Pluralize("classification", "s", $H_ClassificationCount); ?>)
Export Vocabulary
Add Classification Here
(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("");
}
?>
|