plp050452 / simplesamlphp

Automatically exported from code.google.com/p/simplesamlphp
Other
0 stars 0 forks source link

Support for custom getLanguage function #436

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Purpose of code changes on this branch:

Support for custom getLanguage function called from 
SimpleSAML_XHTML_Template::getLanguage().

When reviewing my code changes, please focus on:

-

After the review, I'll merge this branch into:
/trunk

Original issue reported on code.google.com by comel...@gmail.com on 14 Sep 2011 at 1:32

Attachments:

GoogleCodeExporter commented 8 years ago
I am wondering about what the goal of the custom getLanguage function is?

If it is to integrate the language choice with an existing site, shouldn't this 
function replace the getLanguageCookie function instead? (And shouldn't you 
also override setLanguageCookie, so that they stay in sync?)

Original comment by olavmrk@gmail.com on 15 Sep 2011 at 5:39

GoogleCodeExporter commented 8 years ago
My intention was to set language based on more conditions, such as GeoIP, HTTP 
Accept Language... Now when you mentioned setLanguageCookie, I see that I could 
use this instead without the need to change the base code. I'm closing this.

Original comment by comel...@gmail.com on 19 Sep 2011 at 12:59

GoogleCodeExporter commented 8 years ago
I'm reopening this, because with set/getLanguageCookie() there is no 
possibility to change language on first request... The patch stays the same.

Original comment by comel...@gmail.com on 5 Dec 2011 at 11:09

GoogleCodeExporter commented 8 years ago
Could you add description of why someone may want to set the 
'language.get_language_function' option to the comment in config.php? I.e. 
something like:

«This option can be used to implement a custom function for determining the 
default language for the user.»

Also, shouldn't the example be:

    'language.get_language_function' => array('sspmod_example_Template', 'getLanguage'),

(See the "callback"-documentation: 
http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback )

Original comment by olavmrk@gmail.com on 6 Dec 2011 at 8:26

GoogleCodeExporter commented 8 years ago
OK, I updated patch, and committed as r2996.

BTW As of PHP 5.2.3 callback can also be of format 'class::method', see 
mentioned URL (Type 4: Static class method call).

I've used this format already in SimpleSAML_Error_Error::show() for 
'errors.show_function', should I update this also?

Original comment by comel...@gmail.com on 6 Dec 2011 at 12:34

GoogleCodeExporter commented 8 years ago
I hadn't noticed that :) (Didn't get as far down - I just read «Static class 
methods can also be passed without instantiating an object of that class by 
passing the class name instead of an object at index 0.»)

It may be a good idea to update it anyway, since we officially support version 
5.2.0 and newer of PHP. I doubt many people run old versions of it, but...

Original comment by olavmrk@gmail.com on 6 Dec 2011 at 12:52

GoogleCodeExporter commented 8 years ago
OK, I've updated and committed as r2997.

Original comment by comel...@gmail.com on 6 Dec 2011 at 4:46