Home « Server software «
Documentation: feeds/feeds.php
class Feeds - Get news
This data abstraction for feeds provides two main functions, plus several utility functions:get_local_news()
- retrieve local newsget_remote_news()
- retrieve news collected from remote sitesget_remote_news_from()
- actual news fetching from one feeding sitetick_hook()
- trigger feeding in the background
This script is a reference file of this system.
Licence: GNU Lesser General Public License
Auteurs:
- Bernard Paques bernard.paques@bigfoot.com
Testeurs:
- Dobliu
decode_date() - Decode a date
function decode_date($date)
- $date - string some date
- returns int a valid time stamp, or -1
Voir aussi:
get_local_news() - Get current news from this server
function get_local_news($count=20, $variant='feeds')
- $count=20 - int the number of items to list
- $variant='feeds' - 'feeds' to get a regular feed, or 'contents' to get everything
- returns an array of array($time, $title, $author, $section, $image, $description)
get_remote_news() - Get news from remote servers
function get_remote_news($count=20, $variant='compact')
- $count=20 - the maximum number of news to fetch
- $variant='compact' - the expected variant to use
- returns an array to use with
Skin::build_list()
, or NULL
By default, up to 20 items are displayed.
Voir aussi:
get_remote_news_from() - Get news from a remote server
function get_remote_news_from($feed_url)
- $feed_url - string the URL to use to fetch news
- returns either an array of items, or NULL on error
debug_feeds
, at feeds/configure.php).Voir aussi:
tick_hook() - Get news from remote servers
function tick_hook($forced=FALSE)
- $forced=FALSE - boolean if set to true, fetch news on each call; else use normal period of time
- returns a string to be displayed in resulting page, if any
On tick, the including hook calls
Feeds::tick_hook()
.
See control/scan.php for a more complete description of hooks.The function browses the database to locate servers acting as feeders, and read the URLs to use.
A round-robin algorithm is implemented, meaning that servers are polled in sequence throughout successive ticks. At most 1 feed is parsed on each tick, to limit impact when the "poor-man" cron mechanism is used, which is the default setting.
XML feeds are fetched and parsed according to their type. At the moment YACS is able to process RSS and slashdot feeds. Link records are created or updated in the database saving as much of possible of provided data. Item data is reflected in Link, Title, and Description fields. Channel data is used to populate the Source field. Stamping information is based on feeding date, and channel title. Also, the edit action 'link:feed' marks links that are collected from feeders. The anchor field is set to the category assigned in the server profile.
At the end of the feeding process, the database is purged from oldest links according to the limit defined in feeds/parameters.include.php, set through feeds/configure.php. See Links::purge_old_news().
Voir aussi: