Commit 68664dca015673b88df3c9288e289b6cce5d8b02
1 parent
cc6e16eb
Exists in
master
and in
112 other branches
make epntap php file more generic
Showing
2 changed files
with
31 additions
and
17 deletions
Show diff stats
js/app/views/EpnTapUI.js
... | ... | @@ -57,16 +57,13 @@ This list is used to fill the `targetNameCB` combo box, which is updated by `Epn |
57 | 57 | - `id`: the target name in lowercase, with the underscore between each word; |
58 | 58 | - `name`: the target name, capitalized with spaces between each word (done `EpnTapModule.prettify()`). |
59 | 59 | */ |
60 | -Ext.create('Ext.data.Store', { // TODO: ArrayStore | |
60 | +Ext.create('Ext.data.Store', { | |
61 | 61 | storeId: 'targetNamesStore', |
62 | 62 | fields: ['id', 'name', 'type', 'parent', 'aliases'], |
63 | 63 | proxy: { |
64 | 64 | type: 'ajax', |
65 | - url: 'php/epntap_resolver.php', | |
66 | - reader: { | |
67 | - type: 'json', | |
68 | - root: 'hits' | |
69 | - } | |
65 | + url: 'php/epntap.php', | |
66 | + extraParams : { action: 'resolver' } | |
70 | 67 | } |
71 | 68 | }); |
72 | 69 | |
... | ... | @@ -285,7 +282,7 @@ Ext.define('amdaUI.EpnTapUI', { |
285 | 282 | hideTrigger: true, |
286 | 283 | listConfig: { |
287 | 284 | getInnerTpl: function() { |
288 | - return '<div data-qtip="<p><b>{name}</b></p><p>type: {type}</p><p>parent: {parent}</p><p>aliases:</p><ul>{aliases}</ul>">{name}</div>'; | |
285 | + return '<div data-qtip="<h3>{name}</h3><p>type: {type}</p><p>parent: {parent}</p><p>aliases:</p><ul>{aliases}</ul>">{name}</div>'; | |
289 | 286 | } |
290 | 287 | }, |
291 | 288 | listeners: { |
... | ... |
php/epntap_resolver.php renamed to php/epntap.php
1 | 1 | <?php |
2 | -$input = filter_var($_REQUEST['input'], FILTER_SANITIZE_URL); | |
3 | -$resolver_url = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete?q=%22$input%22"; | |
4 | -$result = json_decode(file_get_contents($resolver_url), true); | |
5 | - | |
6 | -$response = array(); | |
7 | -foreach($result['hits'] as $e) { | |
8 | - $aliases = '<li>' . join('</li><li>', $e['aliases']) . '</li>'; | |
9 | - $target = array('name' => $e['name'], 'type' => $e['type'], 'parent' => $e['parent'], 'aliases' => $aliases); | |
10 | - array_push($response, $target); | |
2 | + | |
3 | +$action = preg_replace("/[^a-z]+/", "", filter_var($_GET['action'], FILTER_SANITIZE_STRING)); | |
4 | + | |
5 | +switch ($action) { | |
6 | + case 'resolver': | |
7 | + echo resolver(filter_var($_GET['input'], FILTER_SANITIZE_URL)); | |
8 | + break; | |
9 | + case 'get_services': | |
10 | + echo get_services(); | |
11 | + break; | |
12 | + | |
13 | + default: | |
14 | + break; | |
11 | 15 | } |
12 | -echo json_encode($response); | |
16 | + | |
17 | +function resolver($input) { | |
18 | + $resolver_url = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete?q=%22$input%22"; | |
19 | + $result = json_decode(file_get_contents($resolver_url), true); | |
20 | + | |
21 | + $response = array(); | |
22 | + foreach($result['hits'] as $e) { | |
23 | + $aliases = '<li>' . join('</li><li>', $e['aliases']) . '</li>'; | |
24 | + $target = array('name' => $e['name'], 'type' => $e['type'], 'parent' => $e['parent'], 'aliases' => $aliases); | |
25 | + array_push($response, $target); | |
26 | + } | |
27 | + return json_encode($response); | |
28 | +} | |
29 | + | |
13 | 30 | ?> |
... | ... |