forked from renekreijveld/UserAgentDetector
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuadetector.php
executable file
·38 lines (33 loc) · 1.19 KB
/
uadetector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* ---------------------------------------------------------------------------------------------------------
* User Agent detector plugin
*
* Version 1.0.7
*
* Copyright (C) 2013 Rene Kreijveld. All rights reserved.
*
* User Agent detector is free software and is distributed under the GNU General Public License,
* and as distributed it may include or be derivative of works licensed under the GNU
* General Public License or other free or open source software licenses.
* ---------------------------------------------------------------------------------------------------------
**/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
/**
* UADetector Plugin
*/
class plgSystemUadetector extends JPlugin
{
public function onAfterInitialise()
{
include_once(dirname(__FILE__).'/lib/Mobile_Detect.php');
$detect = new Mobile_Detect();
$layout = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'mobile') : 'desktop');
if (($detect->is('Bot')) || ($detect->is('MobileBot'))) $layout = 'bot';
// store user agent layout in session variable.
$session = JFactory::getSession();
$session->set('ualayout', $layout);
}
}