diff options
-rw-r--r-- | include/category_cats.inc.php | 7 | ||||
-rw-r--r-- | include/functions_category.inc.php | 7 | ||||
-rw-r--r-- | include/functions_html.inc.php | 63 | ||||
-rw-r--r-- | include/functions_user.inc.php | 46 | ||||
-rw-r--r-- | install/db/38-database.php | 50 | ||||
-rw-r--r-- | install/phpwebgallery_structure.sql | 1 | ||||
-rw-r--r-- | template/yoga/menubar.css | 2 |
7 files changed, 108 insertions, 68 deletions
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php index d50347a44..eaa01b80b 100644 --- a/include/category_cats.inc.php +++ b/include/category_cats.inc.php @@ -37,7 +37,7 @@ if ($page['section']=='recent_cats') $query = ' SELECT id,name, representative_picture_id, comment, nb_images, uppercats, - max_date_last, is_child_date_last, count_images, count_categories + date_last, max_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( @@ -50,7 +50,7 @@ else $query = ' SELECT id,name, representative_picture_id, comment, nb_images, - max_date_last, is_child_date_last, count_images, count_categories + date_last, max_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 '. @@ -65,7 +65,8 @@ $image_ids = array(); while ($row = mysql_fetch_assoc($result)) { - $row['is_child_date_last'] = get_boolean($row['is_child_date_last']); + $row['is_child_date_last'] = isset($row['date_last']) + and $row['max_date_last']>$row['date_last']; if (isset($row['representative_picture_id']) and is_numeric($row['representative_picture_id'])) diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index e8a066923..706d9c401 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -61,7 +61,7 @@ SELECT '; name, id, nb_images, global_rank,'; // From USER_CACHE_CATEGORIES_TABLE $query.= ' - max_date_last, is_child_date_last, count_images, count_categories'; + date_last, max_date_last, count_images, count_categories'; // $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE $query.= ' @@ -82,9 +82,8 @@ SELECT '; $result = pwg_query($query); $cats = array(); - while ($row = mysql_fetch_array($result)) + while ($row = mysql_fetch_assoc($result)) { - $row['is_child_date_last'] = get_boolean($row['is_child_date_last']); array_push($cats, $row); } usort($cats, 'global_rank_compare'); @@ -391,4 +390,4 @@ function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_ return $display_text; } -?>
\ No newline at end of file +?> diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index 6c69b0fb0..ef0ee026c 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -26,55 +26,63 @@ function get_icon($date, $is_child_date = false) { - global $page, $user, $conf, $lang; + global $page, $user, $lang; if (empty($date)) { - $date = 'NULL'; + return ''; } - if (isset($page['get_icon_cache'][$is_child_date][$date])) + if (isset($page['get_icon_cache'][$date])) { - return $page['get_icon_cache'][$is_child_date][$date]; + if (! $page['get_icon_cache'][$date] ) + return ''; + return $page['get_icon_cache']['_icons_'][$is_child_date]; } if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})/', $date, $matches)) - { - // date can be empty, no icon to display - $page['get_icon_cache'][$is_child_date][$date] = ''; - return $page['get_icon_cache'][$is_child_date][$date]; + {// date can be empty, no icon to display + $page['get_icon_cache'][$date] = false; + return ''; } list($devnull, $year, $month, $day) = $matches; $unixtime = mktime( 0, 0, 0, $month, $day, $year ); - if ($unixtime === false // PHP 5.1.0 and above or $unixtime === -1) // PHP prior to 5.1.0 { - $page['get_icon_cache'][$is_child_date][$date] = ''; - return $page['get_icon_cache'][$is_child_date][$date]; + $page['get_icon_cache'][$date] = false; + return ''; } $diff = time() - $unixtime; $day_in_seconds = 24*60*60; - $output = ''; - $title = $lang['recent_image'].' '; + $page['get_icon_cache'][$date] = false; if ( $diff < $user['recent_period'] * $day_in_seconds ) { - $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 ); - $icon_url = get_root_url().$icon_url; - $output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;'; - $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />'; + if ( !isset($page['get_icon_cache']['_icons_'] ) ) + { + $icons = array(false => 'recent', true => 'recent_by_child' ); + $title = $lang['recent_image'].' '.$user['recent_period'] + .' '.$lang['days']; + foreach ($icons as $key => $icon) + { + $icon_url = get_themeconf('icon_dir').'/'.$icon.'.png'; + $size = getimagesize( PHPWG_ROOT_PATH.$icon_url ); + $icon_url = get_root_url().$icon_url; + $output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;'; + $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />'; + $page['get_icon_cache']['_icons_'][$key] = $output; + } + } + $page['get_icon_cache'][$date] = true; } - - $page['get_icon_cache'][$is_child_date][$date] = $output; - - return $page['get_icon_cache'][$is_child_date][$date]; + if (! $page['get_icon_cache'][$date] ) + return ''; + return $page['get_icon_cache']['_icons_'][$is_child_date]; } + function create_navigation_bar( $url, $nb_element, $start, $nb_element_page, $clean_url = false ) @@ -392,7 +400,7 @@ 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, max_date_last, is_child_date_last, + * used keys are : id, name, nb_images, max_date_last, date_last * count_images, count_categories * * @param array categories @@ -473,8 +481,9 @@ function get_html_menu_category($categories) : $category['count_images']).']'; $menu.= '</span>'; } - - $menu.= get_icon($category['max_date_last'], $category['is_child_date_last']); + $child_date_last = isset($category['date_last']) + and $category['max_date_last']>$category['date_last'] ; + $menu.= get_icon($category['max_date_last'], $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 206ccf4a6..362679f51 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -272,7 +272,7 @@ SELECT ui.*, uc.* $userdata['forbidden_categories'] = calculate_permissions($userdata['id'], $userdata['status']); - update_user_cache_categorie($userdata['id'], $userdata['forbidden_categories']); + update_user_cache_categories($userdata['id'], $userdata['forbidden_categories']); // Set need update are done $userdata['need_update'] = false; @@ -449,9 +449,6 @@ SELECT id /** * compute data of categories branches - * - * was internal function of update_user_cache_categorie - * move to global because function be redeclare when it's internal */ function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level) { @@ -472,7 +469,6 @@ function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level) 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 { @@ -494,37 +490,37 @@ function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level) } /** - * update data of user_cache_categorie + * update data of user_cache_categories * * @param int user_id * @return null */ -function update_user_cache_categorie($user_id, $user_forbidden_categories) +function update_user_cache_categories($user_id, $user_forbidden_categories) { // delete user cache $query = ' - delete from '.USER_CACHE_CATEGORIES_TABLE.' - where user_id = '.$user_id.' +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; +SELECT id cat_id, date_last max_date_last, nb_images count_images, global_rank + FROM '.CATEGORIES_TABLE; if ($user_forbidden_categories != '') { $query.= ' - where id not in ('.$user_forbidden_categories.')'; + WHERE id NOT IN ('.$user_forbidden_categories.')'; } $query.= ';'; $result = pwg_query($query); $cats = array(); - while ($row = mysql_fetch_array($result)) + while ($row = mysql_fetch_assoc($result)) { + $row['user_id'] = $user_id; + $row['count_categories'] = 0; $cats += array($row['cat_id'] => $row); } usort($cats, 'global_rank_compare'); @@ -535,13 +531,6 @@ function update_user_cache_categorie($user_id, $user_forbidden_categories) 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) @@ -559,21 +548,14 @@ function update_user_cache_categorie($user_id, $user_forbidden_categories) $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' + 'user_id', 'cat_id', + 'max_date_last', 'count_images', 'count_categories' ), $cats ); @@ -800,7 +782,7 @@ function log_user($user_id, $remember_me) { global $conf, $user; - if ($remember_me) + if ($remember_me and $conf['authorize_remembering']) { $key = calculate_auto_login_key($user_id); if ($key!==false) diff --git a/install/db/38-database.php b/install/db/38-database.php new file mode 100644 index 000000000..07dded8f9 --- /dev/null +++ b/install/db/38-database.php @@ -0,0 +1,50 @@ +<?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 = 'delete #user_cache_categories.is_child_date_last'; + +include_once(PHPWG_ROOT_PATH.'include/constants.php'); + +// +-----------------------------------------------------------------------+ +// | Upgrade content | +// +-----------------------------------------------------------------------+ +$query = ' +ALTER TABLE '.USER_CACHE_CATEGORIES_TABLE.' DROP COLUMN is_child_date_last'; +pwg_query($query); + +echo +"\n" +.'"'.$upgrade_description.'"'.' ended' +."\n" +; + +?> diff --git a/install/phpwebgallery_structure.sql b/install/phpwebgallery_structure.sql index 469b1b9a1..dc1d69f0f 100644 --- a/install/phpwebgallery_structure.sql +++ b/install/phpwebgallery_structure.sql @@ -297,7 +297,6 @@ 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, diff --git a/template/yoga/menubar.css b/template/yoga/menubar.css index 831f17fc3..cfa1a2205 100644 --- a/template/yoga/menubar.css +++ b/template/yoga/menubar.css @@ -49,7 +49,7 @@ #menubar .menuInfoCatByChild { font-size: 80%; - font-weight: italic; + font-style: italic; } #menubar HR { |