A free, self-hostable news aggregator…
correction marquage des articles en js
Marien Fressinaudd21c1bb13875
diff --git a/app/controllers/entryController.php b/app/controllers/entryController.phpindex f9275593f..3d9734ca9 100755--- a/app/controllers/entryController.php+++ b/app/controllers/entryController.php@@ -11,6 +11,8 @@ class entryController extends ActionController {$ajax = Request::param ('ajax');if (!$ajax) {Request::forward (array (), true);+ } else {+ Request::_param ('ajax');}}diff --git a/app/models/Category.php b/app/models/Category.phpindex 1713f615c..6e2847b51 100755--- a/app/models/Category.php+++ b/app/models/Category.php@@ -109,7 +109,7 @@ class CategoryDAO extends Model_pdo {}public function listCategories () {- $sql = 'SELECT * FROM category';+ $sql = 'SELECT * FROM category ORDER BY name';$stm = $this->bd->prepare ($sql);$stm->execute ();diff --git a/app/models/Feed.php b/app/models/Feed.phpindex e1e8f6449..92a20eb80 100644--- a/app/models/Feed.php+++ b/app/models/Feed.php@@ -160,7 +160,7 @@ class FeedDAO extends Model_pdo {}public function listFeeds () {- $sql = 'SELECT * FROM feed';+ $sql = 'SELECT * FROM feed ORDER BY name';$stm = $this->bd->prepare ($sql);$stm->execute ();@@ -168,7 +168,7 @@ class FeedDAO extends Model_pdo {}public function listByCategory ($cat) {- $sql = 'SELECT * FROM feed WHERE category=?';+ $sql = 'SELECT * FROM feed WHERE category=? ORDER BY name';$stm = $this->bd->prepare ($sql);$values = array ($cat);diff --git a/app/views/entry/bookmark.phtml b/app/views/entry/bookmark.phtmlnew file mode 100755index 000000000..fe64bb2d8--- /dev/null+++ b/app/views/entry/bookmark.phtml@@ -0,0 +1,15 @@+<?php++if (Request::param ('is_favorite')) {+ Request::_param ('is_favorite', 0);+} else {+ Request::_param ('is_favorite', 1);+}++$url = Url::display (array (+ 'c' => Request::controllerName (),+ 'a' => Request::actionName (),+ 'params' => Request::params (),+));++echo json_encode (array ('url' => preg_replace ('#&#i', '&', $url)));diff --git a/app/views/entry/read.phtml b/app/views/entry/read.phtmlnew file mode 100755index 000000000..4d0a84f45--- /dev/null+++ b/app/views/entry/read.phtml@@ -0,0 +1,15 @@+<?php++if (Request::param ('is_read')) {+ Request::_param ('is_read', 0);+} else {+ Request::_param ('is_read', 1);+}++$url = Url::display (array (+ 'c' => Request::controllerName (),+ 'a' => Request::actionName (),+ 'params' => Request::params (),+));++echo json_encode (array ('url' => preg_replace ('#&#i', '&', $url)));diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtmlindex 1bdde5a8e..c801ba7d0 100644--- a/app/views/javascript/main.phtml+++ b/app/views/javascript/main.phtml@@ -28,45 +28,85 @@ function slide (new_active, old_active) {}}+function mark_read (active) {+ url = active.find ("a.read").attr ("href");++ $.ajax ({+ type: 'POST',+ url: url,+ data : { ajax: true }+ }).done (function (data) {+ res = jQuery.parseJSON(data);++ active.find ("a.read").attr ("href", res.url);+ if (active.hasClass ("not_read")) {+ active.removeClass ("not_read");+ active.find ("a.read").html ("Marquer comme non lu");+ } else {+ active.addClass ("not_read");+ active.find ("a.read").html ("J'ai fini de lire l'article");+ }+ });+}++function mark_favorite (active) {+ url = active.find ("a.bookmark").attr ("href");++ $.ajax ({+ type: 'POST',+ url: url,+ data : { ajax: true }+ }).done (function (data) {+ res = jQuery.parseJSON(data);++ active.find ("a.bookmark").attr ("href", res.url);+ if (active.hasClass ("favorite")) {+ active.removeClass ("favorite");+ active.find ("a.bookmark").html ("Ajouter l'article à mes favoris");+ } else {+ active.addClass ("favorite");+ active.find ("a.bookmark").html ("Retirer l'article de mes favoris");+ }+ });+}+$(document).ready (function () {if (hide_posts) {$(".post.flux .content").slideToggle ();}++ $(".post.flux").click (function () {+ old_active = $(".post.flux.active");+ new_active = $(this);++ if (old_active[0] != new_active[0]) {+ slide (new_active, old_active);+ }+ });++ $(".post.flux a.read").click (function () {+ active = $(this).parents (".post.flux");+ mark_read (active);++ return false;+ });+ $(".post.flux a.bookmark").click (function () {+ active = $(this).parents (".post.flux");+ mark_favorite (active);++ return false;+ });// Touches de manipulationshortcut.add("m", function () {// on marque comme lu ou non luactive = $(".post.flux.active");- url = active.find ("a.read").attr ("href");-- $.ajax ({- type: 'POST',- url: url,- data : { ajax: true }- }).done (function () {- if (active.hasClass ("not_read")) {- active.removeClass ("not_read");- } else {- active.addClass ("not_read");- }- });+ mark_read (active);});shortcut.add("f", function () {// on marque comme favori ou non favoriactive = $(".post.flux.active");- url = active.find ("a.bookmark").attr ("href");-- $.ajax ({- type: 'POST',- url: url,- data : { ajax: true }- }).done (function () {- if (active.hasClass ("favorite")) {- active.removeClass ("favorite");- } else {- active.addClass ("favorite");- }- });+ mark_favorite (active);});// Touches de navigation@@ -108,14 +148,4 @@ $(document).ready (function () {redirect (url);});--- $(".post.flux").click (function () {- old_active = $(".post.flux.active");- new_active = $(this);-- if (old_active[0] != new_active[0]) {- slide (new_active, old_active);- }- });});diff --git a/lib/Request.php b/lib/Request.phpindex 75e2d33f8..4f06be1d8 100644--- a/lib/Request.php+++ b/lib/Request.php@@ -59,8 +59,12 @@ class Request {self::$params = $params;}- public static function _param ($key, $value) {- self::$params[$key] = $value;+ public static function _param ($key, $value = null) {+ if (is_null ($value)) {+ unset (self::$params[$key]);+ } else {+ self::$params[$key] = $value;+ }}/**