From f215a6cf08e23adafcb522897f15f52483fa4e7d Mon Sep 17 00:00:00 2001 From: leosw Date: Wed, 23 Jan 2019 13:32:54 +0100 Subject: [PATCH] Fix blog list page --- controllers/d.blog.php | 12 ++++-------- models/d.blog.php | 6 +++--- views/d.blog.list.html | 22 +++++++++++----------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/controllers/d.blog.php b/controllers/d.blog.php index 982de6f..0bed9b4 100755 --- a/controllers/d.blog.php +++ b/controllers/d.blog.php @@ -41,15 +41,11 @@ switch ($controller->splitted_url[1]) { $i = 0; $blogArticles_list = array(); - foreach ($blogArticles->ids as $row) { - $blogArticles_list[$i] = new Kabano\BlogArticle(); - $blogArticles_list[$i]->id = $row; - $blogArticles_list[$i]->populate(); - $blogArticles_list[$i]->md2txt(); + foreach ($blogArticles->objs as $row) { + $row->md2txt(); $tempUser = new Kabano\User(); - $tempUser->id = $blogArticles_list[$i]->author; - $tempUser->populate(); - $blogArticles_list[$i]->author_name = $tempUser->name; + $tempUser->checkId($row->author); + $row->author_name = $tempUser->name; unset($tempUser); $i++; } diff --git a/models/d.blog.php b/models/d.blog.php index 2891f50..0ec408e 100755 --- a/models/d.blog.php +++ b/models/d.blog.php @@ -263,7 +263,7 @@ class BlogArticles if ($archive == 1) { // You just want one per url and the criteria is ORDER BY archives = true, time DES=C - $query = "SELECT * FROM (SELECT a.id, a.update_date , ROW_NUMBER() OVER (PARTITION BY a.permalink ORDER BY CASE WHEN a.is_archive IS TRUE THEN 1 ELSE 0 END, a.update_date DESC) AS r FROM contents AS a) AS b WHERE r = 1 ORDER BY update_date DESC"; + $query = "SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY a.permalink ORDER BY CASE WHEN a.is_archive IS TRUE THEN 1 ELSE 0 END, a.update_date DESC) AS r FROM contents AS a WHERE type='blog') AS b WHERE r = 1 ORDER BY update_date DESC"; } else { $query = "SELECT * FROM contents WHERE is_archive IS NOT TRUE AND is_public IS TRUE AND type='blog' ORDER BY update_date DESC"; @@ -295,10 +295,10 @@ class BlogArticles if ($archive == 1) { // You just want one per url and the criteria is ORDER BY archives = true, time DES=C - $query = "SELECT * FROM (SELECT a.id, a.update_date , ROW_NUMBER() OVER (PARTITION BY a.permalink ORDER BY CASE WHEN a.is_archive IS TRUE THEN 1 ELSE 0 END, a.update_date DESC) AS r FROM contents AS a) AS b WHERE r = 1 ORDER BY update_date DESC"; + $query = "SELECT * FROM (SELECT a.update_date, ROW_NUMBER() OVER (PARTITION BY a.permalink ORDER BY CASE WHEN a.is_archive IS TRUE THEN 1 ELSE 0 END, a.update_date DESC) AS r FROM contents AS a WHERE type='blog') AS b WHERE r = 1 ORDER BY update_date DESC"; } else { - $query = "SELECT * FROM contents WHERE is_archive IS NOT TRUE AND is_public IS TRUE AND type='blog' ORDER BY update_date DESC"; + $query = "SELECT update_date FROM contents WHERE is_archive IS NOT TRUE AND is_public IS TRUE AND type='blog' ORDER BY update_date DESC"; } pg_prepare($con, "prepare1", $query) diff --git a/views/d.blog.list.html b/views/d.blog.list.html index 56dc58a..cbe683f 100755 --- a/views/d.blog.list.html +++ b/views/d.blog.list.html @@ -10,25 +10,25 @@

Blog.

- role >= 800) { ?> - Nouvel article — + rankIsHigher("moderator")) { ?> + Nouvel article - Flux RSS — + Flux RSS — Articles à sur number?>

- + objs as $row) { ?> -
archive == 't') echo 'class="article_archive" '; ?>> -

title?>.

+
is_archive == 't') echo 'class="article_archive" '; ?>> +

name?>.

content_txt,0,200)?>...

- Lire la suite... + Lire la suite...

- number) { ?> + number) { ?>