Minor code review
git-svn-id: http://piwigo.org/svn/trunk@2162 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
51e3d211c8
commit
4601ff1c36
2 changed files with 49 additions and 64 deletions
|
|
@ -1,11 +1,4 @@
|
|||
<?php /*
|
||||
Plugin Name: Language Switch
|
||||
Version: 1.0
|
||||
Description: Give you an advice on the administration page.
|
||||
Plugin URI: http://www.phpwebgallery.net
|
||||
Author: PhpWebGallery team
|
||||
Author URI: http://www.phpwebgallery.net
|
||||
*/
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
|
|
@ -33,24 +26,21 @@ Author URI: http://www.phpwebgallery.net
|
|||
function language_switch()
|
||||
{
|
||||
global $user, $template, $conf, $lang;
|
||||
|
||||
if (!isset($user['status']))
|
||||
{ die('You are not authorized to access this page'); };
|
||||
|
||||
if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
|
||||
if ( isset( $_GET['lang']) )
|
||||
{
|
||||
if ( !empty($_GET['lang'] ) and
|
||||
file_exists( PHPWG_ROOT_PATH.'language/'.$_GET['lang'].'/common.lang.php') )
|
||||
file_exists( PHPWG_ROOT_PATH.'language/'
|
||||
. $_GET['lang'].'/common.lang.php') )
|
||||
{
|
||||
if ($user['is_the_guest'] or $user['status'] == 'generic')
|
||||
if (is_a_guest() or is_generic())
|
||||
{
|
||||
setcookie( 'pwg_lang_switch', $_GET['lang'],
|
||||
time()+60*60*24*30, cookie_path() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = '
|
||||
UPDATE '.USER_INFOS_TABLE.'
|
||||
$query = 'UPDATE '.USER_INFOS_TABLE.'
|
||||
SET language = \''.$_GET['lang'].'\'
|
||||
WHERE user_id = '.$user['id'].'
|
||||
;';
|
||||
|
|
@ -61,10 +51,11 @@ if ( isset( $_GET['lang']) )
|
|||
}
|
||||
// Users have $user['language']
|
||||
// Guest or generic members will use their cookied language !
|
||||
|
||||
if ((is_a_guest() or is_generic())
|
||||
and isset( $_COOKIE['pwg_lang_switch'] ) )
|
||||
{ $user['language'] = $_COOKIE['pwg_lang_switch']; }
|
||||
{
|
||||
$user['language'] = $_COOKIE['pwg_lang_switch'];
|
||||
}
|
||||
|
||||
load_language('common.lang', '', $user['language']);
|
||||
load_language('local.lang', '', $user['language']);
|
||||
|
|
@ -75,10 +66,6 @@ if (defined('IN_ADMIN') and IN_ADMIN)
|
|||
}
|
||||
//if ( isset( $_GET['lang']) ) { redirect( make_index_url() ); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function Lang_flags()
|
||||
{
|
||||
global $user, $template;
|
||||
|
|
@ -90,8 +77,6 @@ foreach ( $available_lang as $code => $displayname )
|
|||
$qlc_title = $qlc_alt;
|
||||
$qlc_img = PHPWG_PLUGINS_PATH.'language_switch/icons/'
|
||||
. $code . '.gif';
|
||||
// echo $code . ' '. $qlc_url .' // <br />';
|
||||
// echo $user['language'] . ' '. $qlc_img .' /// <br />';
|
||||
|
||||
if ( $code !== $user['language'] and file_exists($qlc_img) )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php /*
|
||||
Plugin Name: Language Switch
|
||||
Version: 1.0
|
||||
Description: Give you an advice on the administration page.
|
||||
Description: Switch to another language from flags on your gallery home page.
|
||||
Plugin URI: http://www.phpwebgallery.net
|
||||
Author: PhpWebGallery team
|
||||
Author URI: http://www.phpwebgallery.net
|
||||
|
|
@ -30,7 +30,7 @@ Author URI: http://www.phpwebgallery.net
|
|||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
add_event_handler('loading_lang', 'language_switch' );
|
||||
include_once(PHPWG_PLUGINS_PATH.'language_switch/language_switch.inc.php');
|
||||
add_event_handler('loading_lang', 'language_switch' );
|
||||
add_event_handler('loc_end_index', 'Lang_flags' );
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue