owncloud.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. require_once "config.php";
  3. class OwnCloud extends Plugin {
  4. private $link;
  5. private $host;
  6. function about() {
  7. return array(1.0,
  8. "Adds support for OwnCloud ReadLater",
  9. "cy8aer");
  10. }
  11. function init($host) {
  12. $this->link = $host->get_link();
  13. $this->host = $host;
  14. $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
  15. }
  16. function get_js() {
  17. return file_get_contents(dirname(__FILE__) . "/owncloud.js");
  18. }
  19. function hook_article_button($line) {
  20. return "<img src=\"".theme_image($this->link, "plugins/owncloud/owncloud.png")."\"
  21. style=\"cursor : pointer\" style=\"cursor : pointer\"
  22. onclick=\"ownArticle(".$line["id"].")\"
  23. class='tagsPic' title='".__('Bookmark on OwnCloud ')."'>";
  24. }
  25. function getOwnCloud() {
  26. $id = db_escape_string($_REQUEST['id']);
  27. $result = db_query($this->link, "SELECT title, link
  28. FROM ttrss_entries, ttrss_user_entries
  29. WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
  30. if (db_num_rows($result) != 0) {
  31. $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')),
  32. 100, '...');
  33. $article_link = db_fetch_result($result, 0, 'link');
  34. }
  35. $own_url = "";
  36. if (defined('OWNCLOUD_URL')) {
  37. $own_url = OWNCLOUD_URL;
  38. }
  39. print json_encode(array("title" => $title, "link" => $article_link,
  40. "id" => $id, "ownurl" => $own_url));
  41. }
  42. }
  43. ?>