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) + + +