]> git.wh0rd.org - tt-rss.git/blob - plugins/owncloud/owncloud.php
OWNCLOUD_URL-parameter out of config.php-dist
[tt-rss.git] / plugins / owncloud / owncloud.php
1 <?php
2 // This plugin creates ReadLater bookmarks in your owncloud.
3 // The plugin needs a
4 // define('OWNCLOUD_URL','http(s)://your.serv.er/owncloud');
5 // in your config.php. The parameter is actually global. user_pref
6 // with editable parameter in future versions.
7
8 require_once "config.php";
9
10 class OwnCloud extends Plugin {
11 private $link;
12 private $host;
13
14 function about() {
15 return array(1.0,
16 "Adds support for OwnCloud ReadLater",
17 "cy8aer");
18 }
19
20 function init($host) {
21 $this->link = $host->get_link();
22 $this->host = $host;
23
24 $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
25 }
26
27 function get_js() {
28 return file_get_contents(dirname(__FILE__) . "/owncloud.js");
29 }
30
31 function hook_article_button($line) {
32 return "<img src=\"".theme_image($this->link, "plugins/owncloud/owncloud.png")."\"
33 style=\"cursor : pointer\" style=\"cursor : pointer\"
34 onclick=\"ownArticle(".$line["id"].")\"
35 class='tagsPic' title='".__('Bookmark on OwnCloud ')."'>";
36 }
37
38 function getOwnCloud() {
39 $id = db_escape_string($_REQUEST['id']);
40
41 $result = db_query($this->link, "SELECT title, link
42 FROM ttrss_entries, ttrss_user_entries
43 WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
44
45 if (db_num_rows($result) != 0) {
46 $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')),
47 100, '...');
48 $article_link = db_fetch_result($result, 0, 'link');
49 }
50
51 $own_url = "";
52 if (defined('OWNCLOUD_URL')) {
53 $own_url = OWNCLOUD_URL;
54 }
55
56 print json_encode(array("title" => $title, "link" => $article_link,
57 "id" => $id, "ownurl" => $own_url));
58 }
59 }
60 ?>