aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-10-23 17:56:46 +0000
committerz0rglub <z0rglub@piwigo.org>2004-10-23 17:56:46 +0000
commit98b65edb831e95695cc840692ab8ad294478f80d (patch)
tree2b1ffe5ba3c8bc1fcdb209e8f8d793bd18e9dd1d /include/functions.inc.php
parent60ac6f180e9500c6fea0c872277f107f05d7d26d (diff)
- refactoring of comments.php
- creation of function get_thumbnail_src used everywhere a thumbnail must be displayed - creation of function parse_comment_content (used in comments.php and picture.php) - concerning undefined index on arrays retrieved in database, instead of testing possibly unset values, use of @ operator (smarter...) - add pre tag in default.css stylesheet for debugging purpose (need to have left aligned text) git-svn-id: http://piwigo.org/svn/trunk@579 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions.inc.php')
-rw-r--r--include/functions.inc.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 841c86f74..82577b66e 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -546,4 +546,52 @@ function get_templates()
{
return get_dirs(PHPWG_ROOT_PATH.'template');
}
+
+/**
+ * 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 tn_ext
+ * @return string
+ */
+function get_thumbnail_src($file, $storage_category_id, $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);
+ }
+
+ if ($tn_ext != '')
+ {
+ $src = $array_cat_directories[$storage_category_id];
+ $src.= 'thumbnail/'.$conf['prefix_thumbnail'];
+ $src.= get_filename_wo_extension($file);
+ $src.= '.'.$tn_ext;
+ }
+ else
+ {
+ $src = PHPWG_ROOT_PATH;
+ $src.= 'template/'.$user['template'].'/mimetypes/';
+ $src.= strtolower(get_extension($file)).'.png';
+ }
+
+ return $src;
+}
?> \ No newline at end of file