<?php include 'en/admin/_adminheader.php'; ?>
<h2>Photos and Videos Page: Photos</h2>
<p>
	Below is a list of the photos that you have on the Photos and Videos page sorted
	into the albums under which they appear.
	You can add, edit or delete albums and you can add photos to and delete
	files from each category.
</p>
<p>
	<a href='/admin/photosandvideos.php?what=photos&do=addalbum' title='Add an Album' class='action'>Add an album</a>
	<a href='/admin/photosandvideos.php?what=photos&do=addphoto' title='Add Photos to an album' class='action'>Add photos to an album</a>
</p>
<table>
	<thead>
		<tr>
			<td>Album</td>
			<td>Photos</td>
			<td>Actions</td>
		</tr>
	</thead>
	<tbody>
<?php $count = 0; foreach($this->data['albums'] as $album): ?>
		<tr <?php if($count % 2 == 1): echo "class='alt_row'"; endif; $count++; ?>>
			<td>
			<?php
				echo $album->name;
				# say if this a subalbum of another album
				if((int)$album->subalbumof != 0):
					for($c = 0; $c < count($this->data['albums']->album); $c++):
						if((int)$this->data['albums']->album[$c]['id'] == (int)$album->subalbumof):
							echo "<br />| sub-album of ".$this->data['albums']->album[$c]->name;
						endif;
					endfor;
				endif;
			?>
			</td>
			<td>
			<?php if(isset($this->data['photos'][(int)$album['id']]) ): ?>
					<div class='photos_cell'>
			<?php foreach($this->data['photos'][(int)$album['id']] as $photo): ?>
				<a href='/admin/photosandvideos.php?what=photos&do=deletephoto&which=<?php echo $photo ?>&album=<?php echo $album['id'] ?>' title='Delete this photo'>delete</a>
				|
				<?php echo $photo; ?>
				<br />
			<?php endforeach; ?>	
				</div>
			<?php else: ?>
				<p>There are no photos in this album.
			<?php endif; ?>
			</td>
			<td>
				<a href='/admin/photosandvideos.php?what=photos&do=editalbum&which=<?php echo $album['id'] ?>' title='Edit Album' class='action'>Edit</a>
				<a href='/admin/photosandvideos.php?what=photos&do=deletealbum&which=<?php echo $album['id'] ?>' title='Delete Album' class='action'>Delete</a>
			</td>
		</tr>
<?php endforeach; ?>
	</tbody>
</table>
