aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2006-11-07 03:37:57 +0000
committerrvelices <rv-github@modusoptimus.com>2006-11-07 03:37:57 +0000
commit8f52e36a6fdb362e204cfec4b865b0cee5735fbf (patch)
tree0b69f745a5f88b9e0148076690ca6c4962b4064e /include
parenteb4214096f9e86a58a8991617696350bede89f7d (diff)
- deprecated get_thumbnail_src (still there for compatibility). use rather
get_thumbnail_path or get_thumbnail_url (these allow plugins to override) - plugins can hook into index thumbnail display (items only so far) git-svn-id: http://piwigo.org/svn/trunk@1596 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/category_default.inc.php16
-rw-r--r--include/functions.inc.php81
2 files changed, 68 insertions, 29 deletions
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index 652f31f50..b1f7bc46a 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -49,7 +49,7 @@ SELECT *
WHERE id IN ('.implode(',', $selection).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
$row['rank'] = $page['rank_of'][ $row['id'] ];
@@ -60,19 +60,20 @@ SELECT *
}
// template thumbnail initialization
-$template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',));
+$template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',));
if (count($pictures) > 0)
{
- $template->assign_block_vars('thumbnails', array());
// first line
$template->assign_block_vars('thumbnails.line', array());
// current row displayed
$row_number = 0;
}
+trigger_action('loc_begin_index_thumbnails', $pictures);
+
foreach ($pictures as $row)
{
- $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
+ $thumbnail_url = get_thumbnail_url($row);
// message in title for the thumbnail
$thumbnail_title = $row['file'];
@@ -80,7 +81,7 @@ foreach ($pictures as $row)
{
$thumbnail_title .= ' : '.$row['filesize'].' KB';
}
-
+
// link on picture.php page
$url = duplicate_picture_url(
array(
@@ -159,6 +160,9 @@ SELECT COUNT(*) AS nb_comments
array('NB_COMMENTS'=>$row['nb_comments']));
}
+ //plugins need to add/modify sth in this loop ?
+ trigger_action('loc_index_thumbnail', $row, 'thumbnails.line.thumbnail' );
+
// create a new line ?
if (++$row_number == $user['nb_image_line'])
{
@@ -166,6 +170,8 @@ SELECT COUNT(*) AS nb_comments
$row_number = 0;
}
}
+
+trigger_action('loc_end_index_thumbnails', $pictures);
$template->assign_var_from_handle('THUMBNAILS', 'thumbnails');
pwg_debug('end include/category_default.inc.php');
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 973bd2fbe..68e06b579 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -681,45 +681,78 @@ function get_pwg_themes()
}
/**
- * returns thumbnail filepath (or distant URL if thumbnail is remote) for a
- * given element
- *
- * the returned string can represente the filepath of the thumbnail or the
- * filepath to the corresponding icon for non picture elements
- *
- * @param string path
- * @param string tn_ext
- * @param bool with_rewrite if true returned path can't be used from the script
- * @return string
+DEPRECATED use get_thumbnail_path or get_thumbnail_url
*/
function get_thumbnail_src($path, $tn_ext = '', $with_rewrite = true)
{
- global $conf, $user;
+ if ($with_rewrite)
+ return get_thumbnail_url( array('path'=>$path, 'tn_ext'=>$tn_ext) );
+ else
+ return get_thumbnail_path( array('path'=>$path, 'tn_ext'=>$tn_ext) );
+}
- if ($tn_ext != '')
+/* Returns the PATH to the thumbnail to be displayed. If the element does not
+ * have a thumbnail, the default mime image path is returned. The PATH can be
+ * used in the php script, but not sent to the browser.
+ * @param array element_info assoc array containing element info from db
+ * at least 'path', 'tn_ext' and 'id' should be present
+ */
+function get_thumbnail_path($element_info)
+{
+ $path = get_thumbnail_location($element_info);
+ if ( !url_is_remote($path) )
{
- $src = substr_replace(
- get_filename_wo_extension($path),
+ $path = PHPWG_ROOT_PATH.$path;
+ }
+ return $path;
+}
+
+/* Returns the URL of the thumbnail to be displayed. If the element does not
+ * have a thumbnail, the default mime image url is returned. The URL can be
+ * sent to the browser, but not used in the php script.
+ * @param array element_info assoc array containing element info from db
+ * at least 'path', 'tn_ext' and 'id' should be present
+ */
+function get_thumbnail_url($element_info)
+{
+ $path = get_thumbnail_location($element_info);
+ if ( !url_is_remote($path) )
+ {
+ $path = get_root_url().$path;
+ }
+ // plugins want another url ?
+ $path = trigger_event('get_thumbnail_url', $path, $element_info);
+ return $path;
+}
+
+/* returns the relative path of the thumnail with regards to to the root
+of phpwebgallery (not the current page!).This function is not intended to be
+called directly from code.*/
+function get_thumbnail_location($element_info)
+{
+ global $conf;
+ if ( !empty( $element_info['tn_ext'] ) )
+ {
+ $path = substr_replace(
+ get_filename_wo_extension($element_info['path']),
'/thumbnail/'.$conf['prefix_thumbnail'],
- strrpos($path,'/'),
+ strrpos($element_info['path'],'/'),
1
);
- $src.= '.'.$tn_ext;
- if ($with_rewrite==true and !url_is_remote($src) )
- {
- $src = get_root_url().$src;
- }
+ $path.= '.'.$element_info['tn_ext'];
}
else
{
- $src = ($with_rewrite==true) ? get_root_url() : '';
- $src .= get_themeconf('mime_icon_dir');
- $src.= strtolower(get_extension($path)).'.png';
+ $path = get_themeconf('mime_icon_dir')
+ .strtolower(get_extension($element_info['path'])).'.png';
}
- return $src;
+ // plugins want another location ?
+ $path = trigger_event( 'get_thumbnail_location', $path, $element_info);
+ return $path;
}
+
// my_error returns (or send to standard output) the message concerning the
// error occured for the last mysql query.
function my_error($header)