From 0895752ea99191b1b0750a359dfa7ef944975340 Mon Sep 17 00:00:00 2001 From: vince Date: Fri, 4 Feb 2022 17:30:30 +0100 Subject: [PATCH] =?UTF-8?q?affiche=20un=20warning=20si=20on=20tente=20de?= =?UTF-8?q?=20commander=20dans=20le=20pass=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.php b/index.php index 1b06b3f..4c1c24c 100644 --- a/index.php +++ b/index.php @@ -4,6 +4,7 @@ define('DEFAULT_TITLE', 'Mon panier bio'); define('SUPPLIER_REGEX', '[A-Za-z]\w{0,31}'); define('EVENT_REGEX', '\d{4}\-[01]\d\-[0123]\d'); +define('EVENT_FORMAT', 'Y-m-d'); define('REQUEST_REGEX', '/^https?:\/\/.+\/(?' . SUPPLIER_REGEX . ')\/?(?' . EVENT_REGEX . ')?\/?$/'); define('ACTION_REGEX', '/^[a-z]{1,16}$/i'); @@ -330,6 +331,10 @@ if (!$isConfig and !$supplierIsNew and $hasSupplier) { $ago = ago(new \DateTimeImmutable($event)); $color = isInPast($event) ? 'text-danger' : 'text-muted'; + $currentEvent = findNext(new \DateTime($config[$supplier]['start']), $config[$supplier]['frequency'], $config[$supplier]['excludes'], true); + $currentDate = (new \IntlDateFormatter('fr_FR.UTF8', \IntlDateFormatter::FULL, \IntlDateFormatter::NONE, 'Europe/Paris'))->format($currentEvent); + $currentAgo = ago($currentEvent); + foreach (['title', 'subtitle', 'description'] as $key) { while (preg_match('/%([^%]+)%/i', $config[$supplier][$key], $match)) $config[$supplier][$key] = str_replace( @@ -635,6 +640,12 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier) + + +