Fix 404 error view

This commit is contained in:
Léo Serre 2018-09-03 22:02:13 +02:00
parent 4fdae170d6
commit 52f82cfe78
4 changed files with 23 additions and 11 deletions

View File

@ -64,7 +64,6 @@ else if(isset($controller->splitted_url[1]) && $wikiPage->checkUrl($controller->
if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2])) if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2]))
$wikiPage->checkUrl($controller->splitted_url[1],$user->role>=600, $controller->splitted_url[2]); $wikiPage->checkUrl($controller->splitted_url[1],$user->role>=600, $controller->splitted_url[2]);
$wikiPage->populate();
$wikiPage->md2html(); $wikiPage->md2html();
$head['title'] = $wikiPage->title; $head['title'] = $wikiPage->title;
include ($config['views_folder']."d.wiki.view.html"); include ($config['views_folder']."d.wiki.view.html");

View File

@ -61,10 +61,9 @@ if($notfound) {
require_once($config['models_folder']."d.wiki.php"); require_once($config['models_folder']."d.wiki.php");
$wikiPage = new WikiPage(); $wikiPage = new WikiPage();
$wikiPage->checkUrl('404'); $wikiPage->checkUrl('404');
$wikiPage->populate();
$wikiPage->md2html(); $wikiPage->md2html();
$head['css'] = "d.index.css;d.wiki.css"; $head['css'] = "d.index.css;d.wiki.css";
$head['title'] = $wikiPage->title; $head['title'] = $wikiPage->name;
include ($config['views_folder']."d.wiki.view.html"); include ($config['views_folder']."d.wiki.view.html");
} }

View File

@ -27,7 +27,7 @@ class WikiPage
public $content = NULL; public $content = NULL;
/***** /*****
** Checks if a page at this URL exists and return the ID ** Checks if a page at this URL exists and return the populated element
*****/ *****/
public function checkUrl($url, $withArchive=0, $elementNb=0) { public function checkUrl($url, $withArchive=0, $elementNb=0) {
global $config; global $config;
@ -37,7 +37,7 @@ class WikiPage
$query = "SELECT * FROM contents WHERE permalink=$1"; $query = "SELECT * FROM contents WHERE permalink=$1";
if($withArchive==0) { if($withArchive==0) {
$query .= " AND is_archive=FALSE AND is_public=FALSE"; $query .= " AND is_archive=FALSE AND is_public=TRUE";
} }
$query .= " ORDER BY update_date DESC LIMIT 1 OFFSET $2"; $query .= " ORDER BY update_date DESC LIMIT 1 OFFSET $2";
@ -59,7 +59,7 @@ class WikiPage
} }
/***** /*****
** Populate the object using its ID ** Populate the object using raw data from SQL
*****/ *****/
private function populate($row) { private function populate($row) {
$this->permalink = $row['permalink']; $this->permalink = $row['permalink'];
@ -76,6 +76,20 @@ class WikiPage
$this->content = $row['content']; $this->content = $row['content'];
} }
/*****
** Return archive status
*****/
public function is_archive() {
return $this->is_archive;
}
/*****
** Return archive status
*****/
public function update_date() {
return $this->update_date;
}
/***** /*****
** Edit a page by archiving the current one and inserting a new one ID ** Edit a page by archiving the current one and inserting a new one ID
*****/ *****/

View File

@ -7,15 +7,15 @@
<? include('blocks/d.nav.html'); ?> <? include('blocks/d.nav.html'); ?>
<section id="wiki_page" <?=$wikiPage->archive=="t"?'class="archive"':''?>> <section id="wiki_page" <?=!$wikiPage->is_archive()?'class="archive"':''?>>
<h1><?=$wikiPage->title?>.</h1> <h1><?=$wikiPage->name?>.</h1>
<? if($user->role >= 600) { ?> <? if($user->role >= 600) { ?>
<span class="subtitle"> <span class="subtitle">
<? if(isset($wikiHistory_list)) { ?> <? if(isset($wikiHistory_list)) { ?>
<select id="wikihistory"> <select id="wikihistory">
<? $i = 0; <? $i = 0;
foreach ($wikiHistory_list as $row) { ?> foreach ($wikiHistory_list as $row) { ?>
<option <?=$row->id==$wikiPage->id?'selected':''?> value="<?=$i?>"><?=$row->archive=="f"?'&bull; ':''?><? echo strftime('%d/%m/%Y %H:%M:%S',strtotime($row->lastedit)) ?></option> <option <?=$row->id==$wikiPage->id?'selected':''?> value="<?=$i?>"><?=$row->is_archive=="f"?'&bull; ':''?><? echo strftime('%d/%m/%Y %H:%M:%S',strtotime($row->lastedit)) ?></option>
<? $i++; <? $i++;
} ?> } ?>
</select> </select>
@ -25,7 +25,7 @@
<? } <? }
if ($user->role >= 800) { ?> if ($user->role >= 800) { ?>
<a href="<?=$config['rel_root_folder']?>wiki/<?=$wikiPage->url?>/edit"><i class="fa fa-pencil"></i> Éditer la page</a> <a href="<?=$config['rel_root_folder']?>wiki/<?=$wikiPage->url?>/edit"><i class="fa fa-pencil"></i> Éditer la page</a>
<? if ($wikiPage->archive == 'f') { ?> <? if (!$wikiPage->is_archive()) { ?>
&mdash; &mdash;
<a href="<?=$config['rel_root_folder']?>wiki/<?=$wikiPage->url?>/delete"><i class="fa fa-trash"></i> Effacer la page</a> <a href="<?=$config['rel_root_folder']?>wiki/<?=$wikiPage->url?>/delete"><i class="fa fa-trash"></i> Effacer la page</a>
<? } ?> <? } ?>
@ -37,7 +37,7 @@
<?=$wikiPage->content_html?> <?=$wikiPage->content_html?>
</div> </div>
<p id="wikiTimestamp">Page mise à jour le <? echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($wikiPage->lastedit)) ?> <small><abbr title="Temps Universel Coordonné">UTC</abbr></small></p> <p id="wikiTimestamp">Page mise à jour le <? echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($wikiPage->update_date())) ?> <small><abbr title="Temps Universel Coordonné">UTC</abbr></small></p>
<div style="clear: both;"> </div> <div style="clear: both;"> </div>
</section> </section>