";
if ($count>1) {
$retval .= "
| ";
} else {
$retval .= "$word | ";
}
$comment = wordwrap($comment, 25, "\n", 1);
// $comment = str_replace("\n", "
", $comment);
$html_trans = htmlentities ($trans);
$html_comment = htmlentities ($comment);
$retval .= "
$count. |
$type |
$html_trans |
$html_comment |
Bearbeiten -
Löschen |
";
return $retval;
}
// connect to the database (with write access)
mysql_connect($hostname, $username, $password);
/* Vars passed to us:
$wid - Word ID (needed)
$trans - translation of the word with ID $wid (optional)
$type - type of the word with ID $wid (optional)
$comment - comment of the translation (optional)
$processed - set if the form has been displayed and the user hit submit
!!! DO NOT SET BY HAND !!!
*/
// see how we were called
if (!$wid) {
$smarty->assign ('caption', 'fehler');
$smarty->assign ('content', 'Dieses Script kann nur von anderen Scripten aus aufgerufen werden!
');
$smarty->display ('standard.tpl');
exit;
}
$smarty->assign ('caption', 'eintrag erweitern');
$content = "";
if (($processed != 1) || !$trans || !$type) {
// no translation or type given
if ((!$trans || !$type) && ($processed == 1)) {
$content .= "Es wurde (noch) keine Übersetzung oder Wortart angegeben!
\n";
$content .= " 
\n";
}
// first of all show the existing entry
$content .= "Der folgende Eintrag wird erweitert:
\n";
$content .= "\n";
$content .= "| Wort | | Wortart | Übersetzung | Kommentar | Aktionen |
";
$query = "SELECT *
FROM $wordstable w, $transtable tr, $typestable typ
WHERE tr.tid = typ.tid
AND typ.wid = w.wid
AND w.wid = '$wid'
ORDER by word";
$result = mysql_db_query($dbName, $query);
if ($result && mysql_num_rows($result) > 0) {
/*
$res = mysql_fetch_array($result);
$word_old = $res[word];
*/
$word_old = "";
$i = 1;
while ($res = mysql_fetch_array($result)) {
if ($word_old != $res[word]) {
$word_old = $res[word];
$i = 1;
$content .= "|   |
";
}
$content .= get_result($res[wid],$res[tid],$res[word],$res[translation],$res[type],$res[comment],$i);
$i++;
}
}
$content .= "|   |
";
$content .= "
";
$content .= '
';
} else {
// all needed data has been passed to us, so just insert the new entry
// here we need the "old style" sql-queries, because we exactly need to know
// steps by step which tables do contain stuff
// first, see if the type $type is already in the table
$type_exists = 0;
$query = "SELECT * FROM $typestable WHERE type = '$type' AND wid = '$wid'";
$result_temp = mysql_db_query($dbName, $query);
$r_temp = mysql_fetch_array($result_temp);
if (!$r_temp) {
// type does not exist, so insert it
$query = "INSERT INTO $typestable VALUES(NULL, '$wid', '$type')";
$result1 = mysql_query($query);
} else {
$type_exists = 1;
}
// get the tid which has been assigned by mySQL
$query = "SELECT * FROM $typestable WHERE type = '$type' AND wid = '$wid'";
$result2 = mysql_db_query($dbName, $query);
$r_temp = mysql_fetch_array($result2);
$tid = $r_temp[tid];
// see if the translation already exists
$query = "SELECT * FROM $transtable WHERE translation = '$trans' AND tid = '$tid'";
$result3 = mysql_db_query($dbName ,$query);
if (0 == mysql_num_rows($result3)) {
// does not exist
// now we can put the new translation in the DB
$query = "INSERT INTO $transtable VALUES('$tid', '$trans', '$comment')";
$result3 = mysql_query($query);
if (($type_exists == 0 && !$result1) || !$result2 || !$result3) {
$content .= 'Es ist ein Fehler beim Eintragen aufgetreten. Bitte kontaktieren sie den Webmaster!
';
} else {
$content .= "Ergänzung wurde erfolgreich in die Datenbank aufgenommen.
";
}
} else {
$content .= "Die Übersetzung für dieses Wort ist in der DB bereits vorhanden!
";
}
}
$smarty->assign ('content', $content);
$smarty->display ('standard.tpl');
?>