1
|
<?php
|
2
|
|
3
|
namespace OpenAIRE\Component\Widget\Site\View\Data;
|
4
|
|
5
|
defined('_JEXEC') or die;
|
6
|
|
7
|
use \Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
8
|
use \Joomla\CMS\Factory;
|
9
|
|
10
|
/**
|
11
|
* @package \Joomla.Site
|
12
|
* @subpackage com_openaire
|
13
|
*
|
14
|
* @copyright Copyright (C) 2020 \John Smith. All rights reserved.
|
15
|
* @license GNU General Public License version 3; see LICENSE
|
16
|
*/
|
17
|
|
18
|
/**
|
19
|
* View for the user identity validation form
|
20
|
*/
|
21
|
class RawView extends BaseHtmlView {
|
22
|
const MODEL = 'Search';
|
23
|
const UNKNOWN = 'UNKNOWN';
|
24
|
const LOG = 'openaire';
|
25
|
|
26
|
/**
|
27
|
* Display the view
|
28
|
*
|
29
|
* @param string $template The name of the layout file to parse.
|
30
|
* @return void
|
31
|
*/
|
32
|
public function display($template = null) {
|
33
|
$input = Factory::getApplication()->input;
|
34
|
|
35
|
$projectId = $input->get('projectId',null,'string');
|
36
|
$ga = $input->get('ga',null,'string');
|
37
|
$funder = $input->get('funder','ec__________::EC', 'string');
|
38
|
$this -> hideOnEmpty = ($input->get('hideOnEmpty') == 'true');
|
39
|
$this -> type = $input->get('type','publication','string');
|
40
|
|
41
|
$this -> data = new \stdClass();
|
42
|
$this -> data -> via = " via ";
|
43
|
$this -> data -> openAireImageUrl = \JUri :: base() . 'components/com_openaire/images/openairelogo.png';
|
44
|
|
45
|
$locale = "en_GB";
|
46
|
\JLog :: add('projectId: '.$projectId. ' Type: '.$this -> type, \JLog :: DEBUG, self::LOG);
|
47
|
|
48
|
if ($projectId != null) {
|
49
|
$model = $this -> getModel(self::MODEL);
|
50
|
$project = $model -> getProject($projectId, $locale);
|
51
|
}else if ($ga != null){
|
52
|
$model = $this -> getModel(self::MODEL);
|
53
|
$project= $model ->getProjectByCodeId($ga, $funder, $locale);
|
54
|
$projectId = $project -> projectId;
|
55
|
|
56
|
}
|
57
|
|
58
|
if($project != null){
|
59
|
$typeInTitle = "PUBLICATIONS";
|
60
|
if($this -> type == 'software') {
|
61
|
$typeInTitle = "SOFTWARE";
|
62
|
}else if($this -> type == 'other') {
|
63
|
$typeInTitle = "OTHER";
|
64
|
}else if($this -> type == 'dataset'){
|
65
|
$typeInTitle = "DATASETS";
|
66
|
}else if($this -> type == 'result'){
|
67
|
$typeInTitle = "RESEARCH_RESULTS";
|
68
|
$this -> type = null;
|
69
|
}else{
|
70
|
$typeInTitle = "PUBLICATIONS";
|
71
|
$this -> type = "publication";
|
72
|
}
|
73
|
\JLog :: add('Type: '.$this -> type. ' '.$typeInTitle , \JLog :: DEBUG, self::LOG);
|
74
|
$this -> data -> title = \JText :: sprintf($typeInTitle .'_OF_PROJECT_S_S_S_', $project -> title, $project -> acronym, $project -> call);
|
75
|
$result = $model -> searchResults($this -> type, 1, 1, $projectId); // fetch the first dataset to view how many there are...
|
76
|
$result = $model -> searchResults($this -> type, 1, $result -> totalDatasets, $projectId); // ... and then fetch them all
|
77
|
$this -> data -> publications = $result -> datasets;
|
78
|
/* if (count($errors = $this -> get('Errors')) > 0) {
|
79
|
\JLog :: add('Error viewing data: ' . implode("\n", $errors), \JLog :: ERROR, self::LOG);
|
80
|
return FALSE;
|
81
|
}
|
82
|
*/
|
83
|
|
84
|
} else {
|
85
|
\JLog :: add('No project id!!!', \JLog :: ERROR, self::LOG);
|
86
|
}
|
87
|
|
88
|
// Call the parent display to display the layout file
|
89
|
|
90
|
parent::display($template);
|
91
|
}
|
92
|
|
93
|
}
|