1
|
<?php
|
2
|
|
3
|
defined('_JEXEC') or die('Access denied');
|
4
|
|
5
|
jimport('joomla.application.component.view');
|
6
|
jimport('joomla.log.log');
|
7
|
|
8
|
class OpenAireViewCommunities extends JView {
|
9
|
const MODEL = 'search';
|
10
|
const CLAIM_MODEL = 'claim';
|
11
|
const LOG = 'openaire';
|
12
|
const SIZE = 10;
|
13
|
|
14
|
function display($template = NULL) {
|
15
|
$locale = JFactory :: getLanguage() -> getTag();
|
16
|
$this -> itemId = JRequest :: getUInt('Itemid', 0);
|
17
|
$this -> id = JRequest :: getString('id');
|
18
|
$term = JRequest :: getString('term');
|
19
|
$type = JRequest :: getString('type');
|
20
|
$parent = JRequest :: getString('parent');
|
21
|
$funder = JRequest :: getString('funder');
|
22
|
$claimModel = $this->getModel(self :: CLAIM_MODEL);
|
23
|
$limit = JRequest :: getUInt('limit', self :: SIZE);
|
24
|
$this -> communities = $claimModel -> getContexts();
|
25
|
$data = array();
|
26
|
|
27
|
if ($type == "root"){
|
28
|
list ($id, $category) = explode("::", $parent);
|
29
|
foreach ($this -> communities[$id] -> categories[$id. "::" . $category] -> concepts as $concept){
|
30
|
if (!$concept -> claim)
|
31
|
continue;
|
32
|
$data_t = new stdClass();
|
33
|
$data_t -> id = $concept -> id;
|
34
|
$data_t -> text = $concept -> name;
|
35
|
$data_t -> children = count($concept -> concepts)?true:false;
|
36
|
$data_t -> type = "root";
|
37
|
$data[] = $data_t;
|
38
|
}
|
39
|
}else{
|
40
|
$concept = $claimModel -> getConcept($this -> id , 1);
|
41
|
$concepts = $concept -> concepts[count($concept -> concepts) - 1] -> concepts;
|
42
|
|
43
|
foreach ($concepts as $concept){
|
44
|
if (!$concept -> claim)
|
45
|
continue;
|
46
|
$data_t = new stdClass();
|
47
|
$data_t -> id = $concept -> id;
|
48
|
$data_t -> text = $concept -> name;
|
49
|
$data_t -> children = count($concept -> concepts)?true:false;
|
50
|
$data_t -> type = "concept";
|
51
|
$data[] = $data_t;
|
52
|
}
|
53
|
}
|
54
|
$this -> communities = $data;
|
55
|
$doc = JFactory::getDocument();
|
56
|
$doc->setMimeEncoding('application/json');
|
57
|
|
58
|
if (count($errors = $this -> get('Errors')) > 0) {
|
59
|
JLog :: add('Error viewing communities (raw): ' . implode("\n", $errors), JLog :: ERROR, self :: LOG);
|
60
|
return FALSE;
|
61
|
}
|
62
|
parent :: display($template);
|
63
|
}
|
64
|
|
65
|
}
|
66
|
|