' . $data . '' . "\n";
} else {
echo '
' . $data["string"] . '
' . "\n";
}
}
function display_warning($data) {
// Display warning messages
if (! is_array($data)) {
echo 'WARNING: ' . $data . '
' . "\n";
} else {
echo 'WARNING: ' . $data["string"] . '
' . "\n";
}
}
function display_page_header($config, $options) {
// Print Page header
include("includes/header.inc");
}
function display_page_footer($config, $options) {
// Print Page footer
include("includes/footer.inc");
}
function display_array($array, $keys) {
// Display an array as a HTML table
echo '' . "\n";
foreach ($keys as $key) {
echo '' . $key . ' ' . "\n";
}
echo ' ' . "\n";
foreach ($array as $data) {
echo '' . "\n";
foreach ($keys as $key) {
echo '' . $data[$key] . ' ' . "\n";
}
}
echo '
' . "\n";
}
function display_navigation($data, $offset, $action, $text) {
// Display the content navigation bar
$this_page = $data["blog"]->content_set_page($offset);
$remainder = $data["total"] % 10;
$remainder = "0." . $remainder;
$total_pages = ($data["total"] / 10) - $remainder - 1;
$total_pages += (($data["total"] > 10) && ($data["total"] % 10 != 0)) ? 1 : 0;
if ($total_pages > 0) {
echo '' . "\n";
if ($this_page > 0) {
$prev_page = $this_page - 1;
echo '
<< previous ' . $text . ' ';
}
for ($page = 0; $page <= $total_pages; $page++) {
if ($page == $this_page) {
echo $page;
} else {
echo '
' . $page . ' ';
}
}
if ($this_page < $total_pages) {
$next_page = $this_page + 1;
echo '
next ' . $text . ' >> ';
}
echo '
';
}
}
function display_posts($data) {
// Callback function to display all posts
$result = $data["query"];
if (empty($result)) {
return;
}
echo "\n" . '' . "\n";
echo '' . "\n";
foreach ($result as $entry) {
echo "\n";
echo '
' . "\n";
echo '
' . $entry['title'] . ' by ' . $entry['author'] . ' at ' . $entry['date'];
if ($entry["published"] != 1) {
echo " (not published)\n";
} else {
echo "\n";
}
echo '
' . "\n";
echo '
' . "\n";
echo strip_tags($entry["teaser"]) . "
\n";
echo '
' . "\n";
echo '
read more ' . "\n";
if ($entry["comments"] > 0) {
echo ' | ' . $entry["comments"] . ' comments';
}
if (isset($_SESSION["uid"]) && $entry["uid"] == $_SESSION["uid"]) {
echo ' |
edit ' . "\n";
} else {
echo "\n";
}
echo '
' . "\n";
echo '
' . "\n";
}
echo "\n";
display_navigation($data, "poffset", "read", "posts");
echo '
';
}
function display_comments($data) {
// Callback function to display comments
$result = $data["query"];
if (empty($result)) {
return;
}
echo "\n" . '' . "\n";
echo '' . "\n";
display("Comments");
foreach ($result as $entry) {
$id = $entry["id"];
echo "\n";
echo '
' . "\n";
echo $entry['title'] . ' by ' . $entry['author'] . ' at ' . $entry['date'];
if ($entry["published"] != 1) {
echo " (not published)\n";
} else {
echo "\n";
}
if (isset($_SESSION["uid"]) && $entry["uid"] == $_SESSION["uid"]) {
echo ' |
edit ' . "\n";
}
echo '
' . "\n";
echo '
' . "\n";
echo $entry["body"] . "\n";
echo '
' . "\n";
}
echo "\n";
if (isset($data["total"])) {
display_navigation($data, "coffset", "read&id=" . $id, "comments");
}
echo '
' . "\n";
}
function display_comment($data) {
// Alias for display_comments
display_comments($data);
}
function display_posts_admin($data) {
// Callback function to display all posts in the admin interface
$result = $data["query"];
if (empty($result)) {
return;
}
$blog = $data["blog"];
echo "\n" . '' . "\n\n";
echo '' . "\n";
display("Post administration");
echo '
' . "\n";
echo 'Id Title Author Date Pub Edit ' . "\n";
foreach ($result as $entry) {
echo '' . $entry["id"] . ' ' . $entry["title"] .
' ' . $entry["author"] . ' ' . $blog->truncate($entry["date"], 3) . "..." .
' ' . $entry["published"] .
' edit ' . "\n";
}
echo '
' . "\n";
display_navigation($data, "poffset", "admin", "posts");
echo '
' . "\n";
echo '
';
}
function display_comments_admin($data) {
// Callback function to display all posts in the admin interface
$result = $data["query"];
if (empty($result)) {
return;
}
$blog = $data["blog"];
echo "\n" . '' . "\n\n";
echo '' . "\n";
display("Comment administration");
echo '
' . "\n";
echo 'Cid Id Title Author Date Pub Edit ' . "\n";
foreach ($result as $entry) {
echo '' . $entry["cid"] . ' ' . $entry["id"] . ' ' . $entry["title"] .
' ' . $entry["author"] . ' ' . $blog->truncate($entry["date"], 3) . "..." .
' ' . $entry["published"] .
' edit ' . "\n";
}
echo '
' . "\n";
display_navigation($data, "coffset", "admin", "comments");
echo '
';
}
function display_post($data) {
// Callback function to display a single post
$result = $data["query"];
if (empty($result)) {
return;
}
$id = $data["id"];
echo "\n" . '' . "\n\n";
echo '' . "\n";
foreach ($result as $entry) {
echo '
' . "\n";
echo '
' . $entry['title'] . ' by ' . $entry['author'] . ' at ' . $entry['date'];
if ($entry["published"] != 1) {
echo " (not published)\n";
} else {
echo "\n";
}
echo '
' . "\n";
echo '
' . "\n";
echo $entry["body"] . "\n";
echo '
' . "\n";
}
$blog = $data["blog"];
$options = $blog->get_site_options();
$acl = $blog->user_acl_check();
if ($acl == "admin" || ($acl == "user" && $options["opencomment"] == "1")) {
echo '
Add a comment ' . "\n";
}
if (isset($_SESSION["uid"]) && $entry["uid"] == $_SESSION["uid"]) {
echo ' |
Edit ' . "\n";
}
echo '
';
}
function display_users($data) {
// Callback function for user display
$result = $data["query"];
echo "\n" . '' . "\n\n";
echo '' . "\n";
display("User administration");
echo '
' . "\n";
echo 'Id User Email Admin Edit ' . "\n";
foreach ($result as $entry) {
echo '' . $entry["uid"] . ' ' . $entry["user"] .
' ' . $entry["email"] . ' ' . $entry["admin"] .
' edit ' . "\n";
}
echo '
' . "\n";
echo '
' . "\n";
echo '
';
}
function display_option_radio($name, $value) {
// Display option radio buttons
if (! empty($value) && $value != "0") {
echo ' Yes' . "\n";
echo ' No ' . "\n";
} else {
echo ' Yes' . "\n";
echo ' No ' . "\n";
}
}
function display_options($data) {
// Display blog options
$blog = $data["blog"];
$options = $blog->get_site_options();
echo "\n" . '' . "\n\n";
echo '' . "\n";
display("Blog options");
$descriptions = $blog->get_option_descriptions();
echo '
' . "\n";
echo '' . "\n";
echo '
' . "\n";
echo '
' . "\n";
}
function display_login_box($data) {
// Display the blog login box
$blog = $data["blog"];
$config = $blog->config;
$options = $blog->get_site_options();
echo "\n" . '' . "\n\n";
echo ''. "\n";
echo '
' . "\n";
echo '
' . "\n";
if ($options["autoregister"] != "0") {
echo '
You can
register yourself for a new account.' . "\n";
}
echo '
' . "\n";
echo '
Search... ' . "\n";
echo '
' . "\n";
}
function display_user_info($data) {
// Display user information
$blog = $data["blog"];
$options = $blog->get_site_options();
$user_options = $blog->user_data($_SESSION["uid"]);
echo "\n" . '' . "\n\n";
echo '' . "\n";
echo '
' . "\n";
echo "Logged as " . $user_options["user"] . " \n";
echo '
' . "\n";
echo '
' . "\n";
echo '
' . "\n";
echo '
' . "\n";
echo '
' . "\n";
}
function display_edit_user_form($data) {
// Display new user form
$blog = $data["blog"];
$action = $data["action"];
$acl = $data["acl"];
$user_data = $data["user"];
echo "\n" . '' . "\n\n";
echo '' . "\n";
if ($action == "edituser") {
display("User editing page");
} else {
display('Welcome to the user registration page!
');
}
foreach (array("user", "email", "uid", "admin") as $key) {
if (! isset($user_data[$key])) {
$user_data[$key] = "";
}
}
echo '
' . "\n";
echo '' . "\n";
echo '
' . "\n";
echo '
' . "\n";
}
function display_post_editing_form($data) {
// Display an edition form for a given post
$result = $data["query"];
if (empty($result)) {
return;
}
if (isset($data["id"])) {
$id = $data["id"];
}
echo "\n" . '' . "\n\n";
echo '' . "\n";
display("Post editing form");
foreach ($result as $entry) {
echo '
' . "\n";
if (! empty($id)) {
echo '' . "\n";
echo '
' . "\n";
}
echo '
' . "\n";
}
function display_comment_editing_form($data) {
// Display an edition form for a given comment
$result = $data["query"];
if (empty($result)) {
return;
}
if (isset($data["cid"])) {
$cid = $data["cid"];
}
$id = $data["id"];
echo "\n" . '' . "\n\n";
echo '' , "\n";
}
function display_rss($data) {
// Callback function to display content in a RSS feed
$result = $data["query"];
if (empty($result)) {
return;
}
$options = $data["blog"]->get_site_options();
$link = 'http://' . $data["blog"]->config["site"] . "/";
header('Content-type: text/xml; charset=UTF-8');
echo '' . "\n";
echo '' . "\n";
echo '' . "\n";
echo '' . $options["sitename"] . ' ' . "\n";
echo '' . $options["sitedesc"] . ' ' . "\n";
echo ' ' . $link . '' . "\n";
echo 'Modulog ' . "\n";
foreach ($result as $entry) {
echo '- ' . "\n";
echo '
' . $entry['title'] . ' ' . "\n";
if (isset($entry["cid"])) {
echo ' ' . $link . '?query=read&id=' . $entry['id'] . '&cid=' . $entry['cid'] . '' . "\n";
echo '' . $link . '?query=read&id=' . $entry['id'] . '&cid=' . $entry['cid'] . ' ' . "\n";
} else {
echo ' ' . $link . '?query=read&id=' . $entry['id'] . '' . "\n";
echo '' . $link . '?query=read&id=' . $entry['id'] . ' ' . "\n";
}
echo '' . $entry['date'] . ' ' . "\n";
echo '' . strip_tags($entry['teaser']) . ' ' . "\n";
echo ' ' . "\n";
}
echo ' ' . "\n";
echo ' ' . "\n";
}
function display_search($data) {
// Display the search form and results
echo "\n" . '' . "\n\n";
echo '' . "\n";
display("Search form");
echo '
' . "\n";
echo 'Search keywords: ';
echo ' ';
echo ' ' . "\n";
echo '' . "\n";
if (isset($data["keywords"])) {
echo "\n" . '' . "\n\n";
echo '' . "\n";
if (isset($data["posts"])) {
display("Search results: posts");
foreach($data["posts"] as $entry) {
echo "\n";
echo '
' . "\n";
echo '
' . $entry['title'] . ' by ' . $entry['author'] . ' at ' . $entry['date'] . "\n";
echo '
' . "\n";
echo '
' . "\n";
echo strip_tags($entry["teaser"]) . "
\n";
echo '
' . "\n";
echo '
read more ' . "\n";
if ($entry["comments"] > 0) {
echo ' | ' . $entry["comments"] . ' comments';
}
if (isset($_SESSION["uid"]) && $entry["uid"] == $_SESSION["uid"]) {
echo ' |
edit ' . "\n";
} else {
echo "\n";
}
echo '
' . "\n";
echo '
' . "\n";
}
if (isset($data["comments"])) {
display("Search results: comments");
foreach($data["comments"] as $entry) {
$id = $entry["id"];
echo "\n";
echo '
' . "\n";
echo '
' . $entry['title'] . ' by ' . $entry['author'] . ' at ' . $entry['date'] . "\n";
if (isset($_SESSION["uid"]) && $entry["uid"] == $_SESSION["uid"]) {
echo ' |
edit ' . "\n";
}
echo '
' . "\n";
echo '
' . "\n";
echo $entry["body"] . "\n";
echo '
' . "\n";
}
}
echo '
' . "\n";
}
}
}
?>