forked from ZwiiCMS-Team/ZwiiCMS
Normalisation
This commit is contained in:
parent
29d46887e9
commit
a85dedbeb3
@ -13,7 +13,8 @@
|
||||
* @link http://zwiicms.fr/
|
||||
*/
|
||||
|
||||
class news extends common {
|
||||
class news extends common
|
||||
{
|
||||
|
||||
const VERSION = '4.22';
|
||||
const REALNAME = 'News';
|
||||
@ -89,7 +90,8 @@ class news extends common {
|
||||
/**
|
||||
* Flux RSS
|
||||
*/
|
||||
public function rss() {
|
||||
public function rss()
|
||||
{
|
||||
// Inclure les classes
|
||||
include_once 'module/news/vendor/FeedWriter/Item.php';
|
||||
include_once 'module/news/vendor/FeedWriter/Feed.php';
|
||||
@ -111,7 +113,7 @@ class news extends common {
|
||||
$newsIdsPublishedOns = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC');
|
||||
$newsIdsStates = helper::arrayColumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC');
|
||||
foreach ($newsIdsPublishedOns as $newsId => $newsPublishedOn) {
|
||||
if($newsPublishedOn <= time() AND $newsIdsStates[$newsId]) {
|
||||
if ($newsPublishedOn <= time() and $newsIdsStates[$newsId]) {
|
||||
$newsArticle = $feeds->createNewItem();
|
||||
$author = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $newsId, 'userId']));
|
||||
$newsArticle->addElementArray([
|
||||
@ -137,7 +139,8 @@ class news extends common {
|
||||
/**
|
||||
* Ajout d'un article
|
||||
*/
|
||||
public function add() {
|
||||
public function add()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
// Crée la news
|
||||
@ -180,7 +183,8 @@ class news extends common {
|
||||
/**
|
||||
* Configuration
|
||||
*/
|
||||
public function config() {
|
||||
public function config()
|
||||
{
|
||||
|
||||
// Mise à jour des données de module
|
||||
$this->update();
|
||||
@ -228,7 +232,8 @@ class news extends common {
|
||||
]);
|
||||
}
|
||||
|
||||
public function option() {
|
||||
public function option()
|
||||
{
|
||||
// Soumission du formulaire
|
||||
if ($this->isPost()) {
|
||||
|
||||
@ -318,7 +323,8 @@ class news extends common {
|
||||
/**
|
||||
* Suppression
|
||||
*/
|
||||
public function delete() {
|
||||
public function delete()
|
||||
{
|
||||
// La news n'existe pas
|
||||
if ($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2)]) === null) {
|
||||
// Valeurs en sortie
|
||||
@ -349,7 +355,8 @@ class news extends common {
|
||||
/**
|
||||
* Édition
|
||||
*/
|
||||
public function edit() {
|
||||
public function edit()
|
||||
{
|
||||
// Jeton incorrect
|
||||
if ($this->getUrl(3) !== $_SESSION['csrf']) {
|
||||
// Valeurs en sortie
|
||||
@ -416,7 +423,8 @@ class news extends common {
|
||||
/**
|
||||
* Accueil
|
||||
*/
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
|
||||
// Mise à jour des données de module
|
||||
$this->update();
|
||||
@ -425,7 +433,7 @@ class news extends common {
|
||||
if (
|
||||
$this->getUrl(1)
|
||||
// Protection pour la pagination, un ID ne peut pas être un entier, une page oui
|
||||
AND intval($this->getUrl(1)) === 0
|
||||
and intval($this->getUrl(1)) === 0
|
||||
) {
|
||||
// L'article n'existe pas
|
||||
if ($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1)]) === null) {
|
||||
@ -443,7 +451,6 @@ class news extends common {
|
||||
'title' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'title']),
|
||||
'view' => 'article'
|
||||
]);
|
||||
|
||||
}
|
||||
} else {
|
||||
// Affichage index
|
||||
@ -453,10 +460,11 @@ class news extends common {
|
||||
$newsIds = [];
|
||||
foreach ($newsIdsPublishedOns as $newsId => $newsPublishedOn) {
|
||||
$newsIdsPublishedOff = $this->getData(['module', $this->getUrl(0), 'posts', $newsId, 'publishedOff']);
|
||||
if( $newsPublishedOn <= time() AND
|
||||
$newsIdsStates[$newsId] AND
|
||||
if (
|
||||
$newsPublishedOn <= time() and
|
||||
$newsIdsStates[$newsId] and
|
||||
// date de péremption tenant des champs non définis
|
||||
(!is_integer($newsIdsPublishedOff) OR
|
||||
(!is_integer($newsIdsPublishedOff) or
|
||||
$newsIdsPublishedOff > time()
|
||||
)
|
||||
) {
|
||||
@ -473,8 +481,10 @@ 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']) !== -1
|
||||
&& strlen($this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'content'])) >= $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
|
||||
@ -493,14 +503,14 @@ class news extends common {
|
||||
? $this->getData(['module', $this->getUrl(0), 'theme', 'style'])
|
||||
: ''
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la signature d'un utilisateur
|
||||
*/
|
||||
private function signature($userId) {
|
||||
private function signature($userId)
|
||||
{
|
||||
switch ($this->getData(['user', $userId, 'signature'])) {
|
||||
case 1:
|
||||
return $userId;
|
||||
@ -523,10 +533,12 @@ class news extends common {
|
||||
* Mise à jour du module
|
||||
* Appelée par les fonctions index et config
|
||||
*/
|
||||
private function update() {
|
||||
private function update()
|
||||
{
|
||||
|
||||
// le module n'est pas initialisé
|
||||
if ( $this->getData(['module',$this->getUrl(0), 'config']) === NULL
|
||||
if (
|
||||
$this->getData(['module', $this->getUrl(0), 'config']) === NULL
|
||||
|| $this->getData(['module', $this->getUrl(0), 'theme']) === NULL
|
||||
|| !file_exists(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css')
|
||||
) {
|
||||
@ -567,7 +579,8 @@ class news extends common {
|
||||
/**
|
||||
* Initialisation du thème d'un nouveau module
|
||||
*/
|
||||
private function init() {
|
||||
private function init()
|
||||
{
|
||||
|
||||
$fileCSS = self::DATADIRECTORY . $this->getUrl(0) . '/theme.css';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user