本文整理汇总了PHP中Record::getParts方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::getParts方法的具体用法?PHP Record::getParts怎么用?PHP Record::getParts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record::getParts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateDisplayForPartStructures
/**
* Generate HTML for displaying particular parts of the Record
*
* @param object $record The record to print.
* @param array $partStructures An array of particular partstructures to print.
* @return string
* @access public
* @since 10/19/04
*/
function generateDisplayForPartStructures(Id $repositoryId, Id $assetId, Record $record, array $partStructures)
{
ArgumentValidator::validate($partStructures, new ArrayValidatorRuleWithRule(new ExtendsValidatorRule("PartStructure")));
$partIterator = $record->getParts();
$parts = array();
while ($partIterator->hasNext()) {
$part = $partIterator->next();
$partStructure = $part->getPartStructure();
$partStructureId = $partStructure->getId();
if (!isset($parts[$partStructureId->getIdString()]) || !is_array($parts[$partStructureId->getIdString()])) {
$parts[$partStructureId->getIdString()] = array();
}
$parts[$partStructureId->getIdString()][] = $part;
}
// print out the parts;
ob_start();
foreach (array_keys($partStructures) as $key) {
$partStructure = $partStructures[$key];
$partStructureId = $partStructure->getId();
if (isset($parts[$partStructureId->getIdString()])) {
if (is_array($parts[$partStructureId->getIdString()])) {
foreach (array_keys($parts[$partStructureId->getIdString()]) as $key) {
$part = $parts[$partStructureId->getIdString()][$key];
print "\n<strong>" . $partStructure->getDisplayName() . ":</strong> \n";
print $this->getPartStringValue($part);
print "\n<br />";
}
}
}
}
$html = ob_get_contents();
ob_end_clean();
return $html;
}
示例2: generateDisplayForPartStructures
/**
* Generate HTML for displaying particular parts of the Record
*
* @param object $record The record to print.
* @param array $partStructures An array of particular partStructures to print.
* @return string
* @access public
* @since 10/19/04
*/
function generateDisplayForPartStructures(Id $repositoryId, Id $assetId, Record $record, array $partStructures)
{
ArgumentValidator::validate($partStructures, new ArrayValidatorRuleWithRule(new ExtendsValidatorRule("PartStructure")));
$partIterator = $record->getParts();
$parts = array();
while ($partIterator->hasNext()) {
$part = $partIterator->next();
$partStructure = $part->getPartStructure();
$partStructureId = $partStructure->getId();
if (!isset($parts[$partStructureId->getIdString()]) || !is_array($parts[$partStructureId->getIdString()])) {
$parts[$partStructureId->getIdString()] = array();
}
$parts[$partStructureId->getIdString()][] = $part;
}
// print out the parts;
ob_start();
$partStructuresToSkip = array('FILE_DATA', 'THUMBNAIL_DATA', 'THUMBNAIL_MIME_TYPE', 'THUMBNAIL_DIMENSIONS');
$printThumbnail = FALSE;
foreach (array_keys($partStructures) as $key) {
$partStructure = $partStructures[$key];
$partStructureId = $partStructure->getId();
if (!in_array($partStructureId->getIdString(), $partStructuresToSkip)) {
print "\n<strong>" . $partStructure->getDisplayName() . ":</strong> \n";
switch ($partStructureId->getIdString()) {
case 'FILE_SIZE':
$size = ByteSize::withValue($parts[$partStructureId->getIdString()][0]->getValue());
print $size->asString();
break;
case 'DIMENSIONS':
$dimensionArray = $parts[$partStructureId->getIdString()][0]->getValue();
print "<em>" . _('width: ') . "</em>" . $dimensionArray[0] . 'px<em>;</em> ';
print "<em>" . _('height: ') . "</em>" . $dimensionArray[1] . 'px';
break;
default:
print $parts[$partStructureId->getIdString()][0]->getValue();
}
print "\n<br />";
} else {
$printThumbnail = TRUE;
}
}
$html = ob_get_clean();
$harmoni = Harmoni::instance();
$harmoni->request->startNamespace("polyphony-repository");
if ($printThumbnail) {
ob_start();
$recordId = $record->getId();
$ns = $harmoni->request->endNamespace();
// ======= VIEWER LINK ======== //
$xmlAssetIdString = $harmoni->request->get("asset_id");
print "<a href='#' onclick='Javascript:window.open(";
print '"' . VIEWER_URL . "?&source=";
print urlencode($harmoni->request->quickURL("asset", "browserecordxml", array("collection_id" => $repositoryId->getIdString(), "asset_id" => $xmlAssetIdString, "record_id" => $recordId->getIdString(), RequestContext::name("limit_by") => RequestContext::value("limit_by"), RequestContext::name("type") => RequestContext::value("type"), RequestContext::name("searchtype") => RequestContext::value("searchtype"), RequestContext::name("searchstring") => RequestContext::value("searchstring"))));
print '&start=0", ';
print '"' . preg_replace("/[^a-z0-9]/i", '_', $assetId->getIdString()) . '", ';
print '"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500"';
print ")'>";
$harmoni->request->startNamespace($ns);
// If we have a thumbnail with a valid mime type, print a link to that.
$thumbnailName = preg_replace("/\\.[^\\.]+\$/", "", $parts['FILE_NAME'][0]->getValue());
if ($thumbnailMimeType = $parts['THUMBNAIL_MIME_TYPE'][0]->getValue()) {
$mime = Services::getService("MIME");
$thumbnailName .= "." . $mime->getExtensionForMIMEType($thumbnailMimeType);
}
print "\n<img src='";
print RepositoryInputOutputModuleManager::getThumbnailUrlForRecord($assetId, $record);
print "'";
print " style='border: 0px;'";
print " alt='Thumbnail image.'";
print " align='left'";
print " />";
print "</a> <br />";
$html2 = ob_get_clean();
ob_start();
print "\n<a href='";
print RepositoryInputOutputModuleManager::getFileUrlForRecord($assetId, $record);
print "' target='_blank'>";
print "Download This File</a>\n";
$downloadlink = ob_get_clean();
$html = "<table border=0><tr><td>" . $html2 . "</td><td>" . $html . $downloadlink . "</td></tr></table>";
}
$harmoni->request->endNamespace();
return $html;
}