Allow to tag new feeds on adding
parent
11e280dbbe
commit
098d962eb4
|
@ -15,9 +15,20 @@
|
||||||
include_once("fof-main.php");
|
include_once("fof-main.php");
|
||||||
|
|
||||||
$url = $_REQUEST['url'];
|
$url = $_REQUEST['url'];
|
||||||
|
$tags = $_REQUEST['tags'];
|
||||||
$unread = $_REQUEST['unread'];
|
$unread = $_REQUEST['unread'];
|
||||||
|
|
||||||
$error = fof_subscribe(fof_current_user(), $url, $unread);
|
list($error, $feed) = fof_subscribe(fof_current_user(), $url, $unread);
|
||||||
|
$error .= '<br />';
|
||||||
|
foreach (preg_split("/[\s,]*,[\s,]*/", $tags) as $tag)
|
||||||
|
{
|
||||||
|
if ($tag)
|
||||||
|
{
|
||||||
|
fof_tag_feed(fof_current_user(), $feed['feed_id'], $tag);
|
||||||
|
$error .= 'Tagged \''.htmlspecialchars($feed['feed_title']).'\' as '.htmlspecialchars($tag).'<br />';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (preg_match('/HTTP 401/', $error))
|
if (preg_match('/HTTP 401/', $error))
|
||||||
print "<script>
|
print "<script>
|
||||||
document.addform.basic_login.style.backgroundColor='#FFC0C0';
|
document.addform.basic_login.style.backgroundColor='#FFC0C0';
|
||||||
|
@ -25,4 +36,3 @@ document.addform.basic_password.style.backgroundColor='#FFC0C0';
|
||||||
document.addform.basic_password.focus();
|
document.addform.basic_password.focus();
|
||||||
</script>";
|
</script>";
|
||||||
print $error;
|
print $error;
|
||||||
?>
|
|
||||||
|
|
|
@ -29,4 +29,3 @@ foreach(preg_split("/[\s,]*,[\s,]*/", $tags) as $tag)
|
||||||
fof_tag_item(fof_current_user(), $item, $tag);
|
fof_tag_item(fof_current_user(), $item, $tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
9
add.php
9
add.php
|
@ -17,6 +17,7 @@
|
||||||
include("header.php");
|
include("header.php");
|
||||||
|
|
||||||
$url = $_REQUEST['rss_url'];
|
$url = $_REQUEST['rss_url'];
|
||||||
|
$new_tags = $_REQUEST['new_tags'];
|
||||||
$login = $_REQUEST['basic_login'];
|
$login = $_REQUEST['basic_login'];
|
||||||
$password = $_REQUEST['basic_password'];
|
$password = $_REQUEST['basic_password'];
|
||||||
$opml = $_REQUEST['opml_url'];
|
$opml = $_REQUEST['opml_url'];
|
||||||
|
@ -91,7 +92,8 @@ When adding feeds, mark <select name="unread"><option value=today <?= $unread ==
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
RSS or weblog URL: <input type="text" name="rss_url" size="40" value="<?= htmlspecialchars($url) ?>" /> <input name="do" type="Submit" value="Add a feed" /><br />
|
RSS or weblog URL: <input type="text" name="rss_url" size="40" value="<?= htmlspecialchars($url) ?>" /> <input name="do" type="Submit" value="Add a feed" /><br />
|
||||||
Login: <input type="text" name="basic_login" value="<?= htmlspecialchars($login) ?>" /> Password: <input type="password" name="basic_password" value="<?= htmlspecialchars($password) ?>" /> (optional) for password-protected feeds
|
Login: <input type="text" name="basic_login" value="<?= htmlspecialchars($login) ?>" /> Password: <input type="password" name="basic_password" value="<?= htmlspecialchars($password) ?>" /> (optional) for password-protected feeds<br />
|
||||||
|
Tags for new feed(s): <input type="text" name="new_tags" size="40" value="<?= htmlspecialchars($new_tags) ?>" /> (separate by comma)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h1>OPML import</h1>
|
<h1>OPML import</h1>
|
||||||
|
@ -124,14 +126,11 @@ if(count($feeds))
|
||||||
print("<script>\nwindow.onload = ajaxadd;\nfeedslist = [");
|
print("<script>\nwindow.onload = ajaxadd;\nfeedslist = [");
|
||||||
|
|
||||||
foreach($feeds as $feed)
|
foreach($feeds as $feed)
|
||||||
{
|
|
||||||
$feedjson[] = "{'url': '" . addslashes($feed) . "'}";
|
$feedjson[] = "{'url': '" . addslashes($feed) . "'}";
|
||||||
}
|
|
||||||
|
|
||||||
print(join($feedjson, ", "));
|
print(join($feedjson, ", "));
|
||||||
print("];\n</script>");
|
print("];\n</script>");
|
||||||
}
|
}
|
||||||
print("<br>");
|
print("<br />");
|
||||||
|
|
||||||
include("footer.php");
|
include("footer.php");
|
||||||
?>
|
|
||||||
|
|
30
fof-db.php
30
fof-db.php
|
@ -257,7 +257,7 @@ function fof_db_add_feed($url, $title, $link, $description)
|
||||||
|
|
||||||
fof_safe_query("insert into $FOF_FEED_TABLE (feed_url,feed_title,feed_link,feed_description) values ('%s', '%s', '%s', '%s')", $url, $title, $link, $description);
|
fof_safe_query("insert into $FOF_FEED_TABLE (feed_url,feed_title,feed_link,feed_description) values ('%s', '%s', '%s', '%s')", $url, $title, $link, $description);
|
||||||
|
|
||||||
return(mysql_insert_id($fof_connection));
|
return mysql_insert_id($fof_connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fof_db_add_subscription($user_id, $feed_id)
|
function fof_db_add_subscription($user_id, $feed_id)
|
||||||
|
@ -274,9 +274,7 @@ function fof_db_delete_subscription($user_id, $feed_id)
|
||||||
$result = fof_db_get_items($user_id, $feed_id, $what="all", NULL, NULL);
|
$result = fof_db_get_items($user_id, $feed_id, $what="all", NULL, NULL);
|
||||||
|
|
||||||
foreach($result as $r)
|
foreach($result as $r)
|
||||||
{
|
|
||||||
$items[] = $r['item_id'];
|
$items[] = $r['item_id'];
|
||||||
}
|
|
||||||
|
|
||||||
fof_safe_query("delete from $FOF_SUBSCRIPTION_TABLE where feed_id = %d and user_id = %d", $feed_id, $user_id);
|
fof_safe_query("delete from $FOF_SUBSCRIPTION_TABLE where feed_id = %d and user_id = %d", $feed_id, $user_id);
|
||||||
|
|
||||||
|
@ -304,14 +302,10 @@ function fof_db_find_item($feed_id, $item_guid)
|
||||||
$result = fof_safe_query("select item_id from $FOF_ITEM_TABLE where feed_id=%d and item_guid='%s'", $feed_id, $item_guid);
|
$result = fof_safe_query("select item_id from $FOF_ITEM_TABLE where feed_id=%d and item_guid='%s'", $feed_id, $item_guid);
|
||||||
$row = mysql_fetch_array($result);
|
$row = mysql_fetch_array($result);
|
||||||
|
|
||||||
if(mysql_num_rows($result) == 0)
|
if (mysql_num_rows($result) == 0)
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return($row['item_id']);
|
return($row['item_id']);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$fof_db_item_fields = array('item_guid', 'item_link', 'item_title', 'item_author', 'item_content', 'item_cached', 'item_published', 'item_updated');
|
$fof_db_item_fields = array('item_guid', 'item_link', 'item_title', 'item_author', 'item_content', 'item_cached', 'item_published', 'item_updated');
|
||||||
|
@ -658,25 +652,17 @@ function fof_db_mark_feed_read($user_id, $feed_id)
|
||||||
fof_db_untag_items($user_id, 1, $items);
|
fof_db_untag_items($user_id, 1, $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fof_db_mark_feed_unread($user_id, $feed, $what)
|
function fof_db_mark_feed_unread($user_id, $feed_id, $what)
|
||||||
{
|
{
|
||||||
global $FOF_ITEM_TAG_TABLE;
|
fof_log("fof_db_mark_feed_unread($user_id, $feed_id, $what)");
|
||||||
|
|
||||||
fof_log("fof_db_mark_feed_unread($user_id, $feed, $what)");
|
if ($what == "all")
|
||||||
|
$result = fof_db_get_items($user_id, $feed_id, "all");
|
||||||
if($what == "all")
|
elseif ($what == "today")
|
||||||
{
|
$result = fof_db_get_items($user_id, $feed_id, "all", "today");
|
||||||
$result = fof_db_get_items($user_id, $feed, "all");
|
|
||||||
}
|
|
||||||
if($what == "today")
|
|
||||||
{
|
|
||||||
$result = fof_db_get_items($user_id, $feed, "all", "today");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach((array)$result as $r)
|
foreach((array)$result as $r)
|
||||||
{
|
|
||||||
$items[] = $r['item_id'];
|
$items[] = $r['item_id'];
|
||||||
}
|
|
||||||
|
|
||||||
fof_db_tag_items($user_id, 1, $items);
|
fof_db_tag_items($user_id, 1, $items);
|
||||||
}
|
}
|
||||||
|
|
52
fof-main.php
52
fof-main.php
|
@ -609,34 +609,32 @@ function fof_prepare_url($url)
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fof_subscribe($user_id, $url, $unread="today")
|
function fof_subscribe($user_id, $url, $unread = "today")
|
||||||
{
|
{
|
||||||
if(!$url) return false;
|
if (!$url)
|
||||||
|
return array("Empty URL", false);
|
||||||
|
|
||||||
$url = fof_prepare_url($url);
|
$url = fof_prepare_url($url);
|
||||||
$feed = fof_db_get_feed_by_url($url);
|
$feed = fof_db_get_feed_by_url($url);
|
||||||
|
|
||||||
if(fof_is_subscribed($user_id, $url))
|
if (fof_is_subscribed($user_id, $url))
|
||||||
{
|
return array("You are already subscribed to " . fof_render_feed_link($feed), $feed);
|
||||||
return "You are already subscribed to " . fof_render_feed_link($feed) . "<br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fof_feed_exists($url))
|
if (fof_feed_exists($url))
|
||||||
{
|
{
|
||||||
fof_db_add_subscription($user_id, $feed['feed_id']);
|
fof_db_add_subscription($user_id, $feed['feed_id']);
|
||||||
fof_apply_plugin_tags($id, NULL, $user_id);
|
fof_apply_plugin_tags($id, NULL, $user_id);
|
||||||
fof_update_feed($feed['feed_id']);
|
fof_update_feed($feed['feed_id']);
|
||||||
|
|
||||||
if($unread != "no") fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
|
if ($unread != "no")
|
||||||
return '<font color="green"><b>Subscribed.</b></font><!-- '.$feed['feed_id'].' --><br>';
|
fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
|
||||||
|
return array('<font color="green"><b>Subscribed.</b></font>', $feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rss = fof_parse($url, $user_id);
|
$rss = fof_parse($url, $user_id);
|
||||||
|
|
||||||
if (isset($rss->error))
|
if (isset($rss->error))
|
||||||
{
|
return array("Error: <b>" . $rss->error . "</b>", $feed);
|
||||||
return "Error: <b>" . $rss->error . "</b><br />";
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$url = html_entity_decode($rss->subscribe_url(), ENT_QUOTES);
|
$url = html_entity_decode($rss->subscribe_url(), ENT_QUOTES);
|
||||||
|
@ -645,45 +643,45 @@ function fof_subscribe($user_id, $url, $unread="today")
|
||||||
// Why? 1) handling broken feeds 2) handling authorized feeds 3) user knows URL better
|
// Why? 1) handling broken feeds 2) handling authorized feeds 3) user knows URL better
|
||||||
//if($self) $url = html_entity_decode($self, ENT_QUOTES);
|
//if($self) $url = html_entity_decode($self, ENT_QUOTES);
|
||||||
|
|
||||||
if(fof_feed_exists($url))
|
if (fof_feed_exists($url))
|
||||||
{
|
{
|
||||||
$feed = fof_db_get_feed_by_url($url);
|
$feed = fof_db_get_feed_by_url($url);
|
||||||
|
|
||||||
if(fof_is_subscribed($user_id, $url))
|
if (fof_is_subscribed($user_id, $url))
|
||||||
{
|
return array("You are already subscribed to " . fof_render_feed_link($feed), $feed);
|
||||||
return "You are already subscribed to " . fof_render_feed_link($feed) . "<br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
fof_db_add_subscription($user_id, $feed['feed_id']);
|
fof_db_add_subscription($user_id, $feed['feed_id']);
|
||||||
if($unread != "no") fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
|
if ($unread != "no")
|
||||||
|
fof_db_mark_feed_unread($user_id, $feed['feed_id'], $unread);
|
||||||
|
|
||||||
return '<font color="green"><b>Subscribed.</b></font><!-- '.$feed['feed_id'].' --><br>';
|
return array('<font color="green"><b>Subscribed.</b></font>', $feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = fof_add_feed($url, rss_feed_title($rss), $rss->get_link(), $rss->get_description() );
|
$id = fof_add_feed($url, rss_feed_title($rss), $rss->get_link(), $rss->get_description());
|
||||||
|
|
||||||
fof_update_feed($id);
|
fof_update_feed($id);
|
||||||
fof_db_add_subscription($user_id, $id);
|
fof_db_add_subscription($user_id, $id);
|
||||||
if($unread != "no") fof_db_mark_feed_unread($user_id, $id, $unread);
|
if ($unread != "no")
|
||||||
|
fof_db_mark_feed_unread($user_id, $id, $unread);
|
||||||
|
|
||||||
fof_apply_plugin_tags($id, NULL, $user_id);
|
fof_apply_plugin_tags($id, NULL, $user_id);
|
||||||
|
|
||||||
return "<font color='green'><b>Subscribed.</b></font><!-- $id --><br>";
|
$feed = fof_db_get_feed_by_id($id);
|
||||||
|
return array('<font color="green"><b>Subscribed.</b></font>', $feed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fof_add_feed($url, $title, $link, $description)
|
function fof_add_feed($url, $title, $link, $description)
|
||||||
{
|
{
|
||||||
if($title == "") $title = "[no title]";
|
if ($title == "")
|
||||||
|
$title = "[no title]";
|
||||||
|
|
||||||
$id = fof_db_add_feed($url, $title, $link, $description);
|
return fof_db_add_feed($url, $title, $link, $description);
|
||||||
|
|
||||||
return $id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fof_is_subscribed($user_id, $url)
|
function fof_is_subscribed($user_id, $url)
|
||||||
{
|
{
|
||||||
return(fof_db_is_subscribed($user_id, $url));
|
return fof_db_is_subscribed($user_id, $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fof_feed_exists($url)
|
function fof_feed_exists($url)
|
||||||
|
|
8
fof.js
8
fof.js
|
@ -884,14 +884,16 @@ function continueupdate()
|
||||||
function continueadd()
|
function continueadd()
|
||||||
{
|
{
|
||||||
var feed, f, m, dispUrl;
|
var feed, f, m, dispUrl;
|
||||||
if(feed = feedi())
|
if (feed = feedi())
|
||||||
{
|
{
|
||||||
f = feed();
|
f = feed();
|
||||||
dispUrl = f['url'].replace(/^([a-z]+:\/\/[^\/]+:)([^\/]+)(@.*)$/, '$1******$3');
|
dispUrl = f['url'].replace(/^([a-z]+:\/\/[^\/]+:)([^\/]+)(@.*)$/, '$1******$3');
|
||||||
new Insertion.Bottom($('items'), 'Adding ' + dispUrl + "... ");
|
new Insertion.Bottom($('items'), 'Adding ' + dispUrl + "... ");
|
||||||
$('items').childElements().last().scrollTo();
|
$('items').childElements().last().scrollTo();
|
||||||
|
|
||||||
parameters = 'url=' + encodeURIComponent(f['url']) + "&unread=" + document.addform.unread.value;
|
var parameters = 'url=' + encodeURIComponent(f['url']);
|
||||||
|
parameters += "&unread=" + document.addform.unread.value;
|
||||||
|
parameters += "&tags=" + document.addform.new_tags.value;
|
||||||
|
|
||||||
new Ajax.Updater('items', 'add-single.php', {
|
new Ajax.Updater('items', 'add-single.php', {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
@ -903,7 +905,7 @@ function continueadd()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
new Insertion.Bottom($('items'), '<br>Done!');
|
new Insertion.Bottom($('items'), '<br />Done!');
|
||||||
refreshlist();
|
refreshlist();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,9 +137,9 @@ function globalauth($url, $require = true)
|
||||||
|
|
||||||
function fof_tag_subscribe($userid, $url, $tag)
|
function fof_tag_subscribe($userid, $url, $tag)
|
||||||
{
|
{
|
||||||
$id = fof_subscribe($userid, $url);
|
list($error, $feed) = fof_subscribe($userid, $url);
|
||||||
if (preg_match('/<!-- (\d+) -->/is', $id, $m))
|
if ($feed)
|
||||||
fof_tag_feed($userid, 0+$m[1], $tag);
|
fof_tag_feed($userid, $feed['feed_id'], $tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Добавление фидов для новых юзеров */
|
/* Добавление фидов для новых юзеров */
|
||||||
|
|
|
@ -56,7 +56,7 @@ if (isset($_REQUEST['tagfeeds']))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add tags
|
// add tags
|
||||||
else if ($prop == 'tag')
|
elseif ($prop == 'tag')
|
||||||
{
|
{
|
||||||
foreach (preg_split("/[\s,]*,[\s,]*/", $v) as $tag)
|
foreach (preg_split("/[\s,]*,[\s,]*/", $v) as $tag)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@ if (isset($_REQUEST['tagfeeds']))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// change filter
|
// change filter
|
||||||
else if ($prop == 'filter')
|
elseif ($prop == 'filter')
|
||||||
{
|
{
|
||||||
if (fof_db_set_feedprop(fof_current_user(), $feed_id, 'filter', $v))
|
if (fof_db_set_feedprop(fof_current_user(), $feed_id, 'filter', $v))
|
||||||
$message[] = 'Set filter \''.htmlspecialchars($v).'\' for feed \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\'';
|
$message[] = 'Set filter \''.htmlspecialchars($v).'\' for feed \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\'';
|
||||||
|
|
Loading…
Reference in New Issue