====== User-Agent ====== FIXME Better translate Since the release of R429 in the template can be made distinctions with IF statements, due to the values ​​of the user agent. A small test script which reads out the values ​​of the user agent. The results thereof are illustrated in the various ##%%Do that%%## queries. Please install the php file in the directory /frontend_render/.. The control takes the TAG **{IF-UAG}** or **{IF-UAG:X:Y}**. //Where X is the distance from the left -and Y specify the distance from the upper edge of the browser for the output//. E.g.: * **{IF-UAG}** //(X/Y -Values ​​for the position in the script)// . * **{IF-UAG:200:25}** //(200px in X -and 25px in Y-direction)//. \\ The TAG should be placed near the beginning or end outside of the outer div container. In the php-file, you can edit the IF statements to your own ideas. In this first overview all possible IF statements are included with simple values​​. The negative statements are not entered. \\ ===== Condition: ===== **conf.inc.php:** $phpwcms['render_device'] = 1; // allow user agent specific rendering templates DoMobileDoNotMobileDefault \\ ===== Application: ===== **%%....%%** oder die Nagation: **%%....%%** **mobile** - All Mobile
**desktop** - All Desktop
**platform:** WinPhone, WinCE, Win, iOS, Mac, GoogleTV, Android, BlackBerry, WebOS, Linux, Unix, Symbian, Other - Platform Win PC
- Platform Mac PC
- Platform Win und Mac PC
**device:** Default, Other, Smartphone, Tablet, Desktop, TV - Device Default
- Device Smartphone
- Device Tablet
- Device Desktop
- Device TV
**browser:** Other, Firefox, Chrome, Safari, IE, IEMobile, Opera, Mozilla - Browser Other
- Browser Firefox
- Browser Chrome
- Browser Safari
- Browser IE
- Browser IEMobile
- Browser Opera
- Browser Safari
**engine:** Gecko, Other, WebKit, Opera, KHTML, IE - Engine Gecko
- Engine Other
- Engine WebKit
- Engine Opera
- Engine KHTML
- Engine IE
**version** - Version No 531
**default** - Not Default
\\ ===== Output Examples: ===== === Desktop: === {{ :deutsch:andere-erweiterungen:tools:uag_mac-desktop_1.gif|}} {{:deutsch:andere-erweiterungen:tools:uag_win-desktop_1.gif|}} {{:deutsch:andere-erweiterungen:tools:uag_linux-desktop_1.gif|}} === Tablets: === **Since version 1.5 (r452) there is no "mobile" output when using tablets.** {{ :deutsch:andere-erweiterungen:tools:uag_android-tablet_1.gif|}} {{:deutsch:andere-erweiterungen:tools:uag_ios-tablet_1.gif|}} === Smartphones: === {{ :deutsch:andere-erweiterungen:tools:uag_android-smartphone_1.gif|}} {{:deutsch:andere-erweiterungen:tools:uag_ios-smartphone_1.gif|}} {{:deutsch:andere-erweiterungen:tools:uag_winphone-smartphone_1.gif|}} \\ ===== PHP Script: ===== **Very simple method:** \\ The values ​​of the user agent read directly: dumpVar(phpwcms_getUserAgent()); \\ **Comfortable Script:** **File:** template/inc_script/frontend_render/rt_test_if_user_agent.php IF-Statement
'.LF; // ************************************************************************* // Geasmmelte IF Abfragen: Editierbarer Bereich // ************************************************************************* // ************************************************************************* // mobile $_if .= ' - All Mobile
'; // desktop $_if .= ' - All Desktop
'; // platform: WinPhone, WinCE, Win, iOS, Mac, GoogleTV, Android, BlackBerry, WebOS, Linux, Unix, Symbian, Other $_if .= ' - Platform Win PC
- Platform Mac PC
- Platform Win und Mac PC
'; // device: Default, Other, Smartphone, Tablet, Desktop, TV $_if .= ' - Device Default
- Device Smartphone
- Device Tablet
- Device Desktop
- Device TV
'; // browser: Other, Firefox, Chrome, Safari, IE, IEMobile, Opera, Mozilla $_if .= ' - Browser Other
- Browser Firefox
- Browser Chrome
- Browser Safari
- Browser IE
- Browser IEMobile
- Browser Opera
- Browser Safari
'; // engine: Gecko, Other, WebKit, Opera, KHTML, IE $_if .= ' - Engine Gecko
- Engine Other
- Engine WebKit
- Engine Opera
- Engine KHTML
- Engine IE
'; // version $_if .= ' - Version No 531
'; // default $_if .= ' - Not Default
'; // ************************************************************************* // ************************************************************************* // ----------------------------------------------------- // Fenster-Ausgabeposition festlegen: {IF-UAG:X:Y} // ----------------------------------------------------- $_left = '200px'; // X px $_top = '10px'; // Y px preg_match('/\{IF-UAG:(.*?):(.*?)\}/', $content['all'], $_matches); if (isset($_matches[1])) $_left = $_matches[1].'px'; // x Position if (isset($_matches[2])) $_top = $_matches[2].'px'; // y Position // ----------------------------------------------------- // User Agent abholen // ----------------------------------------------------- //dumpVar(phpwcms_getUserAgent()); $_userAgent = phpwcms_getUserAgent(); // ----------------------------------------------------- // Ausgabeformat festlegen // ----------------------------------------------------- $_pos_all = '
'; $_pos_uAg = '
'; $_pos_if = '
'; // ----------------------------------------------------- // Output User-Agent // ----------------------------------------------------- $_uAg_Outp = 'User-Agent
'.LF; foreach ($_userAgent as $_key=>$_value) { $_uAg_Outp .= '
['.$_key.']
=> '.$_value.'
'.LF; } $_uAg_Outp .= '
'.LF; $content['all'] = preg_replace('/\{IF-UAG\}/', $_pos_all.$_pos_uAg.$_uAg_Outp.'
'.$_pos_if.$_if.'
', $content['all'] ); $content['all'] = preg_replace('/\{IF-UAG:.*?:.*?\}/', $_pos_all.$_pos_uAg.$_uAg_Outp.''.$_pos_if.$_if.'', $content['all'] ); } ?>
\\ \\ ====== Extracting the OS version from iOS ====== ==== Version 1.0 ==== Use within the CMS e.g.: iOS Version3 iOS Version4 \\ **Simple script:** derived from -> [[http://stackoverflow.com/questions/7768324/detect-ios-version-with-php|Detect iOS version with PHP]] **File:** template/inc_script/**frontend_init**/rt_iOS_OS_user_agent.php iOS_V4, iOS_V5, iOS_V6 * * In CMS e.g.: * iOS Version3 * iOS Version4 * * File: template/inc_script/frontend_init/rt_iOS_OS_user_agent.php * ********************************************************************/ // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");} // ------------------------------------------------------------------------------------------- // Example USER-AGENT iOS // -------------------------------------------------------- // Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5 // Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5 // -------------------------------------------------------- if ($GLOBALS['phpwcms']['USER_AGENT']['platform'] == 'iOS') { $os_vers = preg_replace("/(.*) OS ([0-9]*)_(.*)/","$2", $_SERVER['HTTP_USER_AGENT']); $GLOBALS['phpwcms']['USER_AGENT']['platform'] = $GLOBALS['phpwcms']['USER_AGENT']['platform'].'_V'.$os_vers; } ?> \\ At the output of the platform just the iOS version is appended. With a smartphone or tablet running iOS 5 the output changes from e.g. **iOS** to **iOS_V5**. Please check with the iPod and older iOS versions. \\ ==== Version 1.1 ==== It is tested against iOS versions greater than 5. Use within the CMS e.g.: iOS Version x - 5 iOS Version6 \\ **Simple script:** derived from -> [[http://stackoverflow.com/questions/7768324/detect-ios-version-with-php|Detect iOS version with PHP]] **File:** template/inc_script/**frontend_init**/rt_iOS_OS_user_agent.php iOS, iOS_V6 *Enhanced V1.1: Only if iOS V6 is used, the if statement is extended. * * * In CMS e.g.: * iOS Version x - 5 * iOS Version6 * * File: template/inc_script/frontend_init/rt_iOS_OS_user_agent.php * ********************************************************************/ // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");} // ------------------------------------------------------------------------------------------- // Example USER-AGENT iOS // -------------------------------------------------------- // Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5 // Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5 // -------------------------------------------------------- if ($GLOBALS['phpwcms']['USER_AGENT']['platform'] == 'iOS') { $os_vers = preg_replace("/(.*) OS ([0-9]*)_(.*)/","$2", $_SERVER['HTTP_USER_AGENT']); if (((int) $os_vers) == $os_vers) // Integer ? if ($os_vers > 5) $GLOBALS['phpwcms']['USER_AGENT']['platform'] .= '_V6'; } ?> \\ If iOS6 is in use we simply appended _V6. (**iOS** -> **iOS_V6**) to the output. All of the lower iOS versions have no control. Please check with the iPod and older iOS versions. \\