Skip to content

Commit

Permalink
Fix issue #4 : ajout des retours utilisateur
Browse files Browse the repository at this point in the history
  • Loading branch information
marienfressinaud committed Nov 5, 2012
1 parent 33e47c5 commit 209fb25
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 18 deletions.
10 changes: 10 additions & 0 deletions app/App_FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function init () {
Session::init (); // lancement de la session doit se faire après chargement des modèles sinon bug (pourquoi ?)
$this->loadParamsView ();
$this->loadStylesAndScripts ();
$this->loadNotifications ();
}

private function loadLibs () {
Expand All @@ -31,6 +32,7 @@ private function loadStylesAndScripts () {
View::prependStyle (Url::display ('/theme/base.css'));
View::appendScript ('https://login.persona.org/include.js');
View::appendScript (Url::display ('/scripts/jquery.js'));
View::appendScript (Url::display ('/scripts/notification.js'));
}

private function loadParamsView () {
Expand All @@ -39,4 +41,12 @@ private function loadParamsView () {
$entryDAO = new EntryDAO ();
View::_param ('nb_not_read', $entryDAO->countNotRead ());
}

private function loadNotifications () {
$notif = Session::param ('notification');
if ($notif) {
View::_param ('notification', $notif);
Session::_param ('notification');
}
}
}
35 changes: 35 additions & 0 deletions app/controllers/configureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ public function categorizeAction () {
$catDAO->addCategory ($values);
}

// notif
$notif = array (
'type' => 'good',
'content' => 'Les catégories ont été mises à jour'
);
Session::_param ('notification', $notif);

Request::forward (array ('c' => 'configure', 'a' => 'categorize'), true);
}

$this->view->categories = $catDAO->listCategories ();
Expand Down Expand Up @@ -75,6 +83,15 @@ public function feedAction () {
$feedDAO->updateFeed ($id, $values);

$this->view->flux->_category ($cat);

// notif
$notif = array (
'type' => 'good',
'content' => 'Le flux a été mis à jour'
);
Session::_param ('notification', $notif);

Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => array ('id' => $id)), true);
}

View::prependTitle ('Gestion des flux RSS - ' . $this->view->flux->name () . ' - ');
Expand Down Expand Up @@ -113,6 +130,15 @@ public function displayAction () {
$confDAO->update ($values);
Session::_param ('conf', $this->view->conf);
Session::_param ('mail', $this->view->conf->mailLogin ());

// notif
$notif = array (
'type' => 'good',
'content' => 'La configuration a été mise à jour'
);
Session::_param ('notification', $notif);

Request::forward (array ('c' => 'configure', 'a' => 'display'), true);
}

View::prependTitle ('Gestion générale et affichage - ');
Expand Down Expand Up @@ -183,6 +209,15 @@ public function shortcutAction () {
$confDAO = new RSSConfigurationDAO ();
$confDAO->update ($values);
Session::_param ('conf', $this->view->conf);

// notif
$notif = array (
'type' => 'good',
'content' => 'Les raccourcis ont été mis à jour'
);
Session::_param ('notification', $notif);

Request::forward (array ('c' => 'configure', 'a' => 'shortcut'), true);
}

View::prependTitle ('Gestion des raccourcis - ');
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/entryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public function readAction () {
$entryDAO = new EntryDAO ();
if ($id == false) {
$entryDAO->updateEntries ($values);

// notif
$notif = array (
'type' => 'good',
'content' => 'Tous les flux ont été marqués comme lu'
);
Session::_param ('notification', $notif);
} else {
$entryDAO->updateEntry ($id, $values);
}
Expand Down
35 changes: 34 additions & 1 deletion app/controllers/feedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,20 @@ public function addAction () {
);
$entryDAO->addEntry ($values);
}

// notif
$notif = array (
'type' => 'good',
'content' => 'Le flux <em>' . $feed->url () . '</em> a bien été ajouté'
);
Session::_param ('notification', $notif);
} catch (Exception $e) {
// TODO ajouter une erreur : url non valide
// notif
$notif = array (
'type' => 'bad',
'content' => 'L\'url <em>' . $url . '</em> est invalide'
);
Session::_param ('notification', $notif);
}

Request::forward (array (), true);
Expand Down Expand Up @@ -81,6 +93,13 @@ public function actualizeAction () {

$entryDAO->cleanOldEntries ($this->view->conf->oldEntries ());

// notif
$notif = array (
'type' => 'good',
'content' => 'Les flux ont été mis à jour'
);
Session::_param ('notification', $notif);

Request::forward (array (), true);
}

Expand Down Expand Up @@ -139,6 +158,13 @@ public function massiveImportAction () {
);
$feedDAO->addFeed ($values);
}

// notif
$notif = array (
'type' => 'good',
'content' => 'Les flux ont été importés'
);
Session::_param ('notification', $notif);

Request::forward (array ('c' => 'configure', 'a' => 'importExport'));
}
Expand All @@ -155,6 +181,13 @@ public function deleteAction () {

$feedDAO = new FeedDAO ();
$feedDAO->deleteFeed ($id);

// notif
$notif = array (
'type' => 'good',
'content' => 'Le flux a été supprimé'
);
Session::_param ('notification', $notif);

Request::forward (array ('c' => 'configure', 'a' => 'feed'), true);
}
Expand Down
6 changes: 6 additions & 0 deletions app/layout/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@

<?php $this->partial ('persona'); ?>

<?php if (isset ($this->notification)) { ?>
<div id="notification" class="<?php echo $this->notification['type']; ?>">
<?php echo $this->notification['content']; ?>
<a class="close" href="">X</a>
</div>
<?php } ?>
</body>
</html>
17 changes: 0 additions & 17 deletions public/data/Configuration.array.php
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
<?php
return array (
'posts_per_page' => 10,
'default_view' => 'all',
'display_posts' => 'no',
'sort_order' => 'low_to_high',
'old_entries' => 3,
'shortcuts' => array (
'mark_read' => 'r',
'mark_favorite' => 'f',
'go_website' => 'space',
'next_entry' => 'page_down',
'prev_entry' => 'page_up',
'next_page' => 'right',
'prev_page' => 'left',
),
'mail_login' => '',
);
17 changes: 17 additions & 0 deletions public/scripts/notification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function closeNotification () {
$("#notification").slideUp (200, function () {
$("#notification").remove ();
});
}

$(document).ready (function () {
notif = $("#notification");
if (notif[0] !== undefined) {
timer = setInterval('closeNotification()', 5000);

notif.find ("a.close").click (function () {
closeNotification ();
return false;
});
}
});
38 changes: 38 additions & 0 deletions public/theme/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,41 @@ form {
display: block;
color: #F09600;
}

/*** NOTIFICATION ***/
#notification {
position: fixed;
bottom: 0;
left: 25%;
width: 50%;
height: 50px;
padding: 0 50px;
line-height: 50px;
text-align: center;
border-radius: 5px 5px 0 0;
box-shadow: 0 0 3px #666;
background: #ddd;
color: #fff;
font-weight: bold;
}
#notification.good {
background: #8FD900;
}
#notification.bad {
background: #FF3300;
}
#notification a.close {
display: inline-block;
width: 25px;
height: 25px;
float: right;
margin: -10px -60px 0 0;
background: #fff;
border-radius: 50px;
border: 1px solid #aaa;
line-height: 25px;
color: #666;
}
#notification a.close:hover {
text-decoration: none;
}

0 comments on commit 209fb25

Please sign in to comment.