<?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_password"><?php echo __('Mot de passe'); ?></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>

<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="category">
<?php $num = 0; foreach ($tpl['categories'] 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<?php if (!$i['is_empty']) : ?> href="<?php echo $i['thumb_file']; ?>" class="viewer"<?php endif; ?>><img alt="<?php echo __('Vignette'); ?>" <?php if (!$i['is_empty']) : ?><?php if ($i['thumb_type'] == 'video') : ?>data-video-id="<?php echo $i['thumb_id']; ?>" <?php endif; ?>src="<?php echo $i['thumb_src'](); ?>"<?php else : ?>src="<?php echo $tpl['admin']['style']['path']; ?>/cat-empty.png"<?php endif; ?>></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>
					<p class="obj_childs"><span><?php echo $i['stats']['t_childs']; ?></span></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_password show_parts"><a data-id="obj_fold_password_<?php echo $i['id']; ?>" class="js" href="javascript:;"><?php echo __('Mot de passe'); ?></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('category_informations.tpl.php'); ?>
		</div>
		<div class="obj_fold obj_fold_password" id="obj_fold_password_<?php echo $i['id']; ?>">
<?php include('category_password.tpl.php'); ?>
		</div>
		<div class="obj_fold obj_fold_settings" id="obj_fold_settings_<?php echo $i['id']; ?>">
<?php include('category_settings.tpl.php'); ?>
		</div>
		<div class="obj_fold obj_fold_stats" id="obj_fold_stats_<?php echo $i['id']; ?>">
<?php include('category_stats.tpl.php'); ?>
		</div>
	</div>
<?php $num++; endforeach; ?>

	<div id="submit" class="submit_actions<?php if ($tpl['nb_pages'] > 1) : ?> submit_pages<?php endif; ?>">
		<div>
			<p id="form_save">
				<input class="submit" name="save" type="submit" 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 des fichiers'); ?></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 value="reset_hits"><?php echo __('Nombre de vues à zéro'); ?></option>
					</optgroup>
					<optgroup label="<?php echo __('Suppression'); ?>">
						<option value="delete_confirm"><?php echo __('Supprimer'); ?></option>
					</optgroup>
				</select>
				<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'] == 'category') : ?><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 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 catégories'); ?>"><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>