title), $publication -> accessMode, $publication -> id, $publication -> source, $publication -> url, $itemId,
isset($publication -> inferred)?$publication -> inferred:false,
isset($publication -> trust)?$publication -> trust:"",
isset($publication -> provenance)?$publication -> provenance:"") . PublicationHelper :: _formatData($publication, $itemId). PublicationHelper :: _formatDescription($publication -> description);
return ($publication == NULL) ? '' : ('
' . $publication . '
');
}
public static function _formatTitle($title, $accessMode, $id, $source, $url, $itemId, $inferred = false, $trust = "", $provenance = "") {
switch ($accessMode) {
case PublicationHelper :: OPEN_ACCESS:
$accessModeClass = 'openAccess';
$accessModeTitle = JText :: _('OPEN_ACCESS');
break;
case PublicationHelper :: EMBARGO_ACCESS:
$accessModeClass = 'embargoAccess';
$accessModeTitle = JText :: _('EMBARGO_ACCESS');
break;
case PublicationHelper :: RESTRICTED_ACCESS:
$accessModeClass = 'restrictedAccess';
$accessModeTitle = JText :: _('RESTRICTED_ACCESS');
break;
case PublicationHelper :: CLOSED_ACCESS:
$accessModeClass = 'closedAccess';
$accessModeTitle = JText :: _('CLOSED_ACCESS');
break;
default:
$accessModeClass = NULL;
$accessModeTitle = NULL;
}
//return ($title == NULL) ? '' : ('');
return ($title == NULL) ? '' : ('');
}
public static function formatTrustMeter($publication) {
if ($publication == NULL)
return '';
if ( property_exists($publication,'similarity')){
if ( $publication->similarity!=null){
$similarity=$publication -> similarity*100;
return '' .($similarity<10?'0':'').$similarity.' ';
}
}
return '';
}
public static function _formatData($publication, $itemId) {
if ($publication == NULL)
return '';
$authors = PublicationHelper :: _formatAuthors($publication -> authors, $itemId);
$year = PublicationHelper :: _formatYear($publication -> year);
$data = array();
$data[] = $authors . ((($authors == NULL) || ($year == NULL)) ? '' : ' ') . $year;
$data[] = PublicationHelper :: _formatProjects($publication -> projects, $itemId);
$data[] = PublicationHelper :: _formatEmbargoEndDate($publication -> embargoEndDate);
$data = array_filter($data);
return ($data == NULL) ? '' : ('' . implode('
', $data) . '
');
}
public static function _formatAuthors($authors, $itemId) {
$authors = ($authors == NULL) ? NULL : array_filter(array_map(function ($author) use ($itemId) {return PublicationHelper :: _formatAuthor($author, $itemId);}, $authors));
return ($authors == NULL) ? '' : (implode('; ', array_slice($authors, 0, PublicationHelper :: MAX_AUTHORS)) . ((count($authors) > PublicationHelper :: MAX_AUTHORS) ? ';...' : ''));
}
public static function _formatAuthor($author, $itemId) {
return (($author == NULL) || ((($author -> lastName == NULL) || ($author -> firstName == NULL)) && ($author -> fullName == NULL))) ? '' : ('' . (($author -> id == NULL) ? '' : ('')) . ((($author -> lastName == NULL) || ($author -> firstName == NULL)) ? $author -> fullName : ($author -> lastName . ', ' . $author -> firstName)) . (($author -> id == NULL) ? '' : '') . '');
}
public static function _formatYear($year) {
return ($year == NULL) ? '' : ('(' . $year . ')');
}
public static function _formatProjects($projects, $itemId) {
$projects = ($projects == NULL) ? NULL : array_filter(array_map(function ($project) use ($itemId) {return PublicationHelper :: _formatProject($project, $itemId);}, $projects));
return ($projects == NULL) ? '' : (JText :: _('PROJECTS_') . ' ' . implode(', ', array_slice($projects, 0, PublicationHelper :: MAX_PROJECTS)) . ((count($projects) > PublicationHelper :: MAX_PROJECTS) ? ',...' : ''));
}
public static function _formatProject($project, $itemId) {
return (($project -> acronym == NULL) && ($project -> title == NULL)) ? '' : ('' . (($project -> id == NULL) ? '' : ('')) . (($project -> acronym == NULL) ? $project -> title : $project -> acronym) . (($project -> code == NULL) ? '' : (' (' . $project -> code . ')')) . (($project -> id == NULL) ? '' : '') . '');
}
public static function _formatEmbargoEndDate($embargoEndDate) {
return ($embargoEndDate == NULL) ? '' : (''.JText :: _('EMBARGO_END_DATE_') . ' ' . date(JText :: _('DATE_FORMAT'), $embargoEndDate) . '');
}
public static function _formatDescription($description) {
$description= ($description == NULL) ? '' : strip_tags($description);
return ($description == NULL) ? '' : ('' . ((strlen($description) > PublicationHelper :: MAX_DESCRIPTION) ? (substr($description, 0, PublicationHelper :: MAX_DESCRIPTION - strlen(PublicationHelper :: SUFFIX)) . PublicationHelper :: SUFFIX) : $description) . '
');
}
public static function formatCitationLinks($citation) {
if(sizeof($citation -> ids)==0){
return ''.$citation -> title.'
';
}else{
$citationId=$citation -> ids[0];
if (sizeof($citation -> ids)>1){
usort($citation -> ids, function ($a, $b) {if ($a->confidenceLevel == $b->confidenceLevel) {return 0;}return ($a->confidenceLevel > $b->confidenceLevel) ? -1 : 1;});
$citationId=$citation -> ids[0];
}
$link = ''.$citation -> title.'
';
if(strcmp($citationId -> type,'openaire')==0){
$link ='';
}else if(strcmp($citationId -> type,"pmid")==0){
$link ='';
}else if(strcmp($citationId -> type,"pmcid")==0){
$link ='';
}else if(strcmp($citationId -> type,"arxiv")==0){
$link ='';
}else if(strcmp($citationId -> type,"doi")==0){
$link ='';
}
/*pmid 15558770
doi 4821630
other 380750
medline 22244
pii 8982
publisher-id 8382
pmcid 5107
coden 335
rrn 19
art-access-id 2
doaj 1
arxiv*/
//TODO add the rest id types
return $link;
}
}
}