summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/api.php2
-rw-r--r--classes/handler/public.php19
-rw-r--r--classes/pref/feeds.php2
-rw-r--r--classes/rpc.php19
-rw-r--r--include/functions.php24
-rw-r--r--utility.css31
6 files changed, 91 insertions, 6 deletions
diff --git a/classes/api.php b/classes/api.php
index 6e5ed4aa8..15576c7c0 100644
--- a/classes/api.php
+++ b/classes/api.php
@@ -439,7 +439,7 @@ class API extends Handler {
$url = db_escape_string(strip_tags($_REQUEST["url"]));
$content = db_escape_string(strip_tags($_REQUEST["content"]));
- if (create_published_article($this->link, $title, $url, $content, $_SESSION["uid"])) {
+ if (create_published_article($this->link, $title, $url, $content, "", $_SESSION["uid"])) {
print $this->wrap(self::STATUS_OK, array("status" => 'OK'));
} else {
print $this->wrap(self::STATUS_ERR, array("error" => 'Publishing failed'));
diff --git a/classes/handler/public.php b/classes/handler/public.php
index d3c3fc094..f2a7730c8 100644
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -383,6 +383,7 @@ class Handler_Public extends Handler {
<title>Tiny Tiny RSS</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
<script type=\"text/javascript\" src=\"lib/prototype.js\"></script>
+ <script type=\"text/javascript\" src=\"lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls\"></script>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
</head>
<body id='sharepopup'>";
@@ -396,8 +397,10 @@ class Handler_Public extends Handler {
$title = db_escape_string(strip_tags($_REQUEST["title"]));
$url = db_escape_string(strip_tags($_REQUEST["url"]));
$content = db_escape_string(strip_tags($_REQUEST["content"]));
+ $labels = db_escape_string(strip_tags($_REQUEST["labels"]));
- create_published_article($this->link, $title, $url, $content, $_SESSION["uid"]);
+ create_published_article($this->link, $title, $url, $content, $labels,
+ $_SESSION["uid"]);
print "<script type='text/javascript'>";
print "window.close();";
@@ -424,9 +427,23 @@ class Handler_Public extends Handler {
<td><input name='url' value="<?php echo $url ?>"></td></tr>
<tr><td align='right'><?php echo __("Content:") ?></td>
<td><input name='content' value=""></td></tr>
+ <tr><td align='right'><?php echo __("Labels:") ?></td>
+ <td><input name='labels' id="labels_value"
+ placeholder='Alpha, Beta, Gamma' value="">
+ </td></tr>
+
+ <tr><td>
+ <div class="autocomplete" id="labels_choices"
+ style="display : block"></div></td></tr>
<script type='text/javascript'>document.forms[0].title.focus();</script>
+ <script type='text/javascript'>
+ new Ajax.Autocompleter('labels_value', 'labels_choices',
+ "backend.php?op=rpc&method=completeLabels",
+ { tokens: ',', paramName: "search" });
+ </script>
+
<tr><td colspan='2'>
<div style='float : right' class='insensitive-small'>
<?php echo __("Shared article will appear in the Published feed.") ?>
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php
index 91c504ce4..8cfa5336a 100644
--- a/classes/pref/feeds.php
+++ b/classes/pref/feeds.php
@@ -1479,7 +1479,7 @@ class Pref_Feeds extends Handler_Protected {
print "<p>" . __("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS") . "</p>";
- $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='".SELF_URL_PATH."/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=200')){l.href=g;}}a();})()");
+ $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='".SELF_URL_PATH."/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();})()");
print "<a href=\"$bm_url\" class='bookmarklet'>" . __('Share with Tiny Tiny RSS'). "</a>";
diff --git a/classes/rpc.php b/classes/rpc.php
index cb3eeda98..35de3362a 100644
--- a/classes/rpc.php
+++ b/classes/rpc.php
@@ -2,7 +2,7 @@
class RPC extends Handler_Protected {
function csrf_ignore($method) {
- $csrf_ignored = array("sanitycheck", "buttonplugin", "exportget", "sharepopup");
+ $csrf_ignored = array("sanitycheck", "buttonplugin", "exportget", "completelabels");
return array_search($method, $csrf_ignored) !== false;
}
@@ -426,6 +426,23 @@ class RPC extends Handler_Protected {
print json_encode(array("link" => $new_link));
}
+ function completeLabels() {
+ $search = db_escape_string($_REQUEST["search"]);
+
+ $result = db_query($this->link, "SELECT DISTINCT caption FROM
+ ttrss_labels2
+ WHERE owner_uid = '".$_SESSION["uid"]."' AND
+ LOWER(caption) LIKE LOWER('$search%') ORDER BY caption
+ LIMIT 5");
+
+ print "<ul>";
+ while ($line = db_fetch_assoc($result)) {
+ print "<li>" . $line["caption"] . "</li>";
+ }
+ print "</ul>";
+ }
+
+
function completeTags() {
$search = db_escape_string($_REQUEST["search"]);
diff --git a/include/functions.php b/include/functions.php
index 2695b1cb9..a81a2c0cd 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -5545,10 +5545,18 @@
}
- function create_published_article($link, $title, $url, $content, $owner_uid) {
- $guid = sha1($url);
+ function create_published_article($link, $title, $url, $content, $labels_str,
+ $owner_uid) {
+
+ $guid = sha1($url . $owner_uid); // include owner_uid to prevent global GUID clash
$content_hash = sha1($content);
+ if ($labels_str != "") {
+ $labels = explode(",", $labels_str);
+ } else {
+ $labels = array();
+ }
+
$rc = false;
if (!$title) $title = $url;
@@ -5584,6 +5592,12 @@
('$ref_id', '', NULL, NULL, $owner_uid, true, '', '', NOW(), '', false)");
}
+ if (count($labels) != 0) {
+ foreach ($labels as $label) {
+ label_add_article($link, $ref_id, trim($label), $owner_uid);
+ }
+ }
+
$rc = true;
} else {
@@ -5602,6 +5616,12 @@
VALUES
('$ref_id', '', NULL, NULL, $owner_uid, true, '', '', NOW(), '', false)");
+ if (count($labels) != 0) {
+ foreach ($labels as $label) {
+ label_add_article($link, $ref_id, trim($label), $owner_uid);
+ }
+ }
+
$rc = true;
}
}
diff --git a/utility.css b/utility.css
index 41541c707..de0042a77 100644
--- a/utility.css
+++ b/utility.css
@@ -151,3 +151,34 @@ body#sharepopup form {
body#sharepopup input {
width : 100%;
}
+
+div.autocomplete {
+ position : absolute;
+ width : 250px;
+ background-color : white;
+ border :1px solid #778899;
+ margin : 0px;
+ padding : 0px;
+ z-index : 4;
+}
+
+div.autocomplete ul {
+ list-style-type : none;
+ margin : 0px;
+ padding : 0px;
+ font-size : 10px;
+}
+
+div.autocomplete ul li.selected {
+ background-color : #fff7d5;
+}
+
+div.autocomplete ul li {
+ list-style-type : none;
+ display : block;
+ margin : 0;
+ padding : 2px;
+ height : 32px;
+ cursor : pointer;
+}
+