[TYPO3-english] Is there a condition to check the OS of the server?
Christopher
Christopher at temporaryforwarding.com
Mon Dec 15 21:52:48 CET 2008
Hi Dmitry,
unfortunatelly it does not work.
among other things I have tried the follwing code:
<?php
function user_checkOS($os) {
if (TYPO3_OS == 'WIN') {
$os = 'Windows';
# That should be the way you meant it...
return $os;
}
else {
$os = 'other';
return $os;
}
}
?>
In the Setup-field of the template I added:
includeLibs.user_checkOS = fileadmin/script/user_checkOS.php
# This is also shown in object-browser.
[userFunc = user_checkOS('Windows')]
config.locale_all = german
[ELSE]
config.locale_all = de_DE
[global]
The result is that the ELSE-part is used always.
No matter what, even if I write the following in the function at the top:
if (1 == 1) {
$os = 'Windows';
return $os;
}
else...
It never sets config.locale_all = german...
Regards
Christopher
"Dmitry Dulepov"wrote:
> Hi!
>
> Christopher wrote:
>> What is the right syntax for this condition?
>
> There is no such condition in TS but it is possible with userFunc.
>
> For example, you can put the lines below (except ======) to
> user_checkOS.php inside fileadmin/:
>
> =================
> <?php
>
> function user_checkOS($os) {
> if ($os == 'Windows') {
> return TYPO3_OS == 'WIN';
> }
> $sysinfo = posix_uname();
> return $os == $sysinfo['sysname'];
> }
>
> ?>
> =================
>
> Next you do this in TS:
>
> includeLibs.user_checkOS = fileadmin/user_checkOS.php
>
> And here is conditions:
>
> 10 = TEXT
> 10.value = Who knows?
> 10.noTrimWrap = |Server OS is: ||
> [userFunc = user_checkOS('Windows')]
> 10.value = Windows
> [userFunc = user_checkOS('Linux')]
> 10.value = Linux
> [userFunc = user_checkOS('Darwin')]
> 10.value = Mac OS X
> [global]
>
> Untested but should work.
>
> --
> Dmitry Dulepov
> TYPO3 core team
> In the blog:
> http://typo3bloke.net/post-details/how_will_i_fix_bugs_in_extensions_from_now_on/
> My TYPO3 book: http://www.packtpub.com/typo3-extension-development/book
More information about the TYPO3-english
mailing list