function lingotek_lingonode in Lingotek Translation 6
Same name and namespace in other branches
- 7.2 lingotek.util.inc \lingotek_lingonode()
- 7.3 lingotek.util.inc \lingotek_lingonode()
- 7.4 lingotek.util.inc \lingotek_lingonode()
12 calls to lingotek_lingonode()
File
- ./
lingotek.util.inc, line 20 - Utilities
Code
function lingotek_lingonode($nid, $key = "", $value = "") {
if ($nid == 'all') {
$lingo_node = array();
$result = db_query('SELECT n.nid, n.lingokey, n.lingovalue FROM {lingotek} n');
while ($row = db_fetch_object($result)) {
$lingo_node[$row->nid][$row->lingokey] = check_plain($row->lingovalue);
}
return $lingo_node;
}
elseif (is_numeric($nid) && $nid) {
//Return an array with all of the keys and values.
if ($key == "") {
$lingo_node = array();
$result = db_query('SELECT n.lingokey, n.lingovalue FROM {lingotek} n WHERE n.nid = %d', $nid);
while ($row = db_fetch_object($result)) {
$lingo_node[$row->lingokey] = check_plain($row->lingovalue);
}
return $lingo_node;
}
elseif ($value == "") {
$result = db_query("SELECT n.lingovalue FROM {lingotek} n WHERE n.nid = %d AND n.lingokey = '%s'", $nid, $key);
$row = db_fetch_object($result);
if ($row) {
return check_plain($row->lingovalue);
}
else {
return FALSE;
}
}
else {
//insert or update
// Insert
if (lingotek_lingonode($nid, $key) === FALSE) {
db_query("INSERT INTO {lingotek} VALUES(%d, '%s', '%s')", $nid, $key, $value);
}
else {
db_query("UPDATE {lingotek} SET lingovalue = '%s' WHERE nid = %d AND lingokey = '%s'", $value, $nid, $key);
}
}
}
}