[geeklog-cvs] Geeklog-1.x/system lib-syndication.php,1.42,1.43

Dirk Haun dhaun at qs1489.pair.com
Sun Jul 27 03:36:00 EDT 2008


Update of /cvsroot/geeklog/Geeklog-1.x/system
In directory qs1489.pair.com:/tmp/cvs-serv37552/system

Modified Files:
	lib-syndication.php 
Log Message:
New option "All Frontpage Stories" for article feeds: skip stories that have the "Show only in topic" option set (feature request #0000652)


Index: lib-syndication.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/system/lib-syndication.php,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** lib-syndication.php	26 Jul 2008 16:25:17 -0000	1.42
--- lib-syndication.php	27 Jul 2008 07:35:58 -0000	1.43
***************
*** 41,45 ****
  
  if ($_CONF['trackback_enabled']) {
!     require_once ($_CONF['path_system'] . 'lib-trackback.php');
  }
  
--- 41,45 ----
  
  if ($_CONF['trackback_enabled']) {
!     require_once $_CONF['path_system'] . 'lib-trackback.php';
  }
  
***************
*** 47,50 ****
--- 47,51 ----
  * Check if a feed for all stories needs to be updated.
  *
+ * @param    bool    $frontpage_only true: only articles shown on the frontpage
  * @param    string  $update_info    list of story ids
  * @param    string  $limit          number of entries or number of hours
***************
*** 54,58 ****
  *
  */
! function SYND_feedUpdateCheckAll( $update_info, $limit, $updated_topic = '', $updated_id = '' )
  {
      global $_CONF, $_TABLES, $_SYND_DEBUG;
--- 55,59 ----
  *
  */
! function SYND_feedUpdateCheckAll( $frontpage_only, $update_info, $limit, $updated_topic = '', $updated_id = '' )
  {
      global $_CONF, $_TABLES, $_SYND_DEBUG;
***************
*** 92,95 ****
--- 93,99 ----
          $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" );
***************
*** 187,207 ****
  *
  */
! function SYND_feedUpdateCheck( $topic, $update_data, $limit, $updated_topic = '', $updated_id = '' )
  {
      $is_current = true; 
  
!     switch( $topic )
!     {
!         case '::all':
!         {
!             $is_current = SYND_feedUpdateCheckAll( $update_data, $limit,
!                             $updated_topic, $updated_id );
!         }
          break;
!         default:
!         {
!             $is_current = SYND_feedUpdateCheckTopic( $topic, $update_data,
!                             $limit, $updated_topic, $updated_id );
!         }
          break;
      }
--- 191,212 ----
  *
  */
! function SYND_feedUpdateCheck($topic, $update_data, $limit, $updated_topic = '', $updated_id = '')
  {
      $is_current = true; 
  
!     switch($topic) {
!     case '::all':
!         $is_current = SYND_feedUpdateCheckAll(false, $update_data, $limit,
!                             $updated_topic, $updated_id);
          break;
! 
!     case '::frontpage':
!         $is_current = SYND_feedUpdateCheckAll(true, $update_data, $limit,
!                             $updated_topic, $updated_id);
!         break;
! 
!     default:
!         $is_current = SYND_feedUpdateCheckTopic($topic, $update_data,
!                             $limit, $updated_topic, $updated_id);
          break;
      }
***************
*** 316,319 ****
--- 321,325 ----
  * Get content for a feed that holds all stories.
  *
+ * @param    bool     $frontpage_only true: only articles shown on the frontpage
  * @param    string   $limit    number of entries or number of stories
  * @param    string   $link     link to homepage
***************
*** 324,328 ****
  *
  */
! function SYND_getFeedContentAll( $limit, &$link, &$update, $contentLength, $feedType, $feedVersion, $fid)
  {
      global $_TABLES, $_CONF, $LANG01;
--- 330,334 ----
  *
  */
! function SYND_getFeedContentAll($frontpage_only, $limit, &$link, &$update, $contentLength, $feedType, $feedVersion, $fid)
  {
      global $_TABLES, $_CONF, $LANG01;
***************
*** 367,370 ****
--- 373,379 ----
          $where .= " AND (tid IN ($tlist))";
      }
+     if ($frontpage_only) {
+         $where .= ' AND frontpage = 1';
+     }
  
      $result = DB_query( "SELECT sid,tid,uid,title,introtext,bodytext,postmode,UNIX_TIMESTAMP(date) AS modified,commentcode,trackbackcode FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() $where AND perm_anon > 0 ORDER BY date DESC $limitsql" );
***************
*** 401,405 ****
          $storylink = COM_buildUrl( $_CONF['site_url'] . '/article.php?story='
                                     . $row['sid'] );
!         $extensionTags = PLG_getFeedElementExtensions('article', $row['sid'], $feedType, $feedVersion, $fid, '::all');
          if( $_CONF['trackback_enabled'] && ($feedType == 'RSS') && ($row['trackbackcode'] >= 0))
          {
--- 410,414 ----
          $storylink = COM_buildUrl( $_CONF['site_url'] . '/article.php?story='
                                     . $row['sid'] );
!         $extensionTags = PLG_getFeedElementExtensions('article', $row['sid'], $feedType, $feedVersion, $fid, ($frontpage_only ? '::frontpage' : '::all'));
          if( $_CONF['trackback_enabled'] && ($feedType == 'RSS') && ($row['trackbackcode'] >= 0))
          {
***************
*** 408,421 ****
          }
          $article = array( 'title'      => $storytitle,
!                             'summary'    => $storytext,
!                             'text'       => $fulltext,
!                             'link'       => $storylink,
!                             'uid'        => $row['uid'],
!                             'author'     => COM_getDisplayName( $row['uid'] ),
!                             'date'       => $row['modified'],
!                             'format'     => $row['postmode'],
!                             'topic'      => $topics[$row['tid']],
!                             'extensions' => $extensionTags
!                           );
          if($row['commentcode'] >= 0)
          {
--- 417,430 ----
          }
          $article = array( 'title'      => $storytitle,
!                           'summary'    => $storytext,
!                           'text'       => $fulltext,
!                           'link'       => $storylink,
!                           'uid'        => $row['uid'],
!                           'author'     => COM_getDisplayName( $row['uid'] ),
!                           'date'       => $row['modified'],
!                           'format'     => $row['postmode'],
!                           'topic'      => $topics[$row['tid']],
!                           'extensions' => $extensionTags
!                         );
          if($row['commentcode'] >= 0)
          {
***************
*** 423,428 ****
          }
          $content[] = $article;
- 
- 
      }
  
--- 432,435 ----
***************
*** 450,457 ****
      {
          // Import the feed handling classes:
!         require_once( $_CONF['path_system']
!                       . '/classes/syndication/parserfactory.class.php' );
!         require_once( $_CONF['path_system']
!                       . '/classes/syndication/feedparserbase.class.php' );
  
          // Load the actual feed handlers:
--- 457,464 ----
      {
          // Import the feed handling classes:
!         require_once $_CONF['path_system']
!                      . '/classes/syndication/parserfactory.class.php';
!         require_once $_CONF['path_system']
!                      . '/classes/syndication/feedparserbase.class.php';
  
          // Load the actual feed handlers:
***************
*** 466,501 ****
              $feed->lang = $A['language'];
  
!             if( $A['type'] == 'geeklog' )
!             {
!                 if( $A['topic'] == '::all')
!                 {
!                     $content = SYND_getFeedContentAll( $A['limits'], $link,
!                                                        $data, $A['content_length'],
!                                                        $format[0], $format[1], $fid );
!                 }
!                 else // feed for a single topic only
!                 {
!                     $content = SYND_getFeedContentPerTopic( $A['topic'],
!                             $A['limits'], $link, $data, $A['content_length'],
!                             $format[0], $format[1], $fid );
                  }
!             }
!             else
!             {
!                 $content = PLG_getFeedContent( $A['type'], $fid, $link, $data, $format[0], $format[1] );
                  // can't randomly change the api to send a max length, so
                  // fix it here:
!                 if ($A['content_length'] != 1)
!                 {
!                     $count = count( $content );
!                     for( $i = 0; $i < $count; $i++ )
!                     {
                          $content[$i]['summary'] = SYND_truncateSummary(
!                                     $content[$i]['text'], $A['content_length'] );
                      }
                  }
              }
!             if( empty( $link ))
!             {
                  $link = $_CONF['site_url'];
              }
--- 473,505 ----
              $feed->lang = $A['language'];
  
!             if ($A['type'] == 'geeklog') {
!                 if ($A['topic'] == '::all') {
!                     $content = SYND_getFeedContentAll(false, $A['limits'],
!                                     $link, $data, $A['content_length'],
!                                     $format[0], $format[1], $fid);
!                 } elseif ($A['topic'] == '::frontpage') {
!                     $content = SYND_getFeedContentAll(true, $A['limits'],
!                                     $link, $data, $A['content_length'],
!                                     $format[0], $format[1], $fid);
!                 } else { // feed for a single topic only
!                     $content = SYND_getFeedContentPerTopic($A['topic'],
!                                     $A['limits'], $link, $data,
!                                     $A['content_length'], $format[0],
!                                     $format[1], $fid);
                  }
!             } else {
!                 $content = PLG_getFeedContent($A['type'], $fid, $link, $data, $format[0], $format[1]);
! 
                  // can't randomly change the api to send a max length, so
                  // fix it here:
!                 if ($A['content_length'] != 1) {
!                     $count = count($content);
!                     for ($i = 0; $i < $count; $i++ ) {
                          $content[$i]['summary'] = SYND_truncateSummary(
!                                     $content[$i]['text'], $A['content_length']);
                      }
                  }
              }
!             if (empty($link)) {
                  $link = $_CONF['site_url'];
              }




More information about the geeklog-cvs mailing list