get('id')); $current_month = false; $prev_month = false; $next_month = false; $by_year = array(); $msg = false; if (!empty($months)) { $months = array_reverse($months); if (!empty($_GET['m']) && is_numeric($_GET['m'])) { $current_month = (int) $_GET['m']; } else { $current_month = $months[0]; } if (!in_array($current_month, $months)) { $current_month = $months[0]; } $by_year = array(); $cur = 0; foreach ($months as $k=>$m) { if ($m == $current_month) $cur = $k; $y = substr($m, 0, 4); if (!isset($by_year[$y])) $by_year[$y] = array(); $by_year[$y][] = $m; } // Détermination des mois suivants et précédents $prev_month = isset($months[$cur + 1]) ? $months[$cur + 1] : false; $next_month = isset($months[$cur - 1]) ? $months[$cur - 1] : false; $tpl->assign('ecrits', Ecrit::listForMonth($journal->get('id'), $current_month)); $tpl->assign('current_month', $current_month); $tpl->assign('prev_month', $prev_month); $tpl->assign('next_month', $next_month); } $tpl->assign('month_list', $by_year); function month_to_ts($month) { return gmmktime(0, 0, 0, substr($month, 4, 2), 1, substr($month, 0, 4)); } $tpl->register_modifier('month_to_ts', 'month_to_ts'); if (trim(utils::post('ask_delete')) && !empty($_POST['check'])) { $tpl->assign('checked', utils::post('check')); $tpl->assign('confirm_delete', true); } elseif (trim(utils::post('confirm_delete')) && !empty($_POST['check'])) { if (!utils::CSRF_check('confirm_delete_ecrits')) { $msg = 'OTHER'; } else { foreach ($_POST['check'] as $id) { Ecrit::delete($journal->get('id'), $id); } utils::redirect('/ecrire/gestion.php?m='.rawurlencode($current_month)); } } $tpl->assign('msg', $msg); $tpl->display('ecrire/gestion.tpl'); ?>