aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/category_calendar.inc.php24
-rw-r--r--include/category_default.inc.php6
-rw-r--r--include/category_recent_cats.inc.php8
-rw-r--r--include/category_subcats.inc.php5
-rw-r--r--include/functions.inc.php35
5 files changed, 25 insertions, 53 deletions
diff --git a/include/category_calendar.inc.php b/include/category_calendar.inc.php
index ad0ca1b3c..5c13e940a 100644
--- a/include/category_calendar.inc.php
+++ b/include/category_calendar.inc.php
@@ -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;
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index b092f3c7a..2e89be05b 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -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'];
diff --git a/include/category_recent_cats.inc.php b/include/category_recent_cats.inc.php
index 7d4de1c57..3da82c1f8 100644
--- a/include/category_recent_cats.inc.php
+++ b/include/category_recent_cats.inc.php
@@ -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'];
diff --git a/include/category_subcats.inc.php b/include/category_subcats.inc.php
index 53e4f7f0d..6fe0eece7 100644
--- a/include/category_subcats.inc.php
+++ b/include/category_subcats.inc.php
@@ -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'];
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 8903c28d5..860811c3c 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -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;
}
?>