Id());
if ($Mapping == "Title" && strlen($Resource->GetMapped("Url")))
{
DisplayUrlField($Resource, $Field, $Data);
}
else
{
DisplayResourceField($Resource, $Field, $Data);
}
}
/**
* Display a Paragraph field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayParagraphField(Resource $Resource, MetadataField $Field)
{
$Data = GetResourceFieldValue($Resource, $Field);
$Data = StripXSSThreats($Data);
$IsWysiwygText = $Field->AllowHTML() && $Field->UseWysiwygEditor();
if (!$IsWysiwygText)
{
$Data = nl2br($Data);
}
$Options = array("IsTall" => TRUE, "IsWysiwygText" => $IsWysiwygText);
DisplayResourceField($Resource, $Field, $Data, $Options);
}
/**
* Display a Number field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayNumberField(Resource $Resource, MetadataField $Field)
{
# don't display the rating field
if ($Field->Name() == "Cumulative Rating")
{
return;
}
$Data = GetResourceFieldValue($Resource, $Field);
$Data = StripXSSThreats($Data);
DisplayResourceField($Resource, $Field, $Data);
}
/**
* Display a Date field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayDateField(Resource $Resource, MetadataField $Field)
{
$Data = GetResourceFieldValue($Resource, $Field);
# convert to text if given a Date object
if ($Data instanceof Date)
{
$Data = $Data->Formatted();
$Data = defaulthtmlentities($Data);
}
$Data = StripXSSThreats($Data);
DisplayResourceField($Resource, $Field, $Data);
}
/**
* Display a Timestamp field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayTimestampField(Resource $Resource, MetadataField $Field)
{
$Data = GetResourceFieldValue($Resource, $Field);
$Data = StripXSSThreats($Data);
$Options = array();
if (UserIsLoggedIn() &&
$Resource->UserCanModifyField($GLOBALS["G_User"], $Field) &&
$Field->UpdateMethod() == MetadataField::UPDATEMETHOD_BUTTON)
{
$Options["AdditionalHtml"] = "Id()
."&ID=".$Resource->Id()
."\" class=\"cw-button cw-button-constrained cw-button-elegant\">Update";
}
DisplayResourceField($Resource, $Field, $Data, $Options);
}
/**
* Display a Flag field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayFlagField(Resource $Resource, MetadataField $Field)
{
$Data = GetResourceFieldValue($Resource, $Field);
# convert the value to its corresponding label if the value appears
# unmodified
if (is_numeric($Data))
{
$Data = ($Data > 0) ? $Field->FlagOnLabel() : $Field->FlagOffLabel();
$Data = defaulthtmlentities($Data);
}
$Data = StripXSSThreats($Data);
DisplayResourceField($Resource, $Field, $Data);
}
/**
* Display a Tree field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayTreeField(Resource $Resource, MetadataField $Field)
{
global $AF;
$Names = GetResourceFieldValue($Resource, $Field);
# convert the value to a list if the value appears unmodified
if (is_array($Names))
{
# get additional HTML to display, if any. do this here because the field
# shouldn't be displayed if there no values or additional HTML and the
# DisplayResourceField doesn't have access to that information
$SignalResult = $AF->SignalEvent(
"EVENT_APPEND_HTML_TO_FIELD_DISPLAY",
array(
"Field" => $Field, "Resource" => $Resource,
"Context" => "DISPLAY", "Html" => NULL));
$Html = $SignalResult["Html"];
# only output tree fields with values and no additional HTML
if (count($Names) < 1 && is_null($Html))
{
return;
}
$Data = NULL;
foreach ($Names as $Id => $Name)
{
$LinkAttributes = array(
"href" =>
"index.php?P=AdvancedSearch&Q=Y&G"
.EscapeParam($Field->Id())."=".EscapeParam($Id),
"title" =>
"Search for all resources also classified as \""
.defaulthtmlentities($Name->Name())."\"");
$Data .= PrepareNameValue($Resource, $Field, $Name, $LinkAttributes);
}
$ListAttributes = array(
"class" => "cw-list cw-list-dematte cw-list-unmarked");
$Data = CreateHtmlElement("ul", $ListAttributes, $Data);
# add additional HTML, if any
$Data .= $Html;
}
# value was likely modified and is a string
else
{
$Data = StripXSSThreats($Names);
}
DisplayResourceField(
$Resource,
$Field,
$Data,
array("IsTall" => TRUE, "NoHtml" => TRUE));
}
/**
* Display a Controlled Name field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayControlledNameField(Resource $Resource, MetadataField $Field)
{
global $AF;
$Names = GetResourceFieldValue($Resource, $Field);
# convert the value to a list if the value appears unmodified
if (is_array($Names))
{
# get additional HTML to display, if any. do this here because the field
# shouldn't be displayed if there no values or additional HTML and the
# DisplayResourceField doesn't have access to that information
$SignalResult = $AF->SignalEvent(
"EVENT_APPEND_HTML_TO_FIELD_DISPLAY",
array(
"Field" => $Field, "Resource" => $Resource,
"Context" => "DISPLAY", "Html" => NULL));
$Html = $SignalResult["Html"];
# only output controlled name fields with values and no additional HTML
if (count($Names) < 1 && is_null($Html))
{
return;
}
$Data = NULL;
foreach ($Names as $Id => $Name)
{
$LinkAttributes = array(
"href" =>
"index.php?P=AdvancedSearch&Q=Y&F"
.EscapeParam($Field->Id())."="
.EscapeParam("=".$Name->Name()),
"title" =>
"Search for all resources also classified as \""
.defaulthtmlentities($Name->Name())."\"");
$Data .= PrepareNameValue($Resource, $Field, $Name, $LinkAttributes);
}
$ListAttributes = array(
"class" => "cw-list cw-list-dematte cw-list-unmarked");
$Data = CreateHtmlElement("ul", $ListAttributes, $Data);
# add additional HTML, if any
$Data .= $Html;
}
# value was likely modified and is a string
else
{
$Data = StripXSSThreats($Names);
}
DisplayResourceField(
$Resource, $Field, $Data, array("IsTall" => TRUE, "NoHtml" => TRUE));
}
/**
* Display an Option field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayOptionField(Resource $Resource, MetadataField $Field)
{
global $AF;
$Names = GetResourceFieldValue($Resource, $Field);
# convert the value to a list if the value appears unmodified
if (is_array($Names))
{
# get additional HTML to display, if any. do this here because the field
# shouldn't be displayed if there no values or additional HTML and the
# DisplayResourceField doesn't have access to that information
$SignalResult = $AF->SignalEvent(
"EVENT_APPEND_HTML_TO_FIELD_DISPLAY",
array(
"Field" => $Field, "Resource" => $Resource,
"Context" => "DISPLAY", "Html" => NULL));
$Html = $SignalResult["Html"];
# only output options fields with values and no additional HTML
if (count($Names) < 1 && is_null($Html))
{
return;
}
$Data = NULL;
foreach ($Names as $Id => $Name)
{
$LinkAttributes = array(
"href" =>
"index.php?P=AdvancedSearch&Q=Y&G"
.EscapeParam($Field->Id())."=".EscapeParam($Id),
"title" =>
"Search for all resources also classified as \""
.defaulthtmlentities($Name->Name())."\"");
$Data .= PrepareNameValue($Resource, $Field, $Name, $LinkAttributes);
}
$ListAttributes = array(
"class" => "cw-list cw-list-dematte cw-list-unmarked");
$Data = CreateHtmlElement("ul", $ListAttributes, $Data);
# add additional HTML, if any
$Data .= $Html;
}
# value was likely modified and is a string
else
{
$Data = StripXSSThreats($Names);
}
DisplayResourceField(
$Resource,
$Field,
$Data,
array("IsTall" => TRUE, "NoHtml" => TRUE));
}
/**
* Display an User field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayUserField(Resource $Resource, MetadataField $Field)
{
global $User;
$Data = GetResourceFieldValue($Resource, $Field);
# convert to a user name if given an User object
if ($Data instanceof User)
{
$Data = (is_null($Data->Get("UserId")))
? "Unknown" : $Data->Get("UserName");
$Data = defaulthtmlentities($Data);
}
$Data = StripXSSThreats($Data);
DisplayResourceField($Resource, $Field, $Data);
}
/**
* Display an Image field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayStillImageField(Resource $Resource, MetadataField $Field)
{
$Images = GetResourceFieldValue($Resource, $Field);
# don't display an image that is unavailable
if (is_null($Images) || (is_array($Images) && !count($Images)))
{
return;
}
# if we have images
if (is_array($Images))
{
# for each image
$Data = "";
foreach ($Images as $Image)
{
# only display image fields with an image available
if (is_readable($Image->PreviewUrl()))
{
$ImageAttributes = array(
"src" => $Image->PreviewUrl(),
"alt" => $Image->AltText(),
"title" => $Image->AltText());
if ($Image->PreviewWidth() > 0)
{
$ImageAttributes["width"] = $Image->PreviewWidth();
}
if ($Image->PreviewHeight() > 0)
{
$ImageAttributes["height"] = $Image->PreviewHeight();
}
$ImageElement = CreateHtmlElement("img", $ImageAttributes);
$LinkAttributes = array(
"href" =>
"index.php?P=FullImage&ResourceId=".$Resource->Id()
."&FI=".$Field->Id()."&ID=".$Image->Id());
$ListItemAttributes = array(
"style" => "margin-right: 5px;",
);
$AnchorElement = CreateHtmlElement("a", $LinkAttributes, $ImageElement);
$Data .= CreateHtmlElement("li", $ListItemAttributes, $AnchorElement);
}
}
# bail out if none of the images were valid
if (!strlen($Data)) { return; }
# wrap images in a list
$ListAttributes = array(
"class" => "cw-list cw-list-dematte"
." cw-list-unmarked cw-list-horizontal");
$Data = CreateHtmlElement("ul", $ListAttributes, $Data);
}
# else value was likely modified and is a string
else
{
$Data = StripXSSThreats($Image);
}
DisplayResourceField($Resource, $Field, $Data, array("IsTall" => TRUE));
}
/**
* Display a File field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayFileField(Resource $Resource, MetadataField $Field)
{
$Files = GetResourceFieldValue($Resource, $Field);
# given an array of files
if (is_array($Files))
{
# only display file fields with at least one file
if (count($Files) < 1)
{
return;
}
$Data = NULL;
foreach ($Files as $Id => $File)
{
$Item = defaulthtmlentities($File->Name());
$Attributes = array(
"href" => $File->GetLink(),
"title" => "Download \"".$File->Name()."\"");
$Item = CreateHtmlElement("a", $Attributes, $Item);
$Data .= CreateHtmlElement("li", array(), $Item);
}
$ListAttributes = array(
"class" => "cw-list cw-list-dematte cw-list-unmarked");
$Data = CreateHtmlElement("ul", $ListAttributes, $Data);
}
# value was likely modified and is a string
else
{
$Data = StripXSSThreats($Files);
}
DisplayResourceField($Resource, $Field, $Data, array("IsTall" => TRUE));
}
/**
* Display an Url field.
* @param $Resource Resource object
* @param $Field MetadataField object
* @param $Value optional value for the URL
*/
function DisplayUrlField(Resource $Resource, MetadataField $Field, $Value=NULL)
{
global $SysConfig;
$Data = GetResourceFieldValue($Resource, $Field);
# only display URLs with a set value
if (strlen($Data) < 1)
{
return;
}
# if the data looks like an URL
if (IsSensibleUrl($Data))
{
$TruncData = (!is_null($Value))
? $Value : defaulthtmlentities(NeatlyTruncateString($Data, 70, TRUE));
$LinkAttributes = array(
"href" => "index.php?P=GoTo&ID=".$Resource->Id()."&MF=".$Field->Id(),
"title" => $Data);
if ($SysConfig->ResourceLaunchesNewWindowEnabled())
{
$LinkAttributes["target"] = "_blank";
}
$Link = CreateHtmlElement("a", $LinkAttributes, $TruncData);
}
# value was likely modified and is a string
else
{
$Link = StripXSSThreats($Data);
}
DisplayResourceField($Resource, $Field, $Link);
}
/**
* Display a Point field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayPointField(Resource $Resource, MetadataField $Field)
{
$Data = GetResourceFieldValue($Resource, $Field);
# reduce to a single value if given an array that contains the point values
if (is_array($Data))
{
$X = $Data["X"];
$Y = $Data["Y"];
$Data = !is_null($X) ? $X . ", " . $Y : NULL;
}
$Data = StripXSSThreats($Data);
DisplayResourceField($Resource, $Field, $Data, array("IsTall" => TRUE));
}
/**
* Display a Reference field.
* @param $Resource Resource object
* @param $Field MetadataField object
*/
function DisplayReferenceField(Resource $Resource, MetadataField $Field)
{
$References = GetResourceFieldValue($Resource, $Field);
# only display reference fields with at least one value
if (count($References) < 1)
{
return;
}
$Schema = new MetadataSchema();
$TitleField = $Schema->GetFieldByMappedName("Title");
$Data = NULL;
foreach ($References as $Id => $Reference)
{
$Title = $Reference->Get($TitleField);
$Item = $Title;
# escape and strip HTML if necessary
if (!$TitleField->AllowHTML())
{
$Title = strip_tags($Title);
$Item = defaulthtmlentities($Item);
}
$Attributes = array(
"href" => "index.php?P=FullRecord&ID=".urlencode($Reference->Id()),
"title" => "View more information for \"".$Title."\"");
$Item = CreateHtmlElement("a", $Attributes, $Item);
$Data .= CreateHtmlElement("li", array(), $Item);
}
$ListAttributes = array(
"class" => "cw-list cw-list-dematte cw-list-unmarked");
$Data = CreateHtmlElement("ul", $ListAttributes, $Data);
DisplayResourceField($Resource, $Field, $Data, array("IsTall" => TRUE));
}
# star rating functions
function PrintRatingGraphic0() { ?> " alt="This resource has a 1 star rating" /> " alt="This resource has a 1 star rating" /> " alt="This resource has a 1 star rating" /> " alt="This resource has a 1.5 star rating" /> " alt="This resource has a 2 star rating" /> " alt="This resource has a 2.5 star rating" /> " alt="This resource has a 3 star rating" /> " alt="This resource has a 3.5 star rating" /> " alt="This resource has a 4 star rating" /> " alt="This resource has a 4.5 star rating" /> " alt="This resource has a 5 star rating" /> (not yet rated)"; }
# ----- LOCAL FUNCTIONS ------------------------------------------------------
/**
* Determine if a MetadataField value can be displayed, depending on whether
* it's enabled and the user has the necessary privileges.
* @param $Field MetadataField object
* return TRUE if the field can be displayed, FALSE otherwise
*/
function CanDisplayField(MetadataField $Field=NULL, Resource $Resource)
{
global $User;
# field not set or not enabled
if (is_null($Field) || !$Field->Enabled())
{
return FALSE;
}
# insufficient privileges
if (!$User->HasPriv($Field->ViewingPrivileges(), $Resource))
{
return FALSE;
}
return TRUE;
}
/**
* Generate an HTML element.
* @param string $Name A valid HTML element name. It doesn't get escaped.
* @param array $Attributes Attributes and their values. Only values are escaped.
* @param string $Inner Inner HTML elements or text. It doesn't get escaped.
* @return Returns an HTML element string.
*/
function CreateHtmlElement($Name, $Attributes=array(), $Inner=NULL)
{
# determine if the HTML element should be a void one
$VoidElements = array("area", "base", "br", "col", "embed", "hr", "img",
"input", "keygen", "link", "menuitem", "meta", "param",
"source", "track", "wbr");
$IsVoidElement = in_array(strtolower($Name), $VoidElements);
$Element = "<" . $Name;
foreach ($Attributes as $Attribute => $Value)
{
$Value = defaulthtmlentities($Value);
$Element .= " " . $Attribute . '="' . $Value . '"';
}
$Element .= $IsVoidElement ? " />" : ">".$Inner."".$Name.">";
return $Element;
}
/**
* Display a resource field value.
* @param $Resource Resource object
* @param $Field MetadataField object
* @param $Data the field value with any alterations made
* @param $Options array of options
*/
function DisplayResourceField(
Resource $Resource, MetadataField $Field, $Data, array $Options=array())
{
global $AF;
$Header = defaulthtmlentities($Field->GetDisplayName());
$Description = defaulthtmlentities($Field->Description());
$IsTall = GetArrayValue($Options, "IsTall", FALSE);
$IsWysiwygText = GetArrayValue($Options, "IsWysiwygText", FALSE);
# vertically align to the top if more than 100 characters
$RowClass = "";
$RowClass .= $IsTall ? " cw-content-tallrow " : "";
$RowClass .= $IsWysiwygText ? " cw-content-wysiwygtext ": "";
$RowClass = ' class="'.$RowClass.'"';
$Html = NULL;
if (!isset($Options["NoHtml"]) || !$Options["NoHtml"])
{
# get additional HTML to display, if any
$SignalResult = $AF->SignalEvent(
"EVENT_APPEND_HTML_TO_FIELD_DISPLAY",
array(
"Field" => $Field, "Resource" => $Resource,
"Context" => "DISPLAY", "Html" => NULL));
$Html = $SignalResult["Html"];
}
?>
>
Name());
$Value = CreateHtmlElement("a", $LinkAttributes, $Value);
$Qualifier = GetFieldQualifier($Resource, $Field, $Name->Id());
if (!is_null($Qualifier) && $Field->ShowQualifiers())
{
$Url = defaulthtmlentities($Qualifier->Url());
$Name = defaulthtmlentities($Qualifier->Name());
$Value .= " (".$Name.")";
}
$Value = CreateHtmlElement("li", array(), $Value) . "\n";
return $Value;
}
/**
* Default field filter used when display resource field values.
* @param $Resource Resource object
* @param $Field MetadataField object
* @return TRUE if the field should be filtered out, FALSE otherwise
*/
function FieldFilter(Resource $Resource, MetadataField $Field)
{
global $User, $FieldsShownSeparately;
# filter fields that aren't enabled or the user can't see
if (!CanDisplayField($Field, $Resource))
{
return TRUE;
}
# filter fields that are displayed outside of the main list
if (in_array($Field->Name(), $FieldsShownSeparately))
{
return TRUE;
}
$Value = GetResourceFieldValue($Resource, $Field);
# filter fields with blank values
if (is_null($Value) || (is_string($Value) && strlen($Value) < 1))
{
return TRUE;
}
$FieldType = $Field->Type();
if (is_array($Value))
{
$IsTree = $FieldType == MetadataSchema::MDFTYPE_TREE;
$IsControlledName = $FieldType == MetadataSchema::MDFTYPE_CONTROLLEDNAME;
$IsOption = $FieldType == MetadataSchema::MDFTYPE_OPTION;
$IsFile = $FieldType == MetadataSchema::MDFTYPE_FILE;
$IsImage = $FieldType == MetadataSchema::MDFTYPE_IMAGE;
$IsReference = $FieldType == MetadataSchema::MDFTYPE_REFERENCE;
# filter fields with a list of values that is empty
if (!count($Value))
{
# these can be empty and still considered okay to print because they
# are checked in the display functions as well
if ($IsTree || $IsControlledName || $IsOption || $IsFile || $IsImage || $IsReference)
{
return FALSE;
}
# don't display the field otherwise
return TRUE;
}
$IsPoint = $FieldType == MetadataSchema::MDFTYPE_POINT;
# filter empty point fields
if ($IsPoint && (!$Value["X"] || !$Value["Y"]))
{
return TRUE;
}
}
$IsDate = $FieldType == MetadataSchema::MDFTYPE_DATE;
# filter empty dates
if ($IsDate && $Value instanceof Date && !strlen($Value->Formatted()))
{
return true;
}
return FALSE;
}
/**
* Encode an URL parameter and then escape any HTML entities it may contain.
* @param $Param URL parameter
* @return the URL parameter after encoding and escaping
*/
function EscapeParam($Param)
{
return defaulthtmlentities(urlencode($Param));
}
/**
* Get the URL field, its URL, its HREF, and its label for a resource.
* @param $Resource Resource object
* @return array(URL Field, URL, HREF, Label)
*/
function GetUrlFieldInfo(Resource $Resource)
{
global $SysConfig;
$Schema = new MetadataSchema();
$UrlField = $Schema->GetFieldByMappedName("Url");
$FileField = $Schema->GetFieldByMappedName("File");
$Url = (IsValidMetadataField($UrlField))
? GetResourceFieldValue($Resource, $UrlField) : "";
$Files = (IsValidMetadataField($FileField))
? GetResourceFieldValue($Resource, $FileField) : array();
if (is_array($Files) && count($Files) > 0
&& ($SysConfig->Value("PreferredLinkValue") == "FILE"
|| !$SysConfig->Value("PreferredLinkValue")))
{
$Result = array();
foreach ($Files as $File)
{
$Result[] = array(
$FileField,
OurBaseUrl().$File->GetLink(),
$File->GetLink(),
defaulthtmlentities($File->Name()));
}
return $Result;
}
if (strlen($Url) > 0)
{
if (IsSensibleUrl($Url))
{
$Href = defaulthtmlentities(
"index.php?P=GoTo&ID=".$Resource->Id()."&MF=".$UrlField->Id());
return array(array(
$UrlField,
$Url,
$Href,
defaulthtmlentities($Url)));
}
else
{
return array(array($UrlField, NULL, NULL, $Url));
}
}
return array();
}
/**
* Determine if the given URL could be a valid URL, but gives no guarantee
* that it is valid.
* @param $Url URL
* @return TRUE if the given URL could be a valid URL, FALSE otherwise
*/
function IsSensibleUrl($Url)
{
return (bool) preg_match('/^\s*[a-zA-Z]+:\/\//', $Url);
}
/**
* Print the URLs for the header bar.
* @param array $UrlFieldInfo URL field info form GetUrlFieldInfo().
*/
function PrintHeaderUrls(array $UrlFieldInfo, Resource $Resource)
{
# do nothing if there's nothing to print
if (!count($UrlFieldInfo))
{
return;
}
$LaunchNewWindow = $GLOBALS["G_SysConfig"]->ResourceLaunchesNewWindowEnabled();
?>
GetFieldByMappedName("Title");
$DescriptionField = $Schema->GetFieldByMappedName("Description");
$ScreenshotField = $Schema->GetFieldByMappedName("Screenshot");
$CumulativeRatingField = $Schema->GetFieldByName("Cumulative Rating");
$RatingDisplayName = $CumulativeRatingField->GetDisplayName();
# ratings are enabled, so let the plugins override whether they're displayed
if ($SysConfig->ResourceRatingsEnabled() && CumulativeRatingEnabled())
{
$SignalResult = $GLOBALS["AF"]->SignalEvent(
"EVENT_RESOURCE_SHOW_RATING",
array(
"Resource" => $Resource,
"Rating" => $Resource->Get($CumulativeRatingField),
"ShowRating" => TRUE));
$ShouldShowRating = $SignalResult["ShowRating"];
}
# ratings aren't enabled, so don't show them
else
{
$ShouldShowRating = FALSE;
}
# whether or not a description field is available
$DescriptionFieldAvailable = $DescriptionField instanceof MetadataField;
# special handling for the URL field
$UrlFieldInfo = GetUrlFieldInfo($Resource);
# format and escape the field values
$Title = StripXSSThreats(GetResourceFieldValue($Resource, $TitleField));
$Description = StripXSSThreats(GetResourceFieldValue($Resource, $DescriptionField));
$Screenshot = GetResourceFieldValue($Resource, $ScreenshotField);
$Screenshot = count($Screenshot) ? array_shift($Screenshot) : NULL;
$IsWysiwygText = $DescriptionFieldAvailable;
$IsWysiwygText = $IsWysiwygText && $DescriptionField->AllowHTML();
$IsWysiwygText = $IsWysiwygText && $DescriptionField->UseWysiwygEditor();
if (!$IsWysiwygText)
{
$Description = nl2br($Description);
}
# fields that are show separately and shouldn't be included in the main list
$FieldsShownSeparately = array();
$TestFields = array($TitleField, $DescriptionField);
foreach ($UrlFieldInfo as $UrlInfo)
{
list($UrlField) = $UrlInfo;
if (IsValidMetadataField($UrlField))
{
# always hide a URL field from the secondary fields
if ($UrlField->Type() == MetadataSchema::MDFTYPE_URL)
{
$TestFields[] = $UrlField;
}
# but only hide a file field if has fewer than two associated files
else if ($UrlField->Type() == MetadataSchema::MDFTYPE_FILE
&& count($Resource->Get($UrlField)) < 2)
{
$TestFields[] = $UrlField;
}
}
}
# don't display the screenshot field separately if it's valid and doesn't have
# multiple values
if (IsValidMetadataField($ScreenshotField)
&& count(GetResourceFieldValue($Resource, $ScreenshotField)) < 2)
{
$FieldsShownSeparately[] = $ScreenshotField->Name();
}
foreach ($TestFields as $Field)
{
if (IsValidMetadataField($Field))
{
$FieldsShownSeparately[] = $Field->Name();
}
}
# whether or not the Folders plugin is enabled
$FoldersEnabled = $G_PluginManager->PluginEnabled("Folders");
# folders-related info
if ($FoldersEnabled && $User->IsLoggedIn())
{
$ReturnToString = urlencode($GLOBALS["AF"]->GetCleanUrl());
$InFolder = $AF->SignalEvent(
"FOLDERS_RESOURCE_IN_SELECTED_FOLDER",
array($Resource, $User));
}
?>
Status() !== 1) { ?>
Resource Comments