<?php
include('includes/databaseLogin.php');
include('includes/installedLanguage.php');
echo "<!DOCTYPE html>";
?>
<html>
<head>
<link rel="stylesheet" href="css/style.css" />
</head>
<?php
$questionsCount = 0;
$indexCount = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
//find the distance from the root and build up a option for a select field
function labelOption($node, $nodeIndex, $tab){
$index=0;
$radice = '';
while($index<$tab){
$index++;
$radice = $radice . "--";
}
echo"<option value=\"" . $nodeIndex . "\">" . $radice . "" . $node . "</option>";
}
//Visit the labels tree and build up a
function moveTreeVisit($node, $index, $tab){
//cast the function to execute on the label
if($node != 'root'){
labelOption($node, $index, $tab);
}
//serch for label's sons
$getLabels = mysql_query("SELECT * FROM labels WHERE labelParent='" . $index . "'");
if(!$getLabels){
}else{
while($row = mysql_fetch_array($getLabels)) {
moveTreeVisit($row[labelName], $row[labelID], $row[labelTab]);
}
}
}
function nodeAndFaqDisplay($node, $index, $tab){
global $questionsCount;
echo "<table><tr><td><a href=\"#index\">[<img src=\"images/frecciasu.png\">]</a></td><td><a name=\"" . $node . "i" . $index . "\"><h" . $tab . " style=\"padding-bottom: 10px;\">" . $node . "</h" . $tab . "></a></td></tr></table>";
$questionsCount++;
$getQuestions = mysql_query("SELECT * FROM questions WHERE questStatus='2' AND questLabel='" . $index . "'");
if(!$getQuestions){
}else{
while($row = mysql_fetch_array($getQuestions)) {
echo "<div style=\"margin: 0px 0px 10px 0px; float: right; border: solid 1px gray; background-color: #FFCCFF; width: 100%;\">";
echo "<table style=\"width: 100%;\">";
echo "<tr><td><b><i>" . nl2br($row[questBody]) . "</i></b></td>";
if($_POST[priv] == 'w'){
echo "<td style=\"width: 10%; vertical-align: top; text-align: right;\"><a class=\"aFaqDelete\" name=\"" . $row[questID] . "\" href=\"#\"><img src=\"images/cancella.png\"></a></td></tr>";
echo "<tr><td><i>" . nl2br($row[questAnswer]) . "</i></td><td></td></tr>";
echo "<tr><td colspan=\"2\" style=\"text-align: right;\" valign=\"top\">" . _T("Move FAQ in") . "<select class=\"sNewChapter\" name=\"" . $row[questID] . "\" id=\"sel_" . $row[questID] . "\"><option value=\"0\"></option>";
moveTreeVisit('root', '1', '0');
echo "</select></td></tr>";
}else{
echo "<td></td></tr>";
echo "<tr><td><i>" . nl2br($row[questAnswer]) . "</i></td><td></td></tr>";
}
echo "</table>";
echo "</div>";
$questionsCount++;
}
}
}
function nodeAndIndexDisplay($node, $index, $tab){
global $indexCount;
$indexCount[$tab]++;
$wIndex = $tab + 1;
while($wIndex <= 20){
$indexCount[$wIndex] = 0;
$wIndex++;
}
$wIndex = 2;
$iIndex = $indexCount[1];
while($wIndex <= $tab){
$iIndex = $iIndex . "." . $indexCount[$wIndex];
$wIndex++;
}
$wIndex = 1;
echo "<p style=\"color: white;\">";
while($wIndex < $tab){
$wIndex++;
echo "....";
}
echo "<a href=\"#" . $node . "i" . $index . "\">[" . $iIndex . "] " . $node . "</a>";
echo "</p>";
}
function questionsDisplay($node, $index, $tab){
//$widthPerCent = 100 - 5 * ($tab - 1) - 1;
$widthPerCent = 100;
//cast the function to execute on the label
if($node != 'root'){
echo "<div style=\"float: right; width: " . $widthPerCent . "%;\">";
nodeAndFaqDisplay($node, $index, $tab);
}
//serch for label's sons
$getLabels = mysql_query("SELECT * FROM labels WHERE labelParent='" . $index . "'");
if(!$getLabels){
}else{
while($row = mysql_fetch_array($getLabels)) {
questionsDisplay($row[labelName], $row[labelID], $row[labelTab]);
}
}
if($node != 'root'){
echo "</div>";
}
}
function indexDisplay($node, $index, $tab){
//cast the function to execute on the label
if($node != 'root'){
nodeAndIndexDisplay($node, $index, $tab);
}
//serch for label's sons
$getLabels = mysql_query("SELECT * FROM labels WHERE labelParent='" . $index . "'");
if(!$getLabels){
}else{
while($row = mysql_fetch_array($getLabels)) {
indexDisplay($row[labelName], $row[labelID], $row[labelTab]);
}
}
}
?>
<body>
<?php
mysql_query("BEGIN");
if(isset($_POST[sCode])){
echo "<span class=\"BlockHeader\"><span>" . _T("FAQs") . "</span></span>";
echo "<div style=\"border: solid 1px gray;\"><a name=\"index\"><h1>" . _T("INDEX") . "</h1></a>";
indexDisplay('root', '1', '0');
echo "</div>";
questionsDisplay('root', '1', '0');
}
mysql_query("COMMIT");
?>
</body>
</html>