Skip to content

Commit

Permalink
Merge e3e93ee into 7fb0026
Browse files Browse the repository at this point in the history
  • Loading branch information
willkoua committed May 3, 2016
2 parents 7fb0026 + e3e93ee commit 9181b94
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 32 deletions.
2 changes: 1 addition & 1 deletion config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
$routes->connect('/tv/*', ['controller' => 'Pages', 'action' => 'tv']);
$routes->connect('/pages/tv/*', ['controller' => 'Pages', 'action' => 'tv']);
$routes->connect('/pages/statistics', ['controller' => 'Pages', 'action' => 'statistics']);
$routes->connect('/pages/administration', ['controller' => 'Pages', 'action' => 'administration']);
$routes->connect('/pages/administration/*', ['controller' => 'Pages', 'action' => 'administration']);

/**
* ...and connect the rest of 'Pages' controller's URLs.
Expand Down
69 changes: 65 additions & 4 deletions src/Controller/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
class PagesController extends AppController
{
const PATH_CAROUSEL = "../webroot/img/carousel/";

/**
* Check if the user has the rights to see the page
*
Expand All @@ -39,7 +41,9 @@ public function isAuthorized($user)
{
$user = $this->Users->findById($user['id'])->first();

if ($user && $this->request->action == "administration" && $user->hasRoleName(['Administrator'])) {
if ($user &&
($this->request->action == "administration" || $this->request->action == "galleriesManager" || $this->request->action == "deleteImg") &&
$user->hasRoleName(['Administrator'])) {
return true;
}
}
Expand Down Expand Up @@ -143,7 +147,9 @@ public function home()
);
$numberMissions = count($missions->toArray());

$this->set(compact('numberUsers', 'numberProjects', 'numberMissions', 'numberStudents'));
$fichiers = $this->getImgCarousel();

$this->set(compact('numberUsers', 'numberProjects', 'numberMissions', 'numberStudents', 'fichiers'));
}

/**
Expand Down Expand Up @@ -544,16 +550,71 @@ public function statistics()
/**
* Administration method
*
* @param null $img
*
* @return void
*/
public function administration()
public function administration($img = null)
{
$this->loadModel("Projects");
$projects = $this->Projects->find('all', ['conditions' => ['accepted' => 0, 'archived' => 0]])->toArray();

$this->loadModel("Organizations");
$organizations = $this->Organizations->find('all', ['conditions' => ['isValidated' => 0, 'isRejected' => 0]])->toArray();

$this->set(compact('projects', 'organizations'));
//gestion des images du carousel
$path = self::PATH_CAROUSEL;
$request = $this->request;

if(is_file($path.$img)) {
unlink($path.$img);
}

if($request->is('post') && !empty($request->data)) {

$image = $this->request->data['avatar_file'];
$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']);
} else {
$this->Flash->error('Erreur: fichier trop petit');
}

} else {
$this->Flash->error('Erreur: vérifier les conditions de tranfert de fichier');
}

}
//fin gestion du carousel

$fichiers = $this->getImgCarousel();

$this->set(compact('projects', 'organizations', 'fichiers'));
}

/**
* getImgCarousel method
*
* @return array
*/
private function getImgCarousel(){
$fichiers = array();

if(false !== ($dossier = opendir(self::PATH_CAROUSEL))) {
while(false !== ($fichier = readdir($dossier))) {

if($fichier != '.' && $fichier != '..' && $fichier != 'index.php') {
array_push($fichiers, $fichier);
}

}
}

return $fichiers;
}

}
48 changes: 48 additions & 0 deletions src/Template/Pages/administration.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
</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,4 +63,51 @@
</div>
</div>
</div>

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

<div class="row">
<div class="row">

<?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>
</div>
</div>
<?php endforeach; ?>

</div>

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

<?= $this->Flash->render() ?>
<?= $this->Form->create('image', array('type'=>'file')); ?>
<ul>
<li>format png</li>
<li>taille minimale (1920 x 1080)</li>
</ul>
<?= $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>
48 changes: 24 additions & 24 deletions src/Template/Pages/home.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@
<div id="carousel-container">
<div id="carousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0"></li>
<li data-target="#carousel" data-slide-to="1"></li>
<li data-target="#carousel" data-slide-to="2"></li>
<li data-target="#carousel" data-slide-to="3" class="active"></li>
<?php
$i = 0;
foreach ($fichiers as $fichier):
?>
<li data-target="#carousel" data-slide-to="<?= $i ?>" class="active"></li>
<?php
$i++;
endforeach;
?>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item">
<div class="fillBackground">
<img src="<?= $this->request->webroot . 'img/carousel/1.jpg'; ?>" class="stretch" alt=""/>
</div>
</div>
<div class="item">
<div class="fillBackground">
<img src="<?= $this->request->webroot . 'img/tv/tv3.png'; ?>" class="stretch" alt=""/>
</div>
</div>
<div class="item">
<div class="fillBackground">
<img src="<?= $this->request->webroot . 'img/tv/tv4.png'; ?>" class="stretch" alt=""/>
</div>
</div>
<div class="item active">
<div class="fillBackground">
<img src="<?= $this->request->webroot . 'img/carousel/financement-montreal.png'; ?>" class="stretch" alt=""/>
</div>
</div>


<?php
$i = 0;
foreach ($fichiers as $fichier):
?>
<div class="item <?= ($i==0)?'active': ''; ?>">
<div class="fillBackground">
<img src="<?= $this->request->webroot . 'img/carousel/'.$fichier; ?>" class="stretch" alt=""/>
</div>
</div>
<?php
$i++;
endforeach;
?>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Pages/tv1.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<?= $this->fetch('meta') ?>
<style>
body {
background: url(webroot/img/banner.png) no-repeat center center fixed;
background: url(webroot/img/tv/tv1.png) no-repeat center center fixed;
-webkit-background-size: 95%;
-moz-background-size: 95%;
-o-background-size: 95%;
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Pages/tv2.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
background-color: #70CCD6;
}
html {
background: url(webroot/img/carousel/financement-montreal.png) #70CCD6 no-repeat fixed;
background: url(webroot/img/tv/tv2.png) #70CCD6 no-repeat fixed;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Pages/tv5.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
background-color: #70CCD6;
}
html {
background: url(webroot/img/sponsors.png) #70CCD6 no-repeat fixed;
background: url(webroot/img/tv/tv5.png) #70CCD6 no-repeat fixed;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
Expand Down
Binary file added webroot/img/carousel/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webroot/img/carousel/tv3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webroot/img/carousel/tv4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webroot/img/ml2-cropped.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webroot/img/tv/tv1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webroot/img/tv/tv2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 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 9181b94

Please sign in to comment.