Menu

#12 add feed icon to view page (for 0.17)

open
nobody
None
5
2004-09-20
2004-09-20
Edmond Hui
No

This patch add the icon of a feed to the view page

1) execute this in MySQL: alter table px_feeds add
favicon varchar(250);

2) replace fof_view_title() in init.php

function fof_view_title($feed=NULL, $what="new",
$when=NULL, $start=NULL, $limit=NULL)
{
$title = "feed on feeds";

if(!is_null($when) && $when != "")
{
$title .= ' - ' . $when ;
}
if(!is_null($feed) && $feed != "")
{
$r = fof_feed_row($feed);
$title .=' - ' .
htmlspecialchars($r['title']);
}
if(is_numeric($start))
{
if(!is_numeric($limit)) $limit =
FOF_HOWMANY;
$title .= " - items $start to " .
($start + $limit);
}
if($what != "all")
{
$title .=' - new items';
}
else
{
$title .= ' - all items';
}

if ($r['favicon'] != "")
{
$title = "<img src=\"" . $r['favicon']
. "\"> " . $title;
}

return $title;
}

3) replace fof_actually_add_feed() in init.php

function fof_actually_add_feed($url, $rss)
{
global $FOF_FEED_TABLE, $FOF_ITEM_TABLE;

$title =
mysql_escape_string($rss->channel['title']);
$link = mysql_escape_string($rss->channel['link']);
$description =
mysql_escape_string($rss->channel['description']);
$favicon = mysql_escape_string($rss->image['url']);

$sql = "insert into $FOF_FEED_TABLE
(url,title,link,description,favicon) values
('$url','$title','$link','$description','$favicon
')";
fof_do_query($sql);

fof_update_feed($url, 0);
}

4) replace fof_feed_row() in init.php

function fof_feed_row($id)
{
global $FOF_FEED_TABLE, $FOF_ITEM_TABLE;

$result = fof_do_query("select url, title,
link, id, favicon from $FOF_FEED_TABLE where id = '$id'");

if(mysql_num_rows($result) == 0)
{
return false;
}
else
{
$row = mysql_fetch_array($result);
return $row;
}
}

5) save and run update-favicon.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head><title>feed on feeds - update feed favicon</title>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<link rel="stylesheet" href="fof.css"
media="screen" />
<script src="fof.js"
type="text/javascript"></script>
<meta name="ROBOTS" content="NOINDEX,
NOFOLLOW" />
</head>
<body>

<BR>
<?php

include_once("init.php");

$sql = "select id, url, favicon from " . FOF_FEED_TABLE;

$result = fof_do_query($sql);

while($row = mysql_fetch_array($result))
{
$id = $row['id'];
print "Updating feed <b>$id</b>...";

$feed = fof_feed_row($id);

$rss = fetch_rss( $row['url'] );
$favicon = $rss->image['url'];

$upd = "update " . FOF_FEED_TABLE . " set
`favicon` = \"" . $favicon . "\" where id=" . $id;

fof_do_query($upd);

print " (favicon: " . $favicon . ") done. ";

print "<br>";
}
?>
<BR>

</body></html>

6) remove update-favicon.php, if desired.

Discussion


Log in to post a comment.