Changeset 3368 for branches


Ignore:
Timestamp:
May 29, 2009, 11:26:27 PM (15 years ago)
Author:
vdigital
Message:

+ Language Switch enhanced design and concepts.

Location:
branches/2.0/plugins/language_switch
Files:
22 added
18 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/plugins/language_switch/language_switch.inc.php

    r3046 r3368  
    2121// | USA.                                                                  |
    2222// +-----------------------------------------------------------------------+
     23if (!defined('LANGUAGE_SWITCH_PATH'))
     24define('LANGUAGE_SWITCH_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    2325function language_switch()
    2426{
     
    6769}
    6870//if ( isset( $_GET['lang']) ) { redirect( make_index_url() ); }
     71function Lang_flags()
     72{
     73  global $user, $template;
     74  $available_lang = get_languages();
     75        $lsw = array();
     76  foreach ( $available_lang as $code => $displayname )
     77  {
     78    $qlc_url = add_url_params( make_index_url(), array( 'lang' => $code ) );
     79    $qlc_alt = ucwords( $displayname );
     80    $qlc_img =  'plugins/language_switch/icons/'
     81       . $code . '.jpg';
     82    if ( $code !== $user['language'] and file_exists(PHPWG_ROOT_PATH.$qlc_img) )
     83    {
     84      $lsw['flags'][$code] = Array(
     85                                'url' => $qlc_url,
     86                                'alt' => $qlc_alt,
     87                                'img' => $qlc_img,
     88                        ) ;
     89    } else {
     90                        $lsw['Active'] = Array(
     91                                'url' => $qlc_url,
     92                                'alt' => $qlc_alt,
     93                                'img' => $qlc_img,
     94                        );
     95                }
     96  }
     97        $template->set_filename('language_flags', dirname(__FILE__) . '/flags.tpl');
     98        $lsw['side'] = ceil(sqrt(count($available_lang)));
     99        $template->assign(array(
     100                'lang_switch'=> $lsw,
     101                'LANGUAGE_SWITCH_PATH' => LANGUAGE_SWITCH_PATH,
     102        ));
     103        $flags = $template->parse('language_flags',true);
     104        $template->clear_assign('lang_switch');
     105        $template->concat( 'PLUGIN_INDEX_ACTIONS', $flags);
     106        // In state of making a $flags each time TODO Caching $flags[$user['language']]
     107}
    69108
    70 function Lang_flags()
     109if (!function_exists('Componant_exists')) {
     110        function Componant_exists($path, $file)
     111        {
     112          return file_exists( $path . $file);
     113        }
     114}
     115
     116// Should be deleted later
     117function Lang_flags_previous_function()
    71118{
    72119  global $user, $template;
  • branches/2.0/plugins/language_switch/main.inc.php

    r3274 r3368  
    2424/*
    2525Plugin Name: Language Switch
    26 Version: 2.0.2
     26Version: 2.0.2a
    2727Description: Switch to another language from flags on your gallery home page.
    2828Plugin URI: http://piwigo.org/ext/extension_view.php?eid=123
Note: See TracChangeset for help on using the changeset viewer.