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 finalized version.
Obsolete code of draft are removed.

You can filter categories and images with recent date period on your screen selection.
In the future, filter could be easy done on other type data (plugin?)

You can flat categories and sub-categories with a recent date period of your choice.

Next, perhaps, a panel to choice recent date for the 2 features.

On draft, there have problem with MySql 5, be careful!

Css problem not resolved:
  - Menu "Categories" is bad centered
  - Icon on dark too on the top


git-svn-id: http://piwigo.org/svn/trunk@1677 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rub committed Dec 21, 2006
1 parent a7ce261 commit cab8f98
Show file tree
Hide file tree
Showing 40 changed files with 889 additions and 344 deletions.
8 changes: 5 additions & 3 deletions action.php
Expand Up @@ -80,13 +80,15 @@ function do_error( $code, $str )
{
do_error(404, 'Requested id not found');
}


// $filter['visible_categories'] and $filter['visible_images']
// are not used because it's not necessary (filter <> restriction)
$query='
SELECT id FROM '.CATEGORIES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.'
ON category_id=id
WHERE image_id='.$id.'
AND category_id NOT IN ('.$user['forbidden_categories'].')
WHERE image_id='.$id.'
.'get_sql_condition_FandF(array('forbidden_categories' => 'category_id'), 'AND').'
LIMIT 1
;';
if ( mysql_num_rows(pwg_query($query))<1 )
Expand Down
53 changes: 32 additions & 21 deletions comments.php
Expand Up @@ -216,13 +216,16 @@

$query = '
SELECT id,name,uppercats,global_rank
FROM '.CATEGORIES_TABLE;
if ($user['forbidden_categories'] != '')
{
$query.= '
WHERE id NOT IN ('.$user['forbidden_categories'].')';
}
$query.= '
FROM '.CATEGORIES_TABLE.'
'.get_sql_condition_FandF
(
array
(
'forbidden_categories' => 'id',
'visible_categories' => 'id'
),
'WHERE'
).'
;';
display_select_cat_wrapper($query, array(@$_GET['cat']), $blockname, true);

Expand Down Expand Up @@ -308,13 +311,17 @@
AND '.$page['cat_clause'].'
AND '.$page['author_clause'].'
AND '.$page['keyword_clause'].'
AND '.$page['status_clause'];
if ($user['forbidden_categories'] != '')
{
$query.= '
AND category_id NOT IN ('.$user['forbidden_categories'].')';
}
$query.= '
AND '.$page['status_clause'].'
'.get_sql_condition_FandF
(
array
(
'forbidden_categories' => 'category_id',
'visible_categories' => 'category_id',
'visible_images' => 'ic.image_id'
),
'AND'
).'
;';
list($counter) = mysql_fetch_row(pwg_query($query));

Expand Down Expand Up @@ -354,13 +361,17 @@
AND '.$page['cat_clause'].'
AND '.$page['author_clause'].'
AND '.$page['keyword_clause'].'
AND '.$page['status_clause'];
if ($user['forbidden_categories'] != '')
{
$query.= '
AND category_id NOT IN ('.$user['forbidden_categories'].')';
}
$query.= '
AND '.$page['status_clause'].'
'.get_sql_condition_FandF
(
array
(
'forbidden_categories' => 'category_id',
'visible_categories' => 'category_id',
'visible_images' => 'ic.image_id'
),
'AND'
).'
GROUP BY comment_id
ORDER BY '.$page['sort_by'].' '.$page['sort_order'];
if ('all' != $page['items_number'])
Expand Down
71 changes: 41 additions & 30 deletions include/category_cats.inc.php
Expand Up @@ -42,7 +42,16 @@
ON id = cat_id and user_id = '.$user['id'].'
WHERE date_last > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY
);';
)
'.get_sql_condition_FandF
(
array
(
'visible_categories' => 'id',
),
'AND'
).'
;';
}
else
{
Expand All @@ -54,14 +63,15 @@
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']);
if ($page['filter_local_mode'])
{
$query.= '
AND max_date_last > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
}
$query.= '
(!isset($page['category']) ? 'is NULL' : '= '.$page['category']).'
'.get_sql_condition_FandF
(
array
(
'visible_categories' => 'id',
),
'AND'
).'
ORDER BY rank
;';
}
Expand All @@ -85,21 +95,18 @@
SELECT image_id
FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
ON ic.category_id = c.id';
if ($page['filter_local_mode'] or $user['filter_global_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'].')';
if ($page['filter_local_mode'] or $user['filter_global_mode'])
{
$query.= '
AND i.date_available > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
}
$query.= '
'.get_sql_condition_FandF
(
array
(
'forbidden_categories' => 'c.id',
'visible_categories' => 'c.id',
'visible_images' => 'image_id'
),
'AND'
).'
ORDER BY RAND()
LIMIT 0,1
;';
Expand All @@ -116,14 +123,15 @@
FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
ON id = cat_id and user_id = '.$user['id'].'
WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
AND representative_picture_id IS NOT NULL';
if ($page['filter_local_mode'] or $user['filter_global_mode'])
{
$query.= '
AND max_date_last > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
}
$query.= '
AND representative_picture_id IS NOT NULL
'.get_sql_condition_FandF
(
array
(
'visible_categories' => 'id',
),
'AND'
).'
ORDER BY RAND()
LIMIT 0,1
;';
Expand Down Expand Up @@ -161,6 +169,9 @@

if (count($categories) > 0)
{
// Update filtered data
update_cats_with_filtered_data($categories);

if ($conf['subcatify'])
{
$template->set_filenames(
Expand Down
12 changes: 3 additions & 9 deletions include/category_default.inc.php
Expand Up @@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
Expand Down Expand Up @@ -46,14 +46,8 @@
$query = '
SELECT *
FROM '.IMAGES_TABLE.'
WHERE id IN ('.implode(',', $selection).')';
if ($page['filter_local_mode'] or $user['filter_global_mode'])
{
$query.= '
AND date_available > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
}
$query.= ';';
WHERE id IN ('.implode(',', $selection).')
;';
$result = pwg_query($query);
while ($row = mysql_fetch_assoc($result))
{
Expand Down
12 changes: 12 additions & 0 deletions include/common.inc.php
Expand Up @@ -112,6 +112,7 @@
$user = array();
$lang = array();
$header_msgs = array();
$header_notes = array();

@include(PHPWG_ROOT_PATH .'include/mysql.inc.php');
if (!defined('PHPWG_INSTALLED'))
Expand Down Expand Up @@ -228,6 +229,17 @@
}
}

if (!defined('IN_ADMIN') or !IN_ADMIN)
{
include(PHPWG_ROOT_PATH.'include/functions_filter.inc.php');
include(PHPWG_ROOT_PATH.'include/filter.inc.php');
}

if (isset($conf['header_notes']))
{
$header_notes = array_merge($header_notes, $conf['header_notes']);
}

// default event handlers
add_event_handler('render_comment_content', 'parse_comment_content');
trigger_action('init');
Expand Down
19 changes: 18 additions & 1 deletion include/config_default.inc.php
Expand Up @@ -174,6 +174,10 @@
// page.
$conf['links'] = array();

// List of notes to display on all header page
// example $conf['header_notes'] = array('Test', 'Hello');
$conf['header_notes'] = array();

// show_thumbnail_caption : on thumbnails page, show thumbnail captions ?
$conf['show_thumbnail_caption'] = true;

Expand Down Expand Up @@ -543,7 +547,7 @@
$conf['enable_plugins']=true;

// +-----------------------------------------------------------------------+
// | Set default for Web Service |
// | Set default for Web Service |
// +-----------------------------------------------------------------------+

// Web services are accepted
Expand All @@ -561,4 +565,17 @@
// 0 it's temporary closed (Useful for one access)
$conf['ws_durations'] = array(3650,1825,730,365,182,91,30,15,10,7,5,1,0);

// +-----------------------------------------------------------------------+
// | Filter |
// +-----------------------------------------------------------------------+
// Pages where filter is enabled
// Other pages cancel current filter
$conf['filter_pages'] = array
(
'about.php', 'action.php', 'admin.php', 'comments.php',
'index.php', 'picture.php', 'popuphelp.php', 'profile.php',
'qsearch.php', 'random.php', 'register.php', 'search.php',
'search_rules.php', 'tags.php', 'upload.php'
);

?>

0 comments on commit cab8f98

Please sign in to comment.