1.14.03 fix subword
This commit is contained in:
parent
7862815f1f
commit
75ad5853cf
@ -673,10 +673,30 @@ class helper
|
|||||||
public static function subword($text, $start, $length)
|
public static function subword($text, $start, $length)
|
||||||
{
|
{
|
||||||
$text = trim($text);
|
$text = trim($text);
|
||||||
if (strlen($text) > $length) {
|
|
||||||
|
// Vérifier si la longueur du texte sans les balises dépasse la longueur souhaitée
|
||||||
|
if (mb_strlen(strip_tags($text)) > $length) {
|
||||||
|
// Utiliser mb_substr pour couper le texte
|
||||||
$text = mb_substr($text, $start, $length);
|
$text = mb_substr($text, $start, $length);
|
||||||
$text = mb_substr($text, 0, min(mb_strlen($text), mb_strrpos($text, ' ')));
|
|
||||||
|
// S'assurer que le texte ne se termine pas au milieu d'un mot
|
||||||
|
$lastSpace = mb_strrpos($text, ' ');
|
||||||
|
if ($lastSpace !== false) {
|
||||||
|
$text = mb_substr($text, 0, $lastSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fermer les balises HTML ouvertes
|
||||||
|
$dom = new DOMDocument();
|
||||||
|
@$dom->loadHTML('<div>' . $text . '</div>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||||
|
$text = $dom->saveHTML();
|
||||||
|
|
||||||
|
// Retirer la balise de conteneur ajoutée
|
||||||
|
$text = preg_replace('~^<div>(.*)</div>$~s', '$1', $text);
|
||||||
|
|
||||||
|
// Ajouter des points de suspension si le texte a été coupé
|
||||||
|
$text .= '...';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class common
|
|||||||
const ACCESS_TIMER = 1800;
|
const ACCESS_TIMER = 1800;
|
||||||
|
|
||||||
// Numéro de version
|
// Numéro de version
|
||||||
const ZWII_VERSION = '1.14.02';
|
const ZWII_VERSION = '1.14.03';
|
||||||
|
|
||||||
// URL autoupdate
|
// URL autoupdate
|
||||||
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/campus-update/raw/branch/master/';
|
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/campus-update/raw/branch/master/';
|
||||||
|
@ -95,57 +95,61 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
</div>
|
||||||
<div class="row">
|
<?php else: ?>
|
||||||
<?php if (
|
<div class="row">
|
||||||
$article['picture'] &&
|
<?php if (
|
||||||
file_exists(self::FILE_DIR . 'source/' . $article['picture'])
|
$article['picture'] &&
|
||||||
): ?>
|
file_exists(self::FILE_DIR . 'source/' . $article['picture'])
|
||||||
<div class="col3">
|
): ?>
|
||||||
<?php // Déterminer le nom de la miniature
|
<div class="col3">
|
||||||
$parts = pathinfo($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']));
|
<?php
|
||||||
$thumb = 'mini_' . $parts['basename'];
|
// Déterminer le nom de la miniature
|
||||||
// Créer la miniature si manquante
|
$parts = pathinfo($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']));
|
||||||
if (!file_exists(self::FILE_DIR . 'thumb/' . $thumb)) {
|
$thumb = 'mini_' . $parts['basename'];
|
||||||
$this->makeThumb(
|
// Créer la miniature si manquante
|
||||||
self::FILE_DIR . 'source/' . $article['picture'],
|
if (!file_exists(self::FILE_DIR . 'thumb/' . $thumb)) {
|
||||||
self::FILE_DIR . 'thumb/' . $thumb,
|
$this->makeThumb(
|
||||||
self::THUMBS_WIDTH
|
self::FILE_DIR . 'source/' . $article['picture'],
|
||||||
);
|
self::FILE_DIR . 'thumb/' . $thumb,
|
||||||
}
|
self::THUMBS_WIDTH
|
||||||
?>
|
);
|
||||||
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>" class="blogPicture">
|
}
|
||||||
<img src="<?php echo helper::baseUrl(false) . self::FILE_DIR . 'thumb/' . $thumb; ?>"
|
?>
|
||||||
alt="<?php echo $article['picture']; ?>">
|
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>" class="blogPicture">
|
||||||
|
<img src="<?php echo helper::baseUrl(false) . self::FILE_DIR . 'thumb/' . $thumb; ?>"
|
||||||
|
alt="<?php echo $article['picture']; ?>">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col9">
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="col12">
|
||||||
|
<?php endif; ?>
|
||||||
|
<h2 class="blogTitle">
|
||||||
|
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
|
||||||
|
<?php echo $article['title']; ?>
|
||||||
|
</a>
|
||||||
|
</h2>
|
||||||
|
<div class="blogComment">
|
||||||
|
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>#comment">
|
||||||
|
<?php if ($module::$comments[$articleId]): ?>
|
||||||
|
<?php echo $module::$comments[$articleId]; ?>
|
||||||
|
<?php echo template::ico('comment', ['margin' => 'left']); ?>
|
||||||
|
<?php endif; ?>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col9">
|
<div class="blogDate">
|
||||||
<?php else: ?>
|
<!-- bloc signature et date -->
|
||||||
<div class="col12">
|
<?php echo template::ico('user'); ?>
|
||||||
<?php endif; ?>
|
<?php echo $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'userId'])); ?>
|
||||||
<h2 class="blogTitle">
|
<?php echo template::ico('calendar-empty'); ?>
|
||||||
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
|
<?php echo helper::dateUTF8($module::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']), self::$i18nUI) . ' ' . helper::dateUTF8($module::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']), self::$i18nUI); ?>
|
||||||
<?php echo $article['title']; ?>
|
</div>
|
||||||
</a>
|
<div class="blogContent">
|
||||||
</h2>
|
<?php $lenght = $this->getData(['module', $this->getUrl(0), 'config', 'articlesLenght']); ?>
|
||||||
<div class="blogComment">
|
<?php if ($lenght > 0): ?>
|
||||||
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>#comment">
|
<?php ?>
|
||||||
<?php if ($module::$comments[$articleId]): ?>
|
<?php echo helper::subword($article['content'], 0, $lenght); ?>...
|
||||||
<?php echo $module::$comments[$articleId]; ?>
|
|
||||||
<?php echo template::ico('comment', ['margin' => 'left']); ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="blogDate">
|
|
||||||
<!-- bloc signature et date -->
|
|
||||||
<?php echo template::ico('user'); ?>
|
|
||||||
<?php echo $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'userId'])); ?>
|
|
||||||
<?php echo template::ico('calendar-empty'); ?>
|
|
||||||
<?php echo helper::dateUTF8($module::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']), self::$i18nUI) . ' ' . helper::dateUTF8($module::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'publishedOn']), self::$i18nUI); ?>
|
|
||||||
</div>
|
|
||||||
<div class="blogContent">
|
|
||||||
<?php $lenght = $this->getData(['module', $this->getUrl(0), 'config', 'articlesLenght']) !== 0 ? $this->getData(['module', $this->getUrl(0), 'config', 'articlesLenght']) : 500 ?>
|
|
||||||
<?php echo helper::subword(strip_tags($article['content'], '<br><p>'), 0, $lenght); ?>...
|
|
||||||
<div class="readMoreContainer">
|
<div class="readMoreContainer">
|
||||||
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
|
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $articleId; ?>">
|
||||||
<button class="readMoreButton">
|
<button class="readMoreButton">
|
||||||
@ -153,12 +157,14 @@
|
|||||||
</button>
|
</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<?php else: ?>
|
||||||
|
<?php echo $article['content']; ?>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endif; ?>
|
||||||
</div>
|
<?php endforeach; ?>
|
||||||
</article>
|
</article>
|
||||||
<?php echo $module::$pages; ?>
|
<?php echo $module::$pages; ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user