[geeklog-cvs] geeklog: Fixed remaining part of bug #779: Write "empty" feed fi...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Jan 18 07:46:40 EST 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/c50b9e34d55b
changeset: 6691:c50b9e34d55b
user: Dirk Haun <dirk at haun-online.de>
date: Sun Jan 18 13:45:10 2009 +0100
description:
Fixed remaining part of bug #779: Write "empty" feed files (header/footer only) when topic permissions don't allow inclusion of any articles
diffstat:
2 files changed, 52 insertions(+), 47 deletions(-)
system/classes/syndication/feedparserbase.class.php | 48 +++++++----------
system/lib-syndication.php | 51 +++++++++++--------
diffs (167 lines):
diff -r c31a00d27f02 -r c50b9e34d55b system/classes/syndication/feedparserbase.class.php
--- a/system/classes/syndication/feedparserbase.class.php Sat Jan 17 23:08:07 2009 +0100
+++ b/system/classes/syndication/feedparserbase.class.php Sun Jan 18 13:45:10 2009 +0100
@@ -137,36 +137,30 @@
*/
function createFeed( $fileName, $limit='' )
{
- /* If we have no items, return false */
- if( count( $this->articles ) == 0 )
+ /* Start the XML Feed formating */
+ $xml = $this->_feedHeader();
+
+ /* Start with a limit of the size of the array, then, if we have a
+ * specific max length use that unless it's bigger than our count */
+ $count = count( $this->articles );
+ if( $limit )
{
- return false;
- } else {
- /* Start the XML Feed formating */
- $xml = $this->_feedHeader();
+ if( $limit < $count )
+ {
+ $count = $limit;
+ }
+ }
- /* Start with a limit of the size of the array, then, if we have a
- * specific max length use that unless it's bigger than our count */
- $count = count( $this->articles );
- if( $limit )
- {
- if( $limit < $count )
- {
- $count = $limit;
- }
- }
+ /* Put the first $count items into the xml, using formatArticle */
+ for( $i = 0; $i < $count; $i++ )
+ {
+ $xml .= $this->_formatArticle( $this->articles[$i] );
+ }
- /* Put the first $count items into the xml, using formatArticle */
- for( $i = 0; $i < $count; $i++ )
- {
- $xml .= $this->_formatArticle( $this->articles[$i] );
- }
-
- /* Close off the feed */
- $xml .= $this->_feedFooter();
- /* And write it to file */
- return $this->_writeFile( $fileName, $xml );
- }
+ /* Close off the feed */
+ $xml .= $this->_feedFooter();
+ /* And write it to file */
+ return $this->_writeFile( $fileName, $xml );
}
function _writeFile( $fileName, $data )
diff -r c31a00d27f02 -r c50b9e34d55b system/lib-syndication.php
--- a/system/lib-syndication.php Sat Jan 17 23:08:07 2009 +0100
+++ b/system/lib-syndication.php Sun Jan 18 13:45:10 2009 +0100
@@ -75,6 +75,8 @@
$limitsql = ' LIMIT 10';
}
+ $sids = array ();
+
// get list of topics that anonymous users have access to
$tresult = DB_query( "SELECT tid FROM {$_TABLES['topics']}"
. COM_getPermSQL( 'WHERE', 1 ));
@@ -89,26 +91,26 @@
{
$tlist = "'" . implode( "','", $topiclist ) . "'";
$where .= " AND (tid IN ($tlist))";
- }
- if ($frontpage_only) {
- $where .= ' AND frontpage = 1';
- }
- $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 = array ();
- for( $i = 0; $i < $nrows; $i++ )
- {
- $A = DB_fetchArray( $result );
-
- if( $A['sid'] == $updated_id )
- {
- // no need to look any further - this feed has to be updated
- return false;
+ if ($frontpage_only) {
+ $where .= ' AND frontpage = 1';
}
- $sids[] = $A['sid'];
+ $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 );
+
+ for( $i = 0; $i < $nrows; $i++ )
+ {
+ $A = DB_fetchArray( $result );
+
+ if( $A['sid'] == $updated_id )
+ {
+ // no need to look any further - this feed has to be updated
+ return false;
+ }
+
+ $sids[] = $A['sid'];
+ }
}
$current = implode( ',', $sids );
@@ -153,7 +155,7 @@
$limitsql = ' LIMIT 10';
}
- $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" );
+ $result = DB_query( "SELECT sid FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() AND tid = '$tid'" . COM_getTopicSQL('AND', 1) . " AND perm_anon > 0 ORDER BY date DESC $limitsql" );
$nrows = DB_numRows( $result );
$sids = array ();
@@ -331,6 +333,8 @@
{
global $_TABLES, $_CONF, $LANG01;
+ $link = $_CONF['site_url'];
+
$where = '';
if( !empty( $limit ))
{
@@ -355,6 +359,14 @@
$tresult = DB_query( "SELECT tid,topic FROM {$_TABLES['topics']}"
. COM_getPermSQL( 'WHERE', 1 ));
$tnumrows = DB_numRows( $tresult );
+
+ if ($tnumrows == 0) {
+ // no public topics
+ $update = '';
+
+ return array();
+ }
+
$tlist = '';
for( $i = 1; $i <= $tnumrows; $i++ )
{
@@ -431,7 +443,6 @@
$content[] = $article;
}
- $link = $_CONF['site_url'];
$update = implode( ',', $sids );
return $content;
@@ -527,7 +538,7 @@
* at least one does, then include the trackback namespace:
*/
$trackbackenabled = false;
- foreach($content as $item)
+ foreach ($content as $item)
{
if( array_key_exists('extensions', $item) &&
array_key_exists('trackbacktag', $item['extensions'])
More information about the geeklog-cvs
mailing list