summaryrefslogtreecommitdiffstats
path: root/app/classes/PlanetFeed.php
blob: 39fbe75bffd062e94cd91cc8c9e702e0d0a3fcc0 (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
79
80
<?php

/**
 * Planet person
 */

class PlanetFeed extends SimplePie
{
    public string $name;
    public string $feed;
    public string $website;
    public string $isDown;

    public function __construct($name, $feed, $website, $isDown)
    {
        $this->name    = $name;
        $this->feed    = $feed;
        $this->website = $website;
        $this->isDown  = $isDown;
        parent::__construct();
        $this->set_item_class('PlanetItem');
        $this->set_cache_location(__DIR__.'/../../cache');
        $this->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
        $this->set_feed_url($this->getFeed());
        $this->set_timeout(5);

        $this->enable_order_by_date(false);
        $this->remove_div(false);
        $this->strip_comments(false);
        $this->strip_attributes(false);
        $this->set_image_handler(false);
        $this->set_https_domains(array());
        $this->strip_htmltags([
            'base', 'blink', 'body',
            'doctype',
            'embed',
            'font', 'form', 'frame', 'frameset',
            'html',
            'iframe', 'input',
            'marquee', 'meta',
            'noscript',
            'object',
            'param',
            'script',
            'style'
        ]);
    }

    public function getFeed() : string
    {
        return $this->feed;
    }

    public function getName() : string
    {
        return $this->name;
    }

    public function getWebsite() : string
    {
        return $this->website;
    }

    public function getIsDown() : string
    {
        return $this->isDown;
    }

    /**
     * Compare two Person by their name.
     *
     * @param  PlanetFeed $person1
     * @param  PlanetFeed $person2
     * @return int
     */
    public static function compare($person1, $person2)
    {
        return strcasecmp($person1->name, $person2->name);
    }
}