[TYPO3-core] RFC: #14230: Match TS browser condition with all delivered browsers

Lars Houmark lars at houmark.com
Wed Apr 28 01:56:24 CEST 2010


Hi Steffen,

Steffen Kamper wrote:
> So simply use the all array for compare and [browser=chrome] will work.
> Even something like [browser=webkit] works, which allows adding special
> css for webkit browsers.

I like the idea. Just your implementation was flawed, as using [browser 
= chrome] will not work, due to uppercase 'C' in the useragent value.

So changing strpos to stripos in patch line 19 will make it work as 
expected. I am not sure if it makes sense to bring a space between the 
key and value but it shouldn't change the functionality, so I'll let 
others decide :)

At the same time I noticed that some 'Array' values was in the string, 
which came from the all key. Those data is not needed as they are 
already in the string, so my suggestion is to check for is_array before 
appending to the string. Have a better one?

+1 on reading and testing _v2 which is attached, only changing strpos to 
stripos and is_array check.

P.S. Testing method could be the following TS:

[browser = safari]
page.1000 = TEXT
page.1000.value = Safari browser
[browser = webkit]
page.1001 = TEXT
page.1001.value = Webkit browser
[browser = chrome]
page.1002 = TEXT
page.1002.value = Chrome browser
[browser = chrome] && [version = 5]
page.1003 = TEXT
page.1003.value = Chrome browser version 5
[global]

Using latest Chrome (some 5.x version) will result in something like 
(line breaks manually added for easier reading):

Safari browser
Webkit browser
Chrome browser
Chrome browser version 5

Using Safari:

Safari browser
Webkit browser

Which is the expected behavior. And very flexible.

-- 
Lars Houmark

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 14230_v2.diff
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100427/74c9aec1/attachment.asc>


More information about the TYPO3-team-core mailing list