1
0

Merge branch 'master' of github.com:agourd/dev-fsociety

This commit is contained in:
Korlan Colas
2015-12-04 05:29:08 +01:00
11 changed files with 165 additions and 77 deletions

@ -11,6 +11,8 @@ use Cake\Event\Event;
class CrisisController extends AppController
{
public $state_t = ['spotted' => 'Signalée', 'verified' => 'Vérifiée', 'over' => 'Terminée'];
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
@ -25,12 +27,28 @@ class CrisisController extends AppController
public function index()
{
$this->paginate = [
'contain' => ['Users']
];
$this->set('crisis', $this->paginate($this->Crisis));
$this->set('state_t', $this->state_t);
$this->set('_serialize', ['crisis']);
}
public function validate($id_crise)
{
$crisis = $this->Crisis->get($id_crise);
$crisis->state = 'verified';
if ($this->Crisis->save($crisis))
{
$this->Flash->success(__('Crise validée !'));
}
else
{
$this->Flash->error(__('Impossible de valider la crise'));
}
return $this->redirect(['action' => 'view', $id_crise]);
}
/**
* View method
*
@ -40,14 +58,18 @@ class CrisisController extends AppController
*/
public function view($id = null)
{
$crisi = $this->Crisis->get($id, [
'contain' => ['Users']
]);
$crisi = $this->Crisis->get($id);
$user = 0;
if($crisi->user_id != 0)
$user = $this->Crisis->Users->get($crisi->user_id);
$infos = $this->Crisis->Infos->find()
->where(['crisis_id' => $id])
->order(['created' => 'DESC']);
$this->set('crisi', $crisi);
$this->set('user', $user);
$this->set('infos', $infos);
$this->set('_serialize', ['crisi']);
}
@ -108,7 +130,7 @@ class CrisisController extends AppController
$crisi = $this->Crisis->patchEntity($crisi, $this->request->data);
if ($this->Crisis->save($crisi)) {
$this->Flash->success(__('La crise a bien été enregistrée.'));
return $this->redirect(['action' => 'index']);
return $this->redirect(['action' => 'view', $id]);
} else {
$this->Flash->error(__('La crise n\'a pas pu être enregistrée.'));
}
@ -192,6 +214,8 @@ class CrisisController extends AppController
return false;
}
}
else if($this->request->action === 'validate' and isset($user))
return true;
//A logged user can delete a crisis
if($this->request->action === 'delete' && $user['id'] > 0)

@ -24,6 +24,9 @@ class HomesController extends AppController
$spottedCrises = $this->Crisis->find()
->contain('Infos')
->where(['state' => 'spotted']);
$home_type = 'none';
if($spottedCrises->count() != 0)
{
$home_type = 'spotted';
@ -32,22 +35,21 @@ class HomesController extends AppController
$verifiedCrises = $this->Crisis->find()
->contain('Infos')
->where(['state' => 'verified']);
if($verifiedCrises->count() != 0)
{
$home_type = 'active';
}
else
{
$home_type = 'none';
}
$newCrisis = $this->Crisis->newEntity();
$newCrisis->state = 'spotted';
$newCrisis->severity = 1;
$newCrisis->user_id = 1;
$articles = $this->Articles->find('all')->limit(5)->order('created');
$newCrisis->state = 'spotted';
$newCrisis->severity = 1;
$articles = $this->Articles->find('all')->limit(5)->order('created');
$this->set(compact('spottedCrises', 'verifiedCrises', 'articles',
'home_type', 'newCrisis'));
}

@ -11,12 +11,14 @@
<?php foreach ($articles as $article): ?>
<div class="articles index medium-4 columns content">
<div class="panel">
<h4 class="subheader"><?= h($article->title) ?><hr></h4>
<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>
<em>Tagged : <?= h($article->category) ?></em>
<em>Catégorie : <?= h($article->category) ?><hr></em>
<?= $this->Html->link(__('Editer'), ['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)]) ?>
</div>
</div>
<?php endforeach; ?>

@ -1,31 +1,14 @@
<nav class="large-3 medium-4 columns" id="actions-sidebar">
<ul class="side-nav">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Form->postLink(
__('Supprimer la crise'),
['action' => 'delete', $crisi->id],
['confirm' => __('Êtes-vous sûr de vouloir supprimer la crise #{0} ?', $crisi->id)]
)
?></li>
<li><?= $this->Html->link(__('Liste des crises'), ['action' => 'index']) ?></li>
</ul>
</nav>
<div class="crisis form large-9 medium-8 columns content">
<div class="crisis form large-12 medium-12 columns content">
<?= $this->Form->create($crisi) ?>
<fieldset>
<legend><?= __('Éditer la crise') ?></legend>
<?php
echo $this->Form->input('abstract', ['label' => 'Résumé']);
echo $this->Form->input('severity', ['label' => 'Gravité']);
echo $this->Form->input('longitude', ['label' => 'Longitude']);
echo $this->Form->input('latitude', ['label' => 'Latitude']);
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('user_id', ['options' => $users, 'label' => 'ID utilisateur']);
?>
</fieldset>
<?= $this->Form->button(__('Soumettre')) ?>
<?= $this->Form->button(__('Mettre à jour')) ?>
<?= $this->Form->end() ?>
</div>

@ -1,38 +1,22 @@
<nav class="large-3 medium-3 columns" id="actions-sidebar">
<ul class="side-nav">
<li class="heading"><?= __('Actions') ?></li>
<li><?= $this->Html->link(__('Nouvelle crise'), ['action' => 'add']) ?></li>
</ul>
</nav>
<div class="crisis index large-9 medium-9 columns content">
<h3 style="margin-top: 20px; margin-bottom: 20px;"><?= __('Crisis') ?></h3>
<div class="crisis index large-12 medium-12 columns content">
<h3 style="margin-top: 20px; margin-bottom: 20px;"><?= __('Consulter toutes les crises recensée') ?></h3>
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th><?= $this->Paginator->sort('id') ?></th>
<th><?= $this->Paginator->sort('abstract') ?></th>
<th><?= $this->Paginator->sort('severity') ?></th>
<th><?= $this->Paginator->sort('longitude') ?></th>
<th><?= $this->Paginator->sort('latitude') ?></th>
<th><?= $this->Paginator->sort('state') ?></th>
<th><?= $this->Paginator->sort('address') ?></th>
<th class="actions"><?= __('Actions') ?></th>
<th><?= $this->Paginator->sort('abstract', 'Résumé') ?></th>
<th><?= $this->Paginator->sort('state', 'État') ?></th>
<th><?= $this->Paginator->sort('address', 'Lieu') ?></th>
<th class="actions"><?= __('Détails') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($crisis as $crisi): ?>
<tr>
<td><?= $this->Number->format($crisi->id) ?></td>
<td><?= h($crisi->abstract) ?></td>
<td><?= $this->Number->format($crisi->severity) ?></td>
<td><?= $this->Number->format($crisi->longitude) ?></td>
<td><?= $this->Number->format($crisi->latitude) ?></td>
<td><?= h($crisi->state) ?></td>
<td><?= $state_t[$crisi->state] ?></td>
<td><?= h($crisi->address) ?></td>
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $crisi->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $crisi->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $crisi->id], ['confirm' => __('Êtes-vous sûr de vouloir supprimer la crise # {0}?', $crisi->id)]) ?>
<?= $this->Html->link(__('Voir le détail'), ['action' => 'view', $crisi->id]) ?>
</td>
</tr>
<?php endforeach; ?>
@ -40,9 +24,9 @@
</table>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->prev('< ' . __('previous')) ?>
<?= $this->Paginator->prev('< ' . __('précédent')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next(__('next') . ' >') ?>
<?= $this->Paginator->next(__('suivant') . ' >') ?>
</ul>
<p><?= $this->Paginator->counter() ?></p>
</div>

@ -21,29 +21,34 @@
<div class="row">
<div class="large-8 columns">
<p><strong>Créé le : </strong><?= h($crisi->created) ?></br></br>
<strong>Description : </strong><?= h($crisi->abstract) ?>
</p>
<div class="row">
<div class="medium-6 column">
<?= $this->Html->link(__('Editer la crise'), ['controller' => 'Crisis', 'action' => 'edit', $crisi->id], array('class' => 'small expanded button alert', 'style' => 'width: 100%;')) ?>
</div>
<div class="medium-6 column">
<p><strong>Créé le : </strong><?= h($crisi->created) ?></br></br>
<strong>Description : </strong><?= h($crisi->abstract) ?>
</p>
</div>
</div>
<br>
<?php if (!($crisi->infos==NULL)): ?>
<h4>Informations à propos de cette crise :</h4>
<?php endif;
<?php
foreach($infos as $info): ?>
<div class="panel">
<h4 class="hide-for-small"><?= $info->title ?><hr></h4>
<h5 class="subheader"><?= $info->body ?></h5>
<em>Tagged : <?= $info->type ?></em>
<div class="panel information_panel">
<h5 class="hide-for-small"><?= $info->title ?>
<span class="label label_right"><?= $info->type ?></span>
<hr class="small_hr"></h5>
<p class="subheader"><?= $info->body ?></p>
</div>
<?php endforeach; ?>
<h4>Chattez avec les autres utilisateurs :</h4>
<h4>Parlez-en :</h4>
<script src="//cdn.temasys.com.sg/skylink/skylinkjs/0.6.x/skylink.complete.min.js"></script>
<script type="text/javascript">
@ -121,9 +126,7 @@ function addMessage(message, className) {
<div id="logingroup">
<input type="text" id="name" placeholder="Votre nom" autofocus>
<a class="small button" onclick="setName()">Changer de nom</a>
<a class="small button" onclick="joinRoom()">Rejoindre le Salon</a>
<a class="small button" onclick="setName(); joinRoom();">Rejoindre le Salon</a>
</div>
<div id="chatgroup">
@ -169,6 +172,12 @@ function addMessage(message, className) {
</div>
<div class="large-4 columns">
<?php if($crisi->state == 'spotted' && $this->request->session()->read('Auth.User.id')): ?>
<?= $this->Html->link(__('Valider cette crise'), ['controller' => 'Crisis', 'action' => 'validate', $crisi->id], array('class' => 'small expanded button alert', 'style' => 'width: 100%;'))?>
<?php endif; ?>
<?php if($crisi->state != 'over' && $this->request->session()->read('Auth.User.id')): ?>
<?= $this->Html->link(__('Ajouter des informations à cette crise'), ['controller' => 'Infos', 'action' => 'add', $crisi->id], array('class' => 'small expanded button alert', 'style' => 'width: 100%;', 'target' => '_blank'))

@ -19,7 +19,7 @@
<div class="row">
<?php $home_type='active' ?>
<?php if ($home_type != 'none') { ?>
<?php if ($home_type == 'active') { ?>
@ -189,7 +189,79 @@
<?php } else { ?>
<?php }?>
<h2>Il n'y a pas d'évènements majeurs actuellement ! </h2>
<a title="Créer une crise" href="/crisis/add"></a>
<table class="body">
<tr>
<td class="center" align="center" valign="top">
<center>
<table class="container">
<tr>
<td>
<table class="row" dir="rtl">
<tr>
<td class="wrapper" dir="ltr">
<table class="four columns" >
<tr>
<td class="center" align="center">
<center>
</center>
</td>
<td class="expander"></td>
</tr>
</table>
</td>
<td class="wrapper last" dir="ltr">
<table class="eight columns">
<tr>
<td>
<p></p>
</td>
<td class="expander"></td>
</tr>
</table>
</td>
</tr>
</table>
<table class="row">
<tr>
<td class="wrapper">
<table class="four columns" >
<tr>
<td class="center" align="center">
<center>
</center>
</td>
<td class="expander"></td>
</tr>
</table>
</td>
<td class="wrapper last">
<table class="eight columns">
<tr>
<td>
<p>
<?= $articlesTableau = $articles->toArray(); ?>
<?= $idArticle = rand() % ($articles->count() + 1); ?>
<?= $this->Html->link(__($articlesTableau[$idArticle]), '/articles/view/{0}', $idArticle); ?>
</p>
</td>
<td class="expander"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</td>
</tr>
</table>
<?php }?>
</div>

@ -67,7 +67,6 @@
<li><?= $this->Html->link(__('Articles'), ['controller'=>'Articles', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('Crisis'), ['controller'=>'Crisis', 'action' => 'index']) ?></li>
<li class="topbar-separator"><?= $this->Html->link(__('Infos'), ['controller'=>'Infos', 'action' => 'index']) ?></li>
<li class="topbar-separator"><?= $this->Html->link(__('User'), ['controller'=>'Users', 'action' => 'index']) ?></li>
<?php if($this->request->session()->read("Auth.User")): ?>
<li><?= $this->Html->link(__('Log out'), ['controller'=>'Users', 'action' => 'logout']) ?></li>

@ -38,4 +38,17 @@
#chatgroup{
display: none;
}
.small_hr{
margin: 0.5em 0!important;
}
.label_right{
float: right;
}
.information_panel{
border-color: #f9f9f9;
background: #F4F4F4;
}

BIN
webroot/img/crisisflag.png Normal file

Binary file not shown.

After

(image error) Size: 25 KiB

BIN
webroot/img/crisisflag.psd Normal file

Binary file not shown.