Deltacms/module/blog/view/article/article.php

220 lines
9.8 KiB
PHP
Raw Normal View History

2022-03-18 07:50:13 +01:00
<?php
// Adaptation de la langue dans tinymce en fonction de la langue de la page
$lang = $this->getData(['config', 'i18n', 'langBase']);
if( null !== $this->getInput('DELTA_I18N_SITE') && $this->getInput('DELTA_I18N_SITE') !== '' ){
if( $this->getInput('DELTA_I18N_SITE') !== 'base' ) $lang = $this->getInput('DELTA_I18N_SITE');
}
$lang_page = $lang;
switch ($lang) {
case 'en' :
$lang_page = 'en_GB';
break;
case 'pt' :
$lang_page = 'pt_PT';
break;
case 'fr' :
$lang_page = 'fr_FR';
break;
}
echo '<script> var lang_admin = "'.$lang_page.'"; </script>';
echo '<script src="'. helper::baseUrl(false).'core/vendor/tinymce/tinymce.min.js"></script>';
echo '<script src="'. helper::baseUrl(false).'core/vendor/tinymce/init.js"></script>';
echo '<script src="'. helper::baseUrl(false).'core/vendor/tinymce/init.css"></script>';
// Lexique
$text = [];
$val = $this->getData(['config', 'i18n', 'langAdmin']);
switch ($val) {
case 'fr' :
//$text[1] = 'Editer';
//$text[2] = 'Cet article ne reçoit pas de commentaire.';
//$text[3] = 'commentaire';
//$text[4] = 'Pas encore de commentaire';
//$text[5] = 'Rédiger un commentaire...';
//$text[6] = 'Nom';
//$text[8] = 'Connexion';
//$text[9] = 'Commentaire avec maximum ';
//$text[10] = ' caractères';
//$text[11] = 'Annuler';
//$text[12] = 'Envoyer';
break;
case 'en' :
//$text[1] = 'Edit';
//$text[2] = 'This article does not receive comments.';
//$text[3] = 'comment';
//$text[4] = 'No comments yet';
//$text[5] = 'Write a comment...';
//$text[6] = 'Name';
//$text[8] = 'Login';
//$text[9] = 'Comment with maximum ';
//$text[10] = ' characters';
//$text[11] = 'Cancel';
//$text[12] = 'Send';
break;
}
// Pour les dates suivant la langue d'administration
setlocale(LC_TIME, 'fr_FR');
if( $this->getData(['config', 'i18n', 'langAdmin']) === 'en') setlocale(LC_TIME, 'en_GB');
?>
2022-01-31 09:10:49 +01:00
<div class="row">
<div class="col12">
<?php $pictureSize = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'pictureSize']) === null ? '100' : $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'pictureSize']); ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'hidePicture']) == false) {
echo '<img class="blogArticlePicture blogArticlePicture' . $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'picturePosition']) .
' pict' . $pictureSize . '" src="' . helper::baseUrl(false) . self::FILE_DIR.'source/' . $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'picture']) .
'" alt="' . $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'picture']) . '">';
} ?>
<?php echo $this->getData(['module', $this->getUrl(0),'posts', $this->getUrl(1), 'content']); ?>
</div>
</div>
<div class="row verticalAlignMiddle">
<div class="col12 blogDate">
<!-- bloc signature et date -->
<?php echo $module::$articleSignature . ' - ';?>
<i class="far fa-calendar-alt"></i>
<?php $date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])), 'UTF-8', true)
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']))
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])));
$heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])), 'UTF-8', true)
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']))
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])));
2022-03-18 07:50:13 +01:00
echo $date .' - ' . $heure;
2022-01-31 09:10:49 +01:00
?>
<!-- Bloc edition -->
<?php if (
$this->getUser('password') === $this->getInput('DELTA_USER_PASSWORD')
AND
( // Propriétaire
(
$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1),'editConsent']) === $module::EDIT_OWNER
AND ( $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1),'userId']) === $this->getUser('id')
OR $this->getUser('group') === self::GROUP_ADMIN )
)
OR (
// Groupe
( $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1),'editConsent']) === self::GROUP_ADMIN
OR $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1),'editConsent']) === self::GROUP_MODERATOR)
AND $this->getUser('group') >= $this->getData(['module',$this->getUrl(0), 'posts', $this->getUrl(1),'editConsent'])
)
OR (
// Tout le monde
$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1),'editConsent']) === $module::EDIT_ALL
AND $this->getUser('group') >= $module::$actions['config']
)
)
): ?>
<a href ="<?php echo helper::baseUrl() . $this->getUrl(0) . '/edit/' . $this->getUrl(1) . '/' . $_SESSION['csrf'];?>">
2022-03-18 07:50:13 +01:00
<?php echo template::ico('pencil'); echo $this->getData(['module', $this->getUrl(0), 'texts', 'Edit']);?>
2022-01-31 09:10:49 +01:00
</a>
<?php endif; ?>
<!-- Bloc RSS-->
<?php if ($this->getData(['module',$this->getUrl(0), 'config', 'feeds'])): ?>
<div id="rssFeed">
<a type="application/rss+xml" href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/rss'; ?>" target="_blank">
<img src='module/news/ressource/feed-icon-16.gif' />
<?php
echo '<p>' . $this->getData(['module',$this->getUrl(0), 'config', 'feedsLabel']) . '</p>' ;
?>
</a>
</div>
<?php endif; ?>
</div>
</div>
<?php if($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentClose'])): ?>
2022-03-18 07:50:13 +01:00
<p><?php echo $this->getData(['module', $this->getUrl(0), 'texts', 'ArticleNoComment']); ?></p>
2022-01-31 09:10:49 +01:00
<?php else: ?>
<h3 id="comment">
<?php //$commentsNb = count($module::$comments); ?>
<?php $commentsNb = $module::$nbCommentsApproved; ?>
<?php $s = $commentsNb === 1 ? '': 's' ?>
2022-03-18 07:50:13 +01:00
<?php echo $commentsNb > 0 ? $commentsNb . ' ' . $this->getData(['module', $this->getUrl(0), 'texts', 'Comment']) . $s : $this->getData(['module', $this->getUrl(0), 'texts', 'NoComment']); ?>
2022-01-31 09:10:49 +01:00
</h3>
<?php echo template::formOpen('blogArticleForm'); ?>
<?php echo template::text('blogArticleCommentShow', [
2022-03-18 07:50:13 +01:00
'placeholder' => $this->getData(['module', $this->getUrl(0), 'texts', 'Write']),
2022-01-31 09:10:49 +01:00
'readonly' => true
]); ?>
<div id="blogArticleCommentWrapper" class="displayNone">
<?php if($this->getUser('password') === $this->getInput('DELTA_USER_PASSWORD')): ?>
<?php echo template::text('blogArticleUserName', [
2022-03-18 07:50:13 +01:00
'label' => $this->getData(['module', $this->getUrl(0), 'texts', 'Name']),
2022-01-31 09:10:49 +01:00
'readonly' => true,
'value' => $module::$editCommentSignature
]); ?>
<?php echo template::hidden('blogArticleUserId', [
'value' => $this->getUser('id')
]); ?>
<?php else: ?>
<div class="row">
<div class="col9">
<?php echo template::text('blogArticleAuthor', [
2022-03-18 07:50:13 +01:00
'label' => $this->getData(['module', $this->getUrl(0), 'texts', 'Name'])
2022-01-31 09:10:49 +01:00
]); ?>
</div>
<div class="col1 textAlignCenter verticalAlignBottom">
2022-03-18 07:50:13 +01:00
<div id="blogArticleOr"><?php echo ' ';?></div>
2022-01-31 09:10:49 +01:00
</div>
<div class="col2 verticalAlignBottom">
<?php echo template::button('blogArticleLogin', [
'href' => helper::baseUrl() . 'user/login/' . str_replace('/', '_', $this->getUrl()) . '__comment',
2022-03-18 07:50:13 +01:00
'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Connection'])
2022-01-31 09:10:49 +01:00
]); ?>
</div>
</div>
2022-03-18 07:50:13 +01:00
<?php endif; ?>
2022-01-31 09:10:49 +01:00
<?php echo template::textarea('blogArticleContent', [
2022-03-18 07:50:13 +01:00
'label' => $this->getData(['module', $this->getUrl(0), 'texts', 'Maxi']).' '.$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentMaxlength']).' '.$this->getData(['module', $this->getUrl(0), 'texts', 'Cara']),
2022-01-31 09:10:49 +01:00
'class' => 'editorWysiwygComment',
'noDirty' => true,
2022-03-18 07:50:13 +01:00
'maxlength' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentMaxlength']),
'TinymceMaxi' => $this->getData(['module', $this->getUrl(0), 'texts', 'TinymceMaxi']),
'TinymceCara' => $this->getData(['module', $this->getUrl(0), 'texts', 'TinymceCara']),
'TinymceExceed' => $this->getData(['module', $this->getUrl(0), 'texts', 'TinymceExceed']),
'caracteres' => $this->getData(['module', $this->getUrl(0), 'texts', 'Cara'])
2022-01-31 09:10:49 +01:00
]); ?>
<div id="blogArticleContentAlarm"> </div>
<?php if($this->getUser('password') !== $this->getInput('DELTA_USER_PASSWORD')): ?>
<div class="row">
<div class="col12">
<?php echo template::captcha('blogArticleCaptcha', [
'limit' => $this->getData(['config','connect', 'captchaStrong']),
'type' => $this->getData(['config','connect', 'captchaType'])
]); ?>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col2 offset8">
<?php echo template::button('blogArticleCommentHide', [
'class' => 'buttonGrey',
2022-03-18 07:50:13 +01:00
'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Cancel'])
2022-01-31 09:10:49 +01:00
]); ?>
</div>
<div class="col2">
<?php echo template::submit('blogArticleSubmit', [
2022-03-18 07:50:13 +01:00
'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Send']),
2022-01-31 09:10:49 +01:00
'ico' => ''
]); ?>
</div>
</div>
</div>
<?php echo template::formClose(); ?>
<?php endif;?>
<div class="row">
<div class="col12">
<?php foreach($module::$comments as $commentId => $comment): ?>
<div class="block">
<h4><?php echo $module::$commentsSignature[$commentId]; ?>
2022-03-18 07:50:13 +01:00
<?php echo ' - '; echo mb_detect_encoding(strftime('%d %B %Y - %H:%M', $comment['createdOn']), 'UTF-8', true)
2022-01-31 09:10:49 +01:00
? strftime('%d %B %Y - %H:%M', $comment['createdOn'])
: utf8_encode(strftime('%d %B %Y - %H:%M', $comment['createdOn']));
?>
</h4>
<?php echo $comment['content']; ?>
</div>
<?php endforeach; ?>
</div>
</div>
<?php echo $module::$pages; ?>