1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8//this script may only be included - so its better to die if called directly.
9if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
10	header("location: index.php");
11	exit;
12}
13
14function smarty_function_gallery($params, $smarty)
15{
16	$tikilib = TikiLib::lib('tiki');
17	$imagegallib = TikiLib::lib('imagegal');
18	extract($params);
19	// Param = id
20
21	if (empty($id)) {
22		trigger_error("assign: missing 'id' parameter");
23		return;
24	}
25	$img = $imagegallib->get_random_image($id);
26	print('<div style="text-align: center">');
27	if (! isset($hidelink) || $hidelink != 1) {
28		print('<a href="tiki-browse_image.php?galleryId=' . $img['galleryId'] . '&amp;imageId=' . $img['imageId'] . '">');
29	}
30	print ('<img alt="thumbnail" class="athumb" src="show_image.php?id=' . $img['imageId'] . '&amp;thumb=1" />');
31	if (! isset($hidelink) || $hidelink != 1) {
32		print('</a>');
33	}
34	if (! isset($hideimgname) || $hideimgname != 1) {
35		print('<br /><b>' . $img['name'] . '</b>');
36	}
37	if (isset($showgalleryname) && $showgalleryname == 1) {
38		print(
39						'<br /><small>' .
40						tra("Gallery") .
41						': <a href="tiki-browse_gallery.php?galleryId=' . $img['galleryId'] . '">' .
42						$img['gallery'] .
43						'</a></small>'
44		);
45	}
46	print('</div>');
47}
48