Gazelle/sections/ajax/wiki.php

42 lines
1.1 KiB
PHP
Raw Normal View History

2012-12-11 08:00:18 +00:00
<?
2013-05-27 08:00:58 +00:00
include(SERVER_ROOT . '/classes/text.class.php');
include(SERVER_ROOT . '/classes/alias.class.php');
2012-12-11 08:00:18 +00:00
$Text = new TEXT(true);
$Alias = new ALIAS;
if (!empty($_GET['id']) && is_number($_GET['id'])) { //Visiting article via ID
$ArticleID = $_GET['id'];
} elseif ($_GET['name'] != '') { //Retrieve article ID via alias.
$ArticleID = $Alias->to_id($_GET['name']);
} 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
}
$Article = $Alias->article($ArticleID, false);
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
}
$TextBody = $Text->full_format($Body, false);
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,
'authorID' => (int) $AuthorID,
'authorName' => $AuthorName,
'date' => $Date,
'revision' => (int) $Revision
2013-04-24 08:00:23 +00:00
));
2013-05-27 08:00:58 +00:00
?>