Skip to content

Commit

Permalink
Merge 9ca0245 into 0f34142
Browse files Browse the repository at this point in the history
  • Loading branch information
willkoua committed May 13, 2016
2 parents 0f34142 + 9ca0245 commit 58907f7
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 30 deletions.
38 changes: 27 additions & 11 deletions src/Controller/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ public function home()
);
$numberMissions = count($missions->toArray());

$fichiers = $this->_getImgCarousel();
$path = WWW_ROOT . "img/carousel/";
$fichiers = $this->_getImgagesDir($path);

$this->set(compact('numberUsers', 'numberProjects', 'numberMissions', 'numberStudents', 'fichiers'));
}
Expand Down Expand Up @@ -561,43 +562,58 @@ public function administration($img = null)
$organizations = $this->Organizations->find('all', ['conditions' => ['isValidated' => 0, 'isRejected' => 0]])->toArray();

//gestion des images du carousel
$path = WWW_ROOT . "img/carousel/";
$pathCar = WWW_ROOT . "img/carousel/";
$pathTV = WWW_ROOT . "img/tv/";

$request = $this->request;

if (is_file($path . $img)) {
unlink($path . $img);
if (is_file($pathCar . $img)) {
unlink($pathCar . $img);
}
if ($request->is('post') && !empty($request->data)) {
$image = $this->request->data['avatar_file'];
$hidden = $this->request->data('hidden');
$fileName = $image['name'];
$dim = null;

if (!empty($image['tmp_name']) && $image['type'] == 'image/png') {
$dim = getimagesize($image['tmp_name']);

if ($dim[0] >= 1920 && $dim[1] >= 1080) {
move_uploaded_file($image['tmp_name'], $path . $image['name']);
if ($hidden == 'car') {
move_uploaded_file($image['tmp_name'], $pathCar . $fileName);
}

if ($hidden == 'tv' ) {
if (preg_match("#tv[1-5]#", $fileName)) {
move_uploaded_file($image['tmp_name'], $pathTV . $fileName);
} else {
$this->Flash->error('Renommer le fichier par tv[le numero de la tv]', ['key' => 'er_tv']);
}
}
} else {
$this->Flash->error('Erreur: fichier trop petit');
$this->Flash->error('Fichier trop petit', 'er_gene');
}
} else {
$this->Flash->error('Erreur: vérifier les conditions de tranfert de fichier');
$this->Flash->error('Vérifier les conditions de tranfert de fichier', 'er_gene');
}
}
//fin gestion du carousel
$fichiers = $this->_getImgCarousel();
$this->set(compact('projects', 'organizations', 'fichiers'));
$filesCar = $this->_getImgagesDir($pathCar);
$filesTV = $this->_getImgagesDir($pathTV);
$this->set(compact('projects', 'organizations', 'filesCar', 'filesTV'));
}

/**
* GetImgCarousel method
*
* @return array
*/
private function _getImgCarousel()
private function _getImgagesDir($path)
{
$fichiers = [];

if (false !== ($dossier = opendir(WWW_ROOT . "img/carousel/"))) {
if (false !== ($dossier = opendir($path))) {
while (false !== ($fichier = readdir($dossier))) {
if ($fichier != '.' && $fichier != '..' && $fichier != 'index.php') {
array_push($fichiers, $fichier);
Expand Down
91 changes: 72 additions & 19 deletions src/Template/Pages/administration.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
</div>
</div>
</div>

</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
Expand Down Expand Up @@ -62,41 +61,95 @@
<a class="btn btn-info pull-right" href="<?= $this->Url->build(['controller' => 'Organizations', 'action' => 'add']);?>"><?= __('Add organization');?></a>
</div>
</div>


</div>

<div class="col-lg-6 col-xs-12">
<div class="col-lg-6 col-xs-12 hidden-xs">
<div class="panel panel-default">
<div class="panel-body">
<h3 class="header-title">Carousel</h3>

<div class="row">
<div class="row">
<div class="col-lg-12 col-md-12">

<?php foreach ($filesCar as $fichier):?>
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="<?= $this->request->webroot . "img/carousel/". $fichier ?>" />
<div class="caption">
<p><a href="<?= "/pages/administration/".$fichier ?>" class="" ><i class="glyphicon glyphicon-trash"></i></a></p>
</div>
</div>
</div>
<?php endforeach; ?>

</div>

<div class="col-lg-12 col-md-12">
<div class='col-lg-5 col-lg-offset-2'>
<h4>Enregistrer une image</h4>

<?= $this->Flash->render('er_gene'); ?>
<?= $this->Form->create('image', array('type'=>'file')); ?>
<ul>
<li>format png</li>
<li>taille minimale (1920 x 1080)</li>
</ul>

<?= $this->Form->hidden('hidden', ['value' => 'car']); ?>
<?= $this->Form->input('avatar_file', array('label' => 'Envoyer votre image',
'type' => 'file')); ?>

<?= $this->Form->button('Envoyé'); ?>
<?= $this->Form->end(); ?>
</div>

</div>
</div>

</div>
</div>
</div>
<div class="col-lg-6 col-xs-12 hidden-xs">
<div class="panel panel-default">
<div class="panel-body">
<h3 class="header-title">TV</h3>

<div class="row">
<div class="col-lg-12 col-md-12">

<?php foreach ($fichiers as $fichier):?>
<div class="col-md-4 thumb">
<a class="thumbnail" href="<?= "/webroot/img/carousel/". $fichier ?>">
<img class="img-responsive" src="<?= "/webroot/img/carousel/". $fichier ?>" alt="">
</a>
<div class="controller">
<a href="<?= "/pages/administration/".$fichier ?>" class="" >
<i class="glyphicon glyphicon-trash"></i>
</a>
<?php
$i = 0;
foreach ($filesTV as $fichier):
$i++;
?>
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="<?= $this->request->webroot . "img/tv/". $fichier ?>" />
<div class="caption">
<p><?= "tv".$i ?></p>
</div>
</div>
</div>
</div>
<?php endforeach; ?>

</div>

<div class="row">
<div class="col-lg-12 col-md-12">
<div class='col-lg-5 col-lg-offset-2'>
<h4>Enregistrer une image</h4>

<?= $this->Flash->render(); ?>
<?= $this->Flash->render('er_tv'); ?>
<?= $this->Flash->render('er_gene'); ?>
<?= $this->Form->create('image', array('type'=>'file')); ?>
<ul>
<li>format png</li>
<li>taille minimale (1920 x 1080)</li>
</ul>
<ul>
<li>Format png</li>
<li>Exemple de nom de fichier: tv1.png</li>
<li>Taille minimale (1920 x 1080)</li>
</ul>

<?= $this->Form->hidden('hidden', ['value' => 'tv']); ?>
<?= $this->Form->input('avatar_file', array('label' => 'Envoyer votre image',
'type' => 'file')); ?>

Expand Down
Binary file modified webroot/img/tv/tv5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 58907f7

Please sign in to comment.