Ignore:
Timestamp:
Sep 19, 2006, 12:51:09 AM (18 years ago)
Author:
rvelices
Message:

RSS feed improvements:

  • send 404 when feed id missing/unknown
  • added a guid element for each feed item (make the difference between 2

different 0/1 items - they have the same link element)

  • don't update last_check unless some news are available
  • new images/updated albums removed from the 0/1 feed item
  • added 5 different feed items for new images/updated albums (generated by

grouping post date) with more information, thumbnails and links

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_notification.inc.php

    r1432 r1549  
    128128    list($count) = mysql_fetch_array(pwg_query($query));
    129129    return $count;
    130    
     130
    131131    break;
    132132    case 'info':
     
    153153      }
    154154
    155     $query = 'SELECT distinct '.implode(', ', $fields).' 
     155    $query = 'SELECT distinct '.implode(', ', $fields).'
    156156'.$query;
    157157    $result = pwg_query($query);
    158158
    159159    $infos = array();
    160  
     160
    161161    while ($row = mysql_fetch_array($result))
    162162    {
     
    346346
    347347/**
     348 * Formats a news line and adds it to the array (e.g. '5 new elements')
     349 */
     350function add_news_line(&$news, $count, $format, $url='', $add_url=false)
     351{
     352  if ($count > 0)
     353  {
     354    $line = sprintf($format, $count);
     355    if ($add_url and !empty($url) )
     356    {
     357      $line = '<a href="'.$url.'">'.$line.'</a>';
     358    }
     359    array_push($news, $line);
     360  }
     361}
     362
     363/**
    348364 * What's new between two dates ?
    349365 *
     
    355371 * @param string start date (mysql datetime format)
    356372 * @param string end date (mysql datetime format)
     373 * @param bool exclude_img_cats if true, no info about new images/categories
     374 * @param bool add_url add html A link around news
    357375 *
    358376 * @return array of news
    359377 */
    360 function news($start, $end)
     378function news($start, $end, $exclude_img_cats=false, $add_url=false)
    361379{
    362380  $news = array();
    363381
    364   $nb_new_comments = nb_new_comments($start, $end);
    365   if ($nb_new_comments > 0)
    366   {
    367     array_push($news, sprintf(l10n('%d new comments'), $nb_new_comments));
    368   }
    369 
    370   $nb_new_elements = nb_new_elements($start, $end);
    371   if ($nb_new_elements > 0)
    372   {
    373     array_push($news, sprintf(l10n('%d new elements'), $nb_new_elements));
    374   }
    375 
    376   $nb_updated_categories = nb_updated_categories($start, $end);
    377   if ($nb_updated_categories > 0)
    378   {
    379     array_push($news, sprintf(l10n('%d categories updated'),
    380                               $nb_updated_categories));
    381   }
    382  
     382  if (!$exclude_img_cats)
     383  {
     384    $nb_new_elements = nb_new_elements($start, $end);
     385    if ($nb_new_elements > 0)
     386    {
     387      array_push($news, sprintf(l10n('%d new elements'), $nb_new_elements));
     388    }
     389  }
     390
     391  if (!$exclude_img_cats)
     392  {
     393    $nb_updated_categories = nb_updated_categories($start, $end);
     394    if ($nb_updated_categories > 0)
     395    {
     396      array_push($news, sprintf(l10n('%d categories updated'),
     397                                $nb_updated_categories));
     398    }
     399  }
     400
     401  add_news_line( $news,
     402      nb_new_comments($start, $end), l10n('%d new comments'),
     403      get_root_url().'comments.php', $add_url );
     404
    383405  if (is_admin())
    384406  {
    385     $nb_unvalidated_comments = nb_unvalidated_comments($end);
    386     if ($nb_unvalidated_comments > 0)
    387     {
    388       array_push($news, sprintf(l10n('%d comments to validate'),
    389                                 $nb_unvalidated_comments));
    390     }
    391 
    392     $nb_new_users = nb_new_users($start, $end);
    393     if ($nb_new_users > 0)
    394     {
    395       array_push($news, sprintf(l10n('%d new users'), $nb_new_users));
    396     }
    397 
    398     $nb_waiting_elements = nb_waiting_elements();
    399     if ($nb_waiting_elements > 0)
    400     {
    401       array_push(
    402         $news,
    403         sprintf(
    404           l10n('%d waiting elements'),
    405           $nb_waiting_elements
    406           )
    407         );
    408     }
     407    add_news_line( $news,
     408        nb_unvalidated_comments($end), l10n('%d comments to validate'),
     409        get_root_url().'admin.php?page=comments', $add_url );
     410
     411    add_news_line( $news,
     412        nb_new_users($start, $end), l10n('%d new users'),
     413        PHPWG_ROOT_PATH.'admin.php?page=user_list', $add_url );
     414
     415    add_news_line( $news,
     416        nb_waiting_elements(), l10n('%d waiting elements'),
     417        PHPWG_ROOT_PATH.'admin.php?page=waiting', $add_url );
    409418  }
    410419
Note: See TracChangeset for help on using the changeset viewer.