1
0

Add placeholder for hashtag + fix some display problems + add some translation + add link to article on home page + add static counter to avoid same articles displayed two times + some truncate instead of strlen() + categories Articles + remove categories of articles on home page

This commit is contained in:
HorlogeSkynet 2015-12-04 19:16:35 +01:00
parent 22d0bd6548
commit 167b1d7b1a
16 changed files with 86 additions and 95 deletions

@ -10,6 +10,7 @@ use Cake\Event\Event;
*/
class ArticlesController extends AppController
{
public $categories = ['articlePresse' => 'Article de presse', 'news' => 'Nouveautés', 'edito' => 'Éditorial', 'conseil' => 'Conseil'];
/**
* beforeFilter method
@ -35,6 +36,7 @@ class ArticlesController extends AppController
];
$this->set('articles', $this->paginate($this->Articles));
$this->set('_serialize', ['articles']);
$this->set('categories', $this->categories);
}
/**
@ -51,6 +53,7 @@ class ArticlesController extends AppController
]);
$this->set('article', $article);
$this->set('_serialize', ['article']);
$this->set('categories', $this->categories);
}
/**
@ -76,6 +79,7 @@ class ArticlesController extends AppController
}
$this->set(compact('article', 'users'));
$this->set('_serialize', ['article']);
$this->set('categories', $this->categories);
}
/**
@ -102,6 +106,7 @@ class ArticlesController extends AppController
$users = $this->Articles->Users->find('list', ['limit' => 200]);
$this->set(compact('article', 'users'));
$this->set('_serialize', ['article']);
$this->set('categories', $this->categories);
}
/**

@ -23,7 +23,7 @@ class CrisisController extends AppController
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->Auth->allow(['add','view','index','test','severityIncrement','severityDecrement']);
$this->Auth->allow(['add', 'view', 'index', 'test', 'severityIncrement', 'severityDecrement']);
}
/**
@ -50,7 +50,7 @@ class CrisisController extends AppController
}
else
{
$this->Flash->error(__('Impossible de valider la crise'));
$this->Flash->error(__('Impossible de valider la crise.'));
}
return $this->redirect(['action' => 'view', $id_crise]);
@ -66,7 +66,7 @@ class CrisisController extends AppController
}
else
{
$this->Flash->error(__('Impossible de terminer la crise'));
$this->Flash->error(__('Impossible de terminer la crise.'));
}
return $this->redirect(['action' => 'view', $id_crise]);
@ -118,7 +118,7 @@ class CrisisController extends AppController
&& abs($crisi_db['latitude'] - $crisi['latitude'] ) < $delta_search ) { //1° lat/long-> 111 km
$crisi_db->severity += 1;
$this->Crisis->save($crisi_db);
$this->Flash->success('Crisis Already notified so we are incrementing severity..');
$this->Flash->success('Cette crise a déjà été signalée, nous incrémentons sa gravité.');
return $this->redirect(['controller' => 'Homes', 'action' => 'index']);
}
}
@ -134,9 +134,6 @@ class CrisisController extends AppController
return $this->redirect(['controller' => 'Homes', 'action' => 'index']);
}
/*$users = $this->Crisis->Users->find('list', ['limit' => 200]);
$this->set(compact('crisi', 'users'));
$this->set('_serialize', ['crisi']);*/
}
/**
@ -197,9 +194,9 @@ class CrisisController extends AppController
$crisi = $this->Crisis->get($id);
$crisi->severity += 1;
if ($this->Crisis->save($crisi)) {
$this->Flash->success(__('Thanks for the information'));
$this->Flash->success(__('Merci pour l\'information.'));
} else {
$this->Flash->error(__('Sorry there was an error'));
$this->Flash->error(__('Désolé, nous avons rencontré une erreur...'));
}
return $this->redirect(['action' => 'view',$crisi->id]);
}
@ -216,9 +213,9 @@ class CrisisController extends AppController
$crisi = $this->Crisis->get($id);
$crisi->severity -= 1;
if ($this->Crisis->save($crisi)) {
$this->Flash->success(__('Thanks for the information'));
$this->Flash->success(__('Merci pour l\'information.'));
} else {
$this->Flash->error(__('Sorry there was an error'));
$this->Flash->error(__('Désolé, nous avons rencontré une erreur...'));
}
return $this->redirect(['action' => 'view',$crisi->id]);
}
@ -237,7 +234,7 @@ class CrisisController extends AppController
&& abs($crisi_db['latitude'] - $crisi['latitude'] ) < $delta_search ) { //1° lat/long-> 111 km
$crisi_db->severity += 1;
$this->Crisis->save($crisi_db);
$this->Flash->success('Crisis Already notified - Increment severity..');
$this->Flash->success('Cette crise a déjà été signalée, nous incrémentons sa gravité.');
}
}
@ -277,13 +274,11 @@ class CrisisController extends AppController
return false;
}
}
else if(($this->request->action === 'validate' || $this->request->action === 'terminate') and isset($user))
return true;
//A logged user can delete a crisis
if($this->request->action === 'delete' && $user['id'] > 0)
//A logged user can delete, validate or terminate a crisis
else if(($this->request->action === 'delete' || $this->request->action === 'validate' || $this->request->action === 'terminate') && isset($user))
{
return true;
return true;
}
return parent::isAuthorized($user);

@ -62,10 +62,10 @@ class InfosController extends AppController
$info->user_id = $user_id;
$info = $this->Infos->patchEntity($info, $this->request->data);
if ($this->Infos->save($info)) {
$this->Flash->success(__('L\information a bien été enregistrée.'));
$this->Flash->success(__('L\'information a bien été enregistrée.'));
return $this->redirect(['controller' => 'crisis', 'action' => 'view', $crisis_id]);
} else {
$this->Flash->error(__('L\information n\'a pas pu être enregistrée.'));
$this->Flash->error(__('L\'information n\'a pas pu être enregistrée.'));
}
}
$Crisis = $this->Infos->Crisis->find('list', ['limit' => 200]);
@ -95,10 +95,10 @@ class InfosController extends AppController
if ($this->request->is(['patch', 'post', 'put'])) {
$info = $this->Infos->patchEntity($info, $this->request->data);
if ($this->Infos->save($info)) {
$this->Flash->success(__('L\information a bien été enregistrée.'));
$this->Flash->success(__('L\'information a bien été enregistrée.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('L\information n\'a pas pu être enregistrée.'));
$this->Flash->error(__('L\'information n\'a pas pu être enregistrée.'));
}
}
$Crisis = $this->Infos->Crisis->find('list', ['limit' => 200]);
@ -121,7 +121,7 @@ class InfosController extends AppController
if ($this->Infos->delete($info)) {
$this->Flash->success(__('L\'information a bien été supprimée.'));
} else {
$this->Flash->error(__('L\information n\'a pas pu être supprimée.'));
$this->Flash->error(__('L\'information n\'a pas pu être supprimée.'));
}
return $this->redirect(['action' => 'index']);
}

@ -27,9 +27,7 @@ class UsersController extends AppController
if(in_array($this->request->action, ['edit', 'delete']))
{
$userId = (int)$this->request->params['pass'][0];
if($userId === $user['id'])
if((int)$this->request->params['pass'][0] === $user['id'])
{
return true;
}
@ -41,11 +39,13 @@ class UsersController extends AppController
if ($this->request->is('post'))
{
$user = $this->Auth->identify();
if ($user)
if($user)
{
$this->Auth->setUser($user);
return $this->redirect($this->Auth->redirectUrl());
}
$this->Flash->error(__('Identifiant et / ou mot de passe incorrect(s).'));
}
}

@ -14,7 +14,6 @@ use Cake\Validation\Validator;
*/
class ArticlesTable extends Table
{
/**
* Initialize method
*

@ -12,7 +12,7 @@
echo $this->Form->input('title', ['label' => 'Titre de l\'article :']);
echo $this->Form->input('body', ['label' => 'Corps du texte :']);
echo "<br>";
echo $this->Form->input('category', ['label' => 'Catégorie :']);
echo $this->Form->input('category', array('type' => 'select', 'options' => $categories, 'label' => 'Catégorie'));
?>
</fieldset>
<?= $this->Form->button(__('Soumettre')) ?>

@ -16,10 +16,8 @@
<legend><?= __('Éditer l\'article') ?></legend>
<?php
echo $this->Form->input('title', ['label' => 'Titre de l\'article']);
echo $this->Form->input('body', ['label' => 'Corps du texte']);
// echo $this->Form->input('user_id', ['options' => $users, 'label' => 'Utilisateur']);
echo "<br />";
echo $this->Form->input('category', ['label' => 'Catégorie']);
echo $this->Form->input('body', ['label' => 'Corps du texte']); echo "<br />";
echo $this->Form->input('category', array('type' => 'select', 'options' => $categories, 'label' => 'Catégorie'));
?>
</fieldset>
<?= $this->Form->button(__('Soumettre')) ?>

@ -18,15 +18,14 @@
<div class="articles index medium-4 columns content">
<div class="panel">
<h4 class="subheader"><?= $this->Html->link(__($article->title), ['action' => 'view', $article->id]) ?><hr></h4>
<h5 class="subheader"><?php $string = $article->body;
$string = (strlen($string) > 50) ? substr($string,0,50).' (...)' : $string; echo $string
?>
<h5 class="subheader">
<?php $this->Text->truncate($article->body, 50); ?>
</h5>
<em>Catégorie : <?= h($article->category) ?><hr></em>
<em>Catégorie : <?= h($categories[$article->category]) ?><hr></em>
<?php if($this->request->session()->read('Auth.User.id')): ?>
<?= $this->Html->link(__('Editer'), ['action' => 'edit', $article->id], array('class' => 'button secondary radius', 'style' => 'width: 49%;')) ?>
<?= $this->Html->link(__('Éditer'), ['action' => 'edit', $article->id], array('class' => 'button secondary radius', 'style' => 'width: 49%;')) ?>
<?= $this->Form->postLink(__('Supprimer'), ['action' => 'delete', $article->id], array('class' => 'button secondary radius', 'style' => 'width: 49%;'), ['confirm' => __('Êtes-vous sûr de vouloir supprimer l\'article #{0} ?', $article->id)]) ?>
<?php endif; ?>

@ -14,7 +14,7 @@
<h3 style="text-align: center;"><?= __($article->title) ?></h3>
</div>
<div class="panel panel_shadow">
<h7 style="font-size: 80%" class="subheader">Catégorie : <?= h($article->category) ?><hr></h7>
<h7 style="font-size: 80%" class="subheader">Catégorie : <?= h($categories[$article->category]) ?><hr></h7>
<h5 class="subheader"><?= __($article->body) ?></h5>
</div>
</div>

@ -16,7 +16,7 @@
echo $this->Form->input('state', ['options' => ['spotted' => 'Spotted', 'verified' => 'Verified', 'over' => 'Over'], 'label' => 'État']);
echo $this->Form->input('address', ['label' => 'Adresse']);
echo $this->Form->input('type', ['label' => 'Type']);
echo $this->Form->input('hashtags', ['label' => 'Hashtags']);
echo $this->Form->input('hashtags', ['label' => 'Hashtags', 'placeholder' => '#']);
echo $this->Form->input('user_id', ['options' => $users, 'label' => 'ID utilisateur']);
?>
</fieldset>

@ -6,7 +6,7 @@
<?php
echo $this->Form->input('abstract', ['label' => 'Résumé']);
echo $this->Form->input('type', array('type'=>'select', 'options'=>$categories, 'label'=>false, 'empty'=>'Categorie'));
echo $this->Form->input('hashtags', ['label' => 'Hashtags']);
echo $this->Form->input('hashtags', ['label' => 'Hashtags', 'placeholder' => '#']);
?>
</fieldset>
<?= $this->Form->button(__('Mettre à jour')) ?>

@ -1,6 +1,6 @@
<div class="row">
<div class="crisis index large-12 medium-12 columns content">
<h3 style="margin-top: 20px; margin-bottom: 20px; text-align: center"><?= __('Consulter toutes les crises recensées') ?></h3>
<h3 style="margin-top: 20px; margin-bottom: 20px; text-align: center"><?= __('Liste des crises recensées jusqu\'à aujourd\'hui:') ?></h3>
<table cellpadding="0" cellspacing="0" style="margin: 0px auto;" >
<thead>
<tr>

@ -31,7 +31,7 @@
<?php if($crisi->state === 'spotted' || ($this->request->session()->read('Auth.User.id') && $crisi->state) === 'verified'): ?>
<?= $this->Html->link(__('Editer la crise'), ['controller' => 'Crisis', 'action' => 'edit', $crisi->id], array('class' => 'small expanded button alert', 'style' => 'width: 100%;')) ?><br>
<?= $this->Html->link(__('Éditer la crise'), ['controller' => 'Crisis', 'action' => 'edit', $crisi->id], array('class' => 'small expanded button alert', 'style' => 'width: 100%;')) ?><br>
<?php endif; ?>

@ -22,7 +22,7 @@
<?php if ($home_type == 'active') {
$frontCrisis=$verifiedCrises->first();
echo "<div class='medium-12 column text-center'>";
echo "<h2>Crise confirmée en cours!</h2>";
echo "<h2>Crise confirmée actuelle !</h2>";
echo "</div>";
} else if ($home_type=='spotted') {
@ -95,9 +95,11 @@
<span class="small crisis-panel-state subheader"><?= $categories[$crisis->type] ?></span>
<span class="small crisis-panel-state subheader spotted-state"><?= $crisis->state ?></span>
<br/>
<span class="small crisis-panel-abstract"><?php
$string = $crisis->abstract;
$string = (strlen($string) > 64) ? substr($string,0,64).'...' : $string; echo $string ?></span>
<span class="small crisis-panel-abstract">
<?php
$this->Text->truncate($crisis->abstract, 64);
?>
</span>
<br/>
<div class="small button-group">
<?= $this->Form->postLink(__('Yes'), ['controller' => 'Crisis','action' => 'severityIncrement', $crisis->id], ['class' => ' fi-arrow-up medium Success ']) ?>
@ -133,9 +135,11 @@
<span class="small crisis-panel-state subheader"><?= $categories[$crisis->type] ?></span>
<span class="small crisis-panel-state subheader verified-state"><?= $crisis->state ?></span>
<br/>
<span class="small crisis-panel-abstract"><?php
$string = $crisis->abstract;
$string = (strlen($string) > 64) ? substr($string,0,64).'...' : $string; echo $string ?></span>
<span class="small crisis-panel-abstract">
<?php
$this->Text->truncate($crisis->abstract, 64);
?>
</span>
<br/>
<div class="small button-group">
<?= $this->Form->postLink(__('Yes'), ['controller' => 'Crisis','action' => 'severityIncrement', $crisis->id], ['class' => ' fi-arrow-up medium Success ']) ?>
@ -188,70 +192,67 @@
<div class="row">
<div class="row text-center">
<h2>Il n'y a pas d'évènements majeurs actuellement ! </h2>
<h2><br>Il n'y a pas d'évènement majeur actuellement !</h2>
</div>
<div class="row">
<h3 style="margin-top: 20px; margin-bottom: 30px; text-align: center;"><?= __('Articles') ?></h3>
<?php $count = 0;?>
<?php foreach ($articles as $article): ?>
<h3 style="margin-top: 20px; margin-bottom: 30px; text-align: center;"><?= __('Nous vous proposons de jeter un coup d\'œil à nos articles de sensibilisation:') ?></h3>
<?php if($count == 2) break; ?>
<?php if($articles->count() != 0) : ?>
<div class="articles index small-12 medium-6 large-4 columns content">
<div class="panel ">
<h4 class="home-article title">
<?= $articles->toArray()[0]->title; ?>
<?= $this->Html->link(__($articles->toArray()[0]->title), ['controller' => 'articles', 'action' => 'view', $articles->toArray()[0]->id]); ?>
</h4>
<h5 class="home-article category subheader">
<?= $articles->toArray()[0]->created; ?>
in
<?= $articles->toArray()[0]->category; ?>
</h5>
<p class="home-article content">
<?= $this->Text->truncate($articles->toArray()[0]->body,590); ?>
</p>
</div>
</div>
<?php $count += 1; ?>
<?php endforeach; ?>
<div class="articles index small-12 medium-6 large-4 columns content">
<div class="panel">
<h4 class="home-article title">
<?= $articles->toArray()[1]->title; ?>
</h4>
<h5 class="home-article category subheader">
<?= $articles->toArray()[1]->created; ?>
in
<?= $articles->toArray()[1]->category; ?>
</h5>
<p class="home-article content">
<?= $this->Text->truncate($articles->toArray()[1]->body,590); ?>
<?= $this->Text->truncate($articles->toArray()[0]->body, 590); ?>
</p>
</div>
</div>
<?php endif; if($articles->count() > 1) :?>
<div class="articles index small-12 medium-6 large-4 columns content">
<div class="panel">
<h4 class="home-article title">
<?= $this->Html->link(__($articles->toArray()[1]->title), ['controller' => 'articles', 'action' => 'view', $articles->toArray()[1]->id]); ?>
</h4>
<h5 class="home-article category subheader">
<?= $articles->toArray()[1]->created; ?>
</h5>
<p class="home-article content">
<?= $this->Text->truncate($articles->toArray()[1]->body, 590); ?>
</p>
</div>
</div>
<?php endif; ?>
<div class="small-12 medium-6 large-4 columns text-center submit-form">
<?= $this->Form->create($newCrisis, ['url' => ['controller' => 'Crisis', 'action' => 'add'], 'method' => 'post']); ?>
<fieldset>
<legend><?= __('Submit crisis') ?></legend>
<legend><?= __('Soumettre une crise') ?></legend>
<!-- Hidden fields-->
<?php echo $this->Form->hidden('severity');
echo $this->Form->hidden('longitude');
echo $this->Form->hidden('latitude');
echo $this->Form->hidden('state');
?>
<?= $this->Form->input('abstract'); ?>
<label class='form-label'>Location:</label>
<?php $types = array('auto' => 'Auto-detect', 'manual' => 'Manual entry');
$attributes = array( 'legend' => false,'label' => true,'class' => 'radio-loc', 'value'=>'auto');
echo $this->Form->radio('type', $types, $attributes);
<?= $this->Form->input('abstract', ['label' => 'En quelques mots...']); ?>
<label class='form-label'>Localisation:</label>
<?php $types = array('auto' => 'Auto-détection', 'manual' => 'Renseignement manuel');
$attributes = array( 'legend' => false,'label' => true,'class' => 'radio-loc', 'value'=>'auto');
echo $this->Form->radio('type', $types, $attributes);
?>
<a id="geolocate" class="button" ><i class="fi-arrow-right large"></i> GeoMe</a>
<?= $this->Form->input('address'); ?>
<?php $types = array('1' => 'Séisme', '2' => 'Zombies'); ?>
<?= $this->Form->input('address', ['label' => 'Adresse']); ?>
<?php $types = array('1' => 'Séisme', '2' => 'Zombies'); ?>
<?= $this->Form->input('type', array('type'=>'select', 'options'=>$types, 'label'=>false, 'empty'=>'Category')); ?>
<?= $this->Form->input('hashtags'); ?>
<?= $this->Form->input('hashtags', ['label' => 'Hashtags', 'placeholder' => '#']); ?>
</fieldset>
<div class="small button-group">
<?= $this->Form->button(__('Submit')) ?>
@ -266,18 +267,16 @@
<div class="row">
<div class="small-12 medium-12 large-12 columns">
<?php foreach($articles as $article): ?>
<?php $_k = -1; foreach($articles as $article): $_k++; if($_k < 2) : continue; endif; ?>
<div class="panel ">
<h4 class="home-article title">
<?= $article->title; ?>
<?= $this->Html->link(__($article->title), ['controller' => 'articles', 'action' => 'view', $article->id]); ?>
</h4>
<h5 class="home-article category subheader">
<?= $article->created; ?>
in
<?= $article->category; ?>
</h5>
<p class="home-article content">
<?= $this->Text->truncate($article->body,256); ?>
<?= $this->Text->truncate($article->body, 256); ?>
</p>
</div>
<?php endforeach;?>

@ -20,7 +20,7 @@
<?= $this->Html->charset() ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
<?= 'Suivie de crise - ' . $this->fetch('title') ?>
<?= 'CrisisFlag - ' . $this->fetch('title') ?>
</title>
<?= $this->Html->meta('icon') ?>
@ -66,8 +66,8 @@
<ul class="off-canvas-list">
<li><label>Menu</label></li>
<li class="topbar-separator"><?= $this->Html->link(__('Accueil'), '/') ?></li>
<li><?= $this->Html->link(__('Les articles'), ['controller'=>'Articles', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('Les crises'), ['controller'=>'Crisis', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('Les articles'), ['controller'=>'Articles', 'action' => 'index']) ?></li>
<li class="topbar-separator"><?= $this->Html->link(__('Utilisateurs'), ['controller'=>'Users', 'action' => 'index']) ?></li>
<?php if($this->request->session()->read("Auth.User")): ?>
<li><?= $this->Html->link(__('Se déconnecter'), ['controller'=>'Users', 'action' => 'logout']) ?></li>
@ -92,10 +92,6 @@
<div class="small-12 columns">
<p><?php echo $this->Html->image('devfsociety.svg', array('alt' => 'CakePHP', 'class' => 'footer-logo'));?></p>
<p class="links">
<a href="http://book.cakephp.org/3.0/">Documentation</a>
<a href="http://api.cakephp.org/3.0/">API</a>
</p>
<p class="copywrite">Fsociety all rights reserved © 2015</p>
</div>

Binary file not shown.

Before

Width: 32px  |  Height: 32px  |  Size: 1.7 KiB

After

Width: 256px  |  Height: 256px  |  Size: 361 KiB