function do_fleshout_names(&$langs, $suffix = '', $append_code = true, $append_default = false, $use_long = true) { $result = array(); if (is_array($langs) and !empty($langs)) { foreach ($langs as $code) { $code = trim($code); $tmp = MLPLanguageHandler::get_native_name_of_lang($code); if ($append_code) { $tmp .= ' [' . $code . ']'; } if (!$use_long) { $code = substr($code, 0, 2); } if (!empty($suffix)) { $tmp .= ' ' . $suffix; } if ($append_default and $code === MLPLanguageHandler::get_site_default_lang()) { $tmp .= ' - ' . gTxt('default'); } $result[$code] = $tmp; } } return $result; }
function _l10n_image_paint($page) { $default = MLPLanguageHandler::get_site_default_lang(); # # Insert the remaining language fields... # global $l10n_mappings; $langs = MLPLanguageHandler::get_site_langs(); $fields = $l10n_mappings['txp_image']; $id = gps('id'); $row = safe_row('*', 'txp_image', "`id`='{$id}'"); $r = ''; $count = 2; foreach ($langs as $lang) { if ($lang !== $default) { $full_name = MLPLanguageHandler::get_native_name_of_lang($lang); $dir = MLPLanguageHandler::get_lang_direction_markup($lang); foreach ($fields as $field => $attributes) { $field_name = _l10n_make_field_name($field, $lang); if ($field === 'alt') { $r .= '<p>' . gTxt('alt_text') . ' ' . $full_name . '<br/>'; $r .= '<input type="text" name="' . $field_name . '" ' . $dir . ' value="' . $row[$field_name] . '" size="50" class="edit" id="' . $field_name . '" /></p>' . n; } else { $r .= '<p>' . gTxt('caption') . ' ' . $full_name . '<br/>'; $r .= '<textarea name="' . $field_name . '" cols="40" rows="5" style="width: 400px; height: 100px;"' . $dir . '>'; $r .= $row[$field_name] . '</textarea></p>' . n; } } } } $f = '<p><input type="submit" value="'; $page = str_replace($f, $r . n . $f, $page); # # Insert the default title field's language's direction... # $dir = MLPLanguageHandler::get_lang_direction_markup($default) . ' '; $f = '<input type="text" name="alt"'; $page = str_replace($f, $f . $dir, $page); $f = '<textarea id="caption"'; $page = str_replace($f, $f . $dir, $page); # # Insert the default title field's language name... # $f = 'for="alt-text">' . gTxt('alt_text'); $r = ' ' . MLPLanguageHandler::get_native_name_of_lang($default); $page = str_replace($f, $f . sp . $r, $page); $f = 'for="caption">' . gTxt('caption'); $page = str_replace($f, $f . sp . $r, $page); return $page; }
function setup_4_cb($table, $field, $attributes) { $langs = MLPLanguageHandler::get_site_langs(); $default = MLPLanguageHandler::get_site_default_lang(); $extend_all = array('txp_category', 'txp_section'); $do_all = in_array($table, $extend_all); $safe_table = safe_pfx($table); foreach ($langs as $lang) { $f = _l10n_make_field_name($field, $lang); $exists = getThing("SHOW COLUMNS FROM {$safe_table} LIKE '{$f}'"); if ($exists) { $this->add_report_item(gTxt('l10n-skip_field', array('{field}' => $f, '{table}' => $table)), true, true); continue; } $sql = "ADD `{$f}` " . $attributes['sql']; $ok = @safe_alter($table, $sql); $this->add_report_item(gTxt('l10n-add_field', array('{field}' => $f, '{table}' => $table)), $ok, true); if (!$ok) { continue; } if ($do_all or $lang === $default) { $sql = "UPDATE {$safe_table} SET `{$f}`=`{$field}` WHERE `{$f}`=''"; $ok = @safe_query($sql); if ($lang === $default) { $this->add_report_item(gTxt('l10n-copy_defaults', array('{field}' => $f, '{table}' => $table)), $ok, true); } } } }
function l10n_get_lang_dir($atts) { /* Outputs the direction (rtl/ltr) of the current language. Use in page/forms to output the direction needed by xhtml elements. */ global $l10n_language; extract(lAtts(array('type' => 'short'), $atts)); if (!$l10n_language) { $lang = MLPLanguageHandler::compact_code(MLPLanguageHandler::get_site_default_lang()); } else { $lang = $l10n_language; } $dir = MLPLanguageHandler::get_lang_direction($lang[$type]); return $dir; }