|   | ',$values['node']['body']).$app2."\n";
}
$keys = array_keys($values);
$i = 1;
foreach($keys as $key){
if(is_numeric($key)){
$string .= getContextRec($number.($i++).'.',$values[$key],$pre1, $pre2, $app1, $app2);
}
}
return $string;
}
function getContext($pre1, $pre2, $app1, $app2){
$val = getAllFaqEntries();
$ret = getContextRec("",$val, $pre1, $pre2, $app1, $app2);
return $ret;
}
function getEntry($faqentry){
$sql = 'Select * from faq_entries WHERE id = '.$faqentry;
$qry = db_query($sql);
return mysqli_fetch_assoc($qry);
}
function updateEntry($faqentry, $parent,$header,$body){
$parentpart = $parent!=null?'parent = '.$parent.',':'';
$sql = 'UPDATE faq_entries SET '.$parentpart.' header = \''.encodeNoHTMLWithBB($header).'\', body = \''.encodeNoHTMLWithBB($body).'\' WHERE id = '.$faqentry;
db_query($sql);
}
function moveUp($faqentry){
$entry = getEntry($faqentry);
$sql = 'Select * from faq_entries WHERE parent = '.$entry['parent'].' AND id < '.$entry['id'].' order by id desc LIMIT 1';
$qry = db_query($sql);
$entry2 = mysqli_fetch_assoc($qry);
if(!$entry2){ // Er ist schon der höchste
return;
}
$sql2 = 'Select * from faq_entries WHERE parent = '.$faqentry;
$qry2 = db_query($sql2);
while($row = mysqli_fetch_assoc($qry2)){
$ids[] = $row['id'];
}
db_query('UPDATE faq_entries SET header = \''.$entry2['header'].'\', body = \''.$entry2['body'].'\' where id = '.$entry['id']);
db_query('UPDATE faq_entries SET header = \''.$entry['header'].'\', body = \''.$entry['body'].'\' where id = '.$entry2['id']);
db_query('Update faq_entries SET parent = '.$entry['id'].' where parent = '.$entry2['id']);
db_query('Update faq_entries SET parent = '.$entry2['id'].' where id IN ('.join($ids, ',').')');
}
function moveDown($faqentry){
$entry = getEntry($faqentry);
$sql = 'Select * from faq_entries WHERE parent = '.$entry['parent'].' AND id > '.$entry['id'].' order by id asc LIMIT 1';
$qry = db_query($sql);
$entry2 = mysqli_fetch_assoc($qry);
if(!$entry2){ // Er ist schon der höchste
return;
}
$sql2 = 'Select * from faq_entries WHERE parent = '.$faqentry;
$qry2 = db_query($sql2);
while($row = mysqli_fetch_assoc($qry2)){
$ids[] = $row['id'];
}
db_query('UPDATE faq_entries SET header = \''.$entry2['header'].'\', body = \''.$entry2['body'].'\' where id = '.$entry['id']);
db_query('UPDATE faq_entries SET header = \''.$entry['header'].'\', body = \''.$entry['body'].'\' where id = '.$entry2['id']);
db_query('Update faq_entries SET parent = '.$entry['id'].' where parent = '.$entry2['id']);
db_query('Update faq_entries SET parent = '.$entry2['id'].' where id IN ('.join($ids, ',').')');
}
function getChildren($faqentry){
$sql = 'Select * from faq_entries where parent = '.$faqentry.' order by id asc';
$qry = db_query($sql);
while($row = mysqli_fetch_assoc($qry)){
$ret[] = $row;
}
return $ret;
}
?> |