<?php
require_once('../../../config.php');
require_once(FOLDER_RELATIVE_COMMON . 'database.php');
require_once(FOLDER_RELATIVE_COMMON . 'builder-user.php');
// Check for XML request (XMLHttpRequest).
$request = isset($_GET['request']) ? $_GET['request'] : '';
if ($request == 'xml') {
header('Content-Type: text/xml');
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n";
$sql = 'SELECT id, title, ' . databaseGetDate('stamp') . ' AS stamp FROM Stories ORDER BY stamp';
$rows = databaseGetRows($sql, array());
if (count($rows) == 0) {
echo "<root></root>\n";
exit;
}
$xml .= "<root>\n";
if (FLAG_TIMESTAMP == 'Y') {
$xml .= " <list_titles>\n";
$xml .= " <record>ID</record>\n";
$xml .= " <record>Modified</record>\n";
$xml .= " <record>Title</record>\n";
$xml .= " </list_titles>\n";
$xml .= " <list_data>\n";
foreach ($rows as $row) {
$story_id = $row['id'];
$story_date = $row['stamp'];
$story_title = $row['title'];
$xml .= " <record>\n";
$xml .= " <a0>$story_id</a0>\n";
$xml .= " <a1>$story_date</a1>\n";
$xml .= " <a2><![CDATA[$story_title]]></a2>\n";
$xml .= " </record>\n";
}
$xml .= " </list_data>\n";
} else {
$xml .= " <list_titles>\n";
$xml .= " <record>ID</record>\n";
$xml .= " <record>Title</record>\n";
$xml .= " </list_titles>\n";
$xml .= " <list_data>\n";
foreach ($rows as $row) {
$story_id = $row['id'];
$story_date = $row['stamp'];
$story_title = $row['title'];
$xml .= " <record>\n";
$xml .= " <a0>$story_id</a0>\n";
$xml .= " <a1><![CDATA[$story_title]]></a1>\n";
$xml .= " </record>\n";
}
$xml .= " </list_data>\n";
}
$xml .= "</root>\n";
echo $xml;
exit;
}
// Display a list of stories.
require_once(FOLDER_RELATIVE_COMMON . 'refolder.php');
$html = templateRefolderCSSAndJavascript(FILE_TEMPLATE_PAGE);
$header = '';
$onload = '';
$onload .= "jaxTableSetSuppressId(); ";
if (FLAG_TIMESTAMP == 'Y') {
$onload .= "jaxTableSetDateColumn(0, 'table_date'); ";
$onload .= "jaxTableSetLinkColumn(1, 'main.php?story_id='); ";
} else {
$onload .= "jaxTableSetLinkColumn(0, 'main.php?story_id='); ";
}
$onload .= "jaxTableRegister('user_stories_list.php?request=xml', 'storylist');";
if (FLAG_BREADCRUMB == 'Y') {
$content = "\t\t<div class=\"breadcrumb\"><a class=\"breadcrumb_link\" href=\"main.php\">Return Home</a></div>\n";
}
$content .= fileRead('user_stories_list.html');
$page = buildUserPage(null, null, $header, $onload, $content, '');
echo $page;
?>