Changeset 3479


Ignore:
Timestamp:
06/30/09 23:24:55 (11 years ago)
Author:
vdigital
Message:

merge r3477 from branch 2.0 to trunk
Bug 964 fixed and more

+ ?&lang=en_UK" => ?lang=en_UK"
+ =&lang=en_UK" => &lang=en_UK"
+ Works for any combinations of
$confquestion_mark_in_urls
$confphp_extension_in_urls
=> BUT force a return to home in some cases.
+ Full technical code review

Location:
trunk/plugins/language_switch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/language_switch/flags.tpl

    r3369 r3479  
    1818                                                                        {foreach from=$lang_switch.flags key=code item=flag name=f} 
    1919                                                                                <li> 
    20                                                                                         <a rel="nofollow" href="{$flag.url}"> 
     20                                                                                        <a rel="nofollow" href="{$SCRIPT_NAME}{$flag.url}"> 
    2121                                                                                                <img class="flags" src="{$flag.img}" alt="{$flag.alt}" title="{$flag.alt}"/> 
    2222                                                                                        </a> 
     
    3636{html_head} 
    3737{if $themeconf.template=='yoga' and $themeconf.theme=='Sylvia'} 
    38 <link rel="stylesheet" type="text/css" href="{$LANGUAGE_SWITCH_PATH|@cat:'language_switch.css'}">  
     38<link rel="stylesheet" type="text/css" href="{$ROOT_URL}{$LANGUAGE_SWITCH_PATH|@cat:'language_switch.css'}">  
    3939{else} 
    40 <link rel="stylesheet" type="text/css" href="{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-default.css'}">  
     40<link rel="stylesheet" type="text/css" href="{$ROOT_URL}{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-default.css'}">  
    4141{/if} 
    4242{if Componant_exists($LANGUAGE_SWITCH_PATH, 'language_switch-local.css')} 
    43 <link rel="stylesheet" type="text/css" href="{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-local.css'}">  
     43<link rel="stylesheet" type="text/css" href="{$ROOT_URL}{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-local.css'}">  
    4444{/if} 
    4545<!--[if lte IE 6]> 
    46 <link rel="stylesheet" type="text/css" href="{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-ie6.css'}">  
     46<link rel="stylesheet" type="text/css" href="{$ROOT_URL}{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-ie6.css'}">  
    4747<![endif]--> 
    4848{/html_head} 
  • trunk/plugins/language_switch/language_switch.inc.php

    r3376 r3479  
    6161    $available_lang = get_languages(); 
    6262    if ( isset($conf['no_flag_languages']) )  
    63       $available_lang = array_diff_key($available_lang, array_flip($conf['no_flag_languages'])); 
    64     $url_starting = $_SERVER['REQUEST_URI']; 
    65     if ( isset( $_GET['lang']) ) { 
    66       $pos = stripos  ( $url_starting  , '&lang=' ); 
    67       if (is_numeric($pos) and $pos > 0) $url_starting = substr($url_starting, 0, $pos); 
    68     } 
    69     $pos = stripos($url_starting, script_basename()); 
    70     if (is_numeric($pos)) $url_starting = substr($url_starting, $pos); 
     63      $available_lang =  
     64        array_diff_key($available_lang, array_flip($conf['no_flag_languages'])); 
     65    $url_starting = get_query_string_diff(array('lang')); 
    7166    foreach ( $available_lang as $code => $displayname ) { 
    7267      $qlc = array (  
    73         'url' => add_url_params( $url_starting, array('lang'=> $code) ), 
     68        'url' => str_replace(array('=&amp;','?&amp;'),array('&amp;','?'), 
     69                 add_url_params( $url_starting, array('lang'=> $code) )), 
    7470        'alt' => ucwords( $displayname ), 
    75         'img' => 'plugins/language_switch/icons/' . $code . '.jpg', 
     71        'img' => get_root_url().'plugins/language_switch/icons/' . $code . '.jpg', 
    7672        ); 
    77       if ( $code !== $user['language'] and file_exists(PHPWG_ROOT_PATH.$qlc['img']) )  
     73      if ( $code !== $user['language'] and  
     74          file_exists(dirname(__FILE__) . '/icons/' . $code . '.jpg') )  
    7875        $lsw['flags'][$code] = $qlc ; 
    7976      else $lsw['Active'] = $qlc; 
     
    8885    $template->clear_assign('lang_switch'); 
    8986    $template->concat( 'PLUGIN_INDEX_ACTIONS', $flags); 
    90     // TODO : Try to cache $flags and $user['language'] in $_SESSION for performance 
    9187  } 
    9288} 
  • trunk/plugins/language_switch/main.inc.php

    r3376 r3479  
    2424/* 
    2525Plugin Name: Language Switch 
    26 Version: 2.0.2a 
     26Version: 2.0.2b 
    2727Description: Switch to another language from flags on your gallery home page. 
    2828Plugin URI: http://piwigo.org/ext/extension_view.php?eid=123 
     
    3232 
    3333include_once(PHPWG_PLUGINS_PATH.'language_switch/language_switch.inc.php'); 
    34 add_event_handler('loading_lang', 'language_controler::_switch', 5 ); 
    35 add_event_handler('loc_end_index', 'language_controler::_flags', 95 ); 
     34$language_controler = new language_controler(); 
     35add_event_handler('loading_lang', array(&$language_controler, '_switch'), 5 ); 
     36add_event_handler('loc_end_index', array(&$language_controler, '_flags'), 95 ); 
    3637?> 
Note: See TracChangeset for help on using the changeset viewer.