Skip to content

Instantly share code, notes, and snippets.

@dshovchko
Created February 23, 2017 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dshovchko/7fb3df74ccafc502181c534329250020 to your computer and use it in GitHub Desktop.
Save dshovchko/7fb3df74ccafc502181c534329250020 to your computer and use it in GitHub Desktop.
_l10n_section_paint() - temporary fix
function _l10n_section_paint( $page )
{
$default = MLPLanguageHandler::get_site_default_lang();
#
# Insert the remaining language title fields...
#
global $l10n_mappings, $prefs;
$langs = MLPLanguageHandler::get_site_langs();
$fields = $l10n_mappings['txp_section'];
$editing = gps( 'name' );
$row = safe_row( '*' , 'txp_section' , "`name`='".doSlash($editing)."'" );
if( $row )
{
$ver = $prefs['version'];
$name = txpspecialchars($row['name']);
$title = txpspecialchars($row['title']);
preg_match_all('/<div class="txp-form-field edit-section-longtitle">([^<]*<[^>]*>){8}/', $page, $m);
$f = $m[0][0];
foreach( $fields as $field => $attributes )
{
$r = '';
foreach( $langs as $lang )
{
$full_name = MLPLanguageHandler::get_native_name_of_lang( $lang );
$dir = MLPLanguageHandler::get_lang_direction_markup( $lang );
if( $lang !== $default )
{
$field_name = _l10n_make_field_name( $field , $lang );
$field_value = $row[$field_name];
$r .= '<div class="txp-form-field edit-section-longtitle">';
$r .= '<div class="txp-form-field-label"><label for="section_title_'.$lang.'">['. $full_name .']</label></div>';
$r .= '<div class="txp-form-field-value"><input id="section_title_'.$lang.'" '.$dir.' name="'. $field_name .'" type="text" size="'.INPUT_REGULAR.'" value="'. $row[$field_name] .'" /></div>';
$r .= '</div>';
}
}
$page = str_replace( $f , $f.n.$r , $page );
}
}
#
# Insert the default title field's language's direction...
#
$dir = MLPLanguageHandler::get_lang_direction_markup( $default ) . ' ';
$f = 'id="section_title"';
$page = str_replace( $f , $f.$dir , $page );
#
# Insert the default title field's language name...
#
$f = '">'.gTxt('section_longtitle');
$r = '['.MLPLanguageHandler::get_native_name_of_lang( $default ) . ']';
$page = str_replace( $f , $f.n.$r , $page );
return $page;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment