1
|
<?php
|
2
|
|
3
|
defined('_JEXEC') or die('Access denied');
|
4
|
|
5
|
jimport('joomla.application.component.view');
|
6
|
jimport('joomla.base.object');
|
7
|
jimport('joomla.environment.request');
|
8
|
jimport('joomla.environment.uri');
|
9
|
jimport('joomla.log.log');
|
10
|
|
11
|
class OpenAireViewData extends JViewLegacy{
|
12
|
const MODEL = 'search';
|
13
|
const UNKNOWN = 'UNKNOWN';
|
14
|
const LOG = 'openaire';
|
15
|
|
16
|
function display($template = NULL) {
|
17
|
$projectId = JRequest :: getString('projectId');
|
18
|
$ga = JRequest :: getString('ga');
|
19
|
$funder = JRequest :: getString('funder','ec__________::EC');
|
20
|
$this -> hideOnEmpty = (JRequest :: getString('hideOnEmpty') == 'true');
|
21
|
$this -> type = JRequest :: getString('type','publication');
|
22
|
|
23
|
$this -> data = new JObject();
|
24
|
$this -> data -> via = JText :: _('VIA_');
|
25
|
$this -> data -> openAireImageUrl = JUri :: base() . 'components/com_openaire/images/openairepluslogo.png';
|
26
|
|
27
|
$locale = JFactory :: getLanguage() -> getTag();
|
28
|
$locale = ($locale == null || strlen($locale) == 0)?"en_GB":$locale;
|
29
|
|
30
|
if ($projectId != null) {
|
31
|
$model = $this -> getModel(self :: MODEL);
|
32
|
$project = $model -> getProject($projectId, $locale);
|
33
|
}else if ($ga != null){
|
34
|
$model = $this -> getModel(self :: MODEL);
|
35
|
$project= $model ->getProjectByCodeId($ga, $funder, $locale);
|
36
|
$projectId = $project -> projectId;
|
37
|
// $project = null;
|
38
|
// foreach ($projects as $_project){
|
39
|
// if($_project -> code == $ga){
|
40
|
// $project = $_project;
|
41
|
// $projectId = $project -> projectId;
|
42
|
// }
|
43
|
//
|
44
|
// }
|
45
|
}
|
46
|
if($project != null){
|
47
|
if( $this -> type == 'publication'){
|
48
|
$this -> data -> title = JText :: sprintf('PUBLICATIONS_OF_PROJECT_S_S_S_', $project -> title, $project -> acronym, $project -> call);
|
49
|
$result = $model -> browsePublications(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, $locale, $projectId, NULL,FALSE); // fetch the first publication to view how many there are...
|
50
|
$result = $model -> browsePublications(NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 1, $result -> totalPublications, $locale, $projectId, NULL,FALSE); // ... and then fetch them all
|
51
|
$this -> data -> publications = $result -> publications;
|
52
|
if (count($errors = $this -> get('Errors')) > 0) {
|
53
|
JLog :: add('Error viewing data: ' . implode("\n", $errors), JLog :: ERROR, self :: LOG);
|
54
|
return FALSE;
|
55
|
}
|
56
|
}else{
|
57
|
$this -> data -> title = JText :: sprintf('DATASETS_OF_PROJECT_S_S_S_', $project -> title, $project -> acronym, $project -> call);
|
58
|
$result = $model -> browseDatasets(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, $locale, $projectId, NULL,FALSE); // fetch the first dataset to view how many there are...
|
59
|
$result = $model -> browseDatasets(NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL, 1, $result -> totalDatasets, $locale, $projectId, NULL,FALSE); // ... and then fetch them all
|
60
|
$this -> data -> publications = $result -> datasets;
|
61
|
|
62
|
if (count($errors = $this -> get('Errors')) > 0) {
|
63
|
JLog :: add('Error viewing data: ' . implode("\n", $errors), JLog :: ERROR, self :: LOG);
|
64
|
return FALSE;
|
65
|
}
|
66
|
}
|
67
|
|
68
|
} else {
|
69
|
JLog :: add('No project id!!!', JLog :: ERROR, self :: LOG);
|
70
|
}
|
71
|
|
72
|
parent :: display($template);
|
73
|
}
|
74
|
|
75
|
}
|
76
|
|