Exemple #1
0
function _l10n_walk_mappings($fn, $atts = '')
{
    if (!is_callable($fn)) {
        return false;
    }
    global $l10n_mappings;
    if (!is_array($l10n_mappings)) {
        $l10n_mappings = _l10n_remap_fields('', '', true);
    }
    foreach ($l10n_mappings as $table => $fields) {
        foreach ($fields as $field => $attributes) {
            #	The user function must create a safe table name by calling safe_pfx() on the table name
            call_user_func($fn, $table, $field, $attributes, $atts);
        }
    }
    return true;
}
Exemple #2
0
function _l10n_check_localise_table($lang)
{
    $result = _l10n_check_lang_code($lang);
    if (!is_string($result)) {
        return $result;
    }
    global $l10n_mappings;
    if (!is_array($l10n_mappings)) {
        $l10n_mappings = _l10n_remap_fields('', '', true);
    }
    $missing_mappings = array();
    foreach ($l10n_mappings as $table => $fields) {
        $safe_table = safe_pfx($table);
        foreach ($fields as $field => $attributes) {
            $f = _l10n_make_field_name($field, $lang);
            $exists = getThing("SHOW COLUMNS FROM {$safe_table} LIKE '{$f}'");
            if (!$exists) {
                if (!isset($missing_mappings[$table])) {
                    $missing_mappings[$table] = array();
                }
                $missing_mappings[$table][$field] = $attributes['sql'];
            }
        }
    }
    if (count($missing_mappings) > 0) {
        return $missing_mappings;
    } else {
        return true;
    }
}