mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 19:29:58 +03:00
put some functionnality from feed.php into a function (to be used
later in the notification by email) git-svn-id: http://piwigo.org/svn/trunk@1639 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
04047f3716
commit
d8ea8fd791
2 changed files with 85 additions and 52 deletions
60
feed.php
60
feed.php
|
@ -188,30 +188,14 @@ UPDATE '.USER_FEED_TABLE.'
|
|||
pwg_query($query);
|
||||
}
|
||||
|
||||
// build items for last images/albums
|
||||
$query = '
|
||||
SELECT date_available,
|
||||
COUNT(DISTINCT id) nb_images,
|
||||
COUNT(DISTINCT category_id) nb_cats
|
||||
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
|
||||
WHERE category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
GROUP BY date_available
|
||||
ORDER BY date_available DESC
|
||||
LIMIT 0,5
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
$dates = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
{
|
||||
array_push($dates, $row);
|
||||
}
|
||||
$dates = get_recent_post_dates( 5, 6, 6);
|
||||
|
||||
foreach($dates as $date_detail)
|
||||
{ // for each recent post date we create a feed item
|
||||
$date = $date_detail['date_available'];
|
||||
$exploded_date = explode_mysqldt($date);
|
||||
$item = new FeedItem();
|
||||
$item->title = l10n_dec('%d element added', '%d elements added', $date_detail['nb_images']);
|
||||
$item->title = l10n_dec('%d element added', '%d elements added', $date_detail['nb_elements']);
|
||||
$item->title .= ' ('.$lang['month'][(int)$exploded_date['month']].' '.$exploded_date['day'].')';
|
||||
$item->link = make_index_url(
|
||||
array(
|
||||
|
@ -227,57 +211,35 @@ foreach($dates as $date_detail)
|
|||
|
||||
$item->description .=
|
||||
'<li>'
|
||||
.l10n_dec('%d element added', '%d elements added', $date_detail['nb_images'])
|
||||
.l10n_dec('%d element added', '%d elements added', $date_detail['nb_elements'])
|
||||
.' ('
|
||||
.'<a href="'.make_index_url(array('section'=>'recent_pics')).'">'
|
||||
.l10n('recent_pics_cat').'</a>'
|
||||
.')'
|
||||
.'</li>';
|
||||
|
||||
// get some thumbnails ...
|
||||
$query = '
|
||||
SELECT DISTINCT id, path, name, tn_ext
|
||||
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
|
||||
WHERE category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
AND date_available="'.$date.'"
|
||||
AND tn_ext IS NOT NULL
|
||||
LIMIT 0,6
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
foreach( $date_detail['elements'] as $element )
|
||||
{
|
||||
$tn_src = get_thumbnail_url($row);
|
||||
$tn_src = get_thumbnail_url($element);
|
||||
$item->description .= '<img src="'.$tn_src.'"/>';
|
||||
}
|
||||
$item->description .= '...<br/>';
|
||||
|
||||
|
||||
$item->description .=
|
||||
'<li>'
|
||||
.l10n_dec('%d category updated', '%d categories updated',
|
||||
.l10n_dec('%d category updated', '%d categories updated',
|
||||
$date_detail['nb_cats'])
|
||||
.'</li>';
|
||||
// get some categories ...
|
||||
$query = '
|
||||
SELECT DISTINCT c.uppercats, COUNT(DISTINCT i.id) img_count
|
||||
FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON i.id=image_id
|
||||
INNER JOIN '.CATEGORIES_TABLE.' c ON c.id=category_id
|
||||
WHERE category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
AND date_available="'.$date.'"
|
||||
GROUP BY category_id
|
||||
ORDER BY img_count DESC
|
||||
LIMIT 0,6
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
|
||||
$item->description .= '<ul>';
|
||||
while ($row = mysql_fetch_array($result))
|
||||
foreach( $date_detail['categories'] as $cat )
|
||||
{
|
||||
$item->description .=
|
||||
'<li>'
|
||||
.get_cat_display_name_cache($row['uppercats'])
|
||||
.get_cat_display_name_cache($cat['uppercats'])
|
||||
.' ('.
|
||||
l10n_dec('%d element added',
|
||||
'%d elements added', $row['img_count']).')'
|
||||
l10n_dec('%d element added',
|
||||
'%d elements added', $cat['img_count']).')'
|
||||
.'</li>';
|
||||
}
|
||||
$item->description .= '</ul>';
|
||||
|
|
|
@ -381,13 +381,13 @@ function news($start, $end, $exclude_img_cats=false, $add_url=false)
|
|||
|
||||
if (!$exclude_img_cats)
|
||||
{
|
||||
add_news_line( $news,
|
||||
add_news_line( $news,
|
||||
nb_new_elements($start, $end), '%d new element', '%d new elements');
|
||||
}
|
||||
|
||||
if (!$exclude_img_cats)
|
||||
{
|
||||
add_news_line( $news,
|
||||
{
|
||||
add_news_line( $news,
|
||||
nb_updated_categories($start, $end), '%d category updated', '%d categories updated');
|
||||
}
|
||||
|
||||
|
@ -413,4 +413,75 @@ function news($start, $end, $exclude_img_cats=false, $add_url=false)
|
|||
return $news;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns information about recently published elements grouped by post date
|
||||
* @param int max_dates maximum returned number of recent dates
|
||||
* @param int max_elements maximum returned number of elements per date
|
||||
* @param int max_cats maximum returned number of categories per date
|
||||
*/
|
||||
function get_recent_post_dates($max_dates, $max_elements, $max_cats)
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
$where_sql = 'WHERE category_id NOT IN ('.$user['forbidden_categories'].')';
|
||||
|
||||
$query = '
|
||||
SELECT date_available,
|
||||
COUNT(DISTINCT id) nb_elements,
|
||||
COUNT(DISTINCT category_id) nb_cats
|
||||
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
|
||||
'.$where_sql.'
|
||||
GROUP BY date_available
|
||||
ORDER BY date_available DESC
|
||||
LIMIT 0,'.$max_dates.'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
$dates = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
{
|
||||
array_push($dates, $row);
|
||||
}
|
||||
|
||||
for ($i=0; $i<count($dates); $i++)
|
||||
{
|
||||
if ($max_elements>0)
|
||||
{ // get some thumbnails ...
|
||||
$query = '
|
||||
SELECT DISTINCT id, path, name, tn_ext
|
||||
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
|
||||
'.$where_sql.'
|
||||
AND date_available="'.$dates[$i]['date_available'].'"
|
||||
AND tn_ext IS NOT NULL
|
||||
LIMIT 0,'.$max_elements.'
|
||||
;';
|
||||
$dates[$i]['elements'] = array();
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
{
|
||||
array_push($dates[$i]['elements'], $row);
|
||||
}
|
||||
}
|
||||
|
||||
if ($max_cats>0)
|
||||
{// get some categories ...
|
||||
$query = '
|
||||
SELECT DISTINCT c.uppercats, COUNT(DISTINCT i.id) img_count
|
||||
FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON i.id=image_id
|
||||
INNER JOIN '.CATEGORIES_TABLE.' c ON c.id=category_id
|
||||
'.$where_sql.'
|
||||
AND date_available="'.$dates[$i]['date_available'].'"
|
||||
GROUP BY category_id
|
||||
ORDER BY img_count DESC
|
||||
LIMIT 0,'.$max_cats.'
|
||||
;';
|
||||
$dates[$i]['categories'] = array();
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
{
|
||||
array_push($dates[$i]['categories'], $row);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $dates;
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue