adding is now ajaxy as well
parent
c9f4d0da8c
commit
1af05fd705
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of FEED ON FEEDS - http://feedonfeeds.com/
|
||||
*
|
||||
* add.php - displays form to add a feed
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2004-2007 Stephen Minutillo
|
||||
* steve@minutillo.com - http://minutillo.com/steve/
|
||||
*
|
||||
* Distributed under the GPL - see LICENSE
|
||||
*
|
||||
*/
|
||||
|
||||
include_once("fof-main.php");
|
||||
|
||||
set_time_limit(60*10);
|
||||
|
||||
$url = $_POST['url'];
|
||||
if(!$url) $url = $_GET['url'];
|
||||
|
||||
print(fof_subscribe(fof_current_user(), $url));
|
||||
?>
|
78
add.php
78
add.php
|
@ -12,9 +12,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
include_once("fof-main.php");
|
||||
|
||||
set_time_limit(60*10);
|
||||
include("header.php");
|
||||
|
||||
$url = $_POST['rss_url'];
|
||||
if(!$url) $url = $_GET['rss_url'];
|
||||
|
@ -22,30 +20,6 @@ $opml = $_POST['opml_url'];
|
|||
$file = $_POST['opml_file'];
|
||||
$feeds = array();
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
|
||||
<div style="background: #eee; border: 1px solid black; padding: 1.5em; margin: 1.5em;">If your browser is cool, you can <a href='javascript:window.navigator.registerContentHandler("application/vnd.mozilla.maybe.feed", "http://<?php echo $_SERVER["HTTP_HOST"] . dirname($_SERVER["SCRIPT_NAME"]) ?>/add.php?rss_url=%s", "Feed on Feeds")'>register Feed on Feeds as a Feed Reader</a>. If it is not cool, you can still use the <a href="javascript:void(location.href='http://<?php echo $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"] ?>?rss_url='+escape(location))">FoF subscribe</a> bookmarklet to subscribe to any page with a feed. Just add it as a bookmark and then click on it when you are at a page you'd like to subscribe to!</div>
|
||||
|
||||
<form method="post" action="add.php" enctype="multipart/form-data">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
|
||||
|
||||
RSS or weblog URL: <input type="text" name="rss_url" size="40" value="<?php echo $url ?>"><input type="Submit" value="Add a feed"><br><br>
|
||||
</form>
|
||||
|
||||
<form method="post" action="add.php" enctype="multipart/form-data">
|
||||
OPML URL: <input type="hidden" name="MAX_FILE_SIZE" value="100000">
|
||||
|
||||
<input type="text" name="opml_url" size="40" value="<?php echo $opml ?>"><input type="Submit" value="Add feeds from OPML file on the Internet"><br><br>
|
||||
</form>
|
||||
|
||||
<form method="post" action="add.php" enctype="multipart/form-data">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
|
||||
OPML filename: <input type="file" name="opml_file" size="40" value="<?php echo $file ?>"><input type="Submit" value="Upload an OPML file">
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if($url) $feeds[] = $url;
|
||||
|
||||
if($opml)
|
||||
|
@ -76,26 +50,42 @@ if($_FILES['opml_file']['tmp_name'])
|
|||
}
|
||||
}
|
||||
|
||||
if(isset($feeds))
|
||||
{
|
||||
foreach ($feeds as $feed)
|
||||
{
|
||||
print "<br>Attempting to subscribe to <a href=\"$url\">$url</a>...<br>";
|
||||
?>
|
||||
|
||||
$message = fof_subscribe(fof_current_user(), $feed);
|
||||
|
||||
print $message;
|
||||
echo "<hr size=1>";
|
||||
flush();
|
||||
}
|
||||
<div style="background: #eee; border: 1px solid black; padding: 1.5em; margin: 1.5em;">If your browser is cool, you can <a href='javascript:window.navigator.registerContentHandler("application/vnd.mozilla.maybe.feed", "http://<?php echo $_SERVER["HTTP_HOST"] . dirname($_SERVER["SCRIPT_NAME"]) ?>/add.php?rss_url=%s", "Feed on Feeds")'>register Feed on Feeds as a Feed Reader</a>. If it is not cool, you can still use the <a href="javascript:void(location.href='http://<?php echo $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"] ?>?rss_url='+escape(location))">FoF subscribe</a> bookmarklet to subscribe to any page with a feed. Just add it as a bookmark and then click on it when you are at a page you'd like to subscribe to!</div>
|
||||
|
||||
<form method="post" action="add.php" enctype="multipart/form-data">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
|
||||
|
||||
RSS or weblog URL: <input type="text" name="rss_url" size="40" value="<?php echo $url ?>"><input type="Submit" value="Add a feed"><br><br>
|
||||
</form>
|
||||
|
||||
<form method="post" action="add.php" enctype="multipart/form-data">
|
||||
OPML URL: <input type="hidden" name="MAX_FILE_SIZE" value="100000">
|
||||
|
||||
<input type="text" name="opml_url" size="40" value="<?php echo $opml ?>"><input type="Submit" value="Add feeds from OPML file on the Internet"><br><br>
|
||||
</form>
|
||||
|
||||
<form method="post" action="add.php" enctype="multipart/form-data">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
|
||||
OPML filename: <input type="file" name="opml_file" size="40" value="<?php echo $file ?>"><input type="Submit" value="Upload an OPML file">
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if(count($feeds))
|
||||
{
|
||||
print("<script>\nwindow.onload = ajaxadd;\nfeedslist = [");
|
||||
|
||||
foreach($feeds as $feed)
|
||||
{
|
||||
$feedjson[] = "{'url': '" . addslashes($feed) . "'}";
|
||||
}
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
include("header.php");
|
||||
|
||||
print $output;
|
||||
print(join($feedjson, ", "));
|
||||
print("];\n</script>");
|
||||
}
|
||||
print("<br>");
|
||||
|
||||
include("footer.php");
|
||||
?>
|
||||
|
|
|
@ -472,7 +472,7 @@ function fof_subscribe($user_id, $url, $autodiscovery=true)
|
|||
|
||||
if(fof_is_subscribed($user_id, $url))
|
||||
{
|
||||
return "You are already subscribed to " . fof_render_feed_link($feed) . "<br><br>";
|
||||
return "You are already subscribed to " . fof_render_feed_link($feed) . "<br>";
|
||||
}
|
||||
|
||||
if(fof_feed_exists($url))
|
||||
|
@ -488,7 +488,7 @@ function fof_subscribe($user_id, $url, $autodiscovery=true)
|
|||
|
||||
if (isset($rss->error))
|
||||
{
|
||||
return "Error: <B>" . $rss->error . "</b> <a href=\"http://feedvalidator.org/check?url=$url\">try to validate it?</a> ";
|
||||
return "Error: <B>" . $rss->error . "</b> <a href=\"http://feedvalidator.org/check?url=$url\">try to validate it?</a><br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -498,7 +498,7 @@ function fof_subscribe($user_id, $url, $autodiscovery=true)
|
|||
|
||||
if(fof_is_subscribed($user_id, $rss->subscribe_url()))
|
||||
{
|
||||
return "You are already subscribed to " . fof_render_feed_link($feed) . "<br><br>";
|
||||
return "You are already subscribed to " . fof_render_feed_link($feed) . "<br>";
|
||||
}
|
||||
|
||||
fof_db_add_subscription($user_id, $feed['feed_id']);
|
||||
|
|
32
fof.js
32
fof.js
|
@ -321,7 +321,8 @@ function continueupdate()
|
|||
{
|
||||
f = feed();
|
||||
new Insertion.Bottom($('items'), 'Updating ' + f['title'] + "... ");
|
||||
|
||||
$('items').childElements().last().scrollTo();
|
||||
|
||||
new Ajax.Updater('items', 'update-single.php', {
|
||||
method: 'get',
|
||||
parameters: 'feed=' + f['id'],
|
||||
|
@ -336,9 +337,38 @@ function continueupdate()
|
|||
}
|
||||
}
|
||||
|
||||
function continueadd()
|
||||
{
|
||||
if(feed = feedi())
|
||||
{
|
||||
f = feed();
|
||||
new Insertion.Bottom($('items'), 'Adding ' + f['url'] + "... ");
|
||||
$('items').childElements().last().scrollTo();
|
||||
|
||||
new Ajax.Updater('items', 'add-single.php', {
|
||||
method: 'get',
|
||||
parameters: 'url=' + encodeURIComponent(f['url']),
|
||||
insertion: Insertion.Bottom,
|
||||
onComplete: continueadd
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
new Insertion.Bottom($('items'), '<br>Done!');
|
||||
refreshlist();
|
||||
}
|
||||
}
|
||||
|
||||
function ajaxupdate()
|
||||
{
|
||||
throb();
|
||||
feedi = iterate(feedslist);
|
||||
continueupdate();
|
||||
}
|
||||
|
||||
function ajaxadd()
|
||||
{
|
||||
throb();
|
||||
feedi = iterate(feedslist);
|
||||
continueadd();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue