Skip to content

Commit

Permalink
Feature Issue ID 0000601: Filter all public pages with only recent el…
Browse files Browse the repository at this point in the history
…ements

It's a draft of the feature witch allows to show only recent elements.
Development are not finished.
Queries and special pages (best rates, tags, etc.) are not modified.
Only main php files about images and categories are ok.

Before to continue, I prefer to determinate a solution between modify cache implementation or hide counters.

Go to http://forum.phpwebgallery.net/viewtopic.php?pid=50015#p50015


git-svn-id: http://piwigo.org/svn/trunk@1648 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rub committed Dec 10, 2006
1 parent 906d9bd commit 222afe2
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 30 deletions.
39 changes: 33 additions & 6 deletions include/category_cats.inc.php
Expand Up @@ -54,7 +54,14 @@
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'].'
WHERE id_uppercat '.
(!isset($page['category']) ? 'is NULL' : '= '.$page['category']).'
(!isset($page['category']) ? 'is NULL' : '= '.$page['category']);
if ($page['filter_mode'])
{
$query.= '
AND max_date_last > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
}
$query.= '
ORDER BY rank
;';
}
Expand All @@ -77,9 +84,22 @@
$query = '
SELECT image_id
FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
ON ic.category_id = c.id
ON ic.category_id = c.id';
if ($page['filter_mode'])
{
$query.= '
INNER JOIN '.IMAGES_TABLE.' AS i on ic.image_id = i.id ';
}
$query.= '
WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
AND c.id NOT IN ('.$user['forbidden_categories'].')
AND c.id NOT IN ('.$user['forbidden_categories'].')';
if ($page['filter_mode'])
{
$query.= '
AND i.date_available > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
}
$query.= '
ORDER BY RAND()
LIMIT 0,1
;';
Expand All @@ -93,10 +113,17 @@
{ // searching a random representant among representant of sub-categories
$query = '
SELECT representative_picture_id
FROM '.CATEGORIES_TABLE.'
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'].'
WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
AND id NOT IN ('.$user['forbidden_categories'].')
AND representative_picture_id IS NOT NULL
AND representative_picture_id IS NOT NULL';
if ($page['filter_mode'])
{
$query.= '
AND max_date_last > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
}
$query.= '
ORDER BY RAND()
LIMIT 0,1
;';
Expand Down
10 changes: 8 additions & 2 deletions include/category_default.inc.php
Expand Up @@ -46,8 +46,14 @@
$query = '
SELECT *
FROM '.IMAGES_TABLE.'
WHERE id IN ('.implode(',', $selection).')
;';
WHERE id IN ('.implode(',', $selection).')';
if ($page['filter_mode'])
{
$query.= '
AND date_available > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
}
$query.= ';';
$result = pwg_query($query);
while ($row = mysql_fetch_assoc($result))
{
Expand Down
20 changes: 15 additions & 5 deletions include/functions_category.inc.php
Expand Up @@ -67,15 +67,25 @@ function get_categories_menu()
$query.= '
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'];
if (!$user['expand'])
if ($page['filter_mode'])
{
$query.= '
WHERE (id_uppercat is NULL';
if (isset($page['category']))
where max_date_last > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
}
else
{
// Always expand when filter_mode is activated
if (!$user['expand'])
{
$query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
$query.= '
WHERE (id_uppercat is NULL';
if (isset($page['category']))
{
$query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
}
$query.= ')';
}
$query.= ')';
}
$query.= '
;';
Expand Down
37 changes: 21 additions & 16 deletions include/menubar.inc.php
Expand Up @@ -167,22 +167,27 @@
'TITLE' => $lang['random_cat_hint'],
'NAME' => $lang['random_cat']
));
// recent pics
$template->assign_block_vars(
'special_cat',
array(
'URL' => make_index_url(array('section' => 'recent_pics')),
'TITLE' => $lang['recent_pics_cat_hint'],
'NAME' => $lang['recent_pics_cat']
));
// recent cats
$template->assign_block_vars(
'special_cat',
array(
'URL' => make_index_url(array('section' => 'recent_cats')),
'TITLE' => $lang['recent_cats_cat_hint'],
'NAME' => $lang['recent_cats_cat']
));

// Not recent menu when filter is activated
if (!$page['filter_mode'])
{
// recent pics
$template->assign_block_vars(
'special_cat',
array(
'URL' => make_index_url(array('section' => 'recent_pics')),
'TITLE' => $lang['recent_pics_cat_hint'],
'NAME' => $lang['recent_pics_cat']
));
// recent cats
$template->assign_block_vars(
'special_cat',
array(
'URL' => make_index_url(array('section' => 'recent_cats')),
'TITLE' => $lang['recent_cats_cat_hint'],
'NAME' => $lang['recent_cats_cat']
));
}

// calendar
$template->assign_block_vars(
Expand Down
29 changes: 29 additions & 0 deletions index.php
Expand Up @@ -106,6 +106,35 @@
$template_title.= ' ['.$page['cat_nb_images'].']';
}

if (isset($_GET['filter_mode']))
{
$page['filter_mode'] = ($_GET['filter_mode'] == 'start');
pwg_set_session_var('filter_mode', $page['filter_mode']);
}
else
{
$page['filter_mode'] = pwg_get_session_var('filter_mode', false);
}

if ($page['filter_mode'])
{
$template->assign_block_vars(
'stop_filter_mode',
array(
'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_mode' => 'stop'))
)
);
}
else
{
$template->assign_block_vars(
'start_filter_mode',
array(
'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_mode' => 'start'))
)
);
}

if (!isset($page['chronology_field']))
{
$chronology_params =
Expand Down
2 changes: 2 additions & 0 deletions language/en_UK.iso-8859-1/common.lang.php
Expand Up @@ -490,6 +490,8 @@
$lang['maxheight_error'] = 'Maximum height must be a number superior to 50';
$lang['maxwidth'] = 'Maximum width of the pictures';
$lang['maxwidth_error'] = 'Maximum width must be a number superior to 50';
$lang['start_filter_mode_hint'] = 'displays only recent elements';
$lang['stop_filter_mode_hint'] = 'return to display all elements';
$lang['mode_created_hint'] = 'displays a calendar by creation date';
$lang['mode_normal_hint'] = 'return to normal view mode';
$lang['mode_posted_hint'] = 'displays a calendar by date posted';
Expand Down
4 changes: 3 additions & 1 deletion language/fr_FR.iso-8859-1/common.lang.php
Expand Up @@ -491,7 +491,9 @@
$lang['maxwidth'] = 'Largeur maximum des images';
$lang['maxwidth_error'] = 'La largeur des images doit être supérieure à 50';
$lang['mode_created_hint'] = 'afficher un calendrier par date de création';
$lang['mode_normal_hint'] = 'retourne à la vue normale';
$lang['start_filter_mode_hint'] = 'afficher que les éléments récents';
$lang['stop_filter_mode_hint'] = 'retourner à l\'affichage de tous les éléments';
$lang['mode_normal_hint'] = 'retourner à la vue normale';
$lang['mode_posted_hint'] = 'afficher un calendrier par date d\'ajout';
$lang['month'][10] = 'Octobre';
$lang['month'][11] = 'Novembre';
Expand Down
Binary file added template/yoga/icon/start_filter_mode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added template/yoga/icon/stop_filter_mode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions template/yoga/index.tpl
Expand Up @@ -27,6 +27,13 @@
<li><a href="{search_rules.URL}" style="border:none;" onclick="popuphelp(this.href); return false;" title="{lang:Search rules}"><img src="{pwg_root}{themeconf:icon_dir}/search_rules.png" class="button" alt="(?)"></a></li>
<!-- END search_rules -->

<!-- BEGIN start_filter_mode -->
<li><a href="{start_filter_mode.URL}" title="{lang:start_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="button" alt="{lang:start_filter_mode_hint}"></a></li>
<!-- END start_filter_mode -->
<!-- BEGIN stop_filter_mode -->
<li><a href="{stop_filter_mode.URL}" title="{lang:stop_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="button" alt="{lang:stop_filter_mode_hint}"></a></li>
<!-- END stop_filter_mode -->

<!-- BEGIN mode_normal -->
<li><a href="{mode_normal.URL}" title="{lang:mode_normal_hint}"><img src="{pwg_root}{themeconf:icon_dir}/normal_mode.png" class="button" alt="{lang:mode_normal_hint}"></a></li>
<!-- END mode_normal -->
Expand Down

0 comments on commit 222afe2

Please sign in to comment.