Gazelle/sections/ajax/wiki.php

36 lines
980 B
PHP
Raw Normal View History

2012-12-11 08:00:18 +00:00
<?
if (!empty($_GET['id']) && is_number($_GET['id'])) { //Visiting article via ID
$ArticleID = $_GET['id'];
} elseif ($_GET['name'] != '') { //Retrieve article ID via alias.
2013-12-24 08:00:55 +00:00
$ArticleID = Wiki::alias_to_id($_GET['name']);
2012-12-11 08:00:18 +00:00
} else {
2013-05-14 08:00:34 +00:00
json_die("failure");
2012-12-11 08:00:18 +00:00
}
if (!$ArticleID) { //No article found
2013-04-24 08:00:23 +00:00
json_die("failure", "article not found");
2012-12-11 08:00:18 +00:00
}
2013-12-24 08:00:55 +00:00
$Article = Wiki::get_article($ArticleID, false);
2012-12-11 08:00:18 +00:00
if (!$Article) {
2013-04-24 08:00:23 +00:00
json_die("failure", "article not found");
2012-12-11 08:00:18 +00:00
}
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName, $Aliases, $UserIDs) = array_shift($Article);
if ($Read > $LoggedUser['EffectiveClass']) {
2013-04-24 08:00:23 +00:00
json_die("failure", "higher user class required to view article");
2012-12-11 08:00:18 +00:00
}
2013-12-12 08:01:01 +00:00
Text::$TOC = true;
$TextBody = Text::full_format($Body, false);
2012-12-11 08:00:18 +00:00
2013-04-24 08:00:23 +00:00
json_die("success", array(
2013-05-14 08:00:34 +00:00
'title' => $Title,
'bbBody' => $Body,
'body' => $TextBody,
'aliases' => $Aliases,
2013-10-30 08:01:19 +00:00
'authorID' => (int)$AuthorID,
2013-05-14 08:00:34 +00:00
'authorName' => $AuthorName,
'date' => $Date,
2013-10-30 08:01:19 +00:00
'revision' => (int)$Revision
2013-04-24 08:00:23 +00:00
));