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
This commit is contained in:
parent
b2de3c32ee
commit
63638b9b6d
12 changed files with 470 additions and 177 deletions
|
@ -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)
|
||||
// inserts all found categories
|
||||
$query = '
|
||||
INSERT INTO '.$table_name.'
|
||||
('.implode(',', $dbfields).')
|
||||
VALUES';
|
||||
foreach ($datas as $insert_id => $insert)
|
||||
{
|
||||
$query.= ',';
|
||||
}
|
||||
$query.= '(';
|
||||
foreach ($dbfields as $field_id => $dbfield)
|
||||
{
|
||||
if ($field_id > 0)
|
||||
$query.= '
|
||||
';
|
||||
if ($insert_id > 0)
|
||||
{
|
||||
$query.= ',';
|
||||
}
|
||||
$query.= '(';
|
||||
foreach ($dbfields as $field_id => $dbfield)
|
||||
{
|
||||
if ($field_id > 0)
|
||||
{
|
||||
$query.= ',';
|
||||
}
|
||||
|
||||
if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
|
||||
{
|
||||
$query.= 'NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query.= "'".$insert[$dbfield]."'";
|
||||
if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
|
||||
{
|
||||
$query.= 'NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query.= "'".$insert[$dbfield]."'";
|
||||
}
|
||||
}
|
||||
$query.=')';
|
||||
}
|
||||
$query.=')';
|
||||
}
|
||||
$query.= '
|
||||
$query.= '
|
||||
;';
|
||||
pwg_query($query);
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -561,120 +571,123 @@ 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)
|
||||
if (count($datas) != 0)
|
||||
{
|
||||
// MySQL is prior to version 4.0.4, multi table update feature is not
|
||||
// available
|
||||
foreach ($datas as $data)
|
||||
// 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)
|
||||
{
|
||||
$query = '
|
||||
UPDATE '.$tablename.'
|
||||
SET ';
|
||||
$is_first = true;
|
||||
foreach ($dbfields['update'] as $num => $key)
|
||||
{
|
||||
if (!$is_first)
|
||||
{
|
||||
$query.= ",\n ";
|
||||
}
|
||||
$query.= $key.' = ';
|
||||
if (isset($data[$key]) and $data[$key] != '')
|
||||
{
|
||||
$query.= '\''.$data[$key].'\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query.= 'NULL';
|
||||
}
|
||||
$is_first = false;
|
||||
}
|
||||
$query.= '
|
||||
WHERE ';
|
||||
foreach ($dbfields['primary'] as $num => $key)
|
||||
{
|
||||
if ($num > 1)
|
||||
{
|
||||
$query.= ' AND ';
|
||||
}
|
||||
$query.= $key.' = \''.$data[$key].'\'';
|
||||
}
|
||||
$query.= '
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// creation of the temporary table
|
||||
$query = '
|
||||
UPDATE '.$tablename.'
|
||||
SET ';
|
||||
$is_first = true;
|
||||
foreach ($dbfields['update'] as $num => $key)
|
||||
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))
|
||||
{
|
||||
if (!$is_first)
|
||||
if (in_array($row['Field'], $all_fields))
|
||||
{
|
||||
$query.= ",\n ";
|
||||
$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);
|
||||
}
|
||||
$query.= $key.' = ';
|
||||
if (isset($data[$key]) and $data[$key] != '')
|
||||
{
|
||||
$query.= '\''.$data[$key].'\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query.= 'NULL';
|
||||
}
|
||||
$is_first = false;
|
||||
}
|
||||
$query.= '
|
||||
WHERE ';
|
||||
foreach ($dbfields['primary'] as $num => $key)
|
||||
{
|
||||
if ($num > 1)
|
||||
{
|
||||
$query.= ' AND ';
|
||||
}
|
||||
$query.= $key.' = \''.$data[$key].'\'';
|
||||
}
|
||||
$query.= '
|
||||
|
||||
$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']
|
||||
)
|
||||
).'
|
||||
;';
|
||||
pwg_query($query);
|
||||
$query = '
|
||||
DROP TABLE '.$temporary_tablename.'
|
||||
;';
|
||||
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))
|
||||
{
|
||||
if (in_array($row['Field'], $all_fields))
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
$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']
|
||||
)
|
||||
).'
|
||||
;';
|
||||
pwg_query($query);
|
||||
$query = '
|
||||
DROP TABLE '.$temporary_tablename.'
|
||||
;';
|
||||
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
|
||||
);
|
||||
|
||||
|
|
|
@ -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']),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
?>
|
|
@ -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'].' ';
|
||||
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 .= ' '.$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));
|
||||
|
|
|
@ -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;
|
||||
|
@ -439,6 +447,132 @@ SELECT id
|
|||
return implode(',', $forbidden_array);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
)
|
||||
);
|
||||
|
||||
|
|
60
install/db/37-database.php
Normal file
60
install/db/37-database.php
Normal file
|
@ -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"
|
||||
;
|
||||
|
||||
?>
|
|
@ -289,6 +289,21 @@ CREATE TABLE `phpwebgallery_user_cache` (
|
|||
PRIMARY KEY (`user_id`)
|
||||
) 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`
|
||||
--
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
BIN
template/yoga/icon/recent_by_child.png
Normal file
BIN
template/yoga/icon/recent_by_child.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 738 B |
Loading…
Reference in a new issue