function _i18nblocks_nodeasblock in Internationalization 5.2
Same name and namespace in other branches
- 5.3 i18nblocks/i18nblocks.module \_i18nblocks_nodeasblock()
- 5 i18nblocks/i18nblocks.module \_i18nblocks_nodeasblock()
Helper function: collect translation nids and get related nodeasblock block
1 call to _i18nblocks_nodeasblock()
- i18nblocks_form_alter in i18nblocks/
i18nblocks.module - Implementation of block form_alter().
File
- i18nblocks/
i18nblocks.module, line 180
Code
function _i18nblocks_nodeasblock($node) {
$nids = $translations = array();
if ($node->trid) {
// It is a translation
$translations = translation_node_get_translations(array(
'trid' => $node->trid,
));
}
elseif ($node->translation_nid) {
// Translation is just being created
$translations = translation_node_get_translations(array(
'nid' => $node->translation_nid,
), TRUE);
$nids[$node->translation_nid] = $node->translation_nid;
}
foreach ($translations as $lang => $trn) {
$nids[$trn->nid] = $trn->nid;
}
if ($node->nid) {
// Updating existing node, no translations yet
$nids[$node->nid] = $node->nid;
}
// Check for existing block
if (!empty($nids) && ($i18nblock = db_fetch_array(db_query_range("SELECT m.* FROM {i18n_blocks} m INNER JOIN {i18n_blocks_i18n} b ON m.delta = b.bid WHERE m.type = 'nodeasblock' AND b.delta IN (%s)", implode(',', $nids), 0, 1)))) {
$i18nblock['nids'] = $nids;
return $i18nblock;
}
}