add LICENSE file
[tt-rss-subtome.git] / init.php
1 <?php
2 /**
3  * Allows user to register their Tiny Tiny RSS instance at subtome.com,
4  * so that they can subscribe to feeds with a few clicks.
5  *
6  * PHP version 5
7  *
8  * @author  Christian Weiske <cweiske@cweiske.de>
9  * @license AGPLv3 or later
10  * @link    http://docs.subtome.com/developers/
11  * @link    https://tt-rss.org/redmine/projects/tt-rss/wiki/FrequentlyAskedQuestions#I-need-a-URL-I-can-call-to-subscribe-to-feed-to-integrate-with-some-third-party-browser-extensionapplication
12  */
13 class SubToMe extends Plugin
14 {
15     public function about()
16     {
17         return array(
18             0.2,
19             'Add Tiny Tiny RSS to SubToMe.com',
20             'cweiske',
21             false
22         );
23     }
24     
25     public function init($host)
26     {
27         $host->add_hook($host::HOOK_PREFS_TAB, $this);
28     }
29
30     public function hook_prefs_tab($args)
31     {
32         if ($args != "prefPrefs") {
33             return;
34         }
35         $name = 'Tiny Tiny RSS @ '
36             . parse_url(get_self_url_prefix(), PHP_URL_HOST);
37
38         $ttSubscribeUrl = get_self_url_prefix()
39             . '/public.php?op=subscribe&feed_url={url}';
40         $regUrl = 'https://www.subtome.com/register-no-ui.html'
41             . '?name=' . urlencode($name)
42             . '&url=' . urlencode($ttSubscribeUrl);
43         $hRegUrl = htmlspecialchars($regUrl);
44
45         $jRegUrl = json_encode($regUrl);
46
47         echo <<<HTM
48 <div dojoType="dijit.layout.AccordionPane" title="SubToMe">
49  <iframe style="display:none;" src="$hRegUrl"></iframe>
50  <p>
51   Tiny Tiny RSS has been added to subtome.com automatically
52   by visiting the Tiny Tiny RSS preferences.
53  </p>
54  <p>
55   Try the "Subscribe" button on
56   <a href="http://blog.superfeedr.com/">blog.superfeedr.com</a>.
57  </p>
58 </div>
59 HTM;
60     }
61
62     public function api_version()
63     {
64         return 2;
65     }
66 }
67 ?>