mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 01:03:31 +02:00
- images.path column added to reduce database access
- function mass_inserts moved from admin/remote_sites.php to admin/include/function.php - function mass_inserts used in admin/update.php git-svn-id: http://piwigo.org/svn/trunk@606 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -219,7 +219,7 @@ if (!isset($page['calendar_year']))
|
||||
foreach ($calendar_years as $calendar_year => $nb_pics)
|
||||
{
|
||||
$query = '
|
||||
SELECT file,tn_ext,'.$conf['calendar_datefield'].',storage_category_id
|
||||
SELECT file,tn_ext,'.$conf['calendar_datefield'].',path
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND YEAR('.$conf['calendar_datefield'].') = '.$calendar_year.'
|
||||
@@ -229,9 +229,7 @@ SELECT file,tn_ext,'.$conf['calendar_datefield'].',storage_category_id
|
||||
;';
|
||||
$row = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
$thumbnail_src = get_thumbnail_src($row['file'],
|
||||
$row['storage_category_id'],
|
||||
@$row['tn_ext']);
|
||||
$thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
|
||||
$name = $calendar_year.' ('.$nb_pics.')';
|
||||
|
||||
@@ -266,7 +264,7 @@ elseif (!isset($page['calendar_month']))
|
||||
foreach ($calendar_months as $calendar_month => $nb_pics)
|
||||
{
|
||||
$query = '
|
||||
SELECT file,tn_ext,'.$conf['calendar_datefield'].',storage_category_id
|
||||
SELECT file,tn_ext,'.$conf['calendar_datefield'].',path
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND YEAR('.$conf['calendar_datefield'].') = '.$page['calendar_year'].'
|
||||
@@ -277,9 +275,7 @@ SELECT file,tn_ext,'.$conf['calendar_datefield'].',storage_category_id
|
||||
;';
|
||||
$row = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
$thumbnail_src = get_thumbnail_src($row['file'],
|
||||
$row['storage_category_id'],
|
||||
@$row['tn_ext']);
|
||||
$thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
|
||||
$name = $lang['month'][$calendar_month];
|
||||
$name.= ' '.$page['calendar_year'];
|
||||
@@ -322,7 +318,7 @@ elseif (!isset($page['calendar_day']))
|
||||
foreach ($calendar_days as $calendar_day => $nb_pics)
|
||||
{
|
||||
$query = '
|
||||
SELECT file,tn_ext,'.$conf['calendar_datefield'].',storage_category_id
|
||||
SELECT file,tn_ext,'.$conf['calendar_datefield'].',path
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND '.$conf['calendar_datefield'].' = \''.$calendar_day.'\'
|
||||
@@ -332,9 +328,7 @@ SELECT file,tn_ext,'.$conf['calendar_datefield'].',storage_category_id
|
||||
;';
|
||||
$row = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
$thumbnail_src = get_thumbnail_src($row['file'],
|
||||
$row['storage_category_id'],
|
||||
@$row['tn_ext']);
|
||||
$thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
|
||||
list($year,$month,$day) = explode('-', $calendar_day);
|
||||
$unixdate = mktime(0,0,0,$month,$day,$year);
|
||||
@@ -385,7 +379,7 @@ elseif (isset($page['calendar_day']))
|
||||
$name.= ' ('.$nb_pics.')';
|
||||
|
||||
$query = '
|
||||
SELECT file,tn_ext,'.$conf['calendar_datefield'].',storage_category_id
|
||||
SELECT file,tn_ext,'.$conf['calendar_datefield'].',path
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
'.$page['where'].'
|
||||
AND '.$conf['calendar_datefield'].' = \''.$page['calendar_date'].'\'';
|
||||
@@ -401,9 +395,7 @@ SELECT file,tn_ext,'.$conf['calendar_datefield'].',storage_category_id
|
||||
;';
|
||||
$row = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
$thumbnail_src = get_thumbnail_src($row['file'],
|
||||
$row['storage_category_id'],
|
||||
@$row['tn_ext']);
|
||||
$thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
|
||||
$thumbnail_title = $lang['calendar_picture_hint'].$name;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
$array_cat_directories = array();
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT(id),file,date_available,category_id
|
||||
SELECT DISTINCT(id),path,file,date_available,category_id
|
||||
,tn_ext,name,filesize,storage_category_id,average_rate
|
||||
FROM '.IMAGES_TABLE.' AS i
|
||||
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id
|
||||
@@ -80,9 +80,7 @@ while ($row = mysql_fetch_array($result))
|
||||
$name = replace_search($name, $_GET['search']);
|
||||
}
|
||||
|
||||
$thumbnail_url = get_thumbnail_src($row['file'],
|
||||
$row['storage_category_id'],
|
||||
@$row['tn_ext']);
|
||||
$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
|
||||
// message in title for the thumbnail
|
||||
$thumbnail_title = $row['file'];
|
||||
|
||||
@@ -66,7 +66,7 @@ while ( $row = mysql_fetch_array( $result ) )
|
||||
$name = get_cat_display_name($cat_infos['name'],'<br />','',false);
|
||||
|
||||
$query = '
|
||||
SELECT id,file,tn_ext,storage_category_id
|
||||
SELECT path,file,tn_ext
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
WHERE category_id = '.$row['category_id'].'
|
||||
AND date_available > SUBDATE(CURRENT_DATE
|
||||
@@ -75,11 +75,9 @@ SELECT id,file,tn_ext,storage_category_id
|
||||
ORDER BY RAND()
|
||||
LIMIT 0,1
|
||||
;';
|
||||
$subrow = mysql_fetch_array( pwg_query( $query ) );
|
||||
$subrow = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
$thumbnail_src = get_thumbnail_src($subrow['file'],
|
||||
$subrow['storage_category_id'],
|
||||
@$subrow['tn_ext']);
|
||||
$thumbnail_src = get_thumbnail_src($subrow['path'], @$subrow['tn_ext']);
|
||||
|
||||
$url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['category_id'];
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ SELECT representative_picture_id
|
||||
$row = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
$query = '
|
||||
SELECT file,tn_ext,storage_category_id
|
||||
SELECT file,path,tn_ext
|
||||
FROM '.IMAGES_TABLE.', '.IMAGE_CATEGORY_TABLE.'
|
||||
WHERE category_id = '.$non_empty_id.'
|
||||
AND id = image_id';
|
||||
@@ -86,8 +86,7 @@ SELECT file,tn_ext,storage_category_id
|
||||
$image_result = pwg_query($query);
|
||||
$image_row = mysql_fetch_array($image_result);
|
||||
|
||||
$thumbnail_link = get_thumbnail_src($image_row['file'],
|
||||
$image_row['storage_category_id'],
|
||||
$thumbnail_link = get_thumbnail_src($image_row['path'],
|
||||
@$image_row['tn_ext']);
|
||||
|
||||
$thumbnail_title = $lang['hint_category'];
|
||||
|
||||
+10
-25
@@ -570,47 +570,32 @@ function get_templates()
|
||||
* returns thumbnail filepath (or distant URL if thumbnail is remote) for a
|
||||
* given element
|
||||
*
|
||||
* this function could have taken only the element id as parameter but to
|
||||
* optimize database access we directly ask file, storage category
|
||||
* identifier and extension since when this function is called,
|
||||
* PhpWebGallery should have all these infos. No need to retrieve them
|
||||
* another time in the database.
|
||||
*
|
||||
* the returned string can represente the filepath of the thumbnail or the
|
||||
* filepath to the corresponding icon for non picture elements
|
||||
*
|
||||
* complete directories are cached to be used more than once during a page
|
||||
* generation (many thumbnails of the same category on the same page)
|
||||
*
|
||||
* @param string file
|
||||
* @param int storage_category_id
|
||||
* @param string path
|
||||
* @param string tn_ext
|
||||
* @return string
|
||||
*/
|
||||
function get_thumbnail_src($file, $storage_category_id, $tn_ext = '')
|
||||
function get_thumbnail_src($path, $tn_ext = '')
|
||||
{
|
||||
global $conf, $user, $array_cat_directories;
|
||||
|
||||
if (!isset($array_cat_directories[$storage_category_id]))
|
||||
{
|
||||
$array_cat_directories[$storage_category_id] =
|
||||
get_complete_dir($storage_category_id);
|
||||
}
|
||||
|
||||
global $conf, $user;
|
||||
|
||||
if ($tn_ext != '')
|
||||
{
|
||||
$src = $array_cat_directories[$storage_category_id];
|
||||
$src.= 'thumbnail/'.$conf['prefix_thumbnail'];
|
||||
$src.= get_filename_wo_extension($file);
|
||||
$src = substr_replace(get_filename_wo_extension($path),
|
||||
'/thumbnail/'.$conf['prefix_thumbnail'],
|
||||
strrpos($path,'/'),
|
||||
1);
|
||||
$src.= '.'.$tn_ext;
|
||||
}
|
||||
else
|
||||
{
|
||||
$src = PHPWG_ROOT_PATH;
|
||||
$src.= 'template/'.$user['template'].'/mimetypes/';
|
||||
$src.= strtolower(get_extension($file)).'.png';
|
||||
$src.= strtolower(get_extension($path)).'.png';
|
||||
}
|
||||
|
||||
|
||||
return $src;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user