diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-06-18 12:57:11 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-06-18 15:40:48 +0200 |
commit | 332603a2637ec46984f0622ee9a930a84a1c367d (patch) | |
tree | fb3eec0496e5223be30b04695ce75caa2a075fac /lib/template.php | |
parent | 79f9d61ec84041c61a8d00042dfeb28afd8219a6 (diff) | |
download | nextcloud-server-332603a2637ec46984f0622ee9a930a84a1c367d.tar.gz nextcloud-server-332603a2637ec46984f0622ee9a930a84a1c367d.zip |
Move formfactor code to OC_Template
Diffstat (limited to 'lib/template.php')
-rw-r--r-- | lib/template.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/template.php b/lib/template.php index a3700e133e7..7e2e1d4d526 100644 --- a/lib/template.php +++ b/lib/template.php @@ -167,10 +167,47 @@ class OC_Template{ } /** + * autodetects the formfactor of the used device + * default -> the normal desktop browser interface + * mobile -> interface for smartphones + * tablet -> interface for tablets + * standalone -> the default interface but without header, footer and + * sidebar, just the application. Useful to use just a specific + * app on the desktop in a standalone window. + */ + public static function detectFormfactor(){ + // please add more useragent strings for other devices + if(isset($_SERVER['HTTP_USER_AGENT'])){ + if(stripos($_SERVER['HTTP_USER_AGENT'],'ipad')>0) { + $mode='tablet'; + }elseif(stripos($_SERVER['HTTP_USER_AGENT'],'iphone')>0){ + $mode='mobile'; + }elseif((stripos($_SERVER['HTTP_USER_AGENT'],'N9')>0) and (stripos($_SERVER['HTTP_USER_AGENT'],'nokia')>0)){ + $mode='mobile'; + }else{ + $mode='default'; + } + }else{ + $mode='default'; + } + return($mode); + } + + /** * @brief Returns the formfactor extension for current formfactor */ static public function getFormFactorExtension() { + // if the formfactor is not yet autodetected do the + // autodetection now. For possible formfactors check the + // detectFormfactor documentation + if(!isset($_SESSION['formfactor'])){ + $_SESSION['formfactor'] = self::detectFormfactor(); + } + // allow manual override via GET parameter + if(isset($_GET['formfactor'])){ + $_SESSION['formfactor']=$_GET['formfactor']; + } $formfactor=$_SESSION['formfactor']; if($formfactor=='default') { $fext=''; |