-
Notifications
You must be signed in to change notification settings - Fork 0
/
vscc_acalog.module
70 lines (58 loc) · 1.68 KB
/
vscc_acalog.module
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
59
60
61
62
63
64
65
66
67
68
69
70
<?php
// private API key from Acalog
const API_KEY = 'XXXXXXXXXXXX';
// gets the current catalog ID from Acalog
function getCatalogID() {
//return 24; // hardcode the catalogID
// query Acalog to get the ID of the current catalog
$request_url = 'http://volstate.apis.acalog.com/v1/content?key=' . API_KEY . '&format=xml&method=getCatalogs';
$client = new \GuzzleHttp\Client();
try {
$response = $client->request('GET', $request_url, [
'headers' => ['Accept' => 'application/xml'],
'connect_timeout' => 5
])->getBody()->getContents();
$xml = simplexml_load_string($response);
foreach ($xml->catalog[0]->attributes() as $a => $b) {
$catalogID = str_replace('acalog-catalog-','',$b);
}
// error connecting to Acalog
} catch (RequestException $e) {
$catalogID = 0;
}
return $catalogID;
}
// use custom Twig template to display Degrees & Certificates Block
function vscc_acalog_theme($existing, $type, $theme, $path){
return [
'vscc_acalog' =>
array(
'variables' => array(
'title' => 'Degrees & Certificates',
'markup' => null,
'catalogID' => null,
'degrees' => null,
'programs' => null,
),
'template' => 'block--DegreesBlock'
),
'vscc_program' =>
array(
'variables' => array(
'markup' => null,
'catalogID' => null,
'programID' => null,
),
'template' => 'block--ProgramBlock'
),
'vscc_alpha' =>
array(
'variables' => array(
'markup' => null,
'catalogID' => null,
'programs' => null,
),
'template' => 'block--AlphaBlock'
)
];
}