<?php include('pagination.tpl.php'); ?>

<div id="obj_links_js">
	<form>
		<a class="js show_all" href="javascript:;"><?php echo __('Tout montrer'); ?></a>
		<span class="sep">-</span>
		<a class="js hide_all" href="javascript:;"><?php echo __('Tout cacher'); ?></a>
		&nbsp;<?php echo __('pour'); ?>&nbsp;
		<select id="show_items">
			<option value="obj_fold"><?php echo __('Tout'); ?></option>
			<option value="obj_fold_edit"><?php echo __('Informations'); ?></option>
			<option value="obj_fold_dates"><?php echo __('Dates'); ?></option>
			<option value="obj_fold_tags"><?php echo __('Tags'); ?></option>
			<option value="obj_fold_settings"><?php echo __('Réglages'); ?></option>
			<option value="obj_fold_stats"><?php echo __('Statistiques'); ?></option>
		</select>
	</form>
<?php include('object_select.tpl.php'); ?>
</div>

<?php
for ($n = 1900, $year = ''; $n <= date('Y'); $n++) { $year .= '<option value="' .  $n . '">' . $n . '</option>'; }
for ($n = 1, $month = ''; $n <= 12; $n++) { $month .= '<option value="' .  $n . '">' . $tpl['locale']('month:' . $n) . '</option>'; }
for ($n = 1, $day = ''; $n <= 31; $n++) { $day .= '<option value="' .  $n . '">' . sprintf("%'.02d", $n) . '</option>'; }
for ($n = 0, $hour = ''; $n <= 23; $n++) { $hour .= '<option value="' .  $n . '">' . sprintf("%'.02d", $n) . '</option>'; }
for ($n = 0, $minsec = ''; $n <= 59; $n++) { $minsec .= '<option value="' .  $n . '">' . sprintf("%'.02d", $n) . '</option>'; }
?>

<form<?php if ($tpl['options']['thumbs_size'][1]['selected']) : ?> class="large"<?php endif; ?> id="obj_form" action="<?php echo $tpl['current_url']; ?>" method="post" data-type="album">
<?php foreach ($tpl['items'] as &$i) : ?>
	<div id="obj_<?php echo $i['id']; ?>" class="selectable_class obj<?php if ($i['deactivated']) : ?> obj_deactivated<?php endif; ?><?php if (!$i['activated']) : ?> obj_invisible<?php endif; ?><?php if (isset($_POST['selected'][$i['id']])) : ?> selected<?php endif; ?>">
		<div class="obj_body">
			<div class="obj_image">
				<a href="<?php echo $i['file']; ?>" class="viewer">
<?php if ($i['type'] == 'video') : ?>					
					<span class="duration" id="videoduration_<?php echo $i['id']; ?>"><?php echo $i['duration_text']; ?></span>
<?php endif; ?>
					<img alt="<?php echo __('Vignette'); ?>"<?php if ($i['type'] == 'video') : ?> data-video-id="<?php echo $i['id']; ?>"<?php endif; ?> src="<?php echo $i['thumb_src'](); ?>">
				</a>
			</div>
			<div class="obj_infos">
				<div class="obj_basics">
					<p class="obj_title">
						<span class="obj_title_link"><a href="<?php echo $i['link']; ?>"><?php echo $i['title']; ?></a></span>
<?php if ($i['gallery_link']) : ?>
						<a title="<?php echo __('Voir dans la galerie'); ?>" class="obj_gallery_link" href="<?php echo $i['gallery_link']; ?>"></a>
<?php endif; ?>
					</p>
<?php if ($i['password']) : ?>
					<p class="obj_password"><img width="24" height="24" src="<?php echo $tpl['admin']['style']['path']; ?>/icons/24x24/key.png" title="<?php echo __('Accès protégé par un mot de passe'); ?>"></p>
<?php endif; ?>
					<p class="obj_status"><span><?php echo $i['status_text']; ?></span></p>
				</div>
				<div class="obj_details">
					<p class="obj_links">
						<span class="icon icon_edit show_parts"><a data-id="obj_fold_edit_<?php echo $i['id']; ?>" class="js" href="javascript:;"><?php echo __('Informations'); ?></a></span>
						<span class="sep">-</span>
						<span class="icon icon_date show_parts"><a data-id="obj_fold_dates_<?php echo $i['id']; ?>" class="js" href="javascript:;"><?php echo __('Dates'); ?></a></span>
						<span class="sep">-</span>
						<span class="icon icon_tags show_parts"><a data-id="obj_fold_tags_<?php echo $i['id']; ?>" class="js" href="javascript:;"><?php echo __('Tags'); ?></a></span>
						<span class="sep">-</span>
						<span class="icon icon_settings show_parts"><a data-id="obj_fold_settings_<?php echo $i['id']; ?>" class="js" href="javascript:;"><?php echo __('Réglages'); ?></a></span>
						<span class="sep">-</span>
						<span class="icon icon_stats show_parts"><a data-id="obj_fold_stats_<?php echo $i['id']; ?>" class="js" href="javascript:;"><?php echo __('Statistiques'); ?></a></span>
					</p>
					<p class="obj_cat"><?php echo $i['type_text']; ?></p>
				</div>
			</div>
			<div class="obj_checkbox selectable_zone">
				<input<?php if (isset($_POST['selected'][$i['id']])) : ?> checked<?php endif; ?> class="selectable" name="selected[<?php echo $i['id']; ?>]" type="checkbox">
			</div>
		</div>
		<div class="obj_fold obj_fold_edit" id="obj_fold_edit_<?php echo $i['id']; ?>">
<?php include('item_informations.tpl.php'); ?>
		</div>
		<div class="obj_fold obj_fold_dates" id="obj_fold_dates_<?php echo $i['id']; ?>">
<?php include('item_dates.tpl.php'); ?>
		</div>
		<div class="obj_fold obj_fold_tags" id="obj_fold_tags_<?php echo $i['id']; ?>">
			<p class="field">
				<label for="tags_<?php echo $i['id']; ?>"><?php echo __('Tags (séparés par une virgule) :'); ?></label>
				<a data-box-list="tags_add" href="javascript:;" title="<?php echo __('Tags de la galerie'); ?>"><img width="16" height="16" src="<?php echo $tpl['admin']['style']['path']; ?>/icons/16x16/search.png"></a>
				<textarea class="large" name="<?php echo $i['id']; ?>[tags]" rows="5" cols="50" id="tags_<?php echo $i['id']; ?>"><?php echo $i['tags']; ?></textarea>
			</p>
		</div>
		<div class="obj_fold obj_fold_settings" id="obj_fold_settings_<?php echo $i['id']; ?>">
<?php include('item_settings.tpl.php'); ?>
		</div>
		<div class="obj_fold obj_fold_stats" id="obj_fold_stats_<?php echo $i['id']; ?>">
<?php include('item_stats.tpl.php'); ?>
		</div>
	</div>
<?php endforeach; ?>

	<div id="submit" class="submit_actions<?php if ($tpl['nb_pages'] > 1) : ?> submit_pages<?php endif; ?>">
		<div>
			<p id="form_save">
				<input type="submit" name="save" value="<?php echo __('Enregistrer les modifications'); ?>">
			</p>
			<div id="form_actions">
				<label for="selection_action"><?php printf(__('Action sur la sélection (%s) :'), '<span id="select_num">' . (empty($_POST['selected']) ? 0 : count($_POST['selected'])) . '</span>'); ?></label>
				<select id="selection_action" name="action">
					<optgroup label="<?php echo __('État'); ?>">
						<option value="activate"><?php echo __('Activer'); ?></option>
						<option value="activate_reset_item_pubdt"><?php echo __('Activer et réinitialiser la date de publication'); ?></option>
						<option value="deactivate"><?php echo __('Désactiver'); ?></option>
					</optgroup>
					<optgroup label="<?php echo __('Déplacement'); ?>">
						<option data-id="list_categories" value="move_confirm"><?php echo __('Déplacer vers'); ?></option>
					</optgroup>
					<optgroup label="<?php echo __('Propriétaire'); ?>">
						<option data-id="list_users" value="owner_confirm"><?php echo __('Nouveau propriétaire'); ?></option>
					</optgroup>
					<optgroup label="<?php echo __('Vues'); ?>">
						<option data-id="change_hits" value="hits_confirm"><?php echo __('Nombre de vues'); ?></option>
					</optgroup>
					<optgroup label="<?php echo __('Mise à jour'); ?>">
						<option value="update"><?php echo __('Mettre à jour les informations'); ?></option>
						<option value="delete_resized"><?php echo __('Recréer les images redimensionnées'); ?></option>
					</optgroup>
					<optgroup label="<?php echo __('Suppression'); ?>">
						<option value="delete_confirm"><?php echo __('Supprimer'); ?></option>
					</optgroup>
				</select>
				<p class="action_second" id="change_hits">
					<input type="text" size="12" maxlength="12" name="hits">
				</p>
				<p class="action_second" id="list_categories">
					<select name="cat_id" id="list_categories_select">
<?php if (isset($_GET['filter'])) : ?>
						<?php foreach ($tpl['categories_move'] as &$i) : ?><?php if ($i['node'] == 'content' && (($i['type'] == 'album' && !$i['current']) || $i['type'] != 'album')) : ?><option id="o<?php echo $i['level'] > 1 ? '' : 'v'; echo ($i['subcats'] || $i['id'] == 1) ? 's' : ''; echo $i['password'] ? 'p' : ''; ?>:<?php echo $i['level']; ?>{<?php echo $i['id']; ?>}<?php echo $i['parents']; ?>" value="<?php echo $i['id']; ?>"<?php if ($i['type'] == 'category') : ?> disabled<?php endif; ?>><?php echo str_repeat(' ', $i['level'] * 4); ?><?php echo $i['title']; ?></option><?php endif; ?><?php endforeach; ?>
<?php endif; ?>
					</select>
					<a data-box-title="<?php echo __('Déplacer vers...'); ?>" data-box-list="categories" href="javascript:;" title="<?php echo __('Liste des albums'); ?>"><img width="16" height="16" src="<?php echo $tpl['admin']['style']['path']; ?>/icons/16x16/search.png"></a>
				</p>
				<p class="action_second" id="list_users">
					<select name="user_id">
<?php foreach ($tpl['users'] as &$i) : ?>
						<option value="<?php echo $i['id']; ?>"><?php echo $i['nickname']; ?></option>
<?php endforeach; ?>
					</select>
				</p>
				<input name="anticsrf" type="hidden" value="<?php echo $tpl['anticsrf'](); ?>">
				<input name="selection" type="submit" value="<?php echo __('Valider'); ?>">
			</div>
		</div>
	</div>
</form>

<?php include('pagination.tpl.php'); ?>

<script nonce="<?php echo CSP_NONCE; ?>" type="text/javascript">
var confirm_delete = "<?php echo $tpl['php2js']($confirm_delete); ?>";
</script>