|   | ',$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 = mysql_query($sql);
return mysql_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;
mysql_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 = mysql_query($sql);
$entry2 = mysql_fetch_assoc($qry);
if(!$entry2){ // Er ist schon der höchste
return;
}
$sql2 = 'Select * from faq_entries WHERE parent = '.$faqentry;
$qry2 = mysql_query($sql2);
while($row = mysql_fetch_assoc($qry2)){
$ids[] = $row['id'];
}
mysql_query('UPDATE faq_entries SET header = \''.$entry2['header'].'\', body = \''.$entry2['body'].'\' where id = '.$entry['id']);
mysql_query('UPDATE faq_entries SET header = \''.$entry['header'].'\', body = \''.$entry['body'].'\' where id = '.$entry2['id']);
mysql_query('Update faq_entries SET parent = '.$entry['id'].' where parent = '.$entry2['id']);
mysql_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 = mysql_query($sql);
$entry2 = mysql_fetch_assoc($qry);
if(!$entry2){ // Er ist schon der höchste
return;
}
$sql2 = 'Select * from faq_entries WHERE parent = '.$faqentry;
$qry2 = mysql_query($sql2);
while($row = mysql_fetch_assoc($qry2)){
$ids[] = $row['id'];
}
mysql_query('UPDATE faq_entries SET header = \''.$entry2['header'].'\', body = \''.$entry2['body'].'\' where id = '.$entry['id']);
mysql_query('UPDATE faq_entries SET header = \''.$entry['header'].'\', body = \''.$entry['body'].'\' where id = '.$entry2['id']);
mysql_query('Update faq_entries SET parent = '.$entry['id'].' where parent = '.$entry2['id']);
mysql_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 = mysql_query($sql);
while($row = mysql_fetch_assoc($qry)){
$ret[] = $row;
}
return $ret;
}
?> |