Browse Source

Fix blog list page

leosw 7 months ago
parent
commit
f215a6cf08
3 changed files with 18 additions and 22 deletions
  1. 4
    8
      controllers/d.blog.php
  2. 3
    3
      models/d.blog.php
  3. 11
    11
      views/d.blog.list.html

+ 4
- 8
controllers/d.blog.php View File

@@ -41,15 +41,11 @@ switch ($controller->splitted_url[1]) {
41 41
 
42 42
 		$i = 0;
43 43
 		$blogArticles_list = array();
44
-		foreach ($blogArticles->ids as $row) {
45
-			$blogArticles_list[$i] = new Kabano\BlogArticle();
46
-			$blogArticles_list[$i]->id = $row;
47
-			$blogArticles_list[$i]->populate();
48
-			$blogArticles_list[$i]->md2txt();
44
+		foreach ($blogArticles->objs as $row) {
45
+			$row->md2txt();
49 46
 			$tempUser = new Kabano\User();
50
-			$tempUser->id = $blogArticles_list[$i]->author;
51
-			$tempUser->populate();
52
-			$blogArticles_list[$i]->author_name = $tempUser->name;
47
+			$tempUser->checkId($row->author);
48
+			$row->author_name = $tempUser->name;
53 49
 			unset($tempUser);
54 50
 			$i++;
55 51
 		}

+ 3
- 3
models/d.blog.php View File

@@ -263,7 +263,7 @@ class BlogArticles
263 263
 
264 264
 		if ($archive == 1) {
265 265
 			// You just want one per url and the criteria is ORDER BY archives = true, time DES=C
266
-			$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";
266
+			$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";
267 267
 		}
268 268
 		else {
269 269
 			$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
295 295
 
296 296
 		if ($archive == 1) {
297 297
 			// You just want one per url and the criteria is ORDER BY archives = true, time DES=C
298
-			$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";
298
+			$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";
299 299
 		}
300 300
 		else {
301
-			$query = "SELECT * FROM contents WHERE is_archive IS NOT TRUE AND is_public IS TRUE AND type='blog' ORDER BY update_date DESC";
301
+			$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";
302 302
 		}
303 303
 
304 304
 		pg_prepare($con, "prepare1", $query) 

+ 11
- 11
views/d.blog.list.html View File

@@ -10,25 +10,25 @@
10 10
 		<section id="blog_list">
11 11
 			<h1>Blog.</h1>
12 12
 			<p class="subtitle">
13
-				<? if ($user->role >= 800) { ?>
14
-					<a href="<?=$config['rel_root_folder']?>blog/new"><i class="fa fa-plus"></i> Nouvel article</a> &mdash; 
13
+				<? if ($user->rankIsHigher("moderator")) { ?>
14
+					<a href="<?=$config['rel_root_folder']?>blog/new"><i class="fas fa-plus"></i> Nouvel article</a> &mdash; 
15 15
 				<? } ?>
16
-				<a href="<?=$config['rel_root_folder']?>blog/rss"><i class="fa fa-rss" aria-hidden="true"></i> Flux RSS</a> &mdash; 
16
+				<a href="<?=$config['rel_root_folder']?>blog/rss"><i class="fas fa-rss" aria-hidden="true"></i> Flux RSS</a> &mdash; 
17 17
 				Articles <?=$first?> à <?=$last?> sur <?=$blogArticles->number?>
18 18
 			</p>
19 19
 
20 20
 			<div id="articles_list">
21 21
 
22
-				<? foreach ($blogArticles_list as $row) { ?>
22
+				<? foreach ($blogArticles->objs as $row) { ?>
23 23
 
24
-					<article <? if($row->archive == 't') echo 'class="article_archive" '; ?>>
25
-						<h2 class="article_title"><?=$row->title?>.</h2>
24
+					<article <? if($row->is_archive == 't') echo 'class="article_archive" '; ?>>
25
+						<h2 class="article_title"><?=$row->name?>.</h2>
26 26
 						<div class="article_content"><?=mb_substr($row->content_txt,0,200)?>...</div>
27 27
 						<p class="article_legend">
28
-							<a class="article_link" href="<?=$config['rel_root_folder']?>blog/<?=$row->url?>">Lire la suite...</a>
28
+							<a class="article_link" href="<?=$config['rel_root_folder']?>blog/<?=$row->permalink?>">Lire la suite...</a>
29 29
 							<span class="article_infos">
30
-								Le <? echo strftime('%e %B %G',strtotime($row->lastedit)) ?> par 
31
-								<? if ($user->role > 0) { ?>
30
+								Le <? echo strftime('%e %B %G',strtotime($row->update_date)) ?> par 
31
+								<? if ($user->rankIsHigher("registered")) { ?>
32 32
 									<a href="<?=$config['rel_root_folder']?>user/p/<?=$row->author?>"><?=$row->author_name?></a>
33 33
 								<? } 
34 34
 								else { ?>
@@ -43,8 +43,8 @@
43 43
 			</div>
44 44
 			
45 45
 			<div class="pagebuttons">
46
-				<? if ($page != 0) { ?><a class="previous" href="<?=$config['rel_root_folder']?>blog/<?=$page?>"><i class="fa fa-chevron-left fa-fw"></i></a><? }
47
-				if (($page+1)*$articles_per_pages < $blogArticles->number) { ?><a class="next" href="<?=$config['rel_root_folder']?>blog/<?=$page+2?>"><i class="fa fa-chevron-right fa-fw"></i></a><? } ?>
46
+				<? if ($page != 0) { ?><a class="previous" href="<?=$config['rel_root_folder']?>blog/<?=$page?>"><i class="fas fa-chevron-left fa-fw"></i></a><? }
47
+				if (($page+1)*$articles_per_pages < $blogArticles->number) { ?><a class="next" href="<?=$config['rel_root_folder']?>blog/<?=$page+2?>"><i class="fas fa-chevron-right fa-fw"></i></a><? } ?>
48 48
 			</div>
49 49
 
50 50
 		</section>

Loading…
Cancel
Save