forked from idea-sketch/SemanticFormsSelect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSemanticFormsSelect.api.php
58 lines (47 loc) · 1.32 KB
/
SemanticFormsSelect.api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
class ApiSemanticFormsSelect extends ApiBase {
public function execute() {
$params = $this->extractRequestParams();
if ( $params['approach'] == 'smw' ) {
$json = SemanticFormsSelect::QueryExecution( $params['query'], $params['sep'] );
} else {
$json = SemanticFormsSelect::FunctionExecution( $params['query'], $params['sep'] );
}
$output = json_decode( $json );
$result = $this->getResult();
$result->setIndexedTagName( $output->values, 'value' );
$result->addValue( $this->getModuleName(), 'values', $output->values );
$result->addValue( $this->getModuleName(), 'count', $output->count );
return true;
}
public function getAllowedParams() {
return array(
'approach' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true
),
'query' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true
),
'sep' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => false
)
);
}
public function getDescription() {
return array(
'API for providing SemanticFormsSelect values'
);
}
public function getParamDescription() {
return array(
'approach' => 'The actual approach: function or smw',
'query' => 'The query of the former'
);
}
public function getVersion() {
return __CLASS__ . ': 1.1';
}
}