Revision 35459
Added by Argiro Kokogiannaki about 9 years ago
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/models/index.html | ||
---|---|---|
1 |
<!DOCTYPE HTML> |
|
2 |
<html> |
|
3 |
<head> |
|
4 |
<title>OpenAIRE</title> |
|
5 |
</head> |
|
6 |
<body> |
|
7 |
<h1>Access denied</h1> |
|
8 |
</body> |
|
9 |
</html> |
|
10 |
|
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/openaire.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<extension type="component" version="2.5.0" method="upgrade"> |
|
3 |
<name>OpenAIRE</name> |
|
4 |
<creationDate>April 2012</creationDate> |
|
5 |
<author>OpenAIRE Consortium</author> |
|
6 |
<authorEmail>admin@openaire.eu</authorEmail> |
|
7 |
<authorUrl>http://www.openaire.eu/</authorUrl> |
|
8 |
<copyright>Copyright © 2010-12, OpenAIRE Consortium</copyright> |
|
9 |
<license>Apache License</license> |
|
10 |
<version>0.0.1</version> |
|
11 |
<description>Open Access Infrastructure for Research in Europe</description> |
|
12 |
<scriptfile>install.php</scriptfile> |
|
13 |
<install> |
|
14 |
<sql> |
|
15 |
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file> |
|
16 |
</sql> |
|
17 |
</install> |
|
18 |
<uninstall> |
|
19 |
<sql> |
|
20 |
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file> |
|
21 |
</sql> |
|
22 |
</uninstall> |
|
23 |
<update> |
|
24 |
<schemas> |
|
25 |
<schemapath type="mysql">sql/updates/mysql</schemapath> |
|
26 |
</schemas> |
|
27 |
</update> |
|
28 |
<files folder="site"> |
|
29 |
<filename>index.html</filename> |
|
30 |
<filename>openaire.php</filename> |
|
31 |
<filename>controller.php</filename> |
|
32 |
<filename>router.php</filename> |
|
33 |
<folder>models</folder> |
|
34 |
<folder>views</folder> |
|
35 |
<folder>helpers</folder> |
|
36 |
<folder>js</folder> |
|
37 |
<folder>css</folder> |
|
38 |
<folder>images</folder> |
|
39 |
<folder>language</folder> |
|
40 |
</files> |
|
41 |
<administration> |
|
42 |
<menu img="./components/com_openaire/images/menu.png">OPENAIRE</menu> |
|
43 |
<files folder="admin"> |
|
44 |
<filename>index.html</filename> |
|
45 |
<filename>openaire.php</filename> |
|
46 |
<filename>controller.php</filename> |
|
47 |
<filename>config.xml</filename> |
|
48 |
<folder>sql</folder> |
|
49 |
<folder>views</folder> |
|
50 |
<folder>css</folder> |
|
51 |
<folder>images</folder> |
|
52 |
<folder>language</folder> |
|
53 |
</files> |
|
54 |
</administration> |
|
55 |
</extension> |
|
56 |
|
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/helpers/publicationhelper.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
defined('_JEXEC') or die('Access denied'); |
|
4 |
|
|
5 |
jimport('joomla.methods'); |
|
6 |
|
|
7 |
// This helper _formats publications. |
|
8 |
abstract class PublicationHelper { |
|
9 |
const OPENAIRE = 'openaire'; |
|
10 |
const MAX_AUTHORS = 15; |
|
11 |
const MAX_PROJECTS = 15; |
|
12 |
const MAX_DESCRIPTION = 500; |
|
13 |
const SUFFIX = '...'; |
|
14 |
const OPEN_ACCESS = 'OPEN'; |
|
15 |
const CLOSED_ACCESS = 'CLOSED'; |
|
16 |
const RESTRICTED_ACCESS = 'RESTRICTED'; |
|
17 |
const EMBARGO_ACCESS = 'EMBARGO'; |
|
18 |
|
|
19 |
// Format a publication. |
|
20 |
// $publication the publication to format |
|
21 |
// $itemId the item ID to use for internal links |
|
22 |
// return a string containing the full HTML for the publication or an empty string if any errors occur |
|
23 |
public static function formatPublication($publication, $itemId) { |
|
24 |
if ($publication == NULL) |
|
25 |
return ''; |
|
26 |
//:: _formatTrustMeter($publication).PublicationHelper |
|
27 |
$publication = PublicationHelper :: _formatTitle(htmlspecialchars($publication -> title), $publication -> accessMode, $publication -> id, $publication -> source, $publication -> url, $itemId, |
|
28 |
isset($publication -> inferred)?$publication -> inferred:false, |
|
29 |
isset($publication -> trust)?$publication -> trust:"", |
|
30 |
isset($publication -> provenance)?$publication -> provenance:"") . PublicationHelper :: _formatData($publication, $itemId). PublicationHelper :: _formatDescription($publication -> description); |
|
31 |
return ($publication == NULL) ? '' : ('<div class="srchRow">' . $publication . '</div>'); |
|
32 |
} |
|
33 |
|
|
34 |
public static function _formatTitle($title, $accessMode, $id, $source, $url, $itemId, $inferred = false, $trust = "", $provenance = "") { |
|
35 |
switch ($accessMode) { |
|
36 |
case PublicationHelper :: OPEN_ACCESS: |
|
37 |
$accessModeClass = 'openAccess'; |
|
38 |
$accessModeTitle = JText :: _('OPEN_ACCESS'); |
|
39 |
break; |
|
40 |
case PublicationHelper :: EMBARGO_ACCESS: |
|
41 |
$accessModeClass = 'embargoAccess'; |
|
42 |
$accessModeTitle = JText :: _('EMBARGO_ACCESS'); |
|
43 |
break; |
|
44 |
case PublicationHelper :: RESTRICTED_ACCESS: |
|
45 |
$accessModeClass = 'restrictedAccess'; |
|
46 |
$accessModeTitle = JText :: _('RESTRICTED_ACCESS'); |
|
47 |
break; |
|
48 |
case PublicationHelper :: CLOSED_ACCESS: |
|
49 |
$accessModeClass = 'closedAccess'; |
|
50 |
$accessModeTitle = JText :: _('CLOSED_ACCESS'); |
|
51 |
break; |
|
52 |
default: |
|
53 |
$accessModeClass = NULL; |
|
54 |
$accessModeTitle = NULL; |
|
55 |
} |
|
56 |
//return ($title == NULL) ? '' : ('<h4' . (($accessModeClass == NULL) ? '' : (' class="' . $accessModeClass . '" title="' . $accessModeTitle . '"')) . '>' . (($source == self :: OPENAIRE) ? (($id == NULL) ? '' : ('<a href="' . JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=article&Itemid=' . $itemId . '&articleId=' . $id) . '">')) : (($url == NULL) ? '' : ('<a target="_blank" class="icon-external" href="' . $url . '">'))) . $title . (($source == self :: OPENAIRE) ? (($id == NULL) ? '' : ('</a>')) : (($url == NULL) ? '' : ('</a>'))) . ($inferred == true?" <span class='inferred'><img src='templates/yoo_solar/styles/openaire/images/box_info_ok.png' /></span><div style='display: none'><div class='inferred-popup' id='popup-". $id. "'>trust: $trust, provenance: $provenance </div></div>" :"") . '</h4>'); |
|
57 |
return ($title == NULL) ? '' : ('<h4' . (($accessModeClass == NULL) ? '' : (' class="' . $accessModeClass . '" title="' . $accessModeTitle . '"')) . '>' . (($source == self :: OPENAIRE) ? (($id == NULL) ? '' : ('<a href="' . JRoute :: _('index.php?option=com_openaire&view=article&Itemid=' . $itemId . '&articleId=' . $id) . '">')) : (($url == NULL) ? '' : ('<a target="_blank" class="icon-external" href="' . $url . '">'))) . $title . (($source == self :: OPENAIRE) ? (($id == NULL) ? '' : ('</a>')) : (($url == NULL) ? '' : ('</a>'))) . '</h4>'); |
|
58 |
} |
|
59 |
|
|
60 |
public static function formatTrustMeter($publication) { |
|
61 |
if ($publication == NULL) |
|
62 |
return ''; |
|
63 |
if ( property_exists($publication,'similarity')){ |
|
64 |
if ( $publication->similarity!=null){ |
|
65 |
$similarity=$publication -> similarity*100; |
|
66 |
return '<span style=" display: none; ">' .($similarity<10?'0':'').$similarity.'</span> <div title="'.($publication -> similarity*100).'%" style="width:80%;" class="uk-progress"><div class="uk-progress-bar" style="width: '.($publication -> similarity*100).'%;"> </div></div>'; |
|
67 |
} |
|
68 |
} |
|
69 |
return ''; |
|
70 |
} |
|
71 |
public static function _formatData($publication, $itemId) { |
|
72 |
if ($publication == NULL) |
|
73 |
return ''; |
|
74 |
$authors = PublicationHelper :: _formatAuthors($publication -> authors, $itemId); |
|
75 |
$year = PublicationHelper :: _formatYear($publication -> year); |
|
76 |
$data = array(); |
|
77 |
$data[] = $authors . ((($authors == NULL) || ($year == NULL)) ? '' : ' ') . $year; |
|
78 |
$data[] = PublicationHelper :: _formatProjects($publication -> projects, $itemId); |
|
79 |
$data[] = PublicationHelper :: _formatEmbargoEndDate($publication -> embargoEndDate); |
|
80 |
$data = array_filter($data); |
|
81 |
return ($data == NULL) ? '' : ('<div class="biblio">' . implode('<br />', $data) . '</div>'); |
|
82 |
} |
|
83 |
public static function _formatAuthors($authors, $itemId) { |
|
84 |
$authors = ($authors == NULL) ? NULL : array_filter(array_map(function ($author) use ($itemId) {return PublicationHelper :: _formatAuthor($author, $itemId);}, $authors)); |
|
85 |
return ($authors == NULL) ? '' : (implode('; ', array_slice($authors, 0, PublicationHelper :: MAX_AUTHORS)) . ((count($authors) > PublicationHelper :: MAX_AUTHORS) ? ';...' : '')); |
|
86 |
} |
|
87 |
|
|
88 |
public static function _formatAuthor($author, $itemId) { |
|
89 |
return (($author == NULL) || ((($author -> lastName == NULL) || ($author -> firstName == NULL)) && ($author -> fullName == NULL))) ? '' : ('<span class="auth">' . (($author -> id == NULL) ? '' : ('<a href="' . JRoute :: _('index.php?option=com_openaire&view=person&Itemid=' . $itemId . '&personId=' . $author -> id) . '">')) . ((($author -> lastName == NULL) || ($author -> firstName == NULL)) ? $author -> fullName : ($author -> lastName . ', ' . $author -> firstName)) . (($author -> id == NULL) ? '' : '</a>') . '</span>'); |
|
90 |
} |
|
91 |
|
|
92 |
public static function _formatYear($year) { |
|
93 |
return ($year == NULL) ? '' : ('<span class="year">(' . $year . ')</span>'); |
|
94 |
} |
|
95 |
|
|
96 |
public static function _formatProjects($projects, $itemId) { |
|
97 |
$projects = ($projects == NULL) ? NULL : array_filter(array_map(function ($project) use ($itemId) {return PublicationHelper :: _formatProject($project, $itemId);}, $projects)); |
|
98 |
return ($projects == NULL) ? '' : (JText :: _('PROJECTS_') . ' ' . implode(', ', array_slice($projects, 0, PublicationHelper :: MAX_PROJECTS)) . ((count($projects) > PublicationHelper :: MAX_PROJECTS) ? ',...' : '')); |
|
99 |
} |
|
100 |
|
|
101 |
public static function _formatProject($project, $itemId) { |
|
102 |
return (($project -> acronym == NULL) && ($project -> title == NULL)) ? '' : ('<span class="proj">' . (($project -> id == NULL) ? '' : ('<a href="' . JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=project&Itemid=' . $itemId . '&projectId=' . $project -> id) . '">')) . (($project -> acronym == NULL) ? $project -> title : $project -> acronym) . (($project -> code == NULL) ? '' : (' (' . $project -> code . ')')) . (($project -> id == NULL) ? '' : '</a>') . '</span>'); |
|
103 |
} |
|
104 |
|
|
105 |
public static function _formatEmbargoEndDate($embargoEndDate) { |
|
106 |
return ($embargoEndDate == NULL) ? '' : ('<span class="dchdr">'.JText :: _('EMBARGO_END_DATE_') . ' </span><span class="embargoDate">' . date(JText :: _('DATE_FORMAT'), $embargoEndDate) . '</span>'); |
|
107 |
} |
|
108 |
|
|
109 |
public static function _formatDescription($description) { |
|
110 |
$description= ($description == NULL) ? '' : strip_tags($description); |
|
111 |
return ($description == NULL) ? '' : ('<div class="description">' . ((strlen($description) > PublicationHelper :: MAX_DESCRIPTION) ? (substr($description, 0, PublicationHelper :: MAX_DESCRIPTION - strlen(PublicationHelper :: SUFFIX)) . PublicationHelper :: SUFFIX) : $description) . '</div>'); |
|
112 |
} |
|
113 |
|
|
114 |
public static function formatCitationLinks($citation) { |
|
115 |
if(sizeof($citation -> ids)==0){ |
|
116 |
return '<h5>'.$citation -> title.'</h5>'; |
|
117 |
}else{ |
|
118 |
$citationId=$citation -> ids[0]; |
|
119 |
if (sizeof($citation -> ids)>1){ |
|
120 |
usort($citation -> ids, function ($a, $b) {if ($a->confidenceLevel == $b->confidenceLevel) {return 0;}return ($a->confidenceLevel > $b->confidenceLevel) ? -1 : 1;}); |
|
121 |
$citationId=$citation -> ids[0]; |
|
122 |
} |
|
123 |
$link = '<h5>'.$citation -> title.'</h5>'; |
|
124 |
if(strcmp($citationId -> type,'openaire')==0){ |
|
125 |
$link ='<h5><a href="'. JUri :: base() . 'index.php?option=com_openaire&view=article&articleId='.$citationId->id.'">'.$citation -> title.'</a></h5>'; |
|
126 |
}else if(strcmp($citationId -> type,"pmid")==0){ |
|
127 |
$link ='<h5><a target="_blank" class="icon-external" href="http://www.ncbi.nlm.nih.gov/pubmed/'.$citationId->id.'">'.$citation -> title.'</a></h5>'; |
|
128 |
}else if(strcmp($citationId -> type,"pmcid")==0){ |
|
129 |
$link ='<h5><a target="_blank" class="icon-external" href="http://europepmc.org/articles/'.$citationId->id.'">'.$citation -> title.'</a></h5>'; |
|
130 |
}else if(strcmp($citationId -> type,"arxiv")==0){ |
|
131 |
$link ='<h5><a target="_blank" class="icon-external" href="http://arxiv.org/abs/'.$citationId->id.'">'.$citation -> title.'</a></h5>'; |
|
132 |
}else if(strcmp($citationId -> type,"doi")==0){ |
|
133 |
$link ='<h5><a target="_blank" class="icon-external" href="http://dx.doi.org/'.$citationId->id.'">'.$citation -> title.'</a></h5>'; |
|
134 |
} |
|
135 |
/*pmid 15558770 |
|
136 |
doi 4821630 |
|
137 |
other 380750 |
|
138 |
medline 22244 |
|
139 |
pii 8982 |
|
140 |
publisher-id 8382 |
|
141 |
pmcid 5107 |
|
142 |
coden 335 |
|
143 |
rrn 19 |
|
144 |
art-access-id 2 |
|
145 |
doaj 1 |
|
146 |
arxiv*/ |
|
147 |
|
|
148 |
//TODO add the rest id types |
|
149 |
return $link; |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
} |
|
154 |
|
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/helpers/datasourcehelper.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
defined('_JEXEC') or die('Access denied'); |
|
4 |
|
|
5 |
jimport('joomla.methods'); |
|
6 |
|
|
7 |
// This helper formats datasources. |
|
8 |
abstract class DatasourceHelper { |
|
9 |
const OPENAIRE = 'OpenAIRE publication 2.0'; |
|
10 |
const DRIVER = 'OpenAIRE publication basic (DRIVER)'; |
|
11 |
const DRIVER_OPENAIRE = 'OpenAIRE funding 2.0'; |
|
12 |
const NON_COMPATIBLE = 'non compatible'; |
|
13 |
const MAX_ORGANIZATIONS = 15; |
|
14 |
const MAX_DESCRIPTION = 500; |
|
15 |
const SUFFIX = '...'; |
|
16 |
|
|
17 |
// Format a datasource. |
|
18 |
// $datasource the datasource to format |
|
19 |
// $itemId the item ID to use for internal links |
|
20 |
// return a string containing the full HTML for the datasource or an empty string if any errors occur |
|
21 |
public static function formatDatasource($datasource, $itemId) { |
|
22 |
if (($datasource == NULL) || (($datasource -> name == NULL) && ($datasource -> englishName == NULL))) |
|
23 |
return ''; |
|
24 |
switch ($datasource -> compatibility) { |
|
25 |
case DatasourceHelper :: OPENAIRE: |
|
26 |
$compatibilityClass = 'openaireCompatible'; |
|
27 |
break; |
|
28 |
case DatasourceHelper :: DRIVER: |
|
29 |
$compatibilityClass = 'driverCompatible'; |
|
30 |
break; |
|
31 |
case DatasourceHelper :: DRIVER_OPENAIRE: |
|
32 |
$compatibilityClass = 'driverOpenaireCompatible'; |
|
33 |
break; |
|
34 |
case DatasourceHelper :: NON_COMPATIBLE: |
|
35 |
$compatibilityClass = 'nonCompatible'; |
|
36 |
break; |
|
37 |
default: |
|
38 |
$compatibilityClass = NULL; |
|
39 |
} |
|
40 |
return '<div class="srchRow"><h4' . (($compatibilityClass == NULL) ? '' : (' class="' . $compatibilityClass . '" title="' . $datasource -> compatibility . '"')) . '>' . (($datasource -> id == NULL) ? '' : ('<a href="' . JRoute :: _('index.php?option=com_openaire&view=datasource&Itemid=' . $itemId . '&datasourceId=' . $datasource -> id) . '">')) . $datasource -> name . ((($datasource -> name == NULL) || ($datasource -> englishName == NULL)) ? '' : ' - ') . $datasource -> englishName . (($datasource -> id == NULL) ? '' : '</a>') . '</h4>' . DatasourceHelper :: _formatData($datasource, $itemId) . DatasourceHelper :: _formatDescription($datasource -> description) . '</div>'; |
|
41 |
} |
|
42 |
|
|
43 |
public static function _formatData($datasource, $itemId) { |
|
44 |
if ($datasource == NULL) |
|
45 |
return ''; |
|
46 |
$data = array(); |
|
47 |
$items = DatasourceHelper :: _formatItems($datasource -> items, $datasource -> date); |
|
48 |
if ($items != NULL) |
|
49 |
$data[] = $items; |
|
50 |
$organizations = DatasourceHelper :: _formatOrganizations($datasource -> organizations, $itemId); |
|
51 |
if ($organizations != NULL) |
|
52 |
$data[] = JText :: _('ORGANIZATIONS_') . ' ' . $organizations; |
|
53 |
if ($datasource -> type != NULL) |
|
54 |
$data[] = JText :: _('TYPE_') . ' ' . $datasource -> type; |
|
55 |
$languages = implode(', ', $datasource -> languages); |
|
56 |
if ($languages != NULL) |
|
57 |
$data[] = JText :: _('LANGUAGES_') . ' ' . $languages; |
|
58 |
$policies = implode(', ', $datasource -> policies); |
|
59 |
if ($policies != NULL) |
|
60 |
$data[] = JText :: _('POLICIES_') . ' ' . $policies; |
|
61 |
$contents = implode(', ', $datasource -> contents); |
|
62 |
if ($contents != NULL) |
|
63 |
$data[] = JText :: _('CONTENTS_') . ' ' . $contents; |
|
64 |
if ($datasource -> url != NULL) |
|
65 |
$data[] = JText :: _('WEBSITE_URL_') . ' <a class="icon-external" target="_blank" href="' . $datasource -> url . '">' . $datasource -> url . '</a>'; |
|
66 |
$oaiPmh = implode(', ', array_filter(array_map(function ($url) { |
|
67 |
return ($url == NULL) ? '' : ('<a class="icon-external" target="_blank" href="' . $url . '">' . $url . '</a>'); |
|
68 |
}, $datasource -> oaiPmhUrls))); |
|
69 |
if ($oaiPmh != NULL) |
|
70 |
$data[] = JText :: _('OAI_PMH_URL_') . ' ' . $oaiPmh; |
|
71 |
|
|
72 |
return ($data == NULL) ? '' : ('<div class="biblio">' . implode('<br />', $data) . '</div>'); |
|
73 |
} |
|
74 |
|
|
75 |
public static function _formatItems($items, $date) { |
|
76 |
return (($items == NULL) && ($date == NULL)) ? '' : ('<span class="items">(' . JText :: sprintf('N_ITEMS', $items) . ((($items == NULL) || ($date == NULL)) ? ' - ' : ' - ') . (($date == NULL) ? '' : date(JText :: _('DATE_FORMAT'), $date)) . ', ' . JText :: _('FROM_OPENDOAR') .')</span>'); |
|
77 |
} |
|
78 |
|
|
79 |
public static function _formatOrganizations($organizations, $itemId) { |
|
80 |
$organizations = ($organizations == NULL) ? NULL : array_filter(array_map(function ($organization) use ($itemId) {return DatasourceHelper :: _formatOrganization($organization, $itemId);}, $organizations)); |
|
81 |
return ($organizations == NULL) ? '' : (implode(', ' , array_slice($organizations, 0, DatasourceHelper :: MAX_ORGANIZATIONS)) . ((count($organizations) > DatasourceHelper :: MAX_ORGANIZATIONS) ? ',...' : '') ); |
|
82 |
} |
|
83 |
|
|
84 |
public static function _formatOrganization($organization, $itemId) { |
|
85 |
return (($organization == NULL) || (($organization -> shortName == NULL) && ($organization -> name == NULL))) ? '' : ('<span class="organization">' . (($organization -> id == NULL) ? '' : ('<a href="' . JRoute :: _('index.php?option=com_openaire&view=organization&Itemid=' . $itemId . '&organizationId=' . $organization -> id) . '">')) . (($organization -> shortName == NULL) ? $organization -> name : $organization -> shortName) . (($organization -> id == NULL) ? '' : '</a>') . '</span>'); |
|
86 |
} |
|
87 |
|
|
88 |
public static function _formatDescription($description) { |
|
89 |
return ($description == NULL) ? '' : ('<div class="description">' . ((strlen($description) > DatasourceHelper :: MAX_DESCRIPTION) ? (substr($description, 0, DatasourceHelper :: MAX_DESCRIPTION - strlen(DatasourceHelper :: SUFFIX)) . DatasourceHelper :: SUFFIX) : $description) . '</div>'); |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
//$datasource -> url δεν το θέλουμε |
|
94 |
//$datasource -> oaiPmhUrls δεν τα θέλουμε |
|
95 |
|
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/helpers/browsehelper.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
defined('_JEXEC') or die('Access denied'); |
|
4 |
|
|
5 |
jimport('joomla.methods'); |
|
6 |
|
|
7 |
// This helper formats paging. |
|
8 |
abstract class BrowseHelper { |
|
9 |
const MAX_ROWS = 5; |
|
10 |
const MAX_ROW = 24; |
|
11 |
|
|
12 |
// Format browse. |
|
13 |
// $statistics the statistics to format |
|
14 |
// $baseUrl the base URL to use for links |
|
15 |
// return a string containing the full HTML for browse or an empty string if any errors occur |
|
16 |
public static function formatBrowse($statistics, $baseUrl) { |
|
17 |
return '<div class="quickViewSelections"><h3>' . JText :: _('AT_A_GLANCE') . '</h3><div class="flowWrapper">' . (($statistics == NULL) ? ('<div class="error">' . JText :: _('ERROR_RETRIEVING_STATISTICS') . '</div>') : implode('', array_map(function ($statistic) use ($baseUrl) {return BrowseHelper :: formatStatistic($statistic, $baseUrl);}, $statistics))) . '</div></div>'; |
|
18 |
} |
|
19 |
|
|
20 |
// Format a single statistic. |
|
21 |
// $statistic the statistic to format |
|
22 |
// $baseUrl the base URL to use for links |
|
23 |
// return a string containing the full HTML for the statistic or an empty string if any errors occur |
|
24 |
public static function formatStatistic($statistic, $baseUrl) { |
|
25 |
// TODO JRoute :: _ keeps decoding urlencoded values, so this is just a hack to cope with this |
|
26 |
$data = ($statistic -> data == NULL) ? NULL : array_map(function ($row) use ($statistic, $baseUrl) {return '<a href="' . JRoute :: _($baseUrl . '&' . urlencode($statistic -> id) . '=' . urlencode($row -> id)) . '" class="entry" title="' . $row -> name . '">' . ((strlen($row -> name) > BrowseHelper :: MAX_ROW) ? (substr($row -> name, 0, BrowseHelper :: MAX_ROW - strlen('...')) . '...') : $row -> name) . '</a> <span>(' . $row -> count . ')</span>';}, $statistic -> data); |
|
27 |
return '<div class="searchCol"><h5>' . $statistic -> title . '</h5>' . (($statistic -> data == NULL) ? ('<div class="box-info">' . $statistic -> error . '</div>') : ('<div><p>' . implode('<br />', array_slice($data, 0, BrowseHelper :: MAX_ROWS)) . ((count($data) > BrowseHelper :: MAX_ROWS) ? ('<br /><span class="viewmore">' . JText :: _('VIEW_MORE') . '</span>') : '') . '</p></div>')) . ((count($data) > BrowseHelper :: MAX_ROWS) ? ('<div style="display: none;"><div class="viewallpop"><div class="header"><h5>' . $statistic -> title . '</h5></div><p>' . implode('<br />', $data) . '</p></div></div>') : '') . '</div>'; |
|
28 |
} |
|
29 |
} |
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/helpers/openairehelper.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
defined('_JEXEC') or die('Access denied'); |
|
4 |
|
|
5 |
jimport('joomla.methods'); |
|
6 |
|
|
7 |
// This helper formats paging. |
|
8 |
abstract class OpenaireHelper { |
|
9 |
|
|
10 |
public static function initSearchAjaxUrls(&$document , $itemId) { |
|
11 |
jimport('joomla.language.helper'); |
|
12 |
$languages = JLanguageHelper::getLanguages('lang_code'); |
|
13 |
$lang_code = JFactory::getLanguage()->getTag(); |
|
14 |
$sef = $languages[$lang_code]->sef; |
|
15 |
$document->addScriptDeclaration("var openairePublicationsRawUrl = '" . JUri::base()."index.php?lang=".$sef."&option=com_openaire&view=searchpublicationsraw&format=raw&Itemid=" . $itemId . "'"); |
|
16 |
$document->addScriptDeclaration("var openaireDatasetsRawUrl = '" . JUri::base()."index.php?lang=".$sef."&option=com_openaire&view=searchdatasetsraw&format=raw&Itemid=" . $itemId . "'"); |
|
17 |
$document->addScriptDeclaration("var openaireProjectsRawUrl = '" . JUri::base()."index.php?lang=".$sef."&option=com_openaire&view=searchprojectsraw&format=raw&Itemid=" . $itemId . "'"); |
|
18 |
$document->addScriptDeclaration("var openairePeopleRawUrl = '" . JUri::base()."index.php?lang=".$sef."&option=com_openaire&view=searchpeopleraw&format=raw&Itemid=" . $itemId . "'"); |
|
19 |
$document->addScriptDeclaration("var openaireDatasourcesRawUrl = '" . JUri::base()."index.php?lang=".$sef."&option=com_openaire&view=searchdatasourcesraw&format=raw&Itemid=" . $itemId . "'"); |
|
20 |
$document->addScriptDeclaration("var openaireOrganizationsRawUrl = '" .JUri::base()."index.php?lang=".$sef."&option=com_openaire&view=searchorganizationsraw&format=raw&Itemid=" . $itemId. "'"); |
|
21 |
} |
|
22 |
|
|
23 |
} |
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/helpers/projecthelper.php.bak | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
defined('_JEXEC') or die('Access denied'); |
|
4 |
|
|
5 |
jimport('joomla.methods'); |
|
6 |
|
|
7 |
// This helper formats projects. |
|
8 |
abstract class ProjectHelper { |
|
9 |
const MAX_ORGANIZATIONS = 15; |
|
10 |
|
|
11 |
// Format a project. |
|
12 |
// $project the project to format |
|
13 |
// $itemId the item ID to use for internal links |
|
14 |
// return a string containing the full HTML for the project or an empty string if any errors occur |
|
15 |
public static function formatProject($project, $itemId) { |
|
16 |
if (($project == NULL) || (($project -> acronym == NULL) && ($project -> title == NULL))) |
|
17 |
return ''; |
|
18 |
return '<div class="srchRow"><h4' . ($project -> sc39 ? (' class="sc39" title="' . JText :: _('SPECIAL_CLAUSE_39') . '"') : '') . '>' . (($project -> id == NULL) ? '' : ('<a ' . 'href="' . JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=project&Itemid=' . $itemId . '&projectId=' . $project -> id) . '">')) . $project -> acronym . ((($project -> acronym == NULL) || ($project -> title == NULL)) ? '' : ' - ') . $project -> title . (($project -> code == NULL) ? '' : (' ('. $project -> code . ')')) . (($project -> id == NULL) ? '' : ('</a>')) . '</h4>' . ProjectHelper :: _formatData($project, $itemId) . '</div>'; |
|
19 |
} |
|
20 |
|
|
21 |
public static function _formatData($project, $itemId) { |
|
22 |
if ($project == NULL) |
|
23 |
return ''; |
|
24 |
$years = ProjectHelper :: _formatYears($project -> startYear, $project -> endYear); |
|
25 |
$organizations = ProjectHelper :: _formatOrganizations($project -> organizations, $itemId); |
|
26 |
return (($project -> funder == NULL) && ($organizations == NULL) && ($years == NULL)) ? '' : ('<div class="biblio">' . $project -> funder . ((($project -> funder == NULL) || ($years == NULL)) ? '' : ' ') . $years . (((($project -> funder == NULL) && ($years == NULL)) || ($organizations == NULL)) ? '' : '<br />') . (($organizations == NULL) ? '' : (JText :: _('PARTICIPANTS_') . ' ' . $organizations)) . '</div>'); |
|
27 |
} |
|
28 |
|
|
29 |
public static function _formatYears($startYear, $endYear) { |
|
30 |
return (($startYear == NULL) && ($endYear == NULL)) ? '' : ('<span class="year">(' . $startYear . ((($startYear == NULL) || ($endYear == NULL)) ? '' : ' - ') . $endYear . ')</span>'); |
|
31 |
} |
|
32 |
|
|
33 |
public static function _formatOrganizations($organizations, $itemId) { |
|
34 |
$organizations = ($organizations == NULL) ? NULL : array_filter(array_map(function ($organization) use ($itemId) {return ProjectHelper :: _formatOrganization($organization, $itemId);}, $organizations)); |
|
35 |
return ($organizations == NULL) ? '' : (implode(', ' , array_slice($organizations, 0, ProjectHelper :: MAX_ORGANIZATIONS)) . ((count($organizations) > ProjectHelper :: MAX_ORGANIZATIONS) ? ',...' : '')); |
|
36 |
} |
|
37 |
|
|
38 |
public static function _formatOrganization($organization, $itemId) { |
|
39 |
return (($organization == NULL) || (($organization -> shortName == NULL) && ($organization -> name == NULL))) ? '' : ('<span class="organization">' . (($organization -> id == NULL) ? '' : ('<a href="' . JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=organization&Itemid=' . $itemId . '&organizationId=' . $organization -> id) . '">')) . (($organization -> shortName == NULL) ? $organization -> name : $organization -> shortName) . (($organization -> id == NULL) ? '' : '</a>') . '</span>'); |
|
40 |
} |
|
41 |
} |
|
42 |
|
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/helpers/form.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
defined('_JEXEC') or die('Restricted access'); |
|
4 |
|
|
5 |
jimport('joomla.methods'); |
|
6 |
|
|
7 |
class OpenaireHelperForm { |
|
8 |
public static function openForm($parameters, $attributes) { |
|
9 |
global $app; |
|
10 |
$mainframe = $app; |
|
11 |
//$attributes['action'] = ($mainframe -> getCfg('sef') ? JRoute :: _('index.php?' . implode('&', array_map(function ($name, $value) {return $name . "=" . $value; }, array_keys($parameters), array_values($parameters)))) : 'index.php'); |
|
12 |
$attributes['action'] = JRoute :: _('index.php?' . implode('&', array_map(function ($name, $value) {return $name . "=" . $value; }, array_keys($parameters), array_values($parameters)))) ; |
|
13 |
echo('<form ' . implode(' ', array_map(function ($name, $value) {return $name . '="' . $value . '"'; }, array_keys($attributes), array_values($attributes))) . '>'); |
|
14 |
if (!$mainframe -> getCfg('sef')) { |
|
15 |
foreach ($parameters as $name => $value) |
|
16 |
echo('<input type="hidden" name="' . $name . '" value="' . $value . '" />'); |
|
17 |
} |
|
18 |
} |
|
19 |
|
|
20 |
public static function closeForm() { |
|
21 |
echo('</form>'); |
|
22 |
} |
|
23 |
} |
|
24 |
|
|
25 |
?> |
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/helpers/piwikhelper.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
defined('_JEXEC') or die('Access denied'); |
|
4 |
|
|
5 |
jimport('joomla.methods'); |
|
6 |
|
|
7 |
// This helper logs page views. |
|
8 |
abstract class PiwikHelper { |
|
9 |
const MAX_DATA = 200; |
|
10 |
|
|
11 |
// Log a page view in Piwik. |
|
12 |
// $title the page title to log |
|
13 |
// $data the data to log |
|
14 |
public static function logPageView($title, $data) { |
|
15 |
$parameters = JComponentHelper :: getParams('com_openaire'); |
|
16 |
$url = $parameters -> get('piwikUrl'); |
|
17 |
$siteId = $parameters -> get('piwikSiteId'); |
|
18 |
$document = JFactory :: getDocument(); |
|
19 |
$document -> addScript(JRoute :: _($url . 'piwik.js')); |
|
20 |
$document -> addScriptDeclaration('try{'); |
|
21 |
$document -> addScriptDeclaration('var tracker = Piwik.getTracker(\'' . $url . 'piwik.php\', ' . $siteId . ');'); |
|
22 |
$document -> addScriptDeclaration('tracker.setDocumentTitle(\''. $title . '\');'); |
|
23 |
$document -> addScriptDeclaration('tracker.setCustomVariable(1, \'user\', \'' . JFactory :: getUser() -> email . '\', \'page\');'); |
|
24 |
$document -> addScriptDeclaration('tracker.setCustomVariable(2, \'session\', \'' . JFactory :: getSession() -> getId() . '\', \'page\');'); |
|
25 |
$document -> addScriptDeclaration('tracker.setCustomVariable(3, \'data\', \'' . substr($data, 0, self :: MAX_DATA) . '\', \'page\');'); |
|
26 |
$document -> addScriptDeclaration('tracker.setCustomVariable(4, \'data\', \'' . substr($data, self :: MAX_DATA, 2 * self :: MAX_DATA) . '\', \'page\');'); |
|
27 |
$document -> addScriptDeclaration('tracker.setCustomVariable(5, \'data\', \'' . substr($data, 2 * self :: MAX_DATA, 3 * self :: MAX_DATA) . '\', \'page\');'); |
|
28 |
$document -> addScriptDeclaration('tracker.trackPageView(\'' . $title . '\');'); |
|
29 |
$document -> addScriptDeclaration('}'); |
|
30 |
$document -> addScriptDeclaration('catch(e){;}'); |
|
31 |
} |
|
32 |
} |
|
33 |
|
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/helpers/organizationhelper.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
defined('_JEXEC') or die('Access denied'); |
|
4 |
|
|
5 |
jimport('joomla.methods'); |
|
6 |
|
|
7 |
// This helper formats organizations. |
|
8 |
abstract class OrganizationHelper { |
|
9 |
const MAX_PROJECTS = 15; |
|
10 |
|
|
11 |
// Format an organization. |
|
12 |
// $organization the organization to format |
|
13 |
// $itemId the item ID to use for internal links |
|
14 |
// return a string containing the full HTML for the organization or an empty string if any errors occur |
|
15 |
public static function formatOrganization($organization, $itemId) { |
|
16 |
if (($organization == NULL) || (($organization -> name == NULL) && ($organization -> shortName == NULL))) |
|
17 |
return ''; |
|
18 |
$projects = OrganizationHelper :: _formatProjects($organization -> projects, $itemId); |
|
19 |
return '<div class="srchRow"><h4>' . (($organization -> id == NULL) ? '' : ('<a href="' . JRoute :: _('index.php?option=com_openaire&view=organization&Itemid=' . $itemId . '&organizationId=' . $organization -> id) . '">')) . $organization -> name . ((($organization -> name == NULL) || ($organization -> shortName == NULL)) ? '' : ' ') . (($organization -> shortName == NULL) ? '' : ('(' . $organization -> shortName . ')')) . (($organization -> id == NULL) ? '' : '</a>') . '</h4>' . ((($organization -> country) && ($projects == NULL)) ? '' : ('<div class="biblio">' . (($organization -> country == NULL) ? '' : (JText :: _('COUNTRY_') . ' ' . $organization -> country)) . ((($organization -> country == NULL) || ($projects == NULL)) ? '' : '<br />') . $projects . '</div>')) . '</div>'; |
|
20 |
} |
|
21 |
|
|
22 |
public static function _formatProjects($projects, $itemId) { |
|
23 |
$projects = ($projects == NULL) ? NULL : array_filter(array_map(function ($project) use ($itemId) {return OrganizationHelper :: _formatProject($project, $itemId);}, $projects)); |
|
24 |
return ($projects == NULL) ? '' : (JText :: _('PROJECTS_') . ' ' . implode(', ', array_slice($projects, 0, OrganizationHelper :: MAX_PROJECTS)) . ((count($projects) > OrganizationHelper :: MAX_PROJECTS) ? ',...' : '')); |
|
25 |
} |
|
26 |
|
|
27 |
public static function _formatProject($project, $itemId) { |
|
28 |
return (($project -> acronym == NULL) && ($project -> title == NULL)) ? '' : ('<span class="proj">' . (($project -> id == NULL) ? '' : ('<a href="' . JRoute :: _('index.php?option=com_openaire&view=project&Itemid=' . $itemId . '&projectId=' . $project -> id) . '">')) . (($project -> acronym == NULL) ? $project -> title : $project -> acronym) . (($project -> code == NULL) ? '' : (' (' . $project -> code . ')')) . (($project -> id == NULL) ? '' : '</a>') . '</span>'); |
|
29 |
} |
|
30 |
} |
|
31 |
|
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/helpers/index.html | ||
---|---|---|
1 |
<!DOCTYPE HTML> |
|
2 |
<html> |
|
3 |
<head> |
|
4 |
<title>OpenAIRE</title> |
|
5 |
</head> |
|
6 |
<body> |
|
7 |
<h1>Access denied</h1> |
|
8 |
</body> |
|
9 |
</html> |
|
10 |
|
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/helpers/paginghelper.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
defined('_JEXEC') or die('Access denied'); |
|
4 |
|
|
5 |
jimport('joomla.methods'); |
|
6 |
|
|
7 |
// This helper formats paging. |
|
8 |
abstract class PagingHelper { |
|
9 |
|
|
10 |
// Format paging. |
|
11 |
// $page the current page |
|
12 |
// $totalPages the total pages |
|
13 |
// $pagingStart the page to start paging from |
|
14 |
// $pagingEnd the page to end paging to |
|
15 |
// $baseUrl the base URL to use for links |
|
16 |
// $fragment the URL fragment to use for links |
|
17 |
// return a string containing the full HTML for paging or an empty string if any errors occur |
|
18 |
public static function formatPaging($page, $totalPages, $pagingStart, $pagingEnd, $baseUrl, $fragment) { |
|
19 |
// TODO JRoute :: _ keeps decoding urlencoded values, so this is just a hack to cope with this |
|
20 |
return '<div class="pages">' . (($page > 1) ? ('<a href="' . JRoute :: _($baseUrl . '1' . $fragment) . '"><<</a><a href="' . JRoute :: _($baseUrl . ($page - 1) . $fragment) . '"><</a>') : '') . implode('', array_map(function ($p) use ($page, $baseUrl, $fragment) {return ($p == $page) ? ('<a class="current">' . $p . '</a>') : ('<a href="' . JRoute :: _($baseUrl . $p . $fragment) . '">' . $p . '</a>');}, range($pagingStart, $pagingEnd))) . (($page < $totalPages) ? ('<a href="' . JRoute :: _($baseUrl . ($page + 1) . $fragment) . '">></a>') : '') . '</div>'; |
|
21 |
} |
|
22 |
|
|
23 |
public static function formatPagingForAjax($page, $totalPages, $pagingStart, $pagingEnd, $baseUrl, $fragment,$source) { |
|
24 |
return '<div class="pages">' . (($page > 1) ? ('<a href="' . JRoute :: _($baseUrl . '1' . $fragment) . '"><<</a> |
|
25 |
<a href="' . JRoute :: _($baseUrl . ($page - 1) . $fragment) . '"><</a>') : '') |
|
26 |
. implode('', |
|
27 |
array_map(function ($p) use ($page, $baseUrl, $fragment,$source) |
|
28 |
{ |
|
29 |
return ($p == $page) ? ('<a class="current">' . $p . '</a>') : |
|
30 |
('<a onclick="gotoPage(\''.$baseUrl .'\',\''. ($p).'\',\'' . ($source) .'\',\''. $fragment.'\');">' . $p . '</a>'); |
|
31 |
}, |
|
32 |
range($pagingStart, $pagingEnd))) . (($page < $totalPages) ? |
|
33 |
('<a onclick="gotoPage(\''.$baseUrl .'\',\'' . ($page + 1) .'\',\'' . ($source) .'\',\''. $fragment.'\');" >></a>') : '') . '</div>'; |
|
34 |
// href="' . JRoute :: _($baseUrl . ($page + 1) . $fragment) . '" |
|
35 |
} |
|
36 |
} |
|
37 |
|
modules/uoa-joomla/trunk/joomla-3.4/com_openaire/site/models/claim.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
defined('_JEXEC') or die('Access denied'); |
|
4 |
|
|
5 |
jimport('joomla.application.component.model'); |
|
6 |
jimport('joomla.http.http'); |
|
7 |
jimport('joomla.log.log'); |
|
8 |
|
|
9 |
$GLOBALS['THRIFT_ROOT'] = dirname(__FILE__) . DS . 'thrift'; |
|
10 |
require_once($GLOBALS['THRIFT_ROOT'] . DS . 'Thrift.php'); |
|
11 |
require_once($GLOBALS['THRIFT_ROOT'] . DS . 'protocol' . DS . 'TBinaryProtocol.php'); |
|
12 |
require_once($GLOBALS['THRIFT_ROOT'] . DS . 'transport' . DS . 'TSocket.php'); |
|
13 |
require_once($GLOBALS['THRIFT_ROOT'] . DS . 'transport' . DS . 'TBufferedTransport.php'); |
|
14 |
require_once($GLOBALS['THRIFT_ROOT'] . DS . 'packages' . DS . 'OpenAIREConnector' . DS . 'OpenAIREConnector.php'); |
|
15 |
|
|
16 |
|
|
17 |
// This model manages claims. |
|
18 |
class OpenAireModelClaim extends JModelItem { |
|
19 |
const SELECTED_PROJECTS = 'selectedProjects'; |
|
20 |
const SELECTED_CONCEPTS = 'selectedConcepts'; |
|
21 |
const SELECTED_PUBLICATIONS = 'selectedPublications'; |
|
22 |
const SEARCH_DOI_CACHE_ID = 'search.doi'; |
|
23 |
const SEARCH_DATASET_CACHE_ID = 'search.datacite'; |
|
24 |
const SEARCH_ORCID_CACHE_ID = 'search.orcid'; |
|
25 |
const CLAIMED_PUBLICATIONS_CACHE_ID = 'claimed.publications'; |
|
26 |
const CACHE_GROUP = 'openaire.claim'; |
|
27 |
const CROSSREF_URL = 'http://www.crossref.org/openurl?noredirect=true&pid=antleb%40di.uoa.gr&format=unixref&id='; |
|
28 |
const CROSSREF_API_DOI = 'http://api.crossref.org/works/'; |
|
29 |
const CROSSREF_API_KEYWORD = 'http://api.crossref.org/works?query='; |
|
30 |
const DOI_SCHEME = 'doi:'; |
|
31 |
const DATACITE_URL = 'http://data.datacite.org/application/rdf+xml/'; |
|
32 |
const DATACITE_URL_KEYWORD = 'http://search.datacite.org/api?q='; |
|
33 |
const DATACITE_URL_KEYWORD_REST = '&fl=doi,title,creator,publisher,created&wt=xml'; |
|
34 |
const DOI_URL = 'http://dx.doi.org/'; |
|
35 |
const ORCID_URL_PREFIX = 'http://pub.orcid.org/'; |
|
36 |
const ORCID_URL_PUBLICATIONS_SUFFIX = '/orcid-works'; |
|
37 |
const ORCID_URL_AUTHOR_SUFFIX = '/orcid-bio'; |
|
38 |
const HTTP_OK = 200; |
|
39 |
const HTTP_NOT_FOUND = 404; |
|
40 |
const DOI = 'doi'; |
|
41 |
const ORCID = 'orcid'; |
|
42 |
const DATACITE = 'datacite'; |
|
43 |
const RELATION = 'rels2actions'; |
|
44 |
const DMF = 'dmf2actions'; |
|
45 |
const UNDETERMINED = 'Undetermined'; |
|
46 |
const LOG = 'openaire'; |
|
47 |
//claim modes |
|
48 |
const CLAIM = 'claim'; |
|
49 |
const CLAIMINLINE = 'claiminline'; |
|
50 |
const CLAIMINLINE2 = 'claiminline2'; |
|
51 |
|
|
52 |
private $cache; |
|
53 |
private $http; |
|
54 |
private $transport; |
|
55 |
private $client; |
|
56 |
|
|
57 |
// Construct a new OpenAireModelClaim. |
|
58 |
// $configuration the configuration to use |
|
59 |
public function __construct($configuration) { |
|
60 |
parent :: __construct($configuration); |
|
61 |
$this -> cache = JCache :: getInstance(); |
|
62 |
$this -> http = new JHttp(); |
|
63 |
$parameters = JComponentHelper :: getParams('com_openaire'); |
|
64 |
$socket = new TSocket($parameters -> get('thriftHost'), intval($parameters -> get('thriftPort'))); |
|
65 |
$socket -> setRecvTimeout(intval($parameters -> get('thriftTimeout'))); |
|
66 |
$this -> transport = new TBufferedTransport($socket); |
|
67 |
$this -> client = new OpenAIREConnectorClient(new TBinaryProtocol($this -> transport)); |
|
68 |
$this -> transport -> open(); |
|
69 |
} |
|
70 |
|
|
71 |
// Close Thrift transport |
|
72 |
public function __destruct() { |
|
73 |
$this -> transport -> close(); |
|
74 |
} |
|
75 |
|
|
76 |
// Get the selected projects stored in session. |
|
77 |
// return the selected projects (array) or NULL if any errors occur |
|
78 |
public function getSelectedProjects($suffix = self :: CLAIM) { |
|
79 |
try { |
|
80 |
$projects = unserialize(JFactory :: getSession() -> get(self :: SELECTED_PROJECTS . $suffix, serialize(array()))); |
|
81 |
JLog :: add('Retrieved ' . count($projects) . ' selected projects', JLog :: INFO, self :: LOG); |
|
82 |
return $projects; |
|
83 |
} catch (Exception $e) { |
|
84 |
JLog :: add('Error retrieving selected projects: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
85 |
return NULL; |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
// Add a project to the selected projects stored in session. |
|
90 |
// $project the project to add |
|
91 |
public function addSelectedProject($project, $suffix = self :: CLAIM) { |
|
92 |
try { |
|
93 |
$session = JFactory :: getSession(); |
|
94 |
$projects = unserialize($session -> get(self :: SELECTED_PROJECTS . $suffix, serialize(array()))); |
|
95 |
$projects[$project -> id] = $project; |
|
96 |
$session -> set(self :: SELECTED_PROJECTS . $suffix, serialize($projects)); |
|
97 |
JLog :: add('Added project ' . $project -> id . ' to selected projects', JLog :: INFO, self :: LOG); |
|
98 |
} catch (Exception $e) { |
|
99 |
JLog :: add('Error adding project ' . $project -> id . ' to selected projects: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
// Remove a project from the selected projects stored in session. |
|
104 |
// $projectId the identifier of the project to remove |
|
105 |
public function removeSelectedProject($projectId, $suffix = self :: CLAIM) { |
|
106 |
try { |
|
107 |
$session = JFactory :: getSession(); |
|
108 |
$projects = unserialize($session -> get(self :: SELECTED_PROJECTS . $suffix, serialize(array()))); |
|
109 |
unset($projects[$projectId]); |
|
110 |
$session -> set(self :: SELECTED_PROJECTS . $suffix, serialize($projects)); |
|
111 |
JLog :: add('Removed project ' . $projectId . ' from selected projects', JLog :: INFO, self :: LOG); |
|
112 |
} catch (Exception $e) { |
|
113 |
JLog :: add('Error removing project ' . $projectId . ' from selected projects: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
114 |
} |
|
115 |
} |
|
116 |
|
|
117 |
//empties selected concepts |
|
118 |
public function emptySelectedProjects($suffix = self :: CLAIM) { |
|
119 |
try { |
|
120 |
$session = JFactory :: getSession(); |
|
121 |
$session -> set(self :: SELECTED_PROJECTS . $suffix, serialize(array())); |
|
122 |
} catch (Exception $e) { |
|
123 |
; |
|
124 |
} |
|
125 |
} |
|
126 |
//empties selected publications |
|
127 |
public function emptySelectedPublications($suffix = self :: CLAIM) { |
|
128 |
try { |
|
129 |
$session = JFactory :: getSession(); |
|
130 |
$session -> set(self :: SELECTED_PUBLICATIONS . $suffix, serialize(array())); |
|
131 |
} catch (Exception $e) { |
|
132 |
; |
|
133 |
} |
|
134 |
} |
|
135 |
//Get concept using id |
|
136 |
//returns concept object or error |
|
137 |
public function getConcept($conceptId, $withChildren = false){ |
|
138 |
$contexts = $this->getContexts(); |
|
139 |
|
|
140 |
$concept = new JObject(); |
|
141 |
$concept->context = new JObject(); |
|
142 |
$concept->category = new JObject(); |
|
143 |
$concept->concepts = array(); |
|
144 |
$concept->id = $conceptId; |
|
145 |
|
|
146 |
$data = explode("::", $conceptId); |
|
147 |
if (count($data) > 1){ |
|
148 |
list ($context, $category) = $data; |
|
149 |
$category = $context . "::" . $category; |
|
150 |
} |
|
151 |
else{ |
|
152 |
$context = $data[0]; |
|
153 |
$category = null; |
|
154 |
} |
|
155 |
if (!isset($contexts[$context])) |
|
156 |
return NULL; |
|
157 |
|
|
158 |
$concept->context->id = $context; |
|
159 |
$concept->context->name = $contexts[$context]->name; |
|
160 |
if ($category == null){ |
|
161 |
$concept->category = null; |
|
162 |
$concept->path = $this->getConceptPath($concept); |
|
163 |
return $concept; |
|
164 |
} |
|
165 |
if (!isset($contexts[$context]->categories[$category])) |
|
166 |
return NULL; |
|
167 |
|
|
168 |
$concept->category->id = $category; |
|
169 |
$concept->category->name = $contexts[$context]->categories[$category]->name; |
|
170 |
|
|
171 |
$concepts = $contexts[$context]->categories[$category]->concepts; |
|
172 |
$conceptId2 = $category; |
|
173 |
for ($i = 2; $i < count($data); $i++){ |
|
174 |
$conceptId2 = $conceptId2 . "::" . $data[$i]; |
|
175 |
$concept_s = new JObject(); |
|
176 |
$concept_s -> id = $conceptId2; |
|
177 |
$concept_s -> name = $concepts[$conceptId2] -> name; |
|
178 |
$concepts = isset($concepts[$conceptId2] -> concepts)?$concepts[$conceptId2] -> concepts:array(); |
|
179 |
$concept_s -> concepts = $concepts; |
|
180 |
$concept -> concepts[] = $concept_s; |
|
181 |
} |
|
182 |
|
|
183 |
$concept->path = $this->getConceptPath($concept); |
|
184 |
return $concept; |
|
185 |
} |
|
186 |
|
|
187 |
//Get concept using id |
|
188 |
//returns concept object or error |
|
189 |
public function getConceptPath($concept){ |
|
190 |
$path = $concept->context->name . ($concept->category != null?" > " . $concept->category->name:""); |
|
191 |
$concept_parts = array(); |
|
192 |
foreach ($concept -> concepts as $concept_part){ |
|
193 |
$concept_parts[] = $concept_part -> name; |
|
194 |
} |
|
195 |
$path = $path . (count($concept_parts)?" > " . implode(" > ", $concept_parts):""); |
|
196 |
return $path; |
|
197 |
} |
|
198 |
|
|
199 |
// Get the selected concepts stored in session. |
|
200 |
// return the selected concepts (array) or NULL if any errors occur |
|
201 |
public function getSelectedConcepts($suffix = self :: CLAIM) { |
|
202 |
try { |
|
203 |
$concepts = unserialize(JFactory :: getSession() -> get(self :: SELECTED_CONCEPTS . $suffix, serialize(array()))); |
|
204 |
JLog :: add('Retrieved ' . count($concepts) . ' selected concepts', JLog :: INFO, self :: LOG); |
|
205 |
return $concepts; |
|
206 |
} catch (Exception $e) { |
|
207 |
JLog :: add('Error retrieving selected concepts: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
208 |
return NULL; |
|
209 |
} |
|
210 |
} |
|
211 |
|
|
212 |
// Add a project to the selected projects stored in session. |
|
213 |
// $project the project to add |
|
214 |
public function addSelectedConcept($concept, $suffix = self :: CLAIM) { |
|
215 |
try { |
|
216 |
$session = JFactory :: getSession(); |
|
217 |
$concepts = unserialize($session -> get(self :: SELECTED_CONCEPTS . $suffix, serialize(array()))); |
|
218 |
$concepts[$concept -> id] = $concept; |
|
219 |
$session -> set(self :: SELECTED_CONCEPTS . $suffix, serialize($concepts)); |
|
220 |
JLog :: add('Added project ' . $concept -> id . ' to selected projects', JLog :: INFO, self :: LOG); |
|
221 |
} catch (Exception $e) { |
|
222 |
JLog :: add('Error adding project ' . $concept -> id . ' to selected projects: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 |
// Remove a project from the selected projects stored in session. |
|
227 |
// $projectId the identifier of the project to remove |
|
228 |
public function removeSelectedConcept($conceptId, $suffix = self :: CLAIM) { |
|
229 |
try { |
|
230 |
$session = JFactory :: getSession(); |
|
231 |
$concepts = unserialize($session -> get(self :: SELECTED_CONCEPTS . $suffix, serialize(array()))); |
|
232 |
unset($concepts[$conceptId]); |
|
233 |
$session -> set(self :: SELECTED_CONCEPTS . $suffix, serialize($concepts)); |
|
234 |
JLog :: add('Removed project ' . $conceptId . ' from selected projects', JLog :: INFO, self :: LOG); |
|
235 |
} catch (Exception $e) { |
|
236 |
JLog :: add('Error removing project ' . $conceptId . ' from selected projects: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
237 |
} |
|
238 |
} |
|
239 |
|
|
240 |
//empties selected concepts |
|
241 |
public function emptySelectedConcepts($suffix = self :: CLAIM) { |
|
242 |
try { |
|
243 |
$session = JFactory :: getSession(); |
|
244 |
$session -> set(self :: SELECTED_CONCEPTS . $suffix, serialize(array())); |
|
245 |
} catch (Exception $e) { |
|
246 |
; |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 |
|
|
251 |
// Get the selected publications stored in session. |
|
252 |
// return the selected publications (arary) or NULL if any errors occur |
|
253 |
public function getSelectedPublications($suffix = self :: CLAIM) { |
|
254 |
try { |
|
255 |
$publications = unserialize(JFactory :: getSession() -> get(self :: SELECTED_PUBLICATIONS . $suffix, serialize(array()))); |
|
256 |
JLog :: add('Retrieved ' . count($publications) . ' selected publications', JLog :: INFO, self :: LOG); |
|
257 |
return $publications; |
|
258 |
} catch (Exception $e) { |
|
259 |
JLog :: add('Error retrieving selected publications: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
260 |
return NULL; |
|
261 |
} |
|
262 |
} |
|
263 |
|
|
264 |
// Add a publication to the selected publications stored in session. |
|
265 |
// $publication the publication to add |
|
266 |
public function addSelectedPublication($publication, $suffix = self :: CLAIM) { |
|
267 |
try { |
|
268 |
$session = JFactory :: getSession(); |
|
269 |
$publications = unserialize($session -> get(self :: SELECTED_PUBLICATIONS . $suffix, serialize(array()))); |
|
270 |
$publications[$publication -> source . $publication -> id] = $publication; |
|
271 |
$session -> set(self :: SELECTED_PUBLICATIONS . $suffix, serialize($publications)); |
|
272 |
JLog :: add('Added ' . $publication -> source . ' publication ' . $publication -> id . ' to selected publications', JLog :: INFO, self :: LOG); |
|
273 |
} catch (Exception $e) { |
|
274 |
JLog :: add('Error adding ' . $publication -> source . ' publication ' . $publication -> id . ' to selected publications: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
275 |
} |
|
276 |
} |
|
277 |
|
|
278 |
// Remove a publication from the selected publications stored in session. |
|
279 |
// $source the source of the publication to remove |
|
280 |
// $publicationId the identifier of the publication to remove |
|
281 |
public function removeSelectedPublication($source, $publicationId, $suffix = self :: CLAIM) { |
|
282 |
try { |
|
283 |
$session = JFactory :: getSession(); |
|
284 |
$publications = unserialize($session -> get(self :: SELECTED_PUBLICATIONS . $suffix, serialize(array()))); |
|
285 |
unset($publications[$source . $publicationId]); |
|
286 |
$session -> set(self :: SELECTED_PUBLICATIONS. $suffix, serialize($publications)); |
|
287 |
JLog :: add('Removed ' . $source . ' publication ' . $publicationId . ' from selected publications', JLog :: INFO, self :: LOG); |
|
288 |
} catch (Exception $e) { |
|
289 |
JLog :: add('Error removing ' . $source . ' publication ' . $publicationId . ' from selected publications: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
290 |
} |
|
291 |
} |
|
292 |
|
|
293 |
// Claim all the selected publications. |
|
294 |
// $user the user to claim publications for |
|
295 |
public function claimSelectedPublications($user, $mode = self :: CLAIM, $activePublication = NULL, $suffix = "", $activePublicationType = "publication") { |
|
296 |
try { |
|
297 |
$projects = array_map(function ($project) { |
|
298 |
$project2 = new Project(); |
|
299 |
$project2 -> projectId = $project -> id; |
|
300 |
$project2 -> type = NULL; |
|
301 |
return $project2;}, $this -> getSelectedProjects($mode.$suffix)); |
|
302 |
$concepts = array_map(function ($concept) {return $concept -> id;}, $this -> getSelectedConcepts($mode.$suffix)); |
|
303 |
if ($mode != self :: CLAIMINLINE){ |
|
304 |
$selectedPublications = $this -> getSelectedPublications($mode.$suffix); |
|
305 |
} |
|
306 |
else { |
|
307 |
$selectedPublications = array($activePublication); |
|
308 |
} |
|
309 |
$dcSource = NULL; |
|
310 |
$subjects = array(); |
|
311 |
$category = NULL; |
|
312 |
|
|
313 |
foreach ($selectedPublications as $publication) { |
|
314 |
$authors = array_map(function ($author) { |
|
315 |
$a = array(); |
|
316 |
$a['id'] = $author -> id; |
|
317 |
$a['firstName'] = $author -> firstName; |
|
318 |
$a['lastName'] = $author -> lastName; |
|
319 |
if (($author -> lastName == NULL) && ($author -> fullName != NULL)) |
|
320 |
$a['lastName'] = $author -> fullName; |
|
321 |
return new Author($a); |
|
322 |
}, $publication -> authors); |
|
323 |
$doi = (($publication -> source == self :: DOI) || ($publication -> source == self :: DATACITE)) ? $publication -> id : NULL; |
|
324 |
if ($mode != self :: CLAIMINLINE and $publication -> source != "openaire"){ |
|
325 |
$docId = $this -> client -> insertDocument($publication -> id, $publication -> source, $publication -> title, $publication -> description, isset($publication -> license)?$publication -> license:"", $publication -> embargoEndDate, $authors, $publication -> url, $dcSource, $user -> email, $subjects, $publication -> year, $publication -> publisher, $publication -> language, $category, $doi); |
|
326 |
}else{ |
|
327 |
|
|
328 |
$docId = $publication->id; |
|
329 |
} |
|
330 |
foreach ($concepts as $concept) |
|
331 |
$this -> client -> insertConcept($docId, $publication -> source, $concept, $user -> email); |
|
332 |
foreach ($projects as $project){ |
|
333 |
$this -> client -> insertProjectRelation($docId, $publication -> source, $project, $user -> email); |
|
334 |
} |
|
335 |
if ($activePublication != NULL && $mode === self::CLAIMINLINE2){ |
|
336 |
$this -> client -> insertResultRelation($activePublication -> id, $activePublicationType, |
|
337 |
$activePublication -> source, $docId, $publication -> claim_type, $user -> email); |
|
338 |
} |
|
339 |
} |
|
340 |
if ($this -> cache -> getCaching()){ |
|
341 |
$cacheId = self :: CLAIMED_PUBLICATIONS_CACHE_ID . '.' . $user -> username; |
|
342 |
$this -> cache ->remove($cacheId); |
|
343 |
} |
|
344 |
JLog :: add('Claimed ' . count($selectedPublications) . ' publications (user: ' . $user -> username . ')', JLog :: INFO, self :: LOG); |
|
345 |
return true; |
|
346 |
} catch (Exception $e) { |
|
347 |
JLog :: add('Error claiming selected publications (user: ' . $user -> username . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
348 |
return false; |
|
349 |
} |
|
350 |
} |
|
351 |
|
|
352 |
// Get the publications claimed by a user using caching if enabled. |
|
353 |
// $user the user whose claimed publications to retrieve |
|
354 |
// return an array of publications |
|
355 |
public function getClaimedPublications($user) { |
|
356 |
/* if ($this -> cache -> getCaching()) { |
|
357 |
$cacheId = self :: CLAIMED_PUBLICATIONS_CACHE_ID . '.' . $user -> username; |
|
358 |
$publications = $this -> cache -> get($cacheId, self :: CACHE_GROUP); |
|
359 |
if ($publications === FALSE) { |
|
360 |
$publications = $this -> _getClaimedPublications($user); |
|
361 |
if ($publications !== NULL) |
|
362 |
$this -> cache -> store($publications, $cacheId, self :: CACHE_GROUP); |
|
363 |
} |
|
364 |
} else |
|
365 |
*/ $publications = $this -> _getClaimedPublications($user); |
|
366 |
return $publications; |
|
367 |
} |
|
368 |
|
|
369 |
// Get the publications claimed by a user using caching if enabled. |
|
370 |
// $user the user whose claimed publications to retrieve |
|
371 |
// return an array of publications |
|
372 |
public function getAllClaimedPublications($from, $to) { |
|
373 |
/*if ($this -> cache -> getCaching()) { |
|
374 |
$cacheId = self :: CLAIMED_PUBLICATIONS_CACHE_ID . '.' . $from . "." . $to; |
|
375 |
$publications = $this -> cache -> get($cacheId, self :: CACHE_GROUP); |
|
376 |
if ($publications === FALSE) { |
|
377 |
$publications = $this -> _getAllClaimedPublications($from, $to); |
|
378 |
if ($publications !== NULL) |
|
379 |
$this -> cache -> store($publications, $cacheId, self :: CACHE_GROUP); |
|
380 |
} |
|
381 |
} else*/ |
|
382 |
$publications = $this -> _getAllClaimedPublicationsExtended($from, $to); |
|
383 |
return $publications; |
|
384 |
} |
|
385 |
|
|
386 |
// Search for a publication DOI using caching if enabled. |
|
387 |
// $doi the publication DOI to search for |
|
388 |
// return an array of results |
|
389 |
public function searchDOI($doi, $page, $size) { |
|
390 |
if ($this -> cache -> getCaching()) { |
|
391 |
$cacheId = self :: SEARCH_DOI_CACHE_ID . '.' . $doi; |
|
392 |
$results = $this -> cache -> get($cacheId, self :: CACHE_GROUP); |
|
393 |
if ($results === FALSE) { |
|
394 |
$results = $this -> _searchDOI($doi, $page, $size); |
|
395 |
if ($results !== NULL) |
|
396 |
$this -> cache -> store($results, $cacheId, self :: CACHE_GROUP); |
|
397 |
} |
|
398 |
} else |
|
399 |
$results = $this -> _searchDOI($doi, $page, $size); |
|
400 |
return $results; |
|
401 |
} |
|
402 |
|
|
403 |
// Search for a dataset DOI using caching if enabled. |
|
404 |
// $doi the dataset DOI to search for |
|
405 |
// return a result (object) containing publications and total |
|
406 |
public function searchDataCite($doi, $page, $size) { |
|
407 |
if ($this -> cache -> getCaching()) { |
|
408 |
$cacheId = self :: SEARCH_DATASET_CACHE_ID . '.' . $doi; |
|
409 |
$results = $this -> cache -> get($cacheId, self :: CACHE_GROUP); |
|
410 |
if ($results === FALSE) { |
|
411 |
$results = $this -> _searchDataCite($doi, $page, $size); |
|
412 |
if ($results !== NULL) |
|
413 |
$this -> cache -> store($results, $cacheId, self :: CACHE_GROUP); |
|
414 |
} |
|
415 |
} else |
|
416 |
$results = $this -> _searchDataCite($doi, $page, $size); |
|
417 |
return $results; |
|
418 |
} |
|
419 |
|
|
420 |
// Search for publications in ORCID using caching if enabled. |
|
421 |
// $doi the ORCID id to search for |
|
422 |
// $page the result page to retrieve |
|
423 |
// $size the result page size to use |
|
424 |
// return a result (object) containing datasets and total |
|
425 |
public function searchORCID($orcid, $page, $size) { |
|
426 |
if ($this -> cache -> getCaching()) { |
|
427 |
$cacheId = self :: SEARCH_ORCID_CACHE_ID . '.' . $orcid . '.' . $page . '.' . $size; |
|
428 |
$results = $this -> cache -> get($cacheId, self :: CACHE_GROUP); |
|
429 |
if ($results === FALSE) { |
|
430 |
$results = $this -> _searchORCID($orcid, $page, $size); |
|
431 |
if ($results !== NULL) |
|
432 |
$this -> cache -> store($results, $cacheId, self :: CACHE_GROUP); |
|
433 |
} |
|
434 |
} else |
|
435 |
$results = $this -> _searchORCID($orcid, $page, $size); |
|
436 |
|
|
437 |
return $results; |
|
438 |
} |
|
439 |
|
|
440 |
// Get the publications claimed by a user. |
|
441 |
// $user the user whose claimed publications to retrieve |
|
442 |
// return an array of publications or NULL if any errors occur |
|
443 |
private function _getClaimedPublications($user) { |
|
444 |
try { |
|
445 |
$locale = JFactory :: getLanguage()->getTag(); |
|
446 |
$claimedPublications = array(); |
|
447 |
$claimedPublicationsGrouped = array(); |
|
448 |
$time = microtime(TRUE); |
|
449 |
$claims = $this -> client -> getClaimedPublications($user -> email); |
|
450 |
foreach ($claims as $claim){ |
|
451 |
$parsedClaim = $this -> parseClaimedPublication($claim); |
|
452 |
if ($parsedClaim == null) |
|
453 |
continue; |
|
454 |
$claimedPublications[] = $parsedClaim; |
|
455 |
} |
|
456 |
$resultsToGet = array(); |
|
457 |
$projectsToGet = array(); |
|
458 |
$claimedDocuments = array(); |
|
459 |
foreach ($claimedPublications as $claimedPublication){ |
|
460 |
if ($claimedPublication -> publication != null and $claimedPublication -> publication -> id != null) |
|
461 |
$claimedDocuments[$claimedPublication->publicationId] = $claimedPublication -> publication; |
|
462 |
if ($claimedPublication -> projectId !== null){ |
|
463 |
$projectsToGet[] = $claimedPublication -> projectId; |
|
464 |
} |
|
465 |
if ($claimedPublication -> targetPublicationId !== null){ |
|
466 |
$resultsToGet[] = $claimedPublication -> targetPublicationId; |
|
467 |
} |
|
468 |
if ($claimedPublication -> targetDatasetId !== null){ |
|
469 |
$resultsToGet[] = $claimedPublication -> targetDatasetId; |
|
470 |
} |
|
471 |
if (($claimedPublication -> publication == null || ($claimedPublication -> publication != null and $claimedPublication -> publication -> id == null))){ |
|
472 |
$resultsToGet[] = $claimedPublication -> publicationId; |
|
473 |
} |
|
474 |
if ($claimedPublication -> publication == null && $claimedPublication -> type == "dataset"){ |
|
475 |
$resultsToGet[] = $claimedPublication -> publicationId; |
|
476 |
} |
|
477 |
} |
|
478 |
$resultsToGet = array_unique($resultsToGet); |
|
479 |
$projectsToGet = array_unique($projectsToGet); |
|
480 |
$searchModel = new OpenAireModelSearch(); |
|
481 |
$results = $searchModel->getResults($resultsToGet, $locale); |
|
482 |
$projects = $searchModel->getProjects($projectsToGet, $locale); |
|
483 |
$keydResults = array(); |
|
484 |
$keydProjects = array(); |
|
485 |
foreach ($results as $result) |
|
486 |
$keydResults[$result->id] = $result; |
|
487 |
foreach ($projects as $project) |
|
488 |
$keydProjects[$project->id] = $project; |
|
489 |
|
|
490 |
foreach ($claimedPublications as $claimedPublication){ |
|
491 |
if (!isset($claimedPublicationsGrouped[$claimedPublication -> publicationId])){ |
|
492 |
if ($claimedPublication -> publication == null || $claimedPublication -> publication -> id == null){ |
|
493 |
$publication = isset($keydResults[$claimedPublication -> publicationId])?$keydResults[$claimedPublication -> publicationId]:null; |
|
494 |
} |
|
495 |
else{ |
|
496 |
$publication = $claimedPublication -> publication; |
|
497 |
} |
|
498 |
if ($publication == null || $publication -> id == null) |
|
499 |
continue; |
|
500 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] = new stdClass(); |
|
501 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publicationId = $claimedPublication -> publicationId; |
|
502 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> date = $claimedPublication -> date; |
|
503 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publication = $publication; |
|
504 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publications = array(); |
|
505 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> datasets = array(); |
|
506 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> projects = array(); |
|
507 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> concepts = array(); |
|
508 |
} |
|
509 |
if ($claimedPublicationsGrouped[$claimedPublication -> publicationId] -> date < $claimedPublication -> date) |
|
510 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> date = $claimedPublication -> date; |
|
511 |
if ($claimedPublication -> publication != null){ |
|
512 |
$claimedConcepts = array(); |
|
513 |
foreach ($claimedPublication -> publication -> concepts as $concept){ |
|
514 |
$concept = $this->getConcept($concept); |
|
515 |
$claimedConcept = new stdClass(); |
|
516 |
$claimedConcept->id = $concept->id; |
|
517 |
$claimedConcept->title = $concept->path; |
|
518 |
$claimedConcept->date = $claimedPublication->date; |
|
519 |
$claimedConcepts[] = $claimedConcept; |
|
520 |
} |
|
521 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> concepts = array_merge($claimedPublicationsGrouped[$claimedPublication -> publicationId] -> concepts, $claimedConcepts); |
|
522 |
} |
|
523 |
if ($claimedPublication -> targetPublicationId !== null){ |
|
524 |
$claimedPublication->title = isset($keydResults[$claimedPublication -> targetPublicationId ])?$keydResults[$claimedPublication -> targetPublicationId ]->title:null; |
|
525 |
if ($claimedPublication->title == null){ |
|
526 |
$claimedPublication->title = isset($claimedDocuments[$claimedPublication -> targetDatasetId ])?$claimedDocuments[$claimedPublication -> targetDatasetId ]->title:null; |
|
527 |
} |
|
528 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publications[] = $claimedPublication; |
|
529 |
} |
|
530 |
if ($claimedPublication -> targetDatasetId !== null){ |
|
531 |
$claimedPublication->title = isset($keydResults[$claimedPublication -> targetDatasetId ])?$keydResults[$claimedPublication -> targetDatasetId ]->title:null; |
|
532 |
if ($claimedPublication->title == null){ |
|
533 |
$claimedPublication->title = isset($claimedDocuments[$claimedPublication -> targetDatasetId ])?$claimedDocuments[$claimedPublication -> targetDatasetId ]->title:null; |
|
534 |
} |
|
535 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> datasets[] = $claimedPublication; |
|
536 |
} |
|
537 |
if ($claimedPublication -> projectId !== null){ |
|
538 |
$claimedPublication->title = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->title:null; |
|
539 |
$claimedPublication->acronym = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->acronym:null; |
|
540 |
$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> projects[] = $claimedPublication; |
|
541 |
|
|
542 |
} |
|
543 |
} |
|
544 |
JLog :: add('Retrieved ' . count($claimedPublications) . ' claimed publications (user: ' . $user -> username . ') in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); |
|
545 |
return $claimedPublicationsGrouped; |
|
546 |
} catch (Exception $e) { |
|
547 |
JLog :: add('Error retrieving claimed publications (user: ' . $user -> username . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
548 |
return NULL; |
|
549 |
} |
|
550 |
} |
|
551 |
public function _getAllClaimedPublications($from, $to) { |
|
552 |
try { |
|
553 |
// submit the docs |
|
554 |
$claimedPublications = array(); |
|
555 |
$time1 = strtotime(str_replace("/", "-", $from)) * 1000; |
|
556 |
$time2 = strtotime(str_replace("/", "-", $to)) * 1000; |
|
557 |
$list = $this->client ->getAllClaimedPublications($time1, $time2); |
|
558 |
foreach ($list as $claim){ |
|
559 |
$claimedPublications[] = $this -> parseClaimedPublication($claim); |
|
560 |
} |
|
561 |
} |
|
562 |
catch (Exception $e) { |
|
563 |
JLog :: add('Error retrieving all claims (from: ' . $from . ', to: '. $to .'): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
564 |
return NULL; |
|
565 |
} |
|
566 |
return $claimedPublications; |
|
567 |
} |
|
568 |
// Get the publications claimed |
|
569 |
// return an array of publications or NULL if any errors occur |
|
570 |
private function _getAllClaimedPublicationsExtended($from, $to) { |
|
571 |
try { |
|
572 |
$locale = JFactory :: getLanguage()->getTag(); |
|
573 |
$claimedPublications = array(); |
|
574 |
$claimedPublicationsExtended = array(); |
|
575 |
$time = microtime(TRUE); |
|
576 |
$time1 = strtotime(str_replace("/", "-", $from)) * 1000; |
|
577 |
$time2 = strtotime(str_replace("/", "-", $to)) * 1000; |
|
578 |
$claims = $this->client ->getAllClaimedPublications($time1, $time2); |
|
579 |
foreach ($claims as $claim){ |
|
580 |
$parsedClaim = $this -> parseClaimedPublication($claim); |
|
581 |
if ($parsedClaim == null) |
|
582 |
continue; |
|
583 |
$claimedPublications[] = $parsedClaim; |
|
584 |
} |
|
585 |
$resultsToGet = array(); |
|
586 |
$projectsToGet = array(); |
|
587 |
$claimedDocuments = array(); |
|
588 |
foreach ($claimedPublications as $claimedPublication){ |
|
589 |
if ($claimedPublication -> publication != null and $claimedPublication -> publication -> id != null) |
|
590 |
$claimedDocuments[$claimedPublication->publicationId] = $claimedPublication -> publication; |
|
591 |
if ($claimedPublication -> projectId !== null){ |
|
592 |
$projectsToGet[] = $claimedPublication -> projectId; |
|
593 |
} |
|
594 |
if ($claimedPublication -> targetPublicationId !== null){ |
|
595 |
$resultsToGet[] = $claimedPublication -> targetPublicationId; |
|
596 |
} |
|
597 |
if ($claimedPublication -> targetDatasetId !== null){ |
|
598 |
$resultsToGet[] = $claimedPublication -> targetDatasetId; |
|
599 |
} |
|
600 |
if (($claimedPublication -> publication == null || ($claimedPublication -> publication != null and $claimedPublication -> publication -> id == null))){ |
|
601 |
$resultsToGet[] = $claimedPublication -> publicationId; |
|
602 |
} |
|
603 |
if ($claimedPublication -> publication == null && $claimedPublication -> type == "dataset"){ |
|
604 |
$resultsToGet[] = $claimedPublication -> publicationId; |
|
605 |
} |
|
606 |
} |
|
607 |
$resultsToGet = array_unique($resultsToGet); |
|
608 |
$projectsToGet = array_unique($projectsToGet); |
|
609 |
$searchModel = new OpenAireModelSearch(); |
|
610 |
$results = $searchModel->getResults($resultsToGet, $locale); |
|
611 |
$projects = $searchModel->getProjects($projectsToGet, $locale); |
|
612 |
$keydResults = array(); |
|
613 |
$keydProjects = array(); |
|
614 |
foreach ($results as $result) |
|
615 |
$keydResults[$result->id] = $result; |
|
616 |
foreach ($projects as $project) |
|
617 |
$keydProjects[$project->id] = $project; |
|
618 |
|
|
619 |
foreach ($claimedPublications as $claimedPublication){ |
|
620 |
|
|
621 |
/* if ($claimedPublication -> publication == null || $claimedPublication -> publication -> id == null){ |
|
622 |
//print_r($claimedPublication -> publication -> concepts); |
|
623 |
$claimedPublication -> publication = isset($keydResults[$claimedPublication -> publicationId])?$keydResults[$claimedPublication -> publicationId]:null; |
|
624 |
} |
|
625 |
*/ |
|
626 |
$claimedPublication->targetConceptId=null; |
|
627 |
if ($claimedPublication -> publication != null && isset($claimedPublication -> publication -> concepts )){ |
|
628 |
$claimedConcepts = array(); |
|
629 |
foreach ($claimedPublication -> publication -> concepts as $concept){ |
|
630 |
$concept = $this->getConcept($concept); |
|
631 |
$claimedConcept = new stdClass(); |
|
632 |
$claimedConcept->id = $concept->id; |
|
633 |
$claimedConcept->title = $concept->path; |
|
634 |
$claimedConcept->date = $claimedPublication->date; |
|
635 |
$claimedConcepts[] = $claimedConcept; |
|
636 |
$claimedPublication->title=$concept->path; |
|
637 |
$claimedPublication->targetConceptId= $concept->id; |
|
638 |
} |
|
639 |
$claimedPublication -> concepts= $claimedConcepts; |
|
640 |
} |
|
641 |
if ($claimedPublication -> targetPublicationId !== null){ |
|
642 |
$claimedPublication->title = isset($keydResults[$claimedPublication -> targetPublicationId ])?$keydResults[$claimedPublication -> targetPublicationId ]->title:null; |
|
643 |
if ($claimedPublication->title == null){ |
|
644 |
$claimedPublication->title = isset($claimedDocuments[$claimedPublication -> targetDatasetId ])?$claimedDocuments[$claimedPublication -> targetDatasetId ]->title:null; |
|
645 |
} |
|
646 |
} |
|
647 |
if ($claimedPublication -> targetDatasetId !== null){ |
|
648 |
$claimedPublication->title = isset($keydResults[$claimedPublication -> targetDatasetId ])?$keydResults[$claimedPublication -> targetDatasetId ]->title:null; |
|
649 |
if ($claimedPublication->title == null){ |
|
650 |
$claimedPublication->title = isset($claimedDocuments[$claimedPublication -> targetDatasetId ])?$claimedDocuments[$claimedPublication -> targetDatasetId ]->title:null; |
|
651 |
} |
|
652 |
} |
|
653 |
if ($claimedPublication -> projectId !== null){ |
|
654 |
$claimedPublication->title = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->title:null; |
|
655 |
$claimedPublication->acronym = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->acronym:null; |
|
656 |
|
|
657 |
} |
|
658 |
if ($claimedPublication -> publication == null || $claimedPublication -> publication -> id == null){ |
|
659 |
//print_r($claimedPublication -> publication -> concepts); |
|
660 |
$claimedPublication -> publication = isset($keydResults[$claimedPublication -> publicationId])?$keydResults[$claimedPublication -> publicationId]:null; |
|
661 |
} |
|
662 |
} |
|
663 |
JLog :: add('Retrieved ' . count($claimedPublications) . ' claimed publications in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); |
|
664 |
return $claimedPublications; |
|
665 |
} catch (Exception $e) { |
|
666 |
JLog :: add('Error retrieving claimed publications (user: ' . $user -> username . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
667 |
return NULL; |
|
668 |
} |
|
669 |
} |
|
670 |
// Search for a publication DOI. |
|
671 |
// $doi the publication DOI to search for |
|
672 |
// return a result (object) containing publications and total |
|
673 |
private function _searchDOI($doi, $page, $size) { |
|
674 |
try { |
|
675 |
$result = new JObject(); |
|
676 |
$result -> publications = array(); |
|
677 |
$result -> totalPublications = 0; |
|
678 |
$result -> totalDatasets = 0; |
|
679 |
$dois = explode(" ", preg_replace('/\s+/', ' ',$doi)); |
|
680 |
$unique_dois =array_slice( array_unique($dois),0,10); |
|
681 |
$pattern1 ='#\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?!["&\'<>])\S)+)\b#'; |
|
682 |
$pattern2 ='#\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?!["&\'<>])[[:graph:]])+)\b#'; |
|
683 |
if (preg_match($pattern1,$unique_dois[0])||preg_match($pattern2,$unique_dois[0])){ |
|
684 |
if(count($dois)>10){ |
|
685 |
$result = new JObject(); |
|
686 |
$result->publications = array(); |
|
687 |
$result->totalPublications = '-'; |
|
688 |
$result->totalDatasets = 0; |
|
689 |
$result->maxDoisExceeded = true; |
|
690 |
return $result; |
|
691 |
} |
|
692 |
JLog :: add('It;s a DOI!!!!!!!!! '.$dois[0] , JLog :: INFO, self :: LOG); |
|
693 |
JLog :: add('Searching for DOIs ' , JLog :: INFO, self :: LOG); |
|
694 |
foreach($unique_dois as $doi_){ |
|
695 |
JLog :: add('DOI::: '.$doi_ , JLog :: INFO, self :: LOG); |
|
696 |
$publication = $this->_searchSingleDOI($doi_); |
|
697 |
if ($publication != null) { |
|
698 |
$result->publications[] = $publication; |
|
699 |
} |
|
700 |
} |
|
701 |
}else{ |
|
702 |
JLog :: add('It;s NOOOOT a DOI!!!!!!!!! '.$dois[0] , JLog :: INFO, self :: LOG); |
|
703 |
} |
|
704 |
|
|
705 |
$result -> totalPublications = count( $result -> publications); |
|
706 |
if($result -> totalPublications ===0){ |
|
707 |
//.'&rows='.$size.'&offset='.$page |
|
708 |
$request = "http://api.crossref.org/works?query=" . urlencode( trim($doi))."&rows=".$size."&offset=".($page-1)*$size; |
|
709 |
JLog :: add('Requesting ' . $request, JLog :: INFO, self :: LOG); |
|
710 |
$time = microtime(TRUE); |
|
711 |
$response = $this -> http -> get($request); |
|
712 |
JLog :: add('Received response in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); |
|
713 |
if ($response == NULL) |
|
714 |
throw new Exception('no HTTP response'); |
|
715 |
if ($response -> code != self :: HTTP_OK) |
|
716 |
throw new Exception('HTTP response code ' . $response -> code); |
|
717 |
$res = array(); |
|
718 |
$res = json_decode(str_replace("-", "_", $response -> body)); |
|
719 |
if(isset($res -> status)&&$res -> status === "ok" && isset($res -> message)){ |
|
720 |
foreach($res ->message -> items as $item){ |
|
721 |
$publication = $this -> _parseJsonDOI($item); |
|
722 |
if($publication!=null){ |
|
723 |
$result -> publications[] = $publication; |
|
724 |
} |
|
725 |
} |
|
726 |
$result -> totalPublications = $res -> message ->total_results; |
|
727 |
/*if(isset($size)&&isset($page)){ |
|
728 |
$result -> publications = array_slice($result -> publications, ($page - 1) * $size, $size); |
|
729 |
}*/ |
|
730 |
} |
|
731 |
} |
|
732 |
return $result; |
|
733 |
} catch (Exception $e) { |
|
734 |
JLog :: add('Error performing DOI search (doi: ' . $doi . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
735 |
$result = new JObject(); |
|
736 |
$result -> publications = array(); |
|
737 |
$result -> totalPublications = 0; |
|
738 |
$result -> totalDatasets = 0; |
|
739 |
JLog :: add('error parsing DOI record', JLog :: INFO, self :: LOG); |
|
740 |
return $result; |
|
741 |
} |
|
742 |
} |
|
743 |
public function searchSingleDOI($doi) { |
|
744 |
if ($this -> cache -> getCaching()) { |
|
745 |
$cacheId = self :: SEARCH_DOI_CACHE_ID . '.' . $doi; |
|
746 |
$results = $this -> cache -> get($cacheId, self :: CACHE_GROUP); |
|
747 |
if ($results === FALSE) { |
|
748 |
$results = $this -> _searchSingleDOI($doi); |
|
749 |
if ($results !== NULL) |
|
750 |
$this -> cache -> store($results, $cacheId, self :: CACHE_GROUP); |
|
751 |
} |
|
752 |
} else |
|
753 |
$results = $this -> _searchSingleDOI($doi); |
|
754 |
return $results; |
|
755 |
} |
|
756 |
private function _searchSingleDOI($doi) { |
|
757 |
try { |
|
758 |
$request = self :: CROSSREF_API_DOI . urlencode( trim($doi)); |
|
759 |
JLog :: add('Requesting ' . $request, JLog :: INFO, self :: LOG); |
|
760 |
$time = microtime(TRUE); |
|
761 |
$response = $this -> http -> get($request); |
|
762 |
JLog :: add('Received response in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); |
|
763 |
if ($response == NULL) |
|
764 |
throw new Exception('no HTTP response'); |
|
765 |
if ($response -> code != self :: HTTP_OK) |
|
766 |
throw new Exception('HTTP response code ' . $response -> code); |
|
767 |
$res = array(); |
|
768 |
$res = json_decode(str_replace("-", "_", $response -> body)); |
|
769 |
if(isset($res -> status) && $res -> status === "ok" && isset($res -> message)){ |
|
770 |
$publication = $this -> _parseJsonDOI($res -> message); |
|
771 |
return $publication; |
|
772 |
} |
|
773 |
|
|
774 |
} catch (Exception $e) { |
|
775 |
JLog :: add('Error performing DOI search (doi: ' . $doi . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); |
|
776 |
$result = new JObject(); |
|
777 |
$result -> publications = array(); |
|
778 |
$result -> totalPublications = 0; |
|
779 |
$result -> totalDatasets = 0; |
|
780 |
JLog :: add('error parsing DOI record', JLog :: INFO, self :: LOG); |
|
781 |
return null; |
|
782 |
} |
|
783 |
} |
|
784 |
private function _parseJsonDOI($message) { |
|
785 |
$publication = new JObject(); |
|
786 |
$publication -> id = isset($message -> DOI)?$message -> DOI:NULL; |
|
787 |
$publication -> source = self :: DOI; |
|
788 |
$publication -> url = isset($message -> URL)?$message -> URL:NULL; |
|
789 |
$publication -> accessMode = NULL; |
|
790 |
$publication -> datasources = array(); |
|
791 |
$publication -> title = (isset($message -> title) && isset($message -> title[0]))?$message -> title[0]:NULL; |
|
792 |
$publication -> authors = array(); |
|
793 |
if(isset($message -> author)){ |
|
794 |
foreach ($message -> author as $author_item) { |
|
795 |
$author = new JObject(); |
|
796 |
$author -> id = NULL; |
|
797 |
$author -> lastName = isset($author_item-> family) ? trim($author_item -> family):NULL; |
Also available in: Unified diff
adding folder for Joomla 3 component