[geeklog-cvs] geeklog-1.3/system lib-syndication.php,1.2,1.3
geeklog-cvs-admin at lists.geeklog.net
geeklog-cvs-admin at lists.geeklog.net
Mon Sep 8 13:33:02 EDT 2003
Update of /usr/cvs/geeklog/geeklog-1.3/system
In directory geeklog_prod:/tmp/cvs-serv6466/system
Modified Files:
lib-syndication.php
Log Message:
Added support for (RSS) feeds listing new links.
Index: lib-syndication.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/system/lib-syndication.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** lib-syndication.php 1 Sep 2003 19:01:07 -0000 1.2
--- lib-syndication.php 8 Sep 2003 17:33:00 -0000 1.3
***************
*** 87,91 ****
$result = DB_query( "SELECT sid FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() $where AND perm_anon > 0 ORDER BY date DESC $limitsql" );
$nrows = DB_numRows( $result );
- $sids = '';
$sids = array ();
--- 87,90 ----
***************
*** 138,142 ****
$result = DB_query( "SELECT sid FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() AND tid = '$tid' AND perm_anon > 0 ORDER BY date DESC $limitsql" );
$nrows = DB_numRows( $result );
- $sids = '';
$sids = array ();
--- 137,140 ----
***************
*** 155,159 ****
}
! /*
* Get content for a feed that holds stories from one topic.
*
--- 153,245 ----
}
! /**
! * Check if a feed for the links needs to be updated.
! *
! * @param string $update_info list of link ids
! * @param string $limit number of entries or number of hours
! * @return bool false = feed needs to be updated
! *
! */
! function SYND_feedUpdateCheckLinks( $update_info, $limit )
! {
! global $_CONF, $_TABLES, $_SYND_DEBUG;
!
! $where = '';
! if( !empty( $limit ))
! {
! if( substr( $limit, -1 ) == 'h' ) // last xx hours
! {
! $limitsql = '';
! $hours = substr( $limit, 0, -1 );
! $where = " AND date >= DATE_SUB(NOW(),INTERVAL $hours HOUR)";
! }
! else
! {
! $limitsql = ' LIMIT ' . $limit;
! }
! }
! else
! {
! $limitsql = ' LIMIT 10';
! }
!
! $result = DB_query( "SELECT lid FROM {$_TABLES['links']} WHERE perm_anon > 0 $where ORDER BY date DESC $limitsql" );
! $nrows = DB_numRows( $result );
!
! $lids = array();
! for( $i = 0; $i < $nrows; $i++ )
! {
! $A = DB_fetchArray( $result );
! $lids[] = $A['lid'];
! }
! $current = implode( ',', $lids );
!
! if ($_SYND_DEBUG) {
! COM_errorLog ("Update check for links: comparing new list ($current) with old list ($update_info)", 1);
! }
!
! return ( $current != $update_info ) ? false : true;
! }
!
! /**
! * Check if the feed contents need to be updated.
! *
! * @param string plugin plugin name
! * @param int feed feed id
! * @param string topic "topic" of the feed - plugin specific
! * @param string limit number of entries or number of hours
! * @return bool false = feed has to be updated, true = ok
! *
! */
! function SYND_feedUpdateCheck( $plugin, $feed, $topic, $update_data, $limit )
! {
! $is_current = true;
!
! switch( $topic )
! {
! case '::all':
! {
! $is_current = SYND_feedUpdateCheckAll( $update_data, $limit );
! }
! break;
!
! case '::links':
! {
! $is_current = SYND_feedUpdateCheckLinks( $update_data, $limit );
! }
! break;
!
! default:
! {
! $is_current = SYND_feedUpdateChecktopic( $topic, $update_data,
! $limit );
! }
! break;
! }
!
! return $is_current;
! }
!
! /**
* Get content for a feed that holds stories from one topic.
*
***************
*** 227,231 ****
}
! /*
* Get content for a feed that holds all stories.
*
--- 313,317 ----
}
! /**
* Get content for a feed that holds all stories.
*
***************
*** 313,316 ****
--- 399,467 ----
/**
+ * Get content for a feed that holds all links.
+ *
+ * @param string $limit number of entries or number of stories
+ * @param string $link link to homepage
+ * @param string $update list of story ids
+ * @return array content of the feed
+ *
+ */
+ function SYND_getFeedContentLinks( $limit, &$link, &$update )
+ {
+ global $_TABLES, $_CONF, $LANG01;
+
+ $where = '';
+ if( !empty( $limit ))
+ {
+ if( substr( $limit, -1 ) == 'h' ) // last xx hours
+ {
+ $limitsql = '';
+ $hours = substr( $limit, 0, -1 );
+ $where = " AND date >= DATE_SUB(NOW(),INTERVAL $hours HOUR) ORDER BY date DESC";
+ }
+ else
+ {
+ $limitsql = ' LIMIT ' . $limit;
+ $where = " ORDER BY lid DESC";
+ }
+ }
+ else
+ {
+ $limitsql = ' LIMIT 10';
+ }
+
+ $result = DB_query( "SELECT lid,owner_id,title,description,UNIX_TIMESTAMP(date) AS modified FROM {$_TABLES['links']} WHERE perm_anon > 0 $where $limitsql" );
+
+ $content = array();
+ $lids = array();
+ $nrows = DB_numRows( $result );
+
+ for( $i = 1; $i <= $nrows; $i++ )
+ {
+ $row = DB_fetchArray( $result );
+ $lids[] = $row['lid'];
+
+ $linktitle = stripslashes( $row['title'] );
+ $linkdesc = stripslashes( $row['description'] );
+
+ $linklink = $_CONF['site_url'] . '/portal.php?what=link&item='
+ . $row['lid'];
+
+ $content[] = array( 'title' => $linktitle,
+ 'text' => $linkdesc,
+ 'link' => $linklink,
+ 'uid' => $row['owner_id'],
+ 'date' => $row['modified'],
+ 'format' => 'plaintext'
+ );
+ }
+
+ $link = $_CONF['site_url'] . '/links.php';
+ $update = implode( ',', $lids );
+
+ return $content;
+ }
+
+ /**
* Update a feed.
*
***************
*** 340,343 ****
--- 491,498 ----
{
$content = SYND_getFeedContentAll( $A['limits'], $link, $data );
+ }
+ elseif( $A['topic'] == '::links')
+ {
+ $content = SYND_getFeedContentLinks( $A['limits'], $link, $data );
}
else // feed for a single topic only
More information about the geeklog-cvs
mailing list