aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2006-12-01 23:31:19 +0000
committerrub <rub@piwigo.org>2006-12-01 23:31:19 +0000
commit63638b9b6dcdcef8baf5363419f0f6c5130c62df (patch)
treecf53c156032a7565dc7db3842cbd10952a920812
parentb2de3c32ee635788f2f34c98d529fdc167ca6a51 (diff)
Resolved Issue ID 0000299:
o Add (new) icon of parent category with children categories including new images o Improved display text for images count o Improved (a little) mass_* functions More explications on the forum. You must call directly upgrade_feep.php (http://127.0.0.1/BSF/upgrade_feed.php for example) git-svn-id: http://piwigo.org/svn/trunk@1624 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/include/functions.php258
-rw-r--r--include/category_cats.inc.php33
-rw-r--r--include/constants.php1
-rw-r--r--include/functions_category.inc.php63
-rw-r--r--include/functions_html.inc.php47
-rw-r--r--include/functions_user.inc.php138
-rw-r--r--index.php6
-rw-r--r--install/db/37-database.php60
-rw-r--r--install/phpwebgallery_structure.sql15
-rw-r--r--language/en_UK.iso-8859-1/common.lang.php6
-rw-r--r--language/fr_FR.iso-8859-1/common.lang.php6
-rw-r--r--template/yoga/icon/recent_by_child.pngbin0 -> 738 bytes
12 files changed, 463 insertions, 170 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php
index bbd5ee80f..1aec5b1db 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -257,6 +257,13 @@ DELETE FROM '.USER_CACHE_TABLE.'
;';
pwg_query($query);
+ // deletion of computed cache data linked to the user
+ $query = '
+DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'
+ WHERE user_id = '.$user_id.'
+;';
+ pwg_query($query);
+
// deletion of phpwebgallery specific informations
$query = '
DELETE FROM '.USER_INFOS_TABLE.'
@@ -514,41 +521,44 @@ function get_fs_directories($path, $recursive = true)
*/
function mass_inserts($table_name, $dbfields, $datas)
{
- // inserts all found categories
- $query = '
-INSERT INTO '.$table_name.'
- ('.implode(',', $dbfields).')
- VALUES';
- foreach ($datas as $insert_id => $insert)
+ if (count($datas) != 0)
{
- $query.= '
- ';
- if ($insert_id > 0)
- {
- $query.= ',';
- }
- $query.= '(';
- foreach ($dbfields as $field_id => $dbfield)
+ // inserts all found categories
+ $query = '
+ INSERT INTO '.$table_name.'
+ ('.implode(',', $dbfields).')
+ VALUES';
+ foreach ($datas as $insert_id => $insert)
{
- if ($field_id > 0)
+ $query.= '
+ ';
+ if ($insert_id > 0)
{
$query.= ',';
}
-
- if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
- {
- $query.= 'NULL';
- }
- else
+ $query.= '(';
+ foreach ($dbfields as $field_id => $dbfield)
{
- $query.= "'".$insert[$dbfield]."'";
+ if ($field_id > 0)
+ {
+ $query.= ',';
+ }
+
+ if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
+ {
+ $query.= 'NULL';
+ }
+ else
+ {
+ $query.= "'".$insert[$dbfield]."'";
+ }
}
+ $query.=')';
}
- $query.=')';
- }
- $query.= '
+ $query.= '
;';
- pwg_query($query);
+ pwg_query($query);
+ }
}
/**
@@ -561,119 +571,122 @@ INSERT INTO '.$table_name.'
*/
function mass_updates($tablename, $dbfields, $datas)
{
- // depending on the MySQL version, we use the multi table update or N
- // update queries
- $query = 'SELECT VERSION() AS version;';
- list($mysql_version) = mysql_fetch_array(pwg_query($query));
- if (count($datas) < 10 or version_compare($mysql_version, '4.0.4') < 0)
- {
- // MySQL is prior to version 4.0.4, multi table update feature is not
- // available
- foreach ($datas as $data)
+ if (count($datas) != 0)
+ {
+ // depending on the MySQL version, we use the multi table update or N
+ // update queries
+ $query = 'SELECT VERSION() AS version;';
+ list($mysql_version) = mysql_fetch_array(pwg_query($query));
+ if (count($datas) < 10 or version_compare($mysql_version, '4.0.4') < 0)
{
- $query = '
-UPDATE '.$tablename.'
- SET ';
- $is_first = true;
- foreach ($dbfields['update'] as $num => $key)
+ // MySQL is prior to version 4.0.4, multi table update feature is not
+ // available
+ foreach ($datas as $data)
{
- if (!$is_first)
- {
- $query.= ",\n ";
- }
- $query.= $key.' = ';
- if (isset($data[$key]) and $data[$key] != '')
+ $query = '
+ UPDATE '.$tablename.'
+ SET ';
+ $is_first = true;
+ foreach ($dbfields['update'] as $num => $key)
{
- $query.= '\''.$data[$key].'\'';
+ if (!$is_first)
+ {
+ $query.= ",\n ";
+ }
+ $query.= $key.' = ';
+ if (isset($data[$key]) and $data[$key] != '')
+ {
+ $query.= '\''.$data[$key].'\'';
+ }
+ else
+ {
+ $query.= 'NULL';
+ }
+ $is_first = false;
}
- else
+ $query.= '
+ WHERE ';
+ foreach ($dbfields['primary'] as $num => $key)
{
- $query.= 'NULL';
- }
- $is_first = false;
- }
- $query.= '
- WHERE ';
- foreach ($dbfields['primary'] as $num => $key)
- {
- if ($num > 1)
- {
- $query.= ' AND ';
+ if ($num > 1)
+ {
+ $query.= ' AND ';
+ }
+ $query.= $key.' = \''.$data[$key].'\'';
}
- $query.= $key.' = \''.$data[$key].'\'';
+ $query.= '
+ ;';
+ pwg_query($query);
}
- $query.= '
-;';
- pwg_query($query);
}
- }
- else
- {
- // creation of the temporary table
- $query = '
-SHOW FULL COLUMNS FROM '.$tablename.'
-;';
- $result = pwg_query($query);
- $columns = array();
- $all_fields = array_merge($dbfields['primary'], $dbfields['update']);
- while ($row = mysql_fetch_array($result))
+ else
{
- if (in_array($row['Field'], $all_fields))
+ // creation of the temporary table
+ $query = '
+ SHOW FULL COLUMNS FROM '.$tablename.'
+;';
+ $result = pwg_query($query);
+ $columns = array();
+ $all_fields = array_merge($dbfields['primary'], $dbfields['update']);
+ while ($row = mysql_fetch_array($result))
{
- $column = $row['Field'];
- $column.= ' '.$row['Type'];
- if (!isset($row['Null']) or $row['Null'] == '')
+ if (in_array($row['Field'], $all_fields))
{
- $column.= ' NOT NULL';
- }
- if (isset($row['Default']))
- {
- $column.= " default '".$row['Default']."'";
- }
- if (isset($row['Collation']) and $row['Collation'] != 'NULL')
- {
- $column.= " collate '".$row['Collation']."'";
+ $column = $row['Field'];
+ $column.= ' '.$row['Type'];
+ if (!isset($row['Null']) or $row['Null'] == '')
+ {
+ $column.= ' NOT NULL';
+ }
+ if (isset($row['Default']))
+ {
+ $column.= " default '".$row['Default']."'";
+ }
+ if (isset($row['Collation']) and $row['Collation'] != 'NULL')
+ {
+ $column.= " collate '".$row['Collation']."'";
+ }
+ array_push($columns, $column);
}
- array_push($columns, $column);
}
- }
- $temporary_tablename = $tablename.'_'.micro_seconds();
+ $temporary_tablename = $tablename.'_'.micro_seconds();
- $query = '
-CREATE TABLE '.$temporary_tablename.'
-(
-'.implode(",\n", $columns).',
-PRIMARY KEY ('.implode(',', $dbfields['primary']).')
-)
-;';
- pwg_query($query);
- mass_inserts($temporary_tablename, $all_fields, $datas);
- // update of images table by joining with temporary table
- $query = '
-UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2
- SET '.
- implode(
- "\n , ",
- array_map(
- create_function('$s', 'return "t1.$s = t2.$s";'),
- $dbfields['update']
- )
- ).'
- WHERE '.
- implode(
- "\n AND ",
- array_map(
- create_function('$s', 'return "t1.$s = t2.$s";'),
- $dbfields['primary']
- )
- ).'
+ $query = '
+ CREATE TABLE '.$temporary_tablename.'
+ (
+ '.implode(",\n", $columns).',
+ PRIMARY KEY ('.implode(',', $dbfields['primary']).')
+ )
;';
- pwg_query($query);
- $query = '
-DROP TABLE '.$temporary_tablename.'
+ pwg_query($query);
+ mass_inserts($temporary_tablename, $all_fields, $datas);
+ // update of images table by joining with temporary table
+ $query = '
+ UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2
+ SET '.
+ implode(
+ "\n , ",
+ array_map(
+ create_function('$s', 'return "t1.$s = t2.$s";'),
+ $dbfields['update']
+ )
+ ).'
+ WHERE '.
+ implode(
+ "\n AND ",
+ array_map(
+ create_function('$s', 'return "t1.$s = t2.$s";'),
+ $dbfields['primary']
+ )
+ ).'
+ ;';
+ pwg_query($query);
+ $query = '
+ DROP TABLE '.$temporary_tablename.'
;';
- pwg_query($query);
+ pwg_query($query);
+ }
}
}
@@ -1159,6 +1172,7 @@ SELECT user_id
USER_INFOS_TABLE,
USER_ACCESS_TABLE,
USER_CACHE_TABLE,
+ USER_CACHE_CATEGORIES_TABLE,
USER_GROUP_TABLE
);
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index 9a3cccceb..86e47cc09 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -33,22 +33,28 @@
if ($page['section']=='recent_cats')
{
+ // $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
$query = '
-SELECT id,name,date_last,representative_picture_id,comment,nb_images,uppercats
- FROM '.CATEGORIES_TABLE.'
+SELECT
+ id,name, representative_picture_id, comment, nb_images, uppercats,
+ max_date_last, is_child_date_last, count_images, count_categories
+ FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
+ ON id = cat_id and user_id = '.$user['id'].'
WHERE date_last > SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY
- )
- AND id NOT IN ('.$user['forbidden_categories'].')';
+ );';
}
else
{
+ // $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
$query = '
-SELECT id,name,date_last,representative_picture_id,comment,nb_images
- FROM '.CATEGORIES_TABLE.'
+SELECT
+ id,name, representative_picture_id, comment, nb_images,
+ max_date_last, is_child_date_last, count_images, count_categories
+ 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']).'
- AND id NOT IN ('.$user['forbidden_categories'].')
ORDER BY rank
;';
}
@@ -59,6 +65,8 @@ $image_ids = array();
while ($row = mysql_fetch_assoc($result))
{
+ $row['is_child_date_last'] = get_boolean($row['is_child_date_last']);
+
if (isset($row['representative_picture_id'])
and is_numeric($row['representative_picture_id']))
{ // if a representative picture is set, it has priority
@@ -145,7 +153,7 @@ if (count($categories) > 0)
else
{
$name = $category['name'];
- $icon_ts = get_icon(@$category['date_last']);
+ $icon_ts = get_icon($category['max_date_last'], $category['is_child_date_last']);
}
$template->assign_block_vars(
@@ -162,7 +170,12 @@ if (count($categories) > 0)
'cat_name' => $category['name'],
)
),
- 'CAPTION_NB_IMAGES' => (($category['nb_images'] == 0) ? '' : sprintf("%d ".l10n('pictures'), $category['nb_images'])),
+ 'CAPTION_NB_IMAGES' => get_display_images_count
+ (
+ $category['nb_images'],
+ $category['count_images'],
+ $category['count_categories']
+ ),
'DESCRIPTION' => @$comment,
'NAME' => $name,
)
@@ -213,7 +226,7 @@ if (count($categories) > 0)
$template->merge_block_vars(
'thumbnails.line.thumbnail',
array(
- 'IMAGE_TS' => get_icon(@$category['date_last']),
+ 'IMAGE_TS' => get_icon($category['max_date_last'], $category['is_child_date_last']),
)
);
}
diff --git a/include/constants.php b/include/constants.php
index ab4afe630..c874205b7 100644
--- a/include/constants.php
+++ b/include/constants.php
@@ -65,6 +65,7 @@ define('WAITING_TABLE', $prefixeTable.'waiting');
define('IMAGE_METADATA_TABLE', $prefixeTable.'image_metadata');
define('RATE_TABLE', $prefixeTable.'rate');
define('USER_CACHE_TABLE', $prefixeTable.'user_cache');
+define('USER_CACHE_CATEGORIES_TABLE', $prefixeTable.'user_cache_categories');
define('CADDIE_TABLE', $prefixeTable.'caddie');
define('UPGRADE_TABLE', $prefixeTable.'upgrade');
define('SEARCH_TABLE', $prefixeTable.'search');
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index ceef3025d..ae8b617f7 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -52,29 +52,31 @@ function check_restrictions($category_id)
function get_categories_menu()
{
- global $page,$user;
-
- $infos = array('');
+ global $page, $user;
$query = '
-SELECT name,id,date_last,nb_images,global_rank
- FROM '.CATEGORIES_TABLE.'
- WHERE 1 = 1'; // stupid but permit using AND after it !
+SELECT ';
+ // From CATEGORIES_TABLE
+ $query.= '
+ name, id, nb_images, global_rank,';
+ // From USER_CACHE_CATEGORIES_TABLE
+ $query.= '
+ max_date_last, is_child_date_last, count_images, count_categories';
+
+ // $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
+ $query.= '
+ FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
+ ON id = cat_id and user_id = '.$user['id'];
if (!$user['expand'])
{
$query.= '
- AND (id_uppercat is NULL';
+ WHERE (id_uppercat is NULL';
if (isset($page['category']))
{
$query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
}
$query.= ')';
}
- if ($user['forbidden_categories'] != '')
- {
- $query.= '
- AND id NOT IN ('.$user['forbidden_categories'].')';
- }
$query.= '
;';
@@ -82,6 +84,7 @@ SELECT name,id,date_last,nb_images,global_rank
$cats = array();
while ($row = mysql_fetch_array($result))
{
+ $row['is_child_date_last'] = get_boolean($row['is_child_date_last']);
array_push($cats, $row);
}
usort($cats, 'global_rank_compare');
@@ -89,6 +92,7 @@ SELECT name,id,date_last,nb_images,global_rank
return get_html_menu_category($cats);
}
+
/**
* Retrieve informations about a category in the database
*
@@ -352,4 +356,39 @@ function rank_compare($a, $b)
return ($a['rank'] < $b['rank']) ? -1 : 1;
}
+
+/**
+ * returns display text for information images of category
+ *
+ * @param array categories
+ * @return string
+ */
+function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_categories, $short_message = true)
+{
+ $display_text = '';
+
+ // Count of category is main
+ // if not picture on categorie, test on sub-categories
+ $count = ($cat_nb_images > 0 ? $cat_nb_images : $cat_count_images);
+
+ if ($count > 0)
+ {
+ $display_text.= sprintf(l10n(($count > 1 ? 'images_available' : 'image_available')), $count);
+
+ if ($cat_nb_images > 0)
+ {
+ if (! $short_message)
+ {
+ $display_text.= ' '.l10n('images_available_cpl');
+ }
+ }
+ else
+ {
+ $display_text.= ' '.sprintf(l10n(($cat_count_categories > 1 ? 'images_available_cats' : 'images_available_cat')), $cat_count_categories);
+ }
+ }
+
+ return $display_text;
+}
+
?> \ No newline at end of file
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 3bc9a4706..6c69b0fb0 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -24,7 +24,7 @@
// | USA. |
// +-----------------------------------------------------------------------+
-function get_icon($date)
+function get_icon($date, $is_child_date = false)
{
global $page, $user, $conf, $lang;
@@ -33,16 +33,16 @@ function get_icon($date)
$date = 'NULL';
}
- if (isset($page['get_icon_cache'][$date]))
+ if (isset($page['get_icon_cache'][$is_child_date][$date]))
{
- return $page['get_icon_cache'][$date];
+ return $page['get_icon_cache'][$is_child_date][$date];
}
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})/', $date, $matches))
{
// date can be empty, no icon to display
- $page['get_icon_cache'][$date] = '';
- return $page['get_icon_cache'][$date];
+ $page['get_icon_cache'][$is_child_date][$date] = '';
+ return $page['get_icon_cache'][$is_child_date][$date];
}
list($devnull, $year, $month, $day) = $matches;
@@ -51,8 +51,8 @@ function get_icon($date)
if ($unixtime === false // PHP 5.1.0 and above
or $unixtime === -1) // PHP prior to 5.1.0
{
- $page['get_icon_cache'][$date] = '';
- return $page['get_icon_cache'][$date];
+ $page['get_icon_cache'][$is_child_date][$date] = '';
+ return $page['get_icon_cache'][$is_child_date][$date];
}
$diff = time() - $unixtime;
@@ -61,7 +61,7 @@ function get_icon($date)
$title = $lang['recent_image'].'&nbsp;';
if ( $diff < $user['recent_period'] * $day_in_seconds )
{
- $icon_url = get_themeconf('icon_dir').'/recent.png';
+ $icon_url = get_themeconf('icon_dir').'/'.($is_child_date ? 'recent_by_child.png' : 'recent.png');
$title .= $user['recent_period'];
$title .= '&nbsp;'.$lang['days'];
$size = getimagesize( PHPWG_ROOT_PATH.$icon_url );
@@ -70,9 +70,9 @@ function get_icon($date)
$output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />';
}
- $page['get_icon_cache'][$date] = $output;
+ $page['get_icon_cache'][$is_child_date][$date] = $output;
- return $page['get_icon_cache'][$date];
+ return $page['get_icon_cache'][$is_child_date][$date];
}
function create_navigation_bar(
@@ -392,7 +392,8 @@ SELECT id,name
*
* HTML code generated uses logical list tags ul and each category is an
* item li. The paramter given is the category informations as an array,
- * used keys are : id, name, nb_images, date_last
+ * used keys are : id, name, nb_images, max_date_last, is_child_date_last,
+ * count_images, count_categories
*
* @param array categories
* @return string
@@ -453,15 +454,27 @@ function get_html_menu_category($categories)
}
$menu.= '>'.$category['name'].'</a>';
- if ($category['nb_images'] > 0)
+ // Count of category is main
+ // if not picture on categorie, test on sub-categories
+ if (($category['nb_images'] > 0) or ($category['count_images'] > 0))
{
- $menu.= "\n".'<span class="menuInfoCat"';
- $menu.= ' title="'.$category['nb_images'];
- $menu.= ' '.$lang['images_available'].'">';
- $menu.= '['.$category['nb_images'].']';
+ $menu.= "\n".'<span class="';
+ $menu.= ($category['nb_images'] > 0 ? "menuInfoCat"
+ : "menuInfoCatByChild").'"';
+ $menu.= ' title="';
+ $menu.= ' '.get_display_images_count
+ (
+ $category['nb_images'],
+ $category['count_images'],
+ $category['count_categories'],
+ false
+ ).'">';
+ $menu.= '['.($category['nb_images'] > 0 ? $category['nb_images']
+ : $category['count_images']).']';
$menu.= '</span>';
- $menu.= get_icon($category['date_last']);
}
+
+ $menu.= get_icon($category['max_date_last'], $category['is_child_date_last']);
}
$menu.= str_repeat("\n</li></ul>",($level));
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 595215266..e1a84e1b6 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -272,6 +272,11 @@ SELECT ui.*, uc.*
$userdata['forbidden_categories'] =
calculate_permissions($userdata['id'], $userdata['status']);
+ update_user_cache_categorie($userdata['id'], $userdata['forbidden_categories']);
+
+ // Set need update are done
+ $userdata['need_update'] = false;
+
$query = '
SELECT COUNT(DISTINCT(image_id)) as total
FROM '.IMAGE_CATEGORY_TABLE.'
@@ -288,13 +293,16 @@ DELETE FROM '.USER_CACHE_TABLE.'
$query = '
INSERT INTO '.USER_CACHE_TABLE.'
- (user_id,need_update,forbidden_categories,nb_total_images)
+ (user_id, need_update, forbidden_categories, nb_total_images)
VALUES
- ('.$userdata['id'].',\'false\',\''
+ ('.$userdata['id'].',\''.boolean_to_string($userdata['need_update']).'\',\''
.$userdata['forbidden_categories'].'\','.$userdata['nb_total_images'].')
;';
pwg_query($query);
}
+
+ {
+ }
}
return $userdata;
@@ -440,6 +448,132 @@ SELECT id
}
/**
+ * update data of user_cache_categorie
+ *
+ * @param int user_id
+ * @return null
+ */
+function update_user_cache_categorie($user_id, $user_forbidden_categories)
+{
+ function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level)
+ {
+ $date = '';
+ $count_images = 0;
+ $count_categories = 0;
+ do
+ {
+ $cat_id = array_pop($list_cat_id);
+ if (!is_null($cat_id))
+ {
+ // Count images and categories
+ $cats[$cat_id]['count_images'] += $count_images;
+ $cats[$cat_id]['count_categories'] += $count_categories;
+ $count_images = $cats[$cat_id]['count_images'];
+ $count_categories = $cats[$cat_id]['count_categories'] + 1;
+
+ if ((empty($cats[$cat_id]['max_date_last'])) or ($cats[$cat_id]['max_date_last'] < $date))
+ {
+ $cats[$cat_id]['max_date_last'] = $date;
+ $cats[$cat_id]['is_child_date_last'] = true;
+ }
+ else
+ {
+ $date = $cats[$cat_id]['max_date_last'];
+ }
+ $ref_level = substr_count($cats[$cat_id]['global_rank'], '.') + 1;
+ }
+ else
+ {
+ $ref_level = 0;
+ }
+ } while ($level <= $ref_level);
+
+ // Last cat updating must be added to list for next branch
+ if ($ref_level <> 0)
+ {
+ array_push($list_cat_id, $cat_id);
+ }
+ }
+
+ // delete user cache
+ $query = '
+ delete from '.USER_CACHE_CATEGORIES_TABLE.'
+ where user_id = '.$user_id.'
+;';
+ pwg_query($query);
+
+ $query = '
+ select
+ id cat_id, date_last,
+ nb_images, global_rank
+ from '.CATEGORIES_TABLE;
+ if ($user_forbidden_categories != '')
+ {
+ $query.= '
+ where id not in ('.$user_forbidden_categories.')';
+ }
+ $query.= ';';
+
+ $result = pwg_query($query);
+
+ $cats = array();
+ while ($row = mysql_fetch_array($result))
+ {
+ $cats += array($row['cat_id'] => $row);
+ }
+ usort($cats, 'global_rank_compare');
+
+ $ref_level = 0;
+ $level = 0;
+ $list_cat_id = array();
+
+ foreach ($cats as $id => $category)
+ {
+ // Update field
+ $cats[$id]['user_id'] = $user_id;
+ $cats[$id]['is_child_date_last'] = false;
+ $cats[$id]['max_date_last'] = $cats[$id]['date_last'];
+ $cats[$id]['count_images'] = $cats[$id]['nb_images'];
+ $cats[$id]['count_categories'] = 0;
+
+ // Compute
+ $level = substr_count($category['global_rank'], '.') + 1;
+ if ($level > $ref_level)
+ {
+ array_push($list_cat_id, $id);
+ }
+ else
+ {
+ compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
+ array_push($list_cat_id, $id);
+ }
+ $ref_level = $level;
+ }
+
+ $level = 1;
+ compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
+
+ foreach ($cats as $id => $category)
+ {
+ // Convert field
+ $cats[$id]['is_child_date_last'] = boolean_to_string($cats[$id]['is_child_date_last']);
+ }
+
+ include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+ mass_inserts
+ (
+ USER_CACHE_CATEGORIES_TABLE,
+ array
+ (
+ 'user_id', 'cat_id',
+ 'is_child_date_last', 'max_date_last',
+ 'count_images', 'count_categories'
+ ),
+ $cats
+ );
+}
+
+/**
* returns the username corresponding to the given user identifier if exists
*
* @param int user_id
diff --git a/index.php b/index.php
index e4d5232e6..30e8be9d9 100644
--- a/index.php
+++ b/index.php
@@ -107,8 +107,6 @@ if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
$template_title.= ' ['.$page['cat_nb_images'].']';
}
-$icon_recent = get_icon(date('Y-m-d'));
-
if (!isset($page['chronology_field']))
{
$chronology_params =
@@ -163,9 +161,7 @@ include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
$template->assign_vars(
array(
- 'TITLE' => $template_title,
- 'TOP_NUMBER' => $conf['top_number'], // still used ?
- 'T_RECENT' => $icon_recent, // still used ?
+ 'TITLE' => $template_title
)
);
diff --git a/install/db/37-database.php b/install/db/37-database.php
new file mode 100644
index 000000000..ba334153b
--- /dev/null
+++ b/install/db/37-database.php
@@ -0,0 +1,60 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | 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 |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $RCSfile$
+// | last update : $Date: 2005-09-21 00:04:57 +0200 (mer, 21 sep 2005) $
+// | last modifier : $Author: plg $
+// | revision : $Revision: 870 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die('Hacking attempt!');
+}
+
+$upgrade_description = 'Cache user categories update';
+
+include_once(PHPWG_ROOT_PATH.'include/constants.php');
+
+// +-----------------------------------------------------------------------+
+// | Upgrade content |
+// +-----------------------------------------------------------------------+
+
+echo "Create table ".USER_CACHE_CATEGORIES_TABLE;
+$query = '
+CREATE TABLE '.USER_CACHE_CATEGORIES_TABLE.' (
+ `user_id` smallint(5) NOT NULL default \'0\',
+ `cat_id` smallint(5) unsigned NOT NULL default \'0\',
+ `is_child_date_last` enum(\'true\',\'false\') NOT NULL default \'false\',
+ `max_date_last` datetime default NULL,
+ `count_images` mediumint(8) unsigned default 0,
+ `count_categories` mediumint(8) unsigned default 0,
+ PRIMARY KEY (`user_id`, `cat_id`)
+) TYPE=MyISAM;';
+pwg_query($query);
+
+echo
+"\n"
+.'"'.$upgrade_description.'"'.' ended'
+."\n"
+;
+
+?>
diff --git a/install/phpwebgallery_structure.sql b/install/phpwebgallery_structure.sql
index 5e1e8c162..469b1b9a1 100644
--- a/install/phpwebgallery_structure.sql
+++ b/install/phpwebgallery_structure.sql
@@ -290,6 +290,21 @@ CREATE TABLE `phpwebgallery_user_cache` (
) TYPE=MyISAM;
--
+-- Table structure for table `phpwebgallery_user_cache_categories`
+--
+
+DROP TABLE IF EXISTS `phpwebgallery_user_cache_categories`;
+CREATE TABLE `phpwebgallery_user_cache_categories` (
+ `user_id` smallint(5) NOT NULL default '0',
+ `cat_id` smallint(5) unsigned NOT NULL default '0',
+ `is_child_date_last` enum('true','false') NOT NULL default 'false',
+ `max_date_last` datetime default NULL,
+ `count_images` mediumint(8) unsigned default 0,
+ `count_categories` mediumint(8) unsigned default 0,
+ PRIMARY KEY (`user_id`, `cat_id`)
+) TYPE=MyISAM;
+
+--
-- Table structure for table `phpwebgallery_user_feed`
--
diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php
index d3f0c357e..94d352b01 100644
--- a/language/en_UK.iso-8859-1/common.lang.php
+++ b/language/en_UK.iso-8859-1/common.lang.php
@@ -462,7 +462,11 @@ $lang['home'] = 'Home';
$lang['home_hint'] = 'Back to the home page';
$lang['ident_title'] = 'ident_title';
$lang['identification'] = 'Identification';
-$lang['images_available'] = 'images in this category';
+$lang['image_available'] = '%d image';
+$lang['images_available'] = '%d images';
+$lang['images_available_cpl'] = 'in this category';
+$lang['images_available_cat'] = 'in %d sub-catégory';
+$lang['images_available_cats'] = 'in %d sub-catégories';
$lang['included'] = 'included';
$lang['invalid_pwd'] = 'Invalid password!';
$lang['language']='Language';
diff --git a/language/fr_FR.iso-8859-1/common.lang.php b/language/fr_FR.iso-8859-1/common.lang.php
index de26cadce..b6e4af2ff 100644
--- a/language/fr_FR.iso-8859-1/common.lang.php
+++ b/language/fr_FR.iso-8859-1/common.lang.php
@@ -461,7 +461,11 @@ $lang['home'] = 'Accueil';
$lang['home_hint'] = 'Retour ŕ la page d\'accueil';
$lang['ident_title'] = 'Identification (FIXME)';
$lang['identification'] = 'Identification';
-$lang['images_available'] = 'images dans cette catégorie';
+$lang['image_available'] = '%d image';
+$lang['images_available'] = '%d images';
+$lang['images_available_cpl'] = 'dans cette catégorie';
+$lang['images_available_cat'] = 'dans %d sous-catégorie';
+$lang['images_available_cats'] = 'dans %d sous-catégories';
$lang['included'] = 'inclus';
$lang['invalid_pwd'] = 'Mot de passe invalide !';
$lang['language'] = 'Langue';
diff --git a/template/yoga/icon/recent_by_child.png b/template/yoga/icon/recent_by_child.png
new file mode 100644
index 000000000..48e2b4bf7
--- /dev/null
+++ b/template/yoga/icon/recent_by_child.png
Binary files differ