name == NULL) && ($datasource -> englishName == NULL))) return ''; switch ($datasource -> compatibility) { case DatasourceHelper :: OPENAIRE: $compatibilityClass = 'openaireCompatible'; break; case DatasourceHelper :: DRIVER: $compatibilityClass = 'driverCompatible'; break; case DatasourceHelper :: DRIVER_OPENAIRE: $compatibilityClass = 'driverOpenaireCompatible'; break; case DatasourceHelper :: NON_COMPATIBLE: $compatibilityClass = 'nonCompatible'; break; default: $compatibilityClass = NULL; } return '
' . (($datasource -> id == NULL) ? '' : ('')) . $datasource -> name . ((($datasource -> name == NULL) || ($datasource -> englishName == NULL)) ? '' : ' - ') . $datasource -> englishName . (($datasource -> id == NULL) ? '' : '') . '' . DatasourceHelper :: _formatData($datasource, $itemId) . DatasourceHelper :: _formatDescription($datasource -> description) . '
'; } public static function _formatData($datasource, $itemId) { if ($datasource == NULL) return ''; $data = array(); $items = DatasourceHelper :: _formatItems($datasource -> items, $datasource -> date); if ($items != NULL) $data[] = $items; $organizations = DatasourceHelper :: _formatOrganizations($datasource -> organizations, $itemId); if ($organizations != NULL) $data[] = JText :: _('ORGANIZATIONS_') . ' ' . $organizations; if ($datasource -> type != NULL) $data[] = JText :: _('TYPE_') . ' ' . $datasource -> type; $languages = implode(', ', $datasource -> languages); if ($languages != NULL) $data[] = JText :: _('LANGUAGES_') . ' ' . $languages; $policies = implode(', ', $datasource -> policies); if ($policies != NULL) $data[] = JText :: _('POLICIES_') . ' ' . $policies; $contents = implode(', ', $datasource -> contents); if ($contents != NULL) $data[] = JText :: _('CONTENTS_') . ' ' . $contents; if ($datasource -> url != NULL) $data[] = JText :: _('WEBSITE_URL_') . ' ' . $datasource -> url . ''; $oaiPmh = implode(', ', array_filter(array_map(function ($url) { return ($url == NULL) ? '' : ('' . $url . ''); }, $datasource -> oaiPmhUrls))); if ($oaiPmh != NULL) $data[] = JText :: _('OAI_PMH_URL_') . ' ' . $oaiPmh; return ($data == NULL) ? '' : ('
' . implode('
', $data) . '
'); } public static function _formatItems($items, $date) { return (($items == NULL) && ($date == NULL)) ? '' : ('(' . JText :: sprintf('N_ITEMS', $items) . ((($items == NULL) || ($date == NULL)) ? ' - ' : ' - ') . (($date == NULL) ? '' : date(JText :: _('DATE_FORMAT'), $date)) . ', ' . JText :: _('FROM_OPENDOAR') .')'); } public static function _formatOrganizations($organizations, $itemId) { $organizations = ($organizations == NULL) ? NULL : array_filter(array_map(function ($organization) use ($itemId) {return DatasourceHelper :: _formatOrganization($organization, $itemId);}, $organizations)); return ($organizations == NULL) ? '' : (implode(', ' , array_slice($organizations, 0, DatasourceHelper :: MAX_ORGANIZATIONS)) . ((count($organizations) > DatasourceHelper :: MAX_ORGANIZATIONS) ? ',...' : '') ); } public static function _formatOrganization($organization, $itemId) { return (($organization == NULL) || (($organization -> shortName == NULL) && ($organization -> name == NULL))) ? '' : ('' . (($organization -> id == NULL) ? '' : ('')) . (($organization -> shortName == NULL) ? $organization -> name : $organization -> shortName) . (($organization -> id == NULL) ? '' : '') . ''); } public static function _formatDescription($description) { return ($description == NULL) ? '' : ('
' . ((strlen($description) > DatasourceHelper :: MAX_DESCRIPTION) ? (substr($description, 0, DatasourceHelper :: MAX_DESCRIPTION - strlen(DatasourceHelper :: SUFFIX)) . DatasourceHelper :: SUFFIX) : $description) . '
'); } } //$datasource -> url δεν το θέλουμε //$datasource -> oaiPmhUrls δεν τα θέλουμε