codysnider /
tt-rss
| 1 | <?php |
||
| 2 | class Bookmarklets extends Plugin { |
||
| 3 | private $host; |
||
| 4 | |||
| 5 | function about() { |
||
| 6 | return array(1.0, |
||
| 7 | "Easy feed subscription and web page sharing using bookmarklets", |
||
| 8 | "fox", |
||
| 9 | false, |
||
| 10 | "https://git.tt-rss.org/fox/tt-rss/wiki/ShareAnything"); |
||
| 11 | } |
||
| 12 | |||
| 13 | function init($host) { |
||
|
0 ignored issues
–
show
|
|||
| 14 | $this->host = $host; |
||
| 15 | |||
| 16 | $host->add_hook($host::HOOK_PREFS_TAB, $this); |
||
| 17 | } |
||
| 18 | |||
| 19 | function hook_prefs_tab($args) { |
||
|
0 ignored issues
–
show
|
|||
| 20 | if ($args == "prefFeeds") { |
||
| 21 | |||
| 22 | print "<div dojoType=\"dijit.layout.AccordionPane\" |
||
| 23 | title=\"<i class='material-icons'>bookmark</i> ".__('Bookmarklets')."\">"; |
||
| 24 | |||
| 25 | print "<h3>".__("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.")."</h3>"; |
||
| 26 | |||
| 27 | $bm_subscribe_url = str_replace('%s', '', Pref_Feeds::subscribe_to_feed_url()); |
||
| 28 | |||
| 29 | $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); |
||
| 30 | |||
| 31 | $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}"); |
||
| 32 | |||
| 33 | print "<p><label class='dijitButton'>"; |
||
| 34 | print "<a href=\"$bm_url\">".__('Subscribe in Tiny Tiny RSS')."</a>"; |
||
| 35 | print "</label></p>"; |
||
| 36 | |||
| 37 | print "<h3>".__("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS")."</h3>"; |
||
| 38 | |||
| 39 | print "<label class='dijitButton'>"; |
||
| 40 | $bm_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".get_self_url_prefix()."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()"); |
||
| 41 | print "<a href=\"$bm_url\">".__('Share with Tiny Tiny RSS')."</a>"; |
||
| 42 | print "</label>"; |
||
| 43 | |||
| 44 | print "<button dojoType='dijit.form.Button' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ShareAnything\")'> |
||
| 45 | <i class='material-icons'>help</i> ".__("More info...")."</button>"; |
||
| 46 | |||
| 47 | print "</div>"; #pane |
||
| 48 | |||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | public function api_version() { |
||
| 53 | return 2; |
||
| 54 | } |
||
| 55 | |||
| 56 | } |
||
| 57 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.