Changeset 1641


Ignore:
Timestamp:
Dec 8, 2006, 12:21:54 AM (17 years ago)
Author:
rvelices
Message:
  • remove #user_cache_categories.is_child_date_last
  • optimize code in get_icon
  • correct css font-wigth:italic to font-style:italic
  • aditionnal check on $confauthorize_remembering before allowing auto_login
Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/category_cats.inc.php

    r1638 r1641  
    3838SELECT
    3939  id,name, representative_picture_id, comment, nb_images, uppercats,
    40   max_date_last, is_child_date_last, count_images, count_categories
     40  date_last, max_date_last, count_images, count_categories
    4141  FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
    4242  ON id = cat_id and user_id = '.$user['id'].'
     
    5151SELECT
    5252  id,name, representative_picture_id, comment, nb_images,
    53   max_date_last, is_child_date_last, count_images, count_categories
     53  date_last, max_date_last, count_images, count_categories
    5454  FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
    5555  ON id = cat_id and user_id = '.$user['id'].'
     
    6666while ($row = mysql_fetch_assoc($result))
    6767{
    68   $row['is_child_date_last'] = get_boolean($row['is_child_date_last']);
     68  $row['is_child_date_last'] = isset($row['date_last'])
     69      and $row['max_date_last']>$row['date_last'];
    6970
    7071  if (isset($row['representative_picture_id'])
  • trunk/include/functions_category.inc.php

    r1637 r1641  
    6262  // From USER_CACHE_CATEGORIES_TABLE
    6363  $query.= '
    64   max_date_last, is_child_date_last, count_images, count_categories';
     64  date_last, max_date_last, count_images, count_categories';
    6565
    6666  // $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
     
    8383  $result = pwg_query($query);
    8484  $cats = array();
    85   while ($row = mysql_fetch_array($result))
    86   {
    87     $row['is_child_date_last'] = get_boolean($row['is_child_date_last']);
     85  while ($row = mysql_fetch_assoc($result))
     86  {
    8887    array_push($cats, $row);
    8988  }
  • trunk/include/functions_html.inc.php

    r1624 r1641  
    2727function get_icon($date, $is_child_date = false)
    2828{
    29   global $page, $user, $conf, $lang;
     29  global $page, $user, $lang;
    3030
    3131  if (empty($date))
    3232  {
    33     $date = 'NULL';
    34   }
    35 
    36   if (isset($page['get_icon_cache'][$is_child_date][$date]))
    37   {
    38     return $page['get_icon_cache'][$is_child_date][$date];
     33    return '';
     34  }
     35
     36  if (isset($page['get_icon_cache'][$date]))
     37  {
     38    if (! $page['get_icon_cache'][$date] )
     39      return '';
     40    return $page['get_icon_cache']['_icons_'][$is_child_date];
    3941  }
    4042
    4143  if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})/', $date, $matches))
    42   {
    43     // date can be empty, no icon to display
    44     $page['get_icon_cache'][$is_child_date][$date] = '';
    45     return $page['get_icon_cache'][$is_child_date][$date];
     44  {// date can be empty, no icon to display
     45    $page['get_icon_cache'][$date] = false;
     46    return '';
    4647  }
    4748
    4849  list($devnull, $year, $month, $day) = $matches;
    4950  $unixtime = mktime( 0, 0, 0, $month, $day, $year );
    50 
    5151  if ($unixtime === false  // PHP 5.1.0 and above
    5252      or $unixtime === -1) // PHP prior to 5.1.0
    5353  {
    54     $page['get_icon_cache'][$is_child_date][$date] = '';
    55     return $page['get_icon_cache'][$is_child_date][$date];
     54    $page['get_icon_cache'][$date] = false;
     55    return '';
    5656  }
    5757
    5858  $diff = time() - $unixtime;
    5959  $day_in_seconds = 24*60*60;
    60   $output = '';
    61   $title = $lang['recent_image'].' ';
     60  $page['get_icon_cache'][$date] = false;
    6261  if ( $diff < $user['recent_period'] * $day_in_seconds )
    6362  {
    64     $icon_url = get_themeconf('icon_dir').'/'.($is_child_date ? 'recent_by_child.png' : 'recent.png');
    65     $title .= $user['recent_period'];
    66     $title .=  '&nbsp;'.$lang['days'];
    67     $size = getimagesize( PHPWG_ROOT_PATH.$icon_url );
    68     $icon_url = get_root_url().$icon_url;
    69     $output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;';
    70     $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />';
    71   }
    72 
    73   $page['get_icon_cache'][$is_child_date][$date] = $output;
    74 
    75   return $page['get_icon_cache'][$is_child_date][$date];
    76 }
     63    if ( !isset($page['get_icon_cache']['_icons_'] ) )
     64    {
     65      $icons = array(false => 'recent', true => 'recent_by_child' );
     66      $title = $lang['recent_image'].'&nbsp;'.$user['recent_period']
     67          .'&nbsp;'.$lang['days'];
     68      foreach ($icons as $key => $icon)
     69      {
     70        $icon_url = get_themeconf('icon_dir').'/'.$icon.'.png';
     71        $size = getimagesize( PHPWG_ROOT_PATH.$icon_url );
     72        $icon_url = get_root_url().$icon_url;
     73        $output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;';
     74        $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />';
     75        $page['get_icon_cache']['_icons_'][$key] = $output;
     76      }
     77    }
     78    $page['get_icon_cache'][$date] = true;
     79  }
     80  if (! $page['get_icon_cache'][$date] )
     81    return '';
     82  return $page['get_icon_cache']['_icons_'][$is_child_date];
     83}
     84
    7785
    7886function create_navigation_bar(
     
    393401 * HTML code generated uses logical list tags ul and each category is an
    394402 * item li. The paramter given is the category informations as an array,
    395  * used keys are : id, name, nb_images, max_date_last, is_child_date_last,
     403 * used keys are : id, name, nb_images, max_date_last, date_last
    396404 * count_images, count_categories
    397405 *
     
    474482      $menu.= '</span>';
    475483    }
    476 
    477     $menu.= get_icon($category['max_date_last'], $category['is_child_date_last']);
     484    $child_date_last = isset($category['date_last'])
     485        and $category['max_date_last']>$category['date_last'] ;
     486    $menu.= get_icon($category['max_date_last'], $child_date_last);
    478487  }
    479488
  • trunk/include/functions_user.inc.php

    r1640 r1641  
    273273        calculate_permissions($userdata['id'], $userdata['status']);
    274274
    275       update_user_cache_categorie($userdata['id'], $userdata['forbidden_categories']);
     275      update_user_cache_categories($userdata['id'], $userdata['forbidden_categories']);
    276276
    277277      // Set need update are done
     
    450450/**
    451451 * compute data of categories branches
    452  *
    453  * was internal function of update_user_cache_categorie
    454  * move to global because function be redeclare when it's internal
    455452 */
    456453function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level)
     
    473470      {
    474471        $cats[$cat_id]['max_date_last'] = $date;
    475         $cats[$cat_id]['is_child_date_last'] = true;
    476472      }
    477473      else
     
    495491
    496492/**
    497  * update data of user_cache_categorie
     493 * update data of user_cache_categories
    498494 *
    499495 * @param int user_id
    500496 * @return null
    501497 */
    502 function update_user_cache_categorie($user_id, $user_forbidden_categories)
     498function update_user_cache_categories($user_id, $user_forbidden_categories)
    503499{
    504500  // delete user cache
    505501  $query = '
    506   delete from '.USER_CACHE_CATEGORIES_TABLE.'
    507   where user_id = '.$user_id.'
     502DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'
     503  WHERE user_id = '.$user_id.'
    508504;';
    509505  pwg_query($query);
    510506
    511507  $query = '
    512     select
    513       id cat_id, date_last,
    514       nb_images, global_rank
    515     from '.CATEGORIES_TABLE;
     508SELECT id cat_id, date_last max_date_last, nb_images count_images, global_rank
     509  FROM '.CATEGORIES_TABLE;
    516510  if ($user_forbidden_categories != '')
    517511  {
    518512    $query.= '
    519     where id not in ('.$user_forbidden_categories.')';
     513    WHERE id NOT IN ('.$user_forbidden_categories.')';
    520514  }
    521515  $query.= ';';
     
    524518
    525519  $cats = array();
    526   while ($row = mysql_fetch_array($result))
    527   {
     520  while ($row = mysql_fetch_assoc($result))
     521  {
     522    $row['user_id'] = $user_id;
     523    $row['count_categories'] = 0;
    528524    $cats += array($row['cat_id'] => $row);
    529525  }
     
    536532  foreach ($cats as $id => $category)
    537533  {
    538     // Update field
    539     $cats[$id]['user_id'] = $user_id;
    540     $cats[$id]['is_child_date_last'] = false;
    541     $cats[$id]['max_date_last'] = $cats[$id]['date_last'];
    542     $cats[$id]['count_images'] = $cats[$id]['nb_images'];
    543     $cats[$id]['count_categories'] = 0;
    544 
    545534    // Compute
    546535    $level = substr_count($category['global_rank'], '.') + 1;
     
    559548  $level = 1;
    560549  compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level);
    561 
    562   foreach ($cats as $id => $category)
    563   {
    564     // Convert field
    565     $cats[$id]['is_child_date_last'] = boolean_to_string($cats[$id]['is_child_date_last']);
    566   }
    567550
    568551  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     
    572555    array
    573556    (
    574       'user_id', 'cat_id',
    575       'is_child_date_last', 'max_date_last',
    576       'count_images', 'count_categories'
     557      'user_id', 'cat_id',
     558      'max_date_last', 'count_images', 'count_categories'
    577559    ),
    578560    $cats
     
    801783  global $conf, $user;
    802784
    803   if ($remember_me)
     785  if ($remember_me and $conf['authorize_remembering'])
    804786  {
    805787    $key = calculate_auto_login_key($user_id);
  • trunk/install/phpwebgallery_structure.sql

    r1624 r1641  
    298298  `user_id` smallint(5) NOT NULL default '0',
    299299  `cat_id` smallint(5) unsigned NOT NULL default '0',
    300   `is_child_date_last` enum('true','false') NOT NULL default 'false',
    301300  `max_date_last` datetime default NULL,
    302301  `count_images` mediumint(8) unsigned default 0,
  • trunk/template/yoga/menubar.css

    r1625 r1641  
    5050#menubar .menuInfoCatByChild {
    5151  font-size: 80%;
    52   font-weight: italic;
     52  font-style: italic;
    5353}
    5454
Note: See TracChangeset for help on using the changeset viewer.