Ignore:
Timestamp:
Jan 17, 2012, 10:02:16 PM (12 years ago)
Author:
rvelices
Message:

feature 2548 multisize - implement delete_element_derivatives

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r12906 r12917  
    33// | Piwigo - a PHP based photo gallery                                    |
    44// +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
     5// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
    66// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    77// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
     
    176176  }
    177177
    178   include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
    179  
    180178  $new_ids = array();
    181179
     
    184182    id,
    185183    path,
    186     tn_ext,
    187     has_high,
    188184    representative_ext
    189185  FROM '.IMAGES_TABLE.'
     
    197193      continue;
    198194    }
    199    
     195
    200196    $files = array();
    201197    $files[] = get_element_path($row);
     
    216212      }
    217213    }
    218    
     214
    219215    if ($ok)
    220216    {
     217      delete_element_derivatives($row);
    221218      $new_ids[] += $row['id'];
    222219    }
     
    389386{
    390387  $orphan_tags = get_orphan_tags();
    391  
     388
    392389  if (count($orphan_tags) > 0)
    393390  {
     
    413410{
    414411  $orphan_tags = array();
    415  
     412
    416413  $query = '
    417414SELECT
     
    13901387    return false;
    13911388  }
    1392  
     1389
    13931390  $query = '
    13941391DELETE
     
    13971394;';
    13981395  pwg_query($query);
    1399  
     1396
    14001397  $query = '
    14011398DELETE
     
    20392036{
    20402037  $result = pwg_query($query);
    2041  
     2038
    20422039  $taglist = array();
    20432040  while ($row = pwg_db_fetch_assoc($result))
     
    20582055      $row['name'] = preg_replace('#\[lang=(.*?)\](.*?)\[/lang\]#is', null, $row['name']);
    20592056    }
    2060    
     2057
    20612058    if (strlen($row['name']) > 0)
    20622059    {
     
    20702067    }
    20712068  }
    2072  
     2069
    20732070  $cmp = create_function('$a,$b', 'return strcasecmp($a["name"], $b["name"]);');
    20742071  usort($taglist, $cmp);
     
    21372134    return;
    21382135  }
    2139  
     2136
    21402137  // make sure categories are private and select uppercats or subcats
    21412138  $cat_ids = (isset($_POST['apply_on_sub'])) ? implode(',', get_subcat_ids($category_ids)).",".implode(',', get_uppercat_ids($category_ids)) : implode(',', get_uppercat_ids($category_ids));
     
    21532150    return;
    21542151  }
    2155  
     2152
    21562153  // We must not reinsert already existing lines in user_access table
    21572154  $granteds = array();
     
    21602157    $granteds[$cat_id] = array();
    21612158  }
    2162  
     2159
    21632160  $query = '
    21642161SELECT
     
    21762173
    21772174  $inserts = array();
    2178  
     2175
    21792176  foreach ($private_cats as $cat_id)
    21802177  {
    21812178    $grant_to_users = array_diff($user_ids, $granteds[$cat_id]);
    2182    
     2179
    21832180    foreach ($grant_to_users as $user_id)
    21842181    {
     
    22082205    $status_list[] = 'webmaster';
    22092206  }
    2210  
     2207
    22112208  $query = '
    22122209SELECT
     
    22462243    $pattern .= derivative_to_url($types[0]);
    22472244  }
    2248  
     2245
    22492246  $pattern.='(_[a-zA-Z0-9]+)*\.[a-zA-Z0-9]{3,4}$#';
    22502247  if ($contents = opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR))
     
    22952292    }
    22962293    closedir($contents);
    2297    
     2294
    22982295    if ($rmdir)
    22992296    {
     
    23092306}
    23102307
    2311 function delete_element_derivatives($ids)
    2312 {
    2313   // todo
    2314   if (!is_array($ids))
    2315   {
    2316     $ids = array($ids);
    2317   }
    2318 
    2319   // for now I do a massive clear, to be removed once the function is
    2320   // properly implemented
    2321   clear_derivative_cache();
     2308function delete_element_derivatives($infos)
     2309{
     2310  $path = $infos['path'];
     2311  if (!empty($infos['representative_ext']))
     2312  {
     2313    $path = original_to_representative( $path, $infos['representative_ext']);
     2314  }
     2315  if (substr_compare($path, '../', 0, 3)==0)
     2316  {
     2317    $path = substr($path, 3);
     2318  }
     2319  $dot = strpos($path, '.');
     2320  $path = substr_replace($path, '-*', $dot, 0);
     2321  foreach( glob(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$path) as $file)
     2322  {
     2323    @unlink($file);
     2324  }
    23222325}
    23232326?>
Note: See TracChangeset for help on using the changeset viewer.