function lingotek_lingonode in Lingotek Translation 7.4
Same name and namespace in other branches
- 6 lingotek.util.inc \lingotek_lingonode()
- 7.2 lingotek.util.inc \lingotek_lingonode()
- 7.3 lingotek.util.inc \lingotek_lingonode()
35 calls to lingotek_lingonode()
- LingotekApi::addAdvancedParameters in lib/
Drupal/ lingotek/ LingotekApi.php - Adds advanced parameters for use with addContentDocument and updateContentDocument.
- LingotekApi::addContentDocument in lib/
Drupal/ lingotek/ LingotekApi.php - Add a document to the Lingotek platform.
- LingotekApi::updateContentDocument in lib/
Drupal/ lingotek/ LingotekApi.php - Updates the content of an existing Lingotek document with the current object contents.
- LingotekNode::loadLingonode in lib/
Drupal/ lingotek/ LingotekNode.php - Method for loading the values for the lingonode
- LingotekNode::__get in lib/
Drupal/ lingotek/ LingotekNode.php - Magic get for access to node and node properties.
1 string reference to 'lingotek_lingonode'
- lingotek_setup_node_translation_settings_form_submit in ./
lingotek.setup.inc - Node Translation Settings - Form Submit
File
- ./
lingotek.util.inc, line 47 - Utility functions.
Code
function lingotek_lingonode($nid, $key = "", $value = "") {
if ($nid == 'all') {
$lingo_node = array();
$result = db_select('lingotek', 'n')
->fields('n', array(
db_escape_field('nid'),
db_escape_field('lingokey'),
db_escape_field('lingovalue'),
))
->execute();
foreach ($result as $row) {
$lingo_node[$row->nid][$row->lingokey] = check_plain($row->lingovalue);
}
return $lingo_node;
}
if ($nid == -1) {
LingotekLog::error("Invalid -1 nid passed to lingotek_lingonode().", array(
'@nid' => $nid,
'@key' => $key,
'@value' => $value,
));
return FALSE;
}
if (is_numeric($nid) && $nid) {
//Return an array with all of the keys and values.
if ($key === "") {
$lingo_node = array();
$result = db_select('lingotek', 'n')
->fields('n', array(
db_escape_field('lingokey'),
db_escape_field('lingovalue'),
))
->condition(db_escape_field('nid'), $nid)
->execute();
foreach ($result as $row) {
$lingo_node[$row->lingokey] = check_plain($row->lingovalue);
}
return $lingo_node;
}
elseif ($value === "") {
$result = db_select('lingotek', 'n')
->fields('n', array(
db_escape_field('lingovalue'),
))
->condition(db_escape_field('nid'), $nid)
->condition(db_escape_field('lingokey'), $key)
->execute();
$row = $result
->fetchObject();
if ($row) {
return check_plain($row->lingovalue);
}
else {
return FALSE;
}
}
else {
$row = array(
db_escape_field('nid') => $nid,
db_escape_field('lingokey') => $key,
db_escape_field('lingovalue') => $value,
);
if (lingotek_lingonode($nid, $key) === FALSE) {
//Insert
drupal_write_record('lingotek', $row);
return "{$nid} : {$key} => {$value} INSERTED";
}
else {
//Update
drupal_write_record('lingotek', $row, array(
db_escape_field('nid'),
db_escape_field('lingokey'),
));
return "{$nid} : {$key} => {$value} UPDATED";
}
}
}
else {
LingotekLog::error("Invalid nid (@nid) passed to lingotek_lingonode().", array(
'@nid' => $nid,
'@key' => $key,
'@value' => $value,
));
return FALSE;
}
}