From 0afbaf81ea73e4f50796691a31c1a868d67a31e7 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Fri, 23 Jul 2021 10:05:37 +0200 Subject: [PATCH] ok --- module/news/news.php | 16 ++++++++++------ module/news/view/index/index.php | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/module/news/news.php b/module/news/news.php index 6153c46d..a79f49e2 100755 --- a/module/news/news.php +++ b/module/news/news.php @@ -62,9 +62,9 @@ class news extends common { public static $height = [ 200 => 'Petite', - 400 => 'Moyenne', - 600 => 'Grande', - 1000 => 'Article complet' + 600 => 'Moyenne', + 1200 => 'Grande', + -1 => 'Article complet' ]; // Signature de l'article @@ -427,9 +427,13 @@ class news extends common { for($i = $pagination['first']; $i < $pagination['last']; $i++) { self::$news[$newsIds[$i]] = $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i]]); // Longueur de la news affichée - if ($this->getData(['module', $this->getUrl(0), 'config', 'height']) !== 1000) { - self::$news[$newsIds[$i]]['content'] = substr($this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'content']), 0, - $this->getData(['module', $this->getUrl(0), 'config', 'height'])) ; + if ( $this->getData(['module', $this->getUrl(0), 'config', 'height']) !== -1 + && strlen($this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'content'])) >= $this->getData(['module', $this->getUrl(0), 'config', 'height']) ) { + // Contenu raccourci + $content = substr($this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'content']), 0, $this->getData(['module', $this->getUrl(0), 'config', 'height'])); + // Ne pas couper un mot + $lastSpace = strrpos($content, ' ', -1 ); + self::$news[$newsIds[$i]]['content'] = substr($content, 0, $lastSpace) ; } // Mise en forme de la signature self::$news[$newsIds[$i]]['userId'] = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'userId'])); diff --git a/module/news/view/index/index.php b/module/news/view/index/index.php index 86b26904..d61d5c98 100644 --- a/module/news/view/index/index.php +++ b/module/news/view/index/index.php @@ -7,7 +7,8 @@
- getData(['module', $this->getUrl(0), 'config', 'height']) !== 1000):?> + getData(['module', $this->getUrl(0), 'config', 'height']) !== -1 + && strlen($this->getData(['module', $this->getUrl(0), 'posts', $newsId, 'content'])) >= $this->getData(['module', $this->getUrl(0), 'config', 'height'])):?> getUrl(0) . '/' . $newsId . '">lire la suite'; ?>