Page 1 of 1

[BUG? REPORT] undefined index: locale and locale_cms error

Posted: Mon Dec 17, 2007 10:15 am
by pshouse
I installed CMSMS MLE 1.2.2 and got this PHP errors on my site (both fronted & admin):

Notice: Undefined index: locale_cms in c:\programmi\easyphp1-8\www\cmsms\include.php on line 229
Notice: Undefined index: locale in c:\programmi\easyphp1-8\www\cmsms\include.php on line 230

I resolved them, by adding locale and locale_cms assignation in config_lang.php
but there it says these parameters are "OPTIONAL", so maybe this is a bug, I wanted to signal.
Or maybe I need community assistance, if I did something wrong that shows me that errors, that shouldn't be there.

Re: [BUG? REPORT] undefined index: locale and locale_cms error

Posted: Mon Dec 17, 2007 12:48 pm
by alby
pshouse wrote: I installed CMSMS MLE 1.2.2 and got this PHP errors on my site (both fronted & admin):

Notice: Undefined index: locale_cms in c:\programmi\easyphp1-8\www\cmsms\include.php on line 229
Notice: Undefined index: locale in c:\programmi\easyphp1-8\www\cmsms\include.php on line 230

I resolved them, by adding locale and locale_cms assignation in config_lang.php
but there it says these parameters are "OPTIONAL", so maybe this is a bug, I wanted to signal.
Or maybe I need community assistance, if I did something wrong that shows me that errors, that shouldn't be there.
They are php Notice not error.
For view this or you have debug to true in config.php or your error_reporting setting (php.ini or .htaccess) is about maximum.

However, it is right, because they are optional this notice should not appear.
My mistake have not controlled with E_ALL the presence of notice  :-[

Alby

Re: [BUG? REPORT] undefined index: locale and locale_cms error

Posted: Thu Feb 21, 2008 10:56 am
by chipper
Hi Alby

After asking a few dumb questions I now have 2 sites running using mle and think it's great. However this morning I find I have the exact problem described in this thread.

My error messages are as follows:

Notice: Undefined index: locale_cms in /home/gwaenysg/public_html/include.php on line 229

Notice: Undefined index: locale in /home/gwaenysg/public_html/include.php on line 230

I have checked the include.php file for the relelvant lines and find:
// Start MLE
$hl = '';
$mleblock = '';
$mlelocale = '';
$mlelocale_cms = '';
if(file_exists(cms_join_path($dirname,'config_lang.php'))) require_once(cms_join_path($dirname,'config_lang.php'));

if(isset($hls))
{
require_once(cms_join_path($dirname,'mle','function.mle.php'));

$mle = '';
if($config['internal_pretty_urls']) $mle = check_mle_pretty_urls($hls);
if(!empty($_POST['hl'])) $mle = $_POST['hl'];
if(!empty($_GET['hl'])) $mle = $_GET['hl'];

if( (! empty($mle)) && in_array($mle, array_keys($hls)) )
{
  $hl = $mle;
  if(isset($CMS_ADMIN_PAGE)) setcookie('mle_admin', $hl, time()+3600, '/');
  elseif( (empty($_COOKIE['mle'])) || ($hl != $_COOKIE['mle']) ) setcookie('mle', $hl, time()+86400, '/');
}
elseif( (isset($CMS_ADMIN_PAGE)) && (isset($_COOKIE['mle_admin'])) ) $hl = $_COOKIE['mle_admin'];
elseif( (! isset($CMS_ADMIN_PAGE)) && (isset($_COOKIE['mle'])) ) $hl = $_COOKIE['mle'];
else
{
  if(isset($CMS_ADMIN_PAGE))
  {
   $mlelocale_cms = get_preference($gCms->variables['user_id'], 'default_cms_language');
   if(! empty($mlelocale_cms))
   {
    if(in_array($mlelocale_cms, array_keys($hls))) $hl = $mlelocale_cms;
    else
    {
     $t_hls = transform_language_arr($hls);
     if(in_array($mlelocale_cms, array_keys($t_hls['locale']))) $hl = $t_hls['locale']["$mlelocale_cms"];
    }
   }
   elseif(in_array(DEFAULT_LANG, array_keys($hls))) $hl = DEFAULT_LANG;
   else die('Check DEFAULT_LANG and language array sintax in config_lang.php!');

   setcookie('mle_admin', $hl, time()+3600, '/');
  }
  else
  {
   if( (! isset($force_mle_default)) || (! $force_mle_default) ) $hl = language_user_setting($hls);
   else $hl = DEFAULT_LANG;

   setcookie('mle', $hl, time()+86400, '/');
  }
}

$mleblock = '_'. $hls[$hl]['block'];
$mlelocale_cms = ($hls[$hl]['locale_cms'])?$hls[$hl]['locale_cms']:$hl;
$mlelocale = ($hls[$hl]['locale'])?$hls[$hl]['locale']:$mlelocale_cms;
$mleparent = ($hls[$hl]['parent'])?$hls[$hl]['parent']:$hls[$hl]['block'];

$mle_translation = cms_join_path($dirname,'mle','lang',$mlelocale_cms.'.php');
if(@is_file($mle_translation))
{
  require_once($mle_translation);
  $smarty->assign_by_ref('mle_translation', $arr_mlelang);
}

$config['locale'] = $mlelocale_cms;
$gCms->config['locale'] = $mlelocale_cms;
$gCms->current_language = $mlelocale_cms;
$smarty->assign('locale', $mlelocale_cms);

$smarty->assign('currlang', $mleparent); //DEPRECATED
$smarty->assign('parent_lang', $mleparent);

$smarty->compile_id = $hl;
}
// End MLE
and config_lang.php reads:
array(
    'block'=> 'DATABASE KEY', //MANDATORY for transform CMSMS in MLE. If there isn't 'parent' then is the PARENT LANGUAGE also
    'flag' => 'HTML IMG TAG FOR LOCALE FLAG', //MANDATORY for compatibility
    'text' => 'TEXTUAL LANGUAGE', //OPTIONAL use for lang plugin if you don't use flags icon
    'parent' => 'PARENT LANGUAGE', //OPTIONAL set for avoid problem with many parent language locale (if you cannot use 'block')
    'locale_cms' => 'LOCALE LANGUAGE IN CMSMS', //MANDATORY ONLY if you don't use 'KEY' for locale (ex: 'KEY' is a label)
    'locale' => 'SERVER LOCALE', //OPTIONAL set for specific locale server if different from 'KEY' or 'locale_cms'
   ),

   1. Change DEFAULT_LANG to your default language (one of 'KEY' lang) if check browser lang failed
   2. OPTIONAL $force_mle_default, switch to true for force initial DEFAULT_LANG
   2. Edit following array with your languages
   3. Rename to config_lang.php
   4. Read README.FIRST file for add languages in database
* ********************************************************************* */
define('DEFAULT_LANG', 'en_GB');
$force_mle_default = true;

$hls = array(


'en_GB' => array(
'block'=>'en',
'flag'=>'',
'text'=>'English',
'parent'=>'en',
),

'cy' => array(
'block'=>'cy',
'flag'=>'',
'text'=>'Cymraeg',
),


);
?>
I don't quite understand how I can fix this from the first question in the thread -
I resolved them, by adding locale and locale_cms assignation in config_lang.php
???

All was working very well until this morning and I can't think what I may have done to cause this. ???

Currently using version 1.2 mle - perhaps an upgrade would help? However if there is a way of fixing it first that would be good.

Many thanks in advance

Regards
Lynne

Re: [BUG? REPORT] undefined index: locale and locale_cms error

Posted: Thu Feb 21, 2008 12:54 pm
by alby
chipper wrote:
$mleblock = '_'. $hls[$hl]['block'];
$mlelocale_cms = ($hls[$hl]['locale_cms'])?$hls[$hl]['locale_cms']:$hl;
$mlelocale = ($hls[$hl]['locale'])?$hls[$hl]['locale']:$mlelocale_cms;
$mleparent = ($hls[$hl]['parent'])?$hls[$hl]['parent']:$hls[$hl]['block'];
This include file is at least version 1.2.2

chipper wrote: Currently using version 1.2 mle - perhaps an upgrade would help? However if there is a way of fixing it first that would be good.
1.2  ???
Have you done upgrade recently? Maybe some files were not overwritten.

chipper wrote:
'en_GB' => array(
'block'=>'en',
'flag'=>'',
'text'=>'English',
'parent'=>'en',
'locale_cms' = 'en_US',
),

'cy' => array(
'block'=>'cy',
'flag'=>'',
'text'=>'Cymraeg',
'locale_cms' = 'en_US',
),
No, your config_lang is wrong.
Try to:
- add red lines, don't exist Welsh locale in CMSMS (no file cy_GB.php)
- clear cache in Global Settings
- DROP your browser cookie of this site

Alby

Re: [BUG? REPORT] undefined index: locale and locale_cms error

Posted: Thu Feb 21, 2008 1:35 pm
by chipper
Thank you very much - if I were to try upgrading now with this problem still in place would it cause more problems or would it resolve the problem automatically?

Or should I fix this first?  :-\

Re: [BUG? REPORT] undefined index: locale and locale_cms error

Posted: Thu Feb 21, 2008 1:47 pm
by alby
chipper wrote: Thank you very much - if I were to try upgrading now with this problem still in place would it cause more problems or would it resolve the problem automatically?

Or should I fix this first?  :-\
What is the version of the file you downloaded from the forge?
CMS version is in version.php, check date of this file VS index.php and include.php (difference must be of a few days only)

Alby

Re: [BUG? REPORT] undefined index: locale and locale_cms error

Posted: Thu Feb 21, 2008 8:28 pm
by chipper
Are you talking about this info in the version.php file?
$CMS_VERSION = "1.2.2";
$CMS_VERSION_NAME = "Holetown";
$CMS_SCHEMA_VERSION = "29";

Re: [BUG? REPORT] undefined index: locale and locale_cms error

Posted: Thu Feb 21, 2008 9:48 pm
by alby
chipper wrote: Are you talking about this info in the version.php file?
$CMS_VERSION = "1.2.2";
$CMS_VERSION_NAME = "Holetown";
$CMS_SCHEMA_VERSION = "29";
Yes, 1.2.2!
Ok, you can correct the config_lang but you should disable TinyMCE or correct a couple of lines of the module or to update 1.2.3 because there is a security problem in Tiny

Alby

Re: [BUG? REPORT] undefined index: locale and locale_cms error

Posted: Tue Feb 26, 2008 4:29 pm
by chipper
Hi Alby

Apologies for the delay in responding - now, after applying the 1.2.3 update files all is well. Had no problems with it since.

Many thanks again for your help

Regards
Lynne