summaryrefslogtreecommitdiff
path: root/config/services/web/rss/MaisonDeLaRadioBridge.php
blob: 25f5bf77f663606a9ca3694218210a382a9e5789 (plain)
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
71
72
73
74
75
76
77
78
<?php

$GLOBALS['DATE_FORMATTER'] = new IntlDateFormatter(
    "fr-FR",
    IntlDateFormatter::FULL,
    IntlDateFormatter::NONE,
    'Etc/UTC',
    IntlDateFormatter::GREGORIAN,
    'EEEE dd MMMM y'
);

class MaisonDeLaRadioBridge extends XPathAbstract {
    const NAME = 'Maison de la Radio Bridge';
    const URI = 'https://www.maisondelaradioetdelamusique.fr/agenda';
    const DESCRIPTION = 'Agenda of the Maison de la Radio et de la Musique.';
    const MAINTAINER = 'Quentin Aristote';
    const CACHE_TIMEOUT = 3600; // 1h

    const XPATH_EXPRESSION_ITEM = '//a[@class="agenda-event-link"]';
    const XPATH_EXPRESSION_ITEM_TITLE = './/h3';
    const XPATH_EXPRESSION_ITEM_CONTENT = './/div[@class="summary]';
    const XPATH_EXPRESSION_ITEM_URI = './@href';
    const XPATH_EXPRESSION_ITEM_AUTHOR = './/div[@class="type"]';
    const XPATH_EXPRESSION_ITEM_TIMESTAMP = './../div[@class="date"]';
    const XPATH_EXPRESSION_ITEM_ENCLOSURES = './/img/@src';
    const XPATH_EXPRESSION_ITEM_CATEGORIES = './/span[@class="location"]';

    const PARAMETERS = array(
        '' => array (
            'type' => array(
                'name' => 'Type',
                'type' => 'number',
                'title' => 'ID of the concert type (optional).',
                'exampleValue' => '3188'
            ),
            'formation' => array(
                'name' => 'Formation',
                'type' => 'number',
                'title' => 'ID of the performing formation (optional).',
                'exampleValue' => '1035'
            ),
            'chef' => array(
                'name' => 'Chef',
                'type' => 'number',
                'title' => 'ID of the conductor (optional).',
                'exampleValue' => '53'
            ),
            'compositeur' => array(
                'name' => 'Compositeur',
                'type' => 'number',
                'title' => 'ID of the composer (optional).',
                'exampleValue' => '131'
            ),
            'soliste' => array(
                'name' => 'Soliste',
                'type' => 'number',
                'title' => 'ID of the solist (optional).',
                'exampleValue' => '3064'
            )
        )
    );

    public function getSourceUrl() {
        $query = '';
        foreach(self::PARAMETERS[''] as $param => $val) {
            $query = $query . $param . '=' . $this->getInput($param) . '&'; 
        }
        return self::URI . '?' . $query;
    }

    public function getIcon() {
        return 'https://rf-maisondelaradio-production.s3.eu-west-3.amazonaws.com/s3fs-public/mdlrfavicon22.ico';
    }

    protected function formatItemTimestamp($value) {
        return $GLOBALS['DATE_FORMATTER']->parse($value);
    }
}