function _l10n_remap_fields($thing, $table, $get_mappings = false) { //$charset_collation = _l10n_get_db_charsetcollation(); static $interfaces = array('public', 'admin'); static $mappings; if (!isset($mappings)) { $mappings = array('txp_category' => array('title' => array('sql' => "varchar(255) NOT NULL DEFAULT ''", 'e' => 'category', 'paint_steps' => array('cat_article_edit', 'cat_link_edit', 'cat_image_edit', 'cat_file_edit'), 'paint' => '_l10n_category_paint', 'save_steps' => array('cat_article_create', 'cat_article_save', 'cat_link_create', 'cat_link_save', 'cat_image_create', 'cat_image_save', 'cat_file_create', 'cat_file_save'), 'save' => '_l10n_category_save')), 'txp_file' => array('description' => array('sql' => "text NOT NULL", 'e' => 'file', 'paint_steps' => array('file_edit'), 'paint' => '_l10n_file_paint', 'save_steps' => array('file_save'), 'save' => '_l10n_file_save')), 'txp_image' => array('alt' => array('sql' => "varchar(255) NOT NULL DEFAULT ''", 'e' => 'image', 'paint_steps' => array('image_edit'), 'paint' => '_l10n_image_paint', 'save_steps' => array('image_save'), 'save' => '_l10n_image_save'), 'caption' => array('sql' => "text NOT NULL", 'e' => '', 'paint_steps' => '', 'paint' => '', 'save_steps' => '', 'save' => '')), 'txp_link' => array('description' => array('sql' => "text NOT NULL", 'e' => 'link', 'save_steps' => array('link_post', 'link_save'), 'save' => '_l10n_link_save', 'paint_steps' => '', 'paint' => '_l10n_link_paint')), 'txp_section' => array('title' => array('sql' => "varchar(255) NOT NULL DEFAULT ''", 'e' => 'section', 'paint_steps' => array(''), 'paint' => '_l10n_section_paint', 'save_steps' => array('section_save', 'section_create'), 'save' => '_l10n_section_save'))); } if ($get_mappings) { //echo br , dmp( $mappings ); return $mappings; } if (!in_array(@txpinterface, $interfaces)) { return $thing; } if (!isset($mappings[$table])) { return $thing; } if (@txpinterface === 'admin') { $lang = MLPLanguageHandler::get_site_default_lang(); } else { global $l10n_language; if (isset($l10n_language['long'])) { $lang = $l10n_language['long']; } else { $lang = LANG; } } foreach ($mappings[$table] as $field => $sql) { $localised_field = _l10n_make_field_name($field, $lang); $r = "`{$localised_field}` as `{$field}`"; # # Replace specific matches... # $thing = str_replace($field, $r, $thing); # # Don't forget to override any wildcard search with specific mappings, # but not in count ops... # if (false === stripos($thing, '(*)')) { $thing = str_replace('*', '*,' . $r, $thing); } } return $thing; }
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 _upgrade_table($table, $table_key) { global $l10n_wiz_upgrade; $keys = safe_rows('*', $table, "1=1"); foreach ($keys as $key) { $index = $key[$table_key]; # Pull all gbp_l10n rows that are associated with this key... $ttable = PFX . $table; $rows = safe_rows('id,entry_value,language', 'gbp_l10n', "`entry_column` = 'title' AND `entry_id`='{$index}' AND `table` = '{$ttable}'"); if (empty($rows)) { continue; } # Build up values for each field... $set = array(); foreach ($rows as $row) { $lang = MLPLanguageHandler::find_lang($row['language'], $l10n_wiz_upgrade); $field = _l10n_make_field_name('title', $lang); $f_value = doSlash($row['entry_value']); $set[] = "`{$field}`='{$f_value}'"; if ($lang === $l10n_wiz_upgrade[0]) { $set[] = "`title`='{$f_value}'"; } } # Write the row back... $set = join(', ', $set); safe_update($table, $set, "`{$table_key}`='{$index}'"); # Delete the gbp_l10n entries used... safe_delete('gbp_l10n', "`entry_column` = 'title' AND `entry_id`='{$index}' AND `table` = '{$ttable}'"); } }
function _l10n_rewrite_sql($field, $lang, $sql) { $localised_field = _l10n_make_field_name($field, $lang); $r = '`' . $localised_field . '` as `' . $field . '`'; # # Replace specific matches... # $newsql = ' ' . $sql . ' '; #inject padding to allow detection of matches at start/end of the string. $v = array('`' . $field . '`' => $r, ',' . $field . ',' => ',' . $r . ',', ',' . $field . ' ' => ',' . $r . ' ', ' ' . $field . ',' => ' ' . $r . ',', ' ' . $field . ' ' => ' ' . $r . ' '); $newsql = str_replace(array_keys($v), array_values($v), $newsql); # # Don't forget to override any wildcard search with specific mappings, # but not in count ops... # if (false === stripos($newsql, '(*)')) { $newsql = str_replace('*', '*,' . $r, $newsql); } return $newsql; }