Nouvelle structure données blog

This commit is contained in:
Fred Tempez 2020-11-17 08:52:32 +01:00
parent 21580cf4fa
commit 82e1493ede
8 changed files with 147 additions and 112 deletions

View File

@ -1449,6 +1449,28 @@ class common {
} }
$this->setData(['core', 'dataVersion', 10304]); $this->setData(['core', 'dataVersion', 10304]);
} }
// Version 10.3.06
if ($this->getData(['core', 'dataVersion']) < 10306) {
// Mettre à jour les données des blogs
$pageList = array();
foreach ($this->getHierarchy(null,null,null) as $parentKey=>$parentValue) {
$pageList [] = $parentKey;
foreach ($parentValue as $childKey) {
$pageList [] = $childKey;
}
}
foreach ($pageList as $parentKey => $parent) {
//La page a une galerie
if ($this->getData(['page',$parent,'moduleId']) === 'blog' ) {
foreach ( $this->getData(['module', $parent]) as $blogKey => $blogItem) {
$data = $this->getdata(['module',$parent,$blogKey]);
$this->deleteData(['module',$parent, $blogKey]);
$this->setData([ 'module', $parent, 'posts', $blogKey, $data ]);
}
}
}
$this->setData(['core', 'dataVersion', 10306]);
}
} }
} }

View File

@ -644,49 +644,55 @@ class init extends common {
], ],
'module' => [ 'module' => [
'blog' => [ 'blog' => [
'mon-premier-article' => [ 'config' => [
'closeComment' => false, 'feeds' => true,
'comment' => [ 'feedsLabel' => "Syndication RSS"
'58e11d09e5aff' => [ ],
'author' => 'Rémi', 'posts' => [
'content' => 'Article bien rédigé et très pertinent, bravo !', 'mon-premier-article' => [
'createdOn' => 1421748000, 'closeComment' => false,
'userId' => '' 'comment' => [
] '58e11d09e5aff' => [
'author' => 'Rémi',
'content' => 'Article bien rédigé et très pertinent, bravo !',
'createdOn' => 1421748000,
'userId' => ''
]
],
'content' => '<p>Et eodem impetu Domitianum praecipitem per scalas itidem funibus constrinxerunt, eosque coniunctos per ampla spatia civitatis acri raptavere discursu. iamque artuum et membrorum divulsa conpage superscandentes corpora mortuorum ad ultimam truncata deformitatem velut exsaturati mox abiecerunt in flumen.</p><p>Ex his quidam aeternitati se commendari posse per statuas aestimantes eas ardenter adfectant quasi plus praemii de figmentis aereis sensu carentibus adepturi, quam ex conscientia honeste recteque factorum, easque auro curant inbracteari, quod Acilio Glabrioni delatum est primo, cum consiliis armisque regem superasset Antiochum. quam autem sit pulchrum exigua haec spernentem et minima ad ascensus verae gloriae tendere longos et arduos, ut memorat vates Ascraeus, Censorius Cato monstravit. qui interrogatus quam ob rem inter multos... statuam non haberet malo inquit ambigere bonos quam ob rem id non meruerim, quam quod est gravius cur inpetraverim mussitare.</p><p>Latius iam disseminata licentia onerosus bonis omnibus Caesar nullum post haec adhibens modum orientis latera cuncta vexabat nec honoratis parcens nec urbium primatibus nec plebeiis.</p>',
'picture' => 'galerie/landscape/meadow.jpg',
'hidePicture' => false,
'pictureSize' => 20,
'publishedOn' => 1548790902,
'state' => true,
'title' => 'Mon premier article',
'userId' => '' // Géré au moment de l'installation
],
'mon-deuxieme-article' => [
'closeComment' => false,
'comment' => [],
'content' => '<p>Et prima post Osdroenam quam, ut dictum est, ab hac descriptione discrevimus, Commagena, nunc Euphratensis, clementer adsurgit, Hierapoli, vetere Nino et Samosata civitatibus amplis inlustris.</p><p>Ob haec et huius modi multa, quae cernebantur in paucis, omnibus timeri sunt coepta. et ne tot malis dissimulatis paulatimque serpentibus acervi crescerent aerumnarum, nobilitatis decreto legati mittuntur: Praetextatus ex urbi praefecto et ex vicario Venustus et ex consulari Minervius oraturi, ne delictis supplicia sint grandiora, neve senator quisquam inusitato et inlicito more tormentis exponeretur.</p><p>Sed ut tum ad senem senex de senectute, sic hoc libro ad amicum amicissimus scripsi de amicitia. Tum est Cato locutus, quo erat nemo fere senior temporibus illis, nemo prudentior; nunc Laelius et sapiens (sic enim est habitus) et amicitiae gloria excellens de amicitia loquetur. Tu velim a me animum parumper avertas, Laelium loqui ipsum putes. C. Fannius et Q. Mucius ad socerum veniunt post mortem Africani; ab his sermo oritur, respondet Laelius, cuius tota disputatio est de amicitia, quam legens te ipse cognosces.</p>',
'picture' => 'galerie/landscape/desert.jpg',
'hidePicture' => false,
'pictureSize' => 40,
'publishedOn' => 1550432502,
'state' => true,
'title' => 'Mon deuxième article',
'userId' => '' // Géré au moment de l'installation
],
'mon-troisieme-article' => [
'closeComment' => true,
'comment' => [],
'content' => '<p>Rogatus ad ultimum admissusque in consistorium ambage nulla praegressa inconsiderate et leviter proficiscere inquit ut praeceptum est, Caesar sciens quod si cessaveris, et tuas et palatii tui auferri iubebo prope diem annonas. hocque solo contumaciter dicto subiratus abscessit nec in conspectum eius postea venit saepius arcessitus.</p><p>Proinde concepta rabie saeviore, quam desperatio incendebat et fames, amplificatis viribus ardore incohibili in excidium urbium matris Seleuciae efferebantur, quam comes tuebatur Castricius tresque legiones bellicis sudoribus induratae.</p><p>Inter has ruinarum varietates a Nisibi quam tuebatur accitus Vrsicinus, cui nos obsecuturos iunxerat imperiale praeceptum, dispicere litis exitialis certamina cogebatur abnuens et reclamans, adulatorum oblatrantibus turmis, bellicosus sane milesque semper et militum ductor sed forensibus iurgiis longe discretus, qui metu sui discriminis anxius cum accusatores quaesitoresque subditivos sibi consociatos ex isdem foveis cerneret emergentes, quae clam palamve agitabantur, occultis Constantium litteris edocebat inplorans subsidia, quorum metu tumor notissimus Caesaris exhalaret.</p>',
'picture' => 'galerie/landscape/iceberg.jpg',
'hidePicture' => false,
'pictureSize' => 100,
'publishedOn' => 1550864502,
'state' => true,
'title' => 'Mon troisième article',
'userId' => '' // Géré au moment de l'installation
], ],
'content' => '<p>Et eodem impetu Domitianum praecipitem per scalas itidem funibus constrinxerunt, eosque coniunctos per ampla spatia civitatis acri raptavere discursu. iamque artuum et membrorum divulsa conpage superscandentes corpora mortuorum ad ultimam truncata deformitatem velut exsaturati mox abiecerunt in flumen.</p><p>Ex his quidam aeternitati se commendari posse per statuas aestimantes eas ardenter adfectant quasi plus praemii de figmentis aereis sensu carentibus adepturi, quam ex conscientia honeste recteque factorum, easque auro curant inbracteari, quod Acilio Glabrioni delatum est primo, cum consiliis armisque regem superasset Antiochum. quam autem sit pulchrum exigua haec spernentem et minima ad ascensus verae gloriae tendere longos et arduos, ut memorat vates Ascraeus, Censorius Cato monstravit. qui interrogatus quam ob rem inter multos... statuam non haberet malo inquit ambigere bonos quam ob rem id non meruerim, quam quod est gravius cur inpetraverim mussitare.</p><p>Latius iam disseminata licentia onerosus bonis omnibus Caesar nullum post haec adhibens modum orientis latera cuncta vexabat nec honoratis parcens nec urbium primatibus nec plebeiis.</p>',
'picture' => 'galerie/landscape/meadow.jpg',
'hidePicture' => false,
'pictureSize' => 20,
'publishedOn' => 1548790902,
'state' => true,
'title' => 'Mon premier article',
'userId' => '' // Géré au moment de l'installation
], ],
'mon-deuxieme-article' => [
'closeComment' => false,
'comment' => [],
'content' => '<p>Et prima post Osdroenam quam, ut dictum est, ab hac descriptione discrevimus, Commagena, nunc Euphratensis, clementer adsurgit, Hierapoli, vetere Nino et Samosata civitatibus amplis inlustris.</p><p>Ob haec et huius modi multa, quae cernebantur in paucis, omnibus timeri sunt coepta. et ne tot malis dissimulatis paulatimque serpentibus acervi crescerent aerumnarum, nobilitatis decreto legati mittuntur: Praetextatus ex urbi praefecto et ex vicario Venustus et ex consulari Minervius oraturi, ne delictis supplicia sint grandiora, neve senator quisquam inusitato et inlicito more tormentis exponeretur.</p><p>Sed ut tum ad senem senex de senectute, sic hoc libro ad amicum amicissimus scripsi de amicitia. Tum est Cato locutus, quo erat nemo fere senior temporibus illis, nemo prudentior; nunc Laelius et sapiens (sic enim est habitus) et amicitiae gloria excellens de amicitia loquetur. Tu velim a me animum parumper avertas, Laelium loqui ipsum putes. C. Fannius et Q. Mucius ad socerum veniunt post mortem Africani; ab his sermo oritur, respondet Laelius, cuius tota disputatio est de amicitia, quam legens te ipse cognosces.</p>',
'picture' => 'galerie/landscape/desert.jpg',
'hidePicture' => false,
'pictureSize' => 40,
'publishedOn' => 1550432502,
'state' => true,
'title' => 'Mon deuxième article',
'userId' => '' // Géré au moment de l'installation
],
'mon-troisieme-article' => [
'closeComment' => true,
'comment' => [],
'content' => '<p>Rogatus ad ultimum admissusque in consistorium ambage nulla praegressa inconsiderate et leviter proficiscere inquit ut praeceptum est, Caesar sciens quod si cessaveris, et tuas et palatii tui auferri iubebo prope diem annonas. hocque solo contumaciter dicto subiratus abscessit nec in conspectum eius postea venit saepius arcessitus.</p><p>Proinde concepta rabie saeviore, quam desperatio incendebat et fames, amplificatis viribus ardore incohibili in excidium urbium matris Seleuciae efferebantur, quam comes tuebatur Castricius tresque legiones bellicis sudoribus induratae.</p><p>Inter has ruinarum varietates a Nisibi quam tuebatur accitus Vrsicinus, cui nos obsecuturos iunxerat imperiale praeceptum, dispicere litis exitialis certamina cogebatur abnuens et reclamans, adulatorum oblatrantibus turmis, bellicosus sane milesque semper et militum ductor sed forensibus iurgiis longe discretus, qui metu sui discriminis anxius cum accusatores quaesitoresque subditivos sibi consociatos ex isdem foveis cerneret emergentes, quae clam palamve agitabantur, occultis Constantium litteris edocebat inplorans subsidia, quorum metu tumor notissimus Caesaris exhalaret.</p>',
'picture' => 'galerie/landscape/iceberg.jpg',
'hidePicture' => false,
'pictureSize' => 100,
'publishedOn' => 1550864502,
'state' => true,
'title' => 'Mon troisième article',
'userId' => '' // Géré au moment de l'installation
]
], ],
'galeries' => [ 'galeries' => [
'beaux-paysages' => [ 'beaux-paysages' => [

View File

@ -33,6 +33,8 @@ class blog extends common {
public static $rssUrl; public static $rssUrl;
public static $rssLabel;
public static $states = [ public static $states = [
false => 'Brouillon', false => 'Brouillon',
true => 'Publié' true => 'Publié'
@ -73,9 +75,9 @@ class blog extends common {
$feeds = new \FeedWriter\RSS2(); $feeds = new \FeedWriter\RSS2();
// En-tête // En-tête
$feeds->setTitle($this->getData (['page', $this->getUrl(0),'title'])); $feeds->setTitle($this->getData (['page', $this->getUrl(0), 'posts','title']));
$feeds->setLink(helper::baseUrl() . $this->getUrl(0)); $feeds->setLink(helper::baseUrl() . $this->getUrl(0));
$feeds->setDescription(html_entity_decode(strip_tags($this->getData (['page', $this->getUrl(0), 'metaDescription'])))); $feeds->setDescription(html_entity_decode(strip_tags($this->getData (['page', $this->getUrl(0), 'posts', 'metaDescription']))));
$feeds->setChannelElement('language', 'fr-FR'); $feeds->setChannelElement('language', 'fr-FR');
$feeds->setDate(time()); $feeds->setDate(time());
$feeds->addGenerator(); $feeds->addGenerator();
@ -86,9 +88,9 @@ class blog extends common {
if($articlePublishedOn <= time() AND $articleIdsStates[$articleId]) { if($articlePublishedOn <= time() AND $articleIdsStates[$articleId]) {
$newsArticle = $feeds->createNewItem(); $newsArticle = $feeds->createNewItem();
$newsArticle->addElementArray([ $newsArticle->addElementArray([
'title' => strip_tags($this->getData(['module', $this->getUrl(0), $articleId, 'title']) ), 'title' => strip_tags($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'title']) ),
'link' => helper::baseUrl() .$this->getUrl(0) . '/' . $articleId, 'link' => helper::baseUrl() .$this->getUrl(0) . '/' . $articleId,
'description' => html_entity_decode(strip_tags($this->getData(['module', $this->getUrl(0), $articleId, 'content']))) 'description' => html_entity_decode(strip_tags($this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'content'])))
]); ]);
$feeds->addItem($newsArticle); $feeds->addItem($newsArticle);
} }
@ -113,7 +115,7 @@ class blog extends common {
$articleId = helper::increment($articleId, (array) $this->getData(['module', $this->getUrl(0)])); $articleId = helper::increment($articleId, (array) $this->getData(['module', $this->getUrl(0)]));
$articleId = helper::increment($articleId, array_keys(self::$actions)); $articleId = helper::increment($articleId, array_keys(self::$actions));
// Crée l'article // Crée l'article
$this->setData(['module', $this->getUrl(0), $articleId, [ $this->setData(['module', $this->getUrl(0), 'posts', $articleId, [
'closeComment' => $this->getInput('blogAddCloseComment', helper::FILTER_BOOLEAN), 'closeComment' => $this->getInput('blogAddCloseComment', helper::FILTER_BOOLEAN),
'mailNotification' => $this->getInput('blogAddMailNotification', helper::FILTER_BOOLEAN), 'mailNotification' => $this->getInput('blogAddMailNotification', helper::FILTER_BOOLEAN),
'groupNotification' => $this->getInput('blogAddGroupNotification', helper::FILTER_INT), 'groupNotification' => $this->getInput('blogAddGroupNotification', helper::FILTER_INT),
@ -200,7 +202,7 @@ class blog extends common {
*/ */
public function commentDelete() { public function commentDelete() {
// Le commentaire n'existe pas // Le commentaire n'existe pas
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3)]) === null) { if($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment', $this->getUrl(3)]) === null) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
@ -216,7 +218,7 @@ class blog extends common {
} }
// Suppression // Suppression
else { else {
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2), 'comment', $this->getUrl(3)]); $this->deleteData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment', $this->getUrl(3)]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment', 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/comment',
@ -243,11 +245,8 @@ class blog extends common {
'state' => true 'state' => true
]); ]);
} else { } else {
// Extraire la clé config mot clé réservé
$articles = $this->getData(['module', $this->getUrl(0)]);
unset($articles['config']);
// Ids des articles par ordre de publication // Ids des articles par ordre de publication
$articleIds = array_keys(helper::arrayCollumn($articles, 'publishedOn', 'SORT_DESC')); $articleIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0),'posts']), 'publishedOn', 'SORT_DESC'));
// Supprimer le bloc config // Supprimer le bloc config
// Pagination // Pagination
$pagination = helper::pagination($articleIds, $this->getUrl(),$this->getData(['config','itemsperPage'])); $pagination = helper::pagination($articleIds, $this->getUrl(),$this->getData(['config','itemsperPage']));
@ -256,16 +255,16 @@ class blog extends common {
// Articles en fonction de la pagination // Articles en fonction de la pagination
for($i = $pagination['first']; $i < $pagination['last']; $i++) { for($i = $pagination['first']; $i < $pagination['last']; $i++) {
// Met en forme le tableau // Met en forme le tableau
$date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])), 'UTF-8', true) $date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'publishedOn'])), 'UTF-8', true)
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])) ? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'publishedOn']))
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn']))); : utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'publishedOn'])));
$heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])), 'UTF-8', true) $heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'publishedOn'])), 'UTF-8', true)
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn'])) ? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'publishedOn']))
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), $articleIds[$i], 'publishedOn']))); : utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'publishedOn'])));
self::$articles[] = [ self::$articles[] = [
$this->getData(['module', $this->getUrl(0), $articleIds[$i], 'title']), $this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'title']),
$date .' à '. $heure, $date .' à '. $heure,
self::$states[$this->getData(['module', $this->getUrl(0), $articleIds[$i], 'state'])], self::$states[$this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i], 'state'])],
template::button('blogConfigEdit' . $articleIds[$i], [ template::button('blogConfigEdit' . $articleIds[$i], [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $articleIds[$i] . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $articleIds[$i] . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil') 'value' => template::ico('pencil')
@ -289,7 +288,7 @@ class blog extends common {
* Suppression * Suppression
*/ */
public function delete() { public function delete() {
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { if($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2)]) === null) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
@ -305,7 +304,7 @@ class blog extends common {
} }
// Suppression // Suppression
else { else {
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]); $this->deleteData(['module', $this->getUrl(0), 'posts', $this->getUrl(2)]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
@ -328,7 +327,7 @@ class blog extends common {
]); ]);
} }
// L'article n'existe pas // L'article n'existe pas
if($this->getData(['module', $this->getUrl(0), $this->getUrl(2)]) === null) { if($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2)]) === null) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
@ -345,11 +344,11 @@ class blog extends common {
$articleId = helper::increment($articleId, $this->getData(['module', $this->getUrl(0)])); $articleId = helper::increment($articleId, $this->getData(['module', $this->getUrl(0)]));
$articleId = helper::increment($articleId, array_keys(self::$actions)); $articleId = helper::increment($articleId, array_keys(self::$actions));
} }
$this->setData(['module', $this->getUrl(0), $articleId, [ $this->setData(['module', $this->getUrl(0), 'posts', $articleId, [
'closeComment' => $this->getInput('blogEditCloseComment'), 'closeComment' => $this->getInput('blogEditCloseComment'),
'mailNotification' => $this->getInput('blogEditMailNotification', helper::FILTER_BOOLEAN), 'mailNotification' => $this->getInput('blogEditMailNotification', helper::FILTER_BOOLEAN),
'groupNotification' => $this->getInput('blogEditGroupNotification', helper::FILTER_INT), 'groupNotification' => $this->getInput('blogEditGroupNotification', helper::FILTER_INT),
'comment' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'comment']), 'comment' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment']),
'content' => $this->getInput('blogEditContent', null), 'content' => $this->getInput('blogEditContent', null),
'picture' => $this->getInput('blogEditPicture', helper::FILTER_STRING_SHORT, true), 'picture' => $this->getInput('blogEditPicture', helper::FILTER_STRING_SHORT, true),
'hidePicture' => $this->getInput('blogEditHidePicture', helper::FILTER_BOOLEAN), 'hidePicture' => $this->getInput('blogEditHidePicture', helper::FILTER_BOOLEAN),
@ -362,7 +361,7 @@ class blog extends common {
]]); ]]);
// Supprime l'ancien article // Supprime l'ancien article
if($articleId !== $this->getUrl(2)) { if($articleId !== $this->getUrl(2)) {
$this->deleteData(['module', $this->getUrl(0), $this->getUrl(2)]); $this->deleteData(['module', $this->getUrl(0), 'posts', $this->getUrl(2)]);
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -380,7 +379,7 @@ class blog extends common {
unset($userFirstname); unset($userFirstname);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'title']), 'title' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'title']),
'vendor' => [ 'vendor' => [
'flatpickr', 'flatpickr',
'tinymce' 'tinymce'
@ -401,7 +400,7 @@ class blog extends common {
AND intval($this->getUrl(1)) === 0 AND intval($this->getUrl(1)) === 0
) { ) {
// L'article n'existe pas // L'article n'existe pas
if($this->getData(['module', $this->getUrl(0), $this->getUrl(1)]) === null) { if($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1)]) === null) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
@ -420,8 +419,8 @@ class blog extends common {
self::$inputNotices['blogArticleCaptcha'] = 'Incorrect'; self::$inputNotices['blogArticleCaptcha'] = 'Incorrect';
} }
// Crée le commentaire // Crée le commentaire
$commentId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment'])); $commentId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment']));
$this->setData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentId, [ $this->setData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment', $commentId, [
'author' => $this->getInput('blogArticleAuthor', helper::FILTER_STRING_SHORT, empty($this->getInput('blogArticleUserId')) ? TRUE : FALSE), 'author' => $this->getInput('blogArticleAuthor', helper::FILTER_STRING_SHORT, empty($this->getInput('blogArticleUserId')) ? TRUE : FALSE),
'content' => $this->getInput('blogArticleContent', helper::FILTER_STRING_SHORT, true), 'content' => $this->getInput('blogArticleContent', helper::FILTER_STRING_SHORT, true),
'createdOn' => time(), 'createdOn' => time(),
@ -433,17 +432,17 @@ class blog extends common {
$to = []; $to = [];
// Liste des destinataires // Liste des destinataires
foreach($this->getData(['user']) as $userId => $user) { foreach($this->getData(['user']) as $userId => $user) {
if ($user['group'] >= $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'groupNotification']) ) { if ($user['group'] >= $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'groupNotification']) ) {
$to[] = $user['mail']; $to[] = $user['mail'];
} }
} }
// Envoi du mail $sent code d'erreur ou de réussite // Envoi du mail $sent code d'erreur ou de réussite
if ($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'mailNotification']) === true) { if ($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'mailNotification']) === true) {
$sent = $this->sendMail( $sent = $this->sendMail(
$to, $to,
'Nouveau commentaire', 'Nouveau commentaire',
'Bonjour' . ' <strong>' . $user['firstname'] . ' ' . $user['lastname'] . '</strong>,<br><br>' . 'Bonjour' . ' <strong>' . $user['firstname'] . ' ' . $user['lastname'] . '</strong>,<br><br>' .
'Nouveau commentaire déposé sur la page "' . $this->getData(['page', $this->getUrl(0), 'title']) . '" :<br><br>', 'Nouveau commentaire déposé sur la page "' . $this->getData(['page', $this->getUrl(0), 'posts', 'title']) . '" :<br><br>',
'' ''
); );
// Valeurs en sortie // Valeurs en sortie
@ -466,20 +465,21 @@ class blog extends common {
} }
// Ids des commentaires par ordre de publication // Ids des commentaires par ordre de publication
$commentIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment']), 'createdOn', 'SORT_DESC')); $commentIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment']), 'createdOn', 'SORT_DESC'));
// Pagination // Pagination
$pagination = helper::pagination($commentIds, $this->getUrl(),$this->getData(['config','itemsperPage']),'#comment'); $pagination = helper::pagination($commentIds, $this->getUrl(),$this->getData(['config','itemsperPage']),'#comment');
// Liste des pages // Liste des pages
self::$pages = $pagination['pages']; self::$pages = $pagination['pages'];
// Commentaires en fonction de la pagination // Commentaires en fonction de la pagination
for($i = $pagination['first']; $i < $pagination['last']; $i++) { for($i = $pagination['first']; $i < $pagination['last']; $i++) {
self::$comments[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment', $commentIds[$i]]); self::$comments[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment', $commentIds[$i]]);
} }
self::$rssUrl = helper::baseUrl() . $this->getUrl(0) . '/rss'; self::$rssUrl = helper::baseUrl() . $this->getUrl(0) . '/rss';
self::$rssLabel = $this->getData(['module', $this->getUrl(0), 'config','feedsLabel']);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'showBarEditButton' => true, 'showBarEditButton' => true,
'title' => $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'title']), 'title' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'title']),
'view' => 'article' 'view' => 'article'
]); ]);
} }
@ -488,8 +488,8 @@ class blog extends common {
// Liste des articles // Liste des articles
else { else {
// Ids des articles par ordre de publication // Ids des articles par ordre de publication
$articleIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0)]), 'publishedOn', 'SORT_DESC'); $articleIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0),'posts']), 'publishedOn', 'SORT_DESC');
$articleIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0)]), 'state', 'SORT_DESC'); $articleIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC');
$articleIds = []; $articleIds = [];
foreach($articleIdsPublishedOns as $articleId => $articlePublishedOn) { foreach($articleIdsPublishedOns as $articleId => $articlePublishedOn) {
if($articlePublishedOn <= time() AND $articleIdsStates[$articleId]) { if($articlePublishedOn <= time() AND $articleIdsStates[$articleId]) {
@ -502,9 +502,10 @@ class blog extends common {
self::$pages = $pagination['pages']; self::$pages = $pagination['pages'];
// Articles en fonction de la pagination // Articles en fonction de la pagination
for($i = $pagination['first']; $i < $pagination['last']; $i++) { for($i = $pagination['first']; $i < $pagination['last']; $i++) {
self::$articles[$articleIds[$i]] = $this->getData(['module', $this->getUrl(0), $articleIds[$i]]); self::$articles[$articleIds[$i]] = $this->getData(['module', $this->getUrl(0), 'posts', $articleIds[$i]]);
} }
self::$rssUrl = helper::baseUrl() . $this->getUrl(0) . '/rss'; self::$rssUrl = helper::baseUrl() . $this->getUrl(0) . '/rss';
self::$rssLabel = $this->getData(['module', $this->getUrl(0), 'config','feedsLabel']);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'showBarEditButton' => true, 'showBarEditButton' => true,

View File

@ -57,7 +57,7 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::checkbox('blogAddHidePicture', true, 'Masquer l\'image dans l\'article', [ <?php echo template::checkbox('blogAddHidePicture', true, 'Masquer l\'image dans l\'article', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'hidePicture']) 'checked' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'hidePicture'])
]); ?> ]); ?>
</div> </div>
</div> </div>

View File

@ -3,12 +3,12 @@
<div class="col10"> <div class="col10">
<div class="blogDate"> <div class="blogDate">
<i class="far fa-calendar-alt"></i> <i class="far fa-calendar-alt"></i>
<?php $date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'publishedOn'])), 'UTF-8', true) <?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), $this->getUrl(1), 'publishedOn'])) ? 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), $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), $this->getUrl(1), 'publishedOn'])), 'UTF-8', true) $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), $this->getUrl(1), 'publishedOn'])) ? 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), $this->getUrl(1), 'publishedOn']))); : utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])));
echo $date . ' à ' . $heure; echo $date . ' à ' . $heure;
?> ?>
</div> </div>
@ -25,30 +25,33 @@
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php $pictureSize = $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'pictureSize']) === null ? '100' : $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'pictureSize']); ?> <?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), $this->getUrl(1), 'hidePicture']) == false) { <?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), $this->getUrl(1), 'picturePosition']) . 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), $this->getUrl(1), 'picture']) . ' 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), $this->getUrl(1), 'picture']) . '">'; '" alt="' . $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'picture']) . '">';
} ?> } ?>
<?php echo $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'content']); ?> <?php echo $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'content']); ?>
<p class="clearBoth signature"> <p class="clearBoth signature">
<?php echo $this->getData(['user', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'userId']), 'firstname']); ?> <?php echo $this->getData(['user', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'userId']), 'firstname']); ?>
<?php echo $this->getData(['user', $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'userId']), 'lastname']); ?> <?php echo $this->getData(['user', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'userId']), 'lastname']); ?>
</p> </p>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>
<!-- Bloc RSS--> <!-- Bloc RSS-->
<div id="rssFeed"> <div id="rssFeed">
<a type="application/rss+xml" href="<?php echo $module::$rssUrl ?> "> <a type="application/rss+xml" href="<?php echo $module::$rssUrl ?> ">
<img src='module/news/ressource/feed-icon-16.gif' /><p>Syndication RSS</p> <img src='module/news/ressource/feed-icon-16.gif' />
<?php
echo '<p>' . $module::$rssLabel . '</p>' ;
?>
</a> </a>
</div> </div>
<?php if($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'closeComment'])): ?> <?php if($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'closeComment'])): ?>
<p>Cet article ne reçoit pas de commentaire.</p> <p>Cet article ne reçoit pas de commentaire.</p>
<?php else: ?> <?php else: ?>
<h3 id="comment"> <h3 id="comment">
<?php $commentsNb = count($this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment'])); ?> <?php $commentsNb = count($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment'])); ?>
<?php $s = $commentsNb === 1 ? '': 's' ?> <?php $s = $commentsNb === 1 ? '': 's' ?>
<?php echo $commentsNb > 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire'; ?> <?php echo $commentsNb > 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire'; ?>
</h3> </h3>

View File

@ -3,7 +3,7 @@
<div class="col2"> <div class="col2">
<?php echo template::button('blogConfigBack', [ <?php echo template::button('blogConfigBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), 'posts',
'ico' => 'left', 'ico' => 'left',
'value' => 'Retour' 'value' => 'Retour'
]); ?> ]); ?>
@ -31,14 +31,14 @@
<h4>Paramètres du module</h4> <h4>Paramètres du module</h4>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::checkbox('blogConfigShowFeeds', true, 'Afficher les flux RSS', [ <?php echo template::checkbox('blogConfigShowFeeds', true, 'Lien du flux RSS', [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'feeds']), 'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'feeds']),
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::text('blogConfigFeedslabel', [ <?php echo template::text('blogConfigFeedslabel', [
'label' => 'Etiquette', 'label' => 'Texte de l\'étiquette',
'value' => empty($this->getData(['module', $this->getUrl(0), 'config','feedsLabel'])) ? 'Syndication RSS' : $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel']) 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel'])
]); ?> ]); ?>
</div> </div>
</div> </div>

View File

@ -31,7 +31,7 @@
<div class="col12"> <div class="col12">
<?php echo template::text('blogEditTitle', [ <?php echo template::text('blogEditTitle', [
'label' => 'Titre', 'label' => 'Titre',
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'title']) 'value' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'title'])
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -41,19 +41,19 @@
'help' => 'Taille optimale de l\'image de couverture : ' . ((int) substr($this->getData(['theme', 'site', 'width']), 0, -2) - (20 * 2)) . ' x 350 pixels.', 'help' => 'Taille optimale de l\'image de couverture : ' . ((int) substr($this->getData(['theme', 'site', 'width']), 0, -2) - (20 * 2)) . ' x 350 pixels.',
'label' => 'Image de couverture', 'label' => 'Image de couverture',
'type' => 1, 'type' => 1,
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'picture']) 'value' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'picture'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('blogEditPictureSize', $module::$pictureSizes, [ <?php echo template::select('blogEditPictureSize', $module::$pictureSizes, [
'label' => 'Largeur de l\'image', 'label' => 'Largeur de l\'image',
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'pictureSize']) 'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'pictureSize'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('blogEditPicturePosition', $module::$picturePositions, [ <?php echo template::select('blogEditPicturePosition', $module::$picturePositions, [
'label' => 'Position', 'label' => 'Position',
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'picturePosition']), 'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'picturePosition']),
'help' => 'Le texte de l\'article est adapté autour de l\'image' 'help' => 'Le texte de l\'article est adapté autour de l\'image'
]); ?> ]); ?>
</div> </div>
@ -61,7 +61,7 @@
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::checkbox('blogEditHidePicture', true, 'Masquer l\'image dans l\'article', [ <?php echo template::checkbox('blogEditHidePicture', true, 'Masquer l\'image dans l\'article', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'hidePicture']) 'checked' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'hidePicture'])
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -70,7 +70,7 @@
</div> </div>
<?php echo template::textarea('blogEditContent', [ <?php echo template::textarea('blogEditContent', [
'class' => 'editorWysiwyg', 'class' => 'editorWysiwyg',
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'content']) 'value' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'content'])
]); ?> ]); ?>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
@ -83,7 +83,7 @@
<?php echo template::date('blogEditPublishedOn', [ <?php echo template::date('blogEditPublishedOn', [
'help' => 'L\'article n\'est visible qu\'après la date de publication prévue.', 'help' => 'L\'article n\'est visible qu\'après la date de publication prévue.',
'label' => 'Date de publication', 'label' => 'Date de publication',
'value' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'publishedOn']) 'value' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'publishedOn'])
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -91,16 +91,16 @@
<div class="block"> <div class="block">
<h4>Options avancées</h4> <h4>Options avancées</h4>
<?php echo template::checkbox('blogEditCloseComment', true, 'Fermer les commentaires', [ <?php echo template::checkbox('blogEditCloseComment', true, 'Fermer les commentaires', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'closeComment']) 'checked' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'closeComment'])
]); ?> ]); ?>
<?php echo template::checkbox('blogEditMailNotification', true, 'Notifier le commentaire aux groupes à partir de :', [ <?php echo template::checkbox('blogEditMailNotification', true, 'Notifier le commentaire aux groupes à partir de :', [
'checked' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'mailNotification']), 'checked' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'mailNotification']),
'help' => 'Editeurs = éditeurs + administrateurs<br/> Membres = membres + éditeurs + administrateurs' 'help' => 'Editeurs = éditeurs + administrateurs<br/> Membres = membres + éditeurs + administrateurs'
]); ?> ]); ?>
<?php echo template::select('blogEditGroupNotification', $module::$groupNews, [ <?php echo template::select('blogEditGroupNotification', $module::$groupNews, [
'label' => '', 'label' => '',
'selected' => $this->getData(['module', $this->getUrl(0), $this->getUrl(2), 'groupNotification']) 'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'groupNotification'])
]); ?> ]); ?>
</div> </div>
</div> </div>

View File

@ -50,7 +50,10 @@
<?php echo $module::$pages; ?> <?php echo $module::$pages; ?>
<div id="rssFeed"> <div id="rssFeed">
<a type="application/rss+xml" href="<?php echo $module::$rssUrl ?> "> <a type="application/rss+xml" href="<?php echo $module::$rssUrl ?> ">
<img src='module/news/ressource/feed-icon-16.gif' /><p>Syndication RSS</p> <img src='module/news/ressource/feed-icon-16.gif' />
<?php
echo '<p>' . $module::$rssLabel . '</p>' ;
?>
</a> </a>
</div> </div>
<?php else: ?> <?php else: ?>