diff options
author | rub <rub@piwigo.org> | 2006-12-10 22:48:32 +0000 |
---|---|---|
committer | rub <rub@piwigo.org> | 2006-12-10 22:48:32 +0000 |
commit | 222afe2caa357d6d31efdef87e2444d3e042880d (patch) | |
tree | 12386628081ccc334971eb7a8cf3456386e110d1 /include | |
parent | 906d9bd7951a77356b9caa04073a7d1c02d44bef (diff) |
Feature Issue ID 0000601: Filter all public pages with only recent elements
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
Diffstat (limited to '')
-rw-r--r-- | include/category_cats.inc.php | 39 | ||||
-rw-r--r-- | include/category_default.inc.php | 10 | ||||
-rw-r--r-- | include/functions_category.inc.php | 20 | ||||
-rwxr-xr-x | include/menubar.inc.php | 37 |
4 files changed, 77 insertions, 29 deletions
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php index 83f4b7209..36f19ca49 100644 --- a/include/category_cats.inc.php +++ b/include/category_cats.inc.php @@ -54,7 +54,14 @@ SELECT 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 ;'; } @@ -77,9 +84,22 @@ while ($row = mysql_fetch_assoc($result)) $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 ;'; @@ -93,10 +113,17 @@ SELECT image_id { // 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 ;'; diff --git a/include/category_default.inc.php b/include/category_default.inc.php index b1f7bc46a..ae2dc4dce 100644 --- a/include/category_default.inc.php +++ b/include/category_default.inc.php @@ -46,8 +46,14 @@ if (count($selection) > 0) $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)) { diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 706d9c401..8113064d6 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -67,15 +67,25 @@ SELECT '; $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.= ' ;'; diff --git a/include/menubar.inc.php b/include/menubar.inc.php index b84d9f09e..79643ba26 100755 --- a/include/menubar.inc.php +++ b/include/menubar.inc.php @@ -167,22 +167,27 @@ $template->assign_block_vars( '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( |