aboutsummaryrefslogtreecommitdiff
path: root/lib/tidypics.php
blob: d81b3ab2f496e40a5f75f1107dbc3af8d517a200 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
	/**
	 * Elgg tidypics library of common functions
	 * 
	 */

	/**
	 * Get images for display on front page
	 *
	 * @param int number of images
	 * @param int (optional) guid of owner
	 * @return string of html for display
	 *
	 * To use with the custom index plugin, use something like this:
	
	if (is_plugin_enabled('tidypics')) {
?>
	<!-- display latest photos -->
		<div class="index_box">
			<h2><a href="<?php echo $vars['url']; ?>pg/photos/world/"><?php echo elgg_echo("tidypics:mostrecent"); ?></a></h2>
			<div class="contentWrapper">
			<?php
				echo tp_get_latest_photos(5);
			?>
			</div>
		</div>
<?php
	}
?>

	 * Good luck
	 */
	function tp_get_latest_photos($num_images, $owner_guid = 0)
	{
		$prev_context = set_context('front');
		$image_html = list_entities('object', 'image', $owner_guid, $num_images, false, false, false);  
		set_context($prev_context);
		return $image_html;
	}
	
	
	/**
	 * Get image directory path
	 *
	 * Each album gets a subdirectory based on its container id
	 *
	 * @return string	path to image directory
	 */
	function tp_get_img_dir()
	{
		$file = new ElggFile();
		return $file->getFilenameOnFilestore() . 'image/';
	}
	
?>