aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-03-17 21:34:14 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-03-17 21:34:14 +0100
commitcaf8d18c1d887f0c918ba181d1c48d9e08af6ea0 (patch)
treeb6d778c7c852432ca060470c41c44d7db7b1cab2 /app
parentdbb0de4e368b814f8cab9e7e1a1462a2839471dc (diff)
Début fix bug #22 : possibilité d'ajouter des notes à des articles et les mettre ou non en public
Diffstat (limited to 'app')
-rwxr-xr-xapp/controllers/entryController.php93
-rw-r--r--app/views/entry/note.phtml63
-rw-r--r--app/views/index/index.phtml22
3 files changed, 161 insertions, 17 deletions
diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php
index b772e1703..f5277fa6d 100755
--- a/app/controllers/entryController.php
+++ b/app/controllers/entryController.php
@@ -8,7 +8,8 @@ class entryController extends ActionController {
array ('error' => array ('Vous n\'avez pas le droit d\'accéder à cette page'))
);
}
-
+
+ $this->redirect = false;
$ajax = Request::param ('ajax');
if ($ajax) {
$this->view->_useLayout (false);
@@ -16,7 +17,7 @@ class entryController extends ActionController {
}
public function lastAction () {
$ajax = Request::param ('ajax');
- if (!$ajax) {
+ if (!$ajax && $this->redirect) {
Request::forward (array (
'c' => 'index',
'a' => 'index',
@@ -28,17 +29,19 @@ class entryController extends ActionController {
}
public function readAction () {
+ $this->redirect = true;
+
$id = Request::param ('id');
$is_read = Request::param ('is_read');
$get = Request::param ('get');
$dateMax = Request::param ('dateMax', time ());
-
+
if ($is_read) {
$is_read = true;
} else {
$is_read = false;
}
-
+
$entryDAO = new EntryDAO ();
if ($id == false) {
if (!$get) {
@@ -55,7 +58,7 @@ class entryController extends ActionController {
$this->params = array ('get' => 'f_' . $get);
}
}
-
+
// notif
$notif = array (
'type' => 'good',
@@ -66,28 +69,98 @@ class entryController extends ActionController {
$entryDAO->updateEntry ($id, array ('is_read' => $is_read));
}
}
-
+
public function bookmarkAction () {
+ $this->redirect = true;
+
$id = Request::param ('id');
$is_fav = Request::param ('is_favorite');
-
+
if ($is_fav) {
$is_fav = true;
} else {
$is_fav = false;
}
-
+
$entryDAO = new EntryDAO ();
if ($id != false) {
$entry = $entryDAO->searchById ($id);
-
+
if ($entry != false) {
$values = array (
'is_favorite' => $is_fav,
);
-
+
$entryDAO->updateEntry ($entry->id (), $values);
}
}
}
+
+ public function noteAction () {
+ $not_found = false;
+ $entryDAO = new EntryDAO ();
+ $catDAO = new CategoryDAO ();
+
+ $id = Request::param ('id');
+ if ($id) {
+ $entry = $entryDAO->searchById ($id);
+
+ if ($entry) {
+ $feed = $entry->feed (true);
+
+ if (Request::isPost ()) {
+ $note = htmlspecialchars (Request::param ('note', ''));
+ $public = Request::param ('public', 'no');
+ if ($public == 'yes') {
+ $public = true;
+ } else {
+ $public = false;
+ }
+
+ $values = array (
+ 'annotation' => $note,
+ 'is_public' => $public
+ );
+
+ if ($entryDAO->updateEntry ($id, $values)) {
+ $notif = array (
+ 'type' => 'good',
+ 'content' => 'Modifications enregistrées'
+ );
+ } else {
+ $notif = array (
+ 'type' => 'bad',
+ 'content' => 'Une erreur est survenue'
+ );
+ }
+ Session::_param ('notification', $notif);
+ Request::forward (array (
+ 'c' => 'entry',
+ 'a' => 'note',
+ 'params' => array (
+ 'id' => $id
+ )
+ ), true);
+ }
+ } else {
+ $not_found = true;
+ }
+ } else {
+ $not_found = true;
+ }
+
+ if ($not_found) {
+ Error::error (
+ 404,
+ array ('error' => array ('La page que vous cherchez n\'existe pas'))
+ );
+ } else {
+ $this->view->entry = $entry;
+ $this->view->cat_aside = $catDAO->listCategories ();
+ $this->view->nb_favorites = $entryDAO->countFavorites ();
+ $this->view->nb_total = $entryDAO->count ();
+ $this->view->get_c = $feed->category ();
+ $this->view->get_f = $feed->id ();
+ }
+ }
}
diff --git a/app/views/entry/note.phtml b/app/views/entry/note.phtml
new file mode 100644
index 000000000..fe330f9b4
--- /dev/null
+++ b/app/views/entry/note.phtml
@@ -0,0 +1,63 @@
+<?php $this->partial ('aside_flux'); ?>
+
+<div class="post">
+ <form method="post" action="<?php echo _url ('entry', 'note', 'id', $this->entry->id ()); ?>">
+ <legend>Note</legend>
+
+ <div class="form-group">
+ <label class="group-name" for="note">Ajouter une note</label>
+ <div class="group-controls">
+ <textarea rows="5" cols="80" name="note" id="note"><?php echo $this->entry->notes (); ?></textarea>
+ </div>
+ </div>
+ <div class="form-group">
+ <label class="group-name" for="public_note">Article public ?</label>
+ <div class="group-controls">
+ <label class="checkbox" for="public">
+ <input type="checkbox" name="public" id="public" value="yes"<?php echo $this->entry->isPublic () ? ' checked="checked"' : ''; ?> /> Oui
+ </label>
+ </div>
+ </div>
+
+ <div class="form-group form-actions">
+ <div class="group-controls">
+ <button type="submit" class="btn btn-important">Sauvegarder</button>
+ <button type="reset" class="btn">Annuler</button>
+ </div>
+ </div>
+
+ <legend>Article</legend>
+
+ <div class="form-group">
+ <label class="group-name">Titre</label>
+ <div class="group-controls">
+ <span class="control"><a href="<?php echo $this->entry->link (); ?>"><?php echo $this->entry->title (); ?></a></span>
+ </div>
+ </div>
+
+ <?php
+ $author = $this->entry->author ();
+ if ($author) { ?>
+ <div class="form-group">
+ <label class="group-name">Auteur</label>
+ <div class="group-controls">
+ <span class="control"><?php echo $author; ?></span>
+ </div>
+ </div>
+ <?php } ?>
+
+ <div class="form-group">
+ <label class="group-name">Date de publication</label>
+ <div class="group-controls">
+ <span class="control"><?php echo $this->entry->date (); ?></span>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="group-name">Article</label>
+ <div class="group-controls">
+ <span class="control"><?php echo $this->entry->content (); ?></span>
+ </div>
+ </div>
+ </form>
+</div>
diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml
index 0db9dac5b..a7ed174c2 100644
--- a/app/views/index/index.phtml
+++ b/app/views/index/index.phtml
@@ -26,21 +26,29 @@ if (isset ($this->entryPaginator)) {
<div class="flux<?php echo !$item->isRead () ? ' not_read' : ''; ?><?php echo $item->isFavorite () ? ' favorite' : ''; ?>" id="flux_<?php echo $item->id (); ?>">
<ul class="flux_header">
+ <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?>
<li class="item manage">
- <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?>
<?php if (!$item->isRead ()) { ?>
- <a class="read" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('id' => $item->id (), 'is_read' => 1))); ?>">&nbsp;</a><!--
+ <a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', 1); ?>">&nbsp;</a>
<?php } else { ?>
- <a class="read" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('id' => $item->id (), 'is_read' => 0))); ?>">&nbsp;</a><!--
+ <a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', 0); ?>">&nbsp;</a>
<?php } ?>
<?php if (!$item->isFavorite ()) { ?>
- --><a class="bookmark" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'bookmark', 'params' => array ('id' => $item->id (), 'is_favorite' => 1))); ?>">&nbsp;</a>
+ <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 1); ?>">&nbsp;</a>
<?php } else { ?>
- --><a class="bookmark" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'bookmark', 'params' => array ('id' => $item->id (), 'is_favorite' => 0))); ?>">&nbsp;</a>
- <?php } ?>
+ <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 0); ?>">&nbsp;</a>
<?php } ?>
+
+ <a class="note" href="<?php echo _url ('entry', 'note', 'id', $item->id ()); ?>">
+ <?php if ($item->notes () != '') { ?>
+ <i class="icon i_note"></i>
+ <?php } else { ?>
+ <i class="icon i_note_empty"></i>
+ <?php } ?>
+ </a>
</li>
+ <?php } ?>
<?php $feed = $item->feed (true); ?>
<li class="item website"><a target="_blank" href="<?php echo $feed->website (); ?>"><img src="http://www.google.com/s2/favicons?domain=<?php echo get_domain ($feed->website ()); ?>" alt="" /><span> <?php echo $feed->name (); ?></span></a></li>
<li class="item title"><h1><?php echo $item->title (); ?></h1></li>
@@ -62,7 +70,7 @@ if (isset ($this->entryPaginator)) {
<div class="alert">
<span class="alert-head">Il n'y a aucun flux à afficher.</span>
<?php if (Session::param ('mode', 'all') == 'not_read') { ?>
- <a class="print_all" href="<?php echo Url::display (array ('a' => 'changeMode', 'params' => array ('mode' => 'all'))); ?>">Afficher tous les articles ?</a>
+ <a class="print_all" href="<?php echo _url ('index', 'changeMode', 'mode', 'all'); ?>">Afficher tous les articles ?</a>
<?php } ?>
</div>
<?php } ?>