- admin/update : deletion of useless lines
- admin/thumbnail : use new process for finding pictures without thumbnails. No more recursivity - admin/thumbnail : only show list of directory containing pictures without thumbnails, not the whole directory tree git-svn-id: http://piwigo.org/svn/trunk@665 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
cc25f4aa35
commit
0c1de32d04
3 changed files with 144 additions and 107 deletions
|
|
@ -215,42 +215,6 @@ function RatioResizeImg( $filename, $newWidth, $newHeight, $path, $tn_ext )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_displayed_dirs builds the tree of dirs under "galleries". If a
|
|
||||||
// directory contains pictures without thumbnails, the become linked to the
|
|
||||||
// page of thumbnails creation.
|
|
||||||
function get_displayed_dirs( $dir, $indent )
|
|
||||||
{
|
|
||||||
global $lang;
|
|
||||||
|
|
||||||
$sub_dirs = get_subdirs( $dir );
|
|
||||||
$output = '';
|
|
||||||
if (!empty($sub_dirs))
|
|
||||||
{
|
|
||||||
$output.='<ul class="menu">';
|
|
||||||
// write of the dirs
|
|
||||||
foreach ( $sub_dirs as $sub_dir ) {
|
|
||||||
$output.='<li>';
|
|
||||||
$pictures = get_images_without_thumbnail( $dir.'/'.$sub_dir );
|
|
||||||
if ( count( $pictures ) > 0 )
|
|
||||||
{
|
|
||||||
$url = add_session_id(PHPWG_ROOT_PATH.'admin.php?page=thumbnail&dir='.$dir.'/'.$sub_dir);
|
|
||||||
$output.='<a class="adminMenu" href="'.$url.'">'.$sub_dir.'</a> [ '.count( $pictures ).' ';
|
|
||||||
$output.=$lang['thumbnail'].' ]';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$output.=$sub_dir;
|
|
||||||
}
|
|
||||||
// recursive call
|
|
||||||
$output.=get_displayed_dirs( $dir.'/'.$sub_dir,
|
|
||||||
$indent+30 );
|
|
||||||
$output.='</li>';
|
|
||||||
}
|
|
||||||
$output.='</ul>';
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$pictures = array();
|
$pictures = array();
|
||||||
$stats = array();
|
$stats = array();
|
||||||
|
|
@ -281,6 +245,7 @@ $template->set_filenames( array('thumbnail'=>'admin/thumbnail.tpl') );
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
'L_THUMBNAIL_TITLE'=>$lang['tn_dirs_title'],
|
'L_THUMBNAIL_TITLE'=>$lang['tn_dirs_title'],
|
||||||
'L_UNLINK'=>$lang['tn_dirs_alone'],
|
'L_UNLINK'=>$lang['tn_dirs_alone'],
|
||||||
|
'L_MISSING_THUMBNAILS'=>$lang['tn_dirs_alone'],
|
||||||
'L_RESULTS'=>$lang['tn_results_title'],
|
'L_RESULTS'=>$lang['tn_results_title'],
|
||||||
'L_TN_PICTURE'=>$lang['tn_picture'],
|
'L_TN_PICTURE'=>$lang['tn_picture'],
|
||||||
'L_FILESIZE'=>$lang['filesize'],
|
'L_FILESIZE'=>$lang['filesize'],
|
||||||
|
|
@ -318,11 +283,12 @@ if ( sizeof( $errors ) != 0 )
|
||||||
$template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i]));
|
$template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( isset( $_GET['dir'] ) && isset( $_POST['submit'] ) && !empty($stats))
|
else if (isset($_GET['dir']) and isset($_POST['submit']) and !empty($stats))
|
||||||
{
|
{
|
||||||
$times = array();
|
$times = array();
|
||||||
foreach ( $stats as $stat ) {
|
foreach ($stats as $stat)
|
||||||
array_push( $times, $stat['time'] );
|
{
|
||||||
|
array_push( $times, $stat['time'] );
|
||||||
}
|
}
|
||||||
$sum=array_sum( $times );
|
$sum=array_sum( $times );
|
||||||
$average = $sum/sizeof($times);
|
$average = $sum/sizeof($times);
|
||||||
|
|
@ -330,81 +296,159 @@ else if ( isset( $_GET['dir'] ) && isset( $_POST['submit'] ) && !empty($stats))
|
||||||
$max = array_pop($times);
|
$max = array_pop($times);
|
||||||
$min = array_shift( $times);
|
$min = array_shift( $times);
|
||||||
|
|
||||||
$template->assign_block_vars('results',array(
|
$template->assign_block_vars(
|
||||||
'TN_NB'=>count( $stats ),
|
'results',
|
||||||
'TN_TOTAL'=>number_format( $sum, 2, '.', ' ').' ms',
|
array(
|
||||||
'TN_MAX'=>number_format( $max, 2, '.', ' ').' ms',
|
'TN_NB'=>count( $stats ),
|
||||||
'TN_MIN'=>number_format( $min, 2, '.', ' ').' ms',
|
'TN_TOTAL'=>number_format( $sum, 2, '.', ' ').' ms',
|
||||||
'TN_AVERAGE'=>number_format( $average, 2, '.', ' ').' ms'
|
'TN_MAX'=>number_format( $max, 2, '.', ' ').' ms',
|
||||||
));
|
'TN_MIN'=>number_format( $min, 2, '.', ' ').' ms',
|
||||||
if ( !count( $pictures ) )
|
'TN_AVERAGE'=>number_format( $average, 2, '.', ' ').' ms'
|
||||||
|
));
|
||||||
|
if (!count($pictures))
|
||||||
{
|
{
|
||||||
$template->assign_block_vars('warning',array());
|
$template->assign_block_vars('warning',array());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $stats as $i => $stat )
|
foreach ($stats as $i => $stat)
|
||||||
{
|
|
||||||
$class = ($i % 2)? 'row1':'row2';
|
|
||||||
$color='';
|
|
||||||
if ($stat['time']==$max) $color = 'red';
|
|
||||||
elseif ($stat['time']==$min) $color = '#33FF00';
|
|
||||||
$template->assign_block_vars('results.picture',array(
|
|
||||||
'NB_IMG'=>($i+1),
|
|
||||||
'FILE_IMG'=>$stat['file'],
|
|
||||||
'FILESIZE_IMG'=>$stat['size'],
|
|
||||||
'WIDTH_IMG'=>$stat['width'],
|
|
||||||
'HEIGHT_IMG'=>$stat['height'],
|
|
||||||
'TN_FILE_IMG'=>$stat['tn_file'],
|
|
||||||
'TN_FILESIZE_IMG'=>$stat['tn_size'],
|
|
||||||
'TN_WIDTH_IMG'=>$stat['tn_width'],
|
|
||||||
'TN_HEIGHT_IMG'=>$stat['tn_height'],
|
|
||||||
'GEN_TIME'=>number_format( $stat['time'], 2, '.', ' ').' ms',
|
|
||||||
|
|
||||||
'T_COLOR'=>$color,
|
|
||||||
'T_CLASS'=>$class
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//-------------------------------------------------- miniaturization parameters
|
|
||||||
if ( isset( $_GET['dir'] ) && !sizeof( $pictures ))
|
|
||||||
{
|
|
||||||
$form_url = PHPWG_ROOT_PATH.'admin.php?page=thumbnail&dir='.$_GET['dir'];
|
|
||||||
$gd = !empty( $_POST['gd'] )?$_POST['gd']:2;
|
|
||||||
$width = !empty( $_POST['width'] )?$_POST['width']:128;
|
|
||||||
$height = !empty( $_POST['height'] )?$_POST['height']:96;
|
|
||||||
$gdlabel = 'GD'.$gd.'_CHECKED';
|
|
||||||
|
|
||||||
$template->assign_block_vars('params',array(
|
|
||||||
'F_ACTION'=>add_session_id($form_url),
|
|
||||||
$gdlabel=>'checked="checked"',
|
|
||||||
'WIDTH_TN'=>$width,
|
|
||||||
'HEIGHT_TN'=>$height
|
|
||||||
));
|
|
||||||
|
|
||||||
//---------------------------------------------------------- remaining pictures
|
|
||||||
$pictures = get_images_without_thumbnail( $_GET['dir'] );
|
|
||||||
$template->assign_block_vars('remainings',array('TOTAL_IMG'=>count( $pictures )));
|
|
||||||
|
|
||||||
foreach ( $pictures as $i => $picture )
|
|
||||||
{
|
{
|
||||||
$class = ($i % 2)? 'row1':'row2';
|
$class = ($i % 2)? 'row1':'row2';
|
||||||
$template->assign_block_vars('remainings.remaining',array(
|
$color='';
|
||||||
'NB_IMG'=>($i+1),
|
if ($stat['time'] == $max)
|
||||||
'FILE_TN'=>$picture['name'],
|
{
|
||||||
'FILESIZE_IMG'=>$picture['size'],
|
$color = 'red';
|
||||||
'WIDTH_IMG'=>$picture['width'],
|
|
||||||
'HEIGHT_IMG'=>$picture['height'],
|
|
||||||
|
|
||||||
'T_CLASS'=>$class
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
else if ($stat['time'] == $min)
|
||||||
|
{
|
||||||
|
$color = '#33FF00';
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign_block_vars(
|
||||||
|
'results.picture',
|
||||||
|
array(
|
||||||
|
'NB_IMG'=>($i+1),
|
||||||
|
'FILE_IMG'=>$stat['file'],
|
||||||
|
'FILESIZE_IMG'=>$stat['size'],
|
||||||
|
'WIDTH_IMG'=>$stat['width'],
|
||||||
|
'HEIGHT_IMG'=>$stat['height'],
|
||||||
|
'TN_FILE_IMG'=>$stat['tn_file'],
|
||||||
|
'TN_FILESIZE_IMG'=>$stat['tn_size'],
|
||||||
|
'TN_WIDTH_IMG'=>$stat['tn_width'],
|
||||||
|
'TN_HEIGHT_IMG'=>$stat['tn_height'],
|
||||||
|
'GEN_TIME'=>number_format( $stat['time'], 2, '.', ' ').' ms',
|
||||||
|
|
||||||
|
'T_COLOR'=>$color,
|
||||||
|
'T_CLASS'=>$class
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-------------------------------------------------- miniaturization parameters
|
||||||
|
if (isset($_GET['dir']) and !sizeof($pictures))
|
||||||
|
{
|
||||||
|
$form_url = PHPWG_ROOT_PATH.'admin.php?page=thumbnail&dir='.$_GET['dir'];
|
||||||
|
$gd = !empty( $_POST['gd'] )?$_POST['gd']:2;
|
||||||
|
$width = !empty( $_POST['width'] )?$_POST['width']:128;
|
||||||
|
$height = !empty( $_POST['height'] )?$_POST['height']:96;
|
||||||
|
$gdlabel = 'GD'.$gd.'_CHECKED';
|
||||||
|
|
||||||
|
$template->assign_block_vars(
|
||||||
|
'params',
|
||||||
|
array(
|
||||||
|
'F_ACTION'=>add_session_id($form_url),
|
||||||
|
$gdlabel=>'checked="checked"',
|
||||||
|
'WIDTH_TN'=>$width,
|
||||||
|
'HEIGHT_TN'=>$height
|
||||||
|
));
|
||||||
|
//---------------------------------------------------------- remaining pictures
|
||||||
|
$pictures = get_images_without_thumbnail( $_GET['dir'] );
|
||||||
|
$template->assign_block_vars(
|
||||||
|
'remainings',
|
||||||
|
array('TOTAL_IMG'=>count($pictures)));
|
||||||
|
|
||||||
|
foreach ($pictures as $i => $picture)
|
||||||
|
{
|
||||||
|
$class = ($i % 2)? 'row1':'row2';
|
||||||
|
$template->assign_block_vars(
|
||||||
|
'remainings.remaining',
|
||||||
|
array(
|
||||||
|
'NB_IMG'=>($i+1),
|
||||||
|
'FILE_TN'=>$picture['name'],
|
||||||
|
'FILESIZE_IMG'=>$picture['size'],
|
||||||
|
'WIDTH_IMG'=>$picture['width'],
|
||||||
|
'HEIGHT_IMG'=>$picture['height'],
|
||||||
|
|
||||||
|
'T_CLASS'=>$class
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------- directory list
|
//-------------------------------------------------------------- directory list
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$categories = get_displayed_dirs( './galleries', 60 );
|
$wo_thumbnails = array();
|
||||||
$template->assign_block_vars('directory_list',array('CATEGORY_LIST'=>$categories));
|
|
||||||
}
|
// what is the directory to search in ?
|
||||||
|
$query = '
|
||||||
|
SELECT galleries_url
|
||||||
|
FROM '.SITES_TABLE.'
|
||||||
|
WHERE id = 1
|
||||||
|
;';
|
||||||
|
list($galleries_url) = mysql_fetch_array(pwg_query($query));
|
||||||
|
$basedir = preg_replace('#/*$#', '', $galleries_url);
|
||||||
|
|
||||||
|
$fs = get_fs($basedir);
|
||||||
|
// because isset is one hundred time faster than in_array
|
||||||
|
$fs['thumbnails'] = array_flip($fs['thumbnails']);
|
||||||
|
|
||||||
|
foreach ($fs['elements'] as $path)
|
||||||
|
{
|
||||||
|
// only pictures need thumbnails
|
||||||
|
if (in_array(get_extension($path), $conf['picture_ext']))
|
||||||
|
{
|
||||||
|
$dirname = dirname($path);
|
||||||
|
$filename = basename($path);
|
||||||
|
// searching the element
|
||||||
|
$filename_wo_ext = get_filename_wo_extension($filename);
|
||||||
|
$tn_ext = '';
|
||||||
|
$base_test = $dirname.'/thumbnail/';
|
||||||
|
$base_test.= $conf['prefix_thumbnail'].$filename_wo_ext.'.';
|
||||||
|
foreach ($conf['picture_ext'] as $ext)
|
||||||
|
{
|
||||||
|
if (isset($fs['thumbnails'][$base_test.$ext]))
|
||||||
|
{
|
||||||
|
$tn_ext = $ext;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($tn_ext))
|
||||||
|
{
|
||||||
|
if (!isset($wo_thumbnails[$dirname]))
|
||||||
|
{
|
||||||
|
$wo_thumbnails[$dirname] = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$wo_thumbnails[$dirname]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($wo_thumbnails) > 0)
|
||||||
|
{
|
||||||
|
$template->assign_block_vars('directory_list', array());
|
||||||
|
foreach ($wo_thumbnails as $directory => $nb_missing)
|
||||||
|
{
|
||||||
|
$url = PHPWG_ROOT_PATH.'admin.php?page=thumbnail&dir='.$directory;
|
||||||
|
|
||||||
|
$template->assign_block_vars(
|
||||||
|
'directory_list.directory',
|
||||||
|
array(
|
||||||
|
'DIRECTORY'=>$directory,
|
||||||
|
'URL'=>add_session_id($url),
|
||||||
|
'NB_MISSING'=>$nb_missing));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$template->assign_var_from_handle('ADMIN_CONTENT', 'thumbnail');
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'thumbnail');
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -341,10 +341,6 @@ SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
|
||||||
$tn_ext = $ext;
|
$tn_ext = $ext;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2 cases : the element is a picture or not. Indeed, for a picture
|
// 2 cases : the element is a picture or not. Indeed, for a picture
|
||||||
|
|
@ -387,10 +383,6 @@ SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
|
||||||
$representative_ext = $ext;
|
$representative_ext = $ext;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$insert{'id'} = $next_element_id++;
|
$insert{'id'} = $next_element_id++;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
<!-- BEGIN directory_list -->
|
<!-- BEGIN directory_list -->
|
||||||
<div class="admin">{L_THUMBNAIL_TITLE}</div>
|
<div class="admin">{L_THUMBNAIL_TITLE}</div>
|
||||||
<ul class="menu">
|
<ul class="menu">
|
||||||
<li>galleries</li>
|
<!-- BEGIN directory -->
|
||||||
{directory_list.CATEGORY_LIST}
|
<li>[<a href="{directory_list.directory.URL}">{directory_list.directory.DIRECTORY}</a>] {directory_list.directory.NB_MISSING} {L_MISSING_THUMBNAILS}</li>
|
||||||
|
<!-- END directory -->
|
||||||
</ul>
|
</ul>
|
||||||
<!-- END directory_list -->
|
<!-- END directory_list -->
|
||||||
<!-- BEGIN warning -->
|
<!-- BEGIN warning -->
|
||||||
|
|
@ -44,7 +45,7 @@
|
||||||
<th>
|
<th>
|
||||||
<div style="text-align:right;margin-right:5px;color:{results.picture.T_COLOR};">{results.picture.GEN_TIME}</div>
|
<div style="text-align:right;margin-right:5px;color:{results.picture.T_COLOR};">{results.picture.GEN_TIME}</div>
|
||||||
</th>
|
</th>
|
||||||
<td>{results.picture.TN_FILE_IMG}</td>
|
<td><img src="{results.picture.TN_FILE_IMG}" /></td>
|
||||||
<td style="text-align:right;">{results.picture.TN_FILESIZE_IMG}</td>
|
<td style="text-align:right;">{results.picture.TN_FILESIZE_IMG}</td>
|
||||||
<td style="text-align:right;">{results.picture.TN_WIDTH_IMG}</td>
|
<td style="text-align:right;">{results.picture.TN_WIDTH_IMG}</td>
|
||||||
<td style="text-align:right;">{results.picture.TN_HEIGHT_IMG}</td>
|
<td style="text-align:right;">{results.picture.TN_HEIGHT_IMG}</td>
|
||||||
|
|
@ -157,4 +158,4 @@
|
||||||
</tr>
|
</tr>
|
||||||
<!-- END remaining -->
|
<!-- END remaining -->
|
||||||
</table>
|
</table>
|
||||||
<!-- END remainings -->
|
<!-- END remainings -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue